]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cavsdec.c
lavc: add a wrapper for AVCodecContext.get_buffer().
[ffmpeg] / libavcodec / cavsdec.c
index e70dad038a02062b5ab45b16025923fd42c73c34..5619071a1039dda0733f7aa82bf0755e0255198a 100644 (file)
@@ -29,6 +29,7 @@
 #include "get_bits.h"
 #include "golomb.h"
 #include "cavs.h"
+#include "internal.h"
 
 static const uint8_t mv_scan[4] = {
     MV_FWD_X0,MV_FWD_X1,
@@ -915,9 +916,10 @@ static int decode_pic(AVSContext *h) {
     enum cavs_mb mb_type;
 
     if (!s->context_initialized) {
-        s->avctx->idct_algo = FF_IDCT_CAVS;
         if (ff_MPV_common_init(s) < 0)
             return -1;
+        ff_init_scantable_permutation(s->dsp.idct_permutation,
+                                      h->cdsp.idct_perm);
         ff_init_scantable(s->dsp.idct_permutation,&h->scantable,ff_zigzag_direct);
     }
     skip_bits(&s->gb,16);//bbv_dwlay
@@ -949,7 +951,7 @@ static int decode_pic(AVSContext *h) {
     if(h->picture.f.data[0])
         s->avctx->release_buffer(s->avctx, &h->picture.f);
 
-    s->avctx->get_buffer(s->avctx, &h->picture.f);
+    ff_get_buffer(s->avctx, &h->picture.f);
     ff_cavs_init_pic(h);
     h->picture.poc = get_bits(&s->gb,8)*2;
 
@@ -1055,12 +1057,21 @@ static int decode_pic(AVSContext *h) {
 static int decode_seq_header(AVSContext *h) {
     MpegEncContext *s = &h->s;
     int frame_rate_code;
+    int width, height;
 
     h->profile =         get_bits(&s->gb,8);
     h->level =           get_bits(&s->gb,8);
     skip_bits1(&s->gb); //progressive sequence
-    s->width =           get_bits(&s->gb,14);
-    s->height =          get_bits(&s->gb,14);
+
+    width  = get_bits(&s->gb, 14);
+    height = get_bits(&s->gb, 14);
+    if ((s->width || s->height) && (s->width != width || s->height != height)) {
+        av_log_missing_feature(s, "Width/height changing in CAVS", 0);
+        return AVERROR_PATCHWELCOME;
+    }
+    s->width  = width;
+    s->height = height;
+
     skip_bits(&s->gb,2); //chroma format
     skip_bits(&s->gb,3); //sample_precision
     h->aspect_ratio =    get_bits(&s->gb,4);
@@ -1071,8 +1082,8 @@ static int decode_seq_header(AVSContext *h) {
     s->low_delay =       get_bits1(&s->gb);
     h->mb_width  = (s->width  + 15) >> 4;
     h->mb_height = (s->height + 15) >> 4;
-    h->s.avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_code].num;
-    h->s.avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_code].den;
+    h->s.avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_code].num;
+    h->s.avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_code].den;
     h->s.avctx->width  = s->width;
     h->s.avctx->height = s->height;
     if(!h->top_qp)