Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavcodec / vp56.c
index a2efca1..f2ee3fa 100644 (file)
 
 #include "avcodec.h"
 #include "bytestream.h"
-#include "internal.h"
+#include "decode.h"
 #include "h264chroma.h"
 #include "vp56.h"
 #include "vp56data.h"
+#include "vpx_rac.h"
 
 
 void ff_vp56_init_dequant(VP56Context *s, int quantizer)
@@ -80,22 +81,22 @@ static int vp56_get_vectors_predictors(VP56Context *s, int row, int col,
 
 static void vp56_parse_mb_type_models(VP56Context *s)
 {
-    VP56RangeCoder *c = &s->c;
+    VPXRangeCoder *c = &s->c;
     VP56Model *model = s->modelp;
     int i, ctx, type;
 
     for (ctx=0; ctx<3; ctx++) {
-        if (vp56_rac_get_prob_branchy(c, 174)) {
+        if (vpx_rac_get_prob_branchy(c, 174)) {
             int idx = vp56_rac_gets(c, 4);
             memcpy(model->mb_types_stats[ctx],
                    ff_vp56_pre_def_mb_type_stats[idx][ctx],
                    sizeof(model->mb_types_stats[ctx]));
         }
-        if (vp56_rac_get_prob_branchy(c, 254)) {
+        if (vpx_rac_get_prob_branchy(c, 254)) {
             for (type=0; type<10; type++) {
                 for(i=0; i<2; i++) {
-                    if (vp56_rac_get_prob_branchy(c, 205)) {
-                        int delta, sign = vp56_rac_get(c);
+                    if (vpx_rac_get_prob_branchy(c, 205)) {
+                        int delta, sign = vpx_rac_get(c);
 
                         delta = vp56_rac_get_tree(c, ff_vp56_pmbtm_tree,
                                                   ff_vp56_mb_type_model_model);
@@ -153,9 +154,9 @@ static VP56mb vp56_parse_mb_type(VP56Context *s,
                                  VP56mb prev_type, int ctx)
 {
     uint8_t *mb_type_model = s->modelp->mb_type[ctx][prev_type];
-    VP56RangeCoder *c = &s->c;
+    VPXRangeCoder *c = &s->c;
 
-    if (vp56_rac_get_prob_branchy(c, mb_type_model[0]))
+    if (vpx_rac_get_prob_branchy(c, mb_type_model[0]))
         return prev_type;
     else
         return vp56_rac_get_tree(c, ff_vp56_pmbt_tree, mb_type_model);
@@ -349,7 +350,7 @@ static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src,
 
     if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
         (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY
-         && !s->frames[VP56_FRAME_CURRENT]->key_frame))
+         && !(s->frames[VP56_FRAME_CURRENT]->flags & AV_FRAME_FLAG_KEY)))
         deblock_filtering = 0;
 
     dx = s->mv[b].x / s->vp56_coord_div[b];
@@ -492,7 +493,7 @@ static int vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
     VP56mb mb_type;
     int ret;
 
-    if (s->frames[VP56_FRAME_CURRENT]->key_frame)
+    if (s->frames[VP56_FRAME_CURRENT]->flags & AV_FRAME_FLAG_KEY)
         mb_type = VP56_MB_INTRA;
     else
         mb_type = vp56_decode_mv(s, row, col);
@@ -510,7 +511,7 @@ static int vp56_conceal_mb(VP56Context *s, int row, int col, int is_alpha)
 {
     VP56mb mb_type;
 
-    if (s->frames[VP56_FRAME_CURRENT]->key_frame)
+    if (s->frames[VP56_FRAME_CURRENT]->flags & AV_FRAME_FLAG_KEY)
         mb_type = VP56_MB_INTRA;
     else
         mb_type = vp56_conceal_mv(s, row, col);
@@ -595,6 +596,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
             if (s->alpha_context)
                 av_frame_unref(s->alpha_context->frames[i]);
         }
+        s->frames[VP56_FRAME_CURRENT]->flags |= AV_FRAME_FLAG_KEY; //FIXME
     }
 
     ret = ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF);
@@ -605,8 +607,7 @@ int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
     }
 
     if (avctx->pix_fmt == AV_PIX_FMT_YUVA420P) {
-        av_frame_unref(s->alpha_context->frames[VP56_FRAME_CURRENT]);
-        if ((ret = av_frame_ref(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) {
+        if ((ret = av_frame_replace(s->alpha_context->frames[VP56_FRAME_CURRENT], p)) < 0) {
             av_frame_unref(p);
             if (res == VP56_SIZE_CHANGE)
                 ff_set_dimensions(avctx, 0, 0);
@@ -669,7 +670,7 @@ static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data,
     int res;
     int damaged = 0;
 
-    if (p->key_frame) {
+    if (p->flags & AV_FRAME_FLAG_KEY) {
         p->pict_type = AV_PICTURE_TYPE_I;
         s->default_models_init(s);
         for (block=0; block<s->mb_height*s->mb_width; block++)
@@ -761,9 +762,8 @@ static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data,
         s->have_undamaged_frame = 1;
 
 next:
-    if (p->key_frame || s->golden_frame) {
-        av_frame_unref(s->frames[VP56_FRAME_GOLDEN]);
-        if ((res = av_frame_ref(s->frames[VP56_FRAME_GOLDEN], p)) < 0)
+    if ((p->flags & AV_FRAME_FLAG_KEY) || s->golden_frame) {
+        if ((res = av_frame_replace(s->frames[VP56_FRAME_GOLDEN], p)) < 0)
             return res;
     }