]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rv10.c
dxva2: Keep code shared between dxva2 and d3d11va under the correct #if
[ffmpeg] / libavcodec / rv10.c
index ddaaae1cc687c73ef5be8bcecd502cb31a5edfab..3b5f4df08418acc6d2b6da9801bb798c5e1db294 100644 (file)
 #include "avcodec.h"
 #include "error_resilience.h"
 #include "h263.h"
+#include "h263data.h"
 #include "internal.h"
+#include "mpeg_er.h"
+#include "mpegutils.h"
 #include "mpegvideo.h"
 #include "mpeg4video.h"
+#include "mpegvideodata.h"
+#include "rv10.h"
 
 #define RV_GET_MAJOR_VER(x)  ((x) >> 28)
 #define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF)
@@ -45,6 +50,7 @@
 typedef struct RVDecContext {
     MpegEncContext m;
     int sub_id;
+    int orig_width, orig_height;
 } RVDecContext;
 
 static const uint16_t rv_lum_code[256] = {
@@ -256,10 +262,10 @@ static int rv10_decode_picture_header(MpegEncContext *s)
 
     pb_frame = get_bits1(&s->gb);
 
-    av_dlog(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
+    ff_dlog(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
 
     if (pb_frame) {
-        avpriv_request_sample(s->avctx, "pb frame");
+        avpriv_request_sample(s->avctx, "PB-frame");
         return AVERROR_PATCHWELCOME;
     }
 
@@ -275,7 +281,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
             s->last_dc[0] = get_bits(&s->gb, 8);
             s->last_dc[1] = get_bits(&s->gb, 8);
             s->last_dc[2] = get_bits(&s->gb, 8);
-            av_dlog(s->avctx, "DC:%d %d %d\n", s->last_dc[0],
+            ff_dlog(s->avctx, "DC:%d %d %d\n", s->last_dc[0],
                     s->last_dc[1], s->last_dc[2]);
         }
     }
@@ -324,7 +330,7 @@ static int rv20_decode_picture_header(RVDecContext *rv)
         return AVERROR_INVALIDDATA;
     }
 
-    if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B) {
+    if (!s->last_picture_ptr && s->pict_type == AV_PICTURE_TYPE_B) {
         av_log(s->avctx, AV_LOG_ERROR, "early B-frame\n");
         return AVERROR_INVALIDDATA;
     }
@@ -364,13 +370,13 @@ static int rv20_decode_picture_header(RVDecContext *rv)
             new_w = 4 * ((uint8_t *) s->avctx->extradata)[6 + 2 * f];
             new_h = 4 * ((uint8_t *) s->avctx->extradata)[7 + 2 * f];
         } else {
-            new_w = s->orig_width;
-            new_h = s->orig_height;
+            new_w = rv->orig_width;
+            new_h = rv->orig_height;
         }
         if (new_w != s->width || new_h != s->height) {
             av_log(s->avctx, AV_LOG_DEBUG,
                    "attempting to change resolution to %dx%d\n", new_w, new_h);
-            ff_MPV_common_end(s);
+            ff_mpv_common_end(s);
 
             ret = ff_set_dimensions(s->avctx, new_w, new_h);
             if (ret < 0)
@@ -378,7 +384,7 @@ static int rv20_decode_picture_header(RVDecContext *rv)
 
             s->width  = new_w;
             s->height = new_h;
-            if ((ret = ff_MPV_common_init(s)) < 0)
+            if ((ret = ff_mpv_common_init(s)) < 0)
                 return ret;
         }
 
@@ -407,7 +413,7 @@ static int rv20_decode_picture_header(RVDecContext *rv)
             if (s->pp_time <= s->pb_time ||
                 s->pp_time <= s->pp_time - s->pb_time || s->pp_time <= 0) {
                 av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible "
-                       "from seeking? skipping current frame\n");
+                       "from seeking? skipping current B-frame\n");
                 return FRAME_SKIPPED;
             }
             ff_mpeg4_init_direct_mv(s);
@@ -453,16 +459,16 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
                                    avctx->coded_height, 0, avctx)) < 0)
         return ret;
 
-    ff_MPV_decode_defaults(s);
+    ff_mpv_decode_defaults(s);
 
     s->avctx       = avctx;
     s->out_format  = FMT_H263;
     s->codec_id    = avctx->codec_id;
 
-    s->orig_width  =
-    s->width       = avctx->coded_width;
-    s->orig_height =
-    s->height      = avctx->coded_height;
+    rv->orig_width  =
+    s->width        = avctx->coded_width;
+    rv->orig_height =
+    s->height       = avctx->coded_height;
 
     s->h263_long_vectors = ((uint8_t *) avctx->extradata)[3] & 1;
     rv->sub_id           = AV_RB32((uint8_t *) avctx->extradata + 4);
@@ -496,7 +502,8 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
-    if ((ret = ff_MPV_common_init(s)) < 0)
+    ff_mpv_idct_init(s);
+    if ((ret = ff_mpv_common_init(s)) < 0)
         return ret;
 
     ff_h263dsp_init(&s->h263dsp);
@@ -520,7 +527,7 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx)
 {
     MpegEncContext *s = avctx->priv_data;
 
-    ff_MPV_common_end(s);
+    ff_mpv_common_end(s);
     return 0;
 }
 
@@ -554,24 +561,24 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
         return AVERROR_INVALIDDATA;
     }
 
-    if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr == NULL) {
+    if ((s->mb_x == 0 && s->mb_y == 0) || !s->current_picture_ptr) {
         // FIXME write parser so we always have complete frames?
         if (s->current_picture_ptr) {
             ff_er_frame_end(&s->er);
-            ff_MPV_frame_end(s);
+            ff_mpv_frame_end(s);
             s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0;
         }
-        if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
+        if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
             return ret;
         ff_mpeg_er_frame_start(s);
     } else {
-        if (s->current_picture_ptr->f.pict_type != s->pict_type) {
+        if (s->current_picture_ptr->f->pict_type != s->pict_type) {
             av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
             return AVERROR_INVALIDDATA;
         }
     }
 
-    av_dlog(avctx, "qscale=%d\n", s->qscale);
+    ff_dlog(avctx, "qscale=%d\n", s->qscale);
 
     /* default quantization values */
     if (s->codec_id == AV_CODEC_ID_RV10) {
@@ -611,7 +618,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
     for (s->mb_num_left = mb_count; s->mb_num_left > 0; s->mb_num_left--) {
         int ret;
         ff_update_block_index(s);
-        av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
+        ff_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
 
         s->mv_dir  = MV_DIR_FORWARD;
         s->mv_type = MV_TYPE_16X16;
@@ -643,7 +650,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
         }
         if (s->pict_type != AV_PICTURE_TYPE_B)
             ff_h263_update_motion_val(s);
-        ff_MPV_decode_mb(s, s->block);
+        ff_mpv_decode_mb(s, s->block);
         if (s->loop_filter)
             ff_h263_loop_filter(s);
 
@@ -683,7 +690,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     int slice_count;
     const uint8_t *slices_hdr = NULL;
 
-    av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
+    ff_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
 
     /* no supplementary picture */
     if (buf_size == 0) {
@@ -734,16 +741,16 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             i++;
     }
 
-    if (s->current_picture_ptr != NULL && s->mb_y >= s->mb_height) {
+    if (s->current_picture_ptr && s->mb_y >= s->mb_height) {
         ff_er_frame_end(&s->er);
-        ff_MPV_frame_end(s);
+        ff_mpv_frame_end(s);
 
         if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
-            if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+            if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
                 return ret;
             ff_print_debug_info(s, s->current_picture_ptr);
-        } else if (s->last_picture_ptr != NULL) {
-            if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+        } else if (s->last_picture_ptr) {
+            if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
                 return ret;
             ff_print_debug_info(s, s->last_picture_ptr);
         }
@@ -768,8 +775,11 @@ AVCodec ff_rv10_decoder = {
     .init           = rv10_decode_init,
     .close          = rv10_decode_end,
     .decode         = rv10_decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
-    .pix_fmts       = ff_pixfmt_list_420,
+    .capabilities   = AV_CODEC_CAP_DR1,
+    .pix_fmts       = (const enum AVPixelFormat[]) {
+        AV_PIX_FMT_YUV420P,
+        AV_PIX_FMT_NONE
+    },
 };
 
 AVCodec ff_rv20_decoder = {
@@ -781,7 +791,10 @@ AVCodec ff_rv20_decoder = {
     .init           = rv10_decode_init,
     .close          = rv10_decode_end,
     .decode         = rv10_decode_frame,
-    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
+    .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
     .flush          = ff_mpeg_flush,
-    .pix_fmts       = ff_pixfmt_list_420,
+    .pix_fmts       = (const enum AVPixelFormat[]) {
+        AV_PIX_FMT_YUV420P,
+        AV_PIX_FMT_NONE
+    },
 };