]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12.c
More okayed chunks of AAC encoder
[ffmpeg] / libavcodec / mpeg12.c
index 96d37c7327b95c8c7cacb71278c29e504d5c43d9..bb59f5455f63a12443767f8a719a926b0dae0bd5 100644 (file)
@@ -70,28 +70,31 @@ extern int XVMC_field_end(MpegEncContext *s);
 extern void XVMC_pack_pblocks(MpegEncContext *s,int cbp);
 extern void XVMC_init_block(MpegEncContext *s);//set s->block
 
-static const enum PixelFormat pixfmt_yuv_420[]= {PIX_FMT_YUV420P,-1};
-static const enum PixelFormat pixfmt_yuv_422[]= {PIX_FMT_YUV422P,-1};
-static const enum PixelFormat pixfmt_yuv_444[]= {PIX_FMT_YUV444P,-1};
+static const enum PixelFormat pixfmt_yuv_420[]= {PIX_FMT_YUV420P,PIX_FMT_NONE};
+static const enum PixelFormat pixfmt_yuv_422[]= {PIX_FMT_YUV422P,PIX_FMT_NONE};
+static const enum PixelFormat pixfmt_yuv_444[]= {PIX_FMT_YUV444P,PIX_FMT_NONE};
 static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = {
                                            PIX_FMT_XVMC_MPEG2_IDCT,
                                            PIX_FMT_XVMC_MPEG2_MC,
-                                           -1};
+                                           PIX_FMT_NONE};
 
 uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
 
-static void init_2d_vlc_rl(RLTable *rl, int use_static)
-{
-    int i;
 
-    init_vlc(&rl->vlc, TEX_VLC_BITS, rl->n + 2,
-             &rl->table_vlc[0][1], 4, 2,
-             &rl->table_vlc[0][0], 4, 2, use_static);
+#define INIT_2D_VLC_RL(rl, static_size)\
+{\
+    static RL_VLC_ELEM rl_vlc_table[static_size];\
+    INIT_VLC_STATIC(&rl.vlc, TEX_VLC_BITS, rl.n + 2,\
+             &rl.table_vlc[0][1], 4, 2,\
+             &rl.table_vlc[0][0], 4, 2, static_size);\
+\
+    rl.rl_vlc[0]= rl_vlc_table;\
+    init_2d_vlc_rl(&rl);\
+}
 
-    if(use_static)
-        rl->rl_vlc[0]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
-    else
-        rl->rl_vlc[0]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
+static void init_2d_vlc_rl(RLTable *rl)
+{
+    int i;
 
     for(i=0; i<rl->vlc.table_size; i++){
         int code= rl->vlc.table[i][0];
@@ -156,33 +159,33 @@ static void init_vlcs(void)
     if (!done) {
         done = 1;
 
-        init_vlc(&dc_lum_vlc, DC_VLC_BITS, 12,
+        INIT_VLC_STATIC(&dc_lum_vlc, DC_VLC_BITS, 12,
                  ff_mpeg12_vlc_dc_lum_bits, 1, 1,
-                 ff_mpeg12_vlc_dc_lum_code, 2, 2, 1);
-        init_vlc(&dc_chroma_vlc,  DC_VLC_BITS, 12,
+                 ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
+        INIT_VLC_STATIC(&dc_chroma_vlc,  DC_VLC_BITS, 12,
                  ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
-                 ff_mpeg12_vlc_dc_chroma_code, 2, 2, 1);
-        init_vlc(&mv_vlc, MV_VLC_BITS, 17,
+                 ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
+        INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 17,
                  &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1,
-                 &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 1);
-        init_vlc(&mbincr_vlc, MBINCR_VLC_BITS, 36,
+                 &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 518);
+        INIT_VLC_STATIC(&mbincr_vlc, MBINCR_VLC_BITS, 36,
                  &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1,
-                 &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 1);
-        init_vlc(&mb_pat_vlc, MB_PAT_VLC_BITS, 64,
+                 &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 538);
+        INIT_VLC_STATIC(&mb_pat_vlc, MB_PAT_VLC_BITS, 64,
                  &ff_mpeg12_mbPatTable[0][1], 2, 1,
-                 &ff_mpeg12_mbPatTable[0][0], 2, 1, 1);
+                 &ff_mpeg12_mbPatTable[0][0], 2, 1, 512);
 
-        init_vlc(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
+        INIT_VLC_STATIC(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
                  &table_mb_ptype[0][1], 2, 1,
-                 &table_mb_ptype[0][0], 2, 1, 1);
-        init_vlc(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
+                 &table_mb_ptype[0][0], 2, 1, 64);
+        INIT_VLC_STATIC(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
                  &table_mb_btype[0][1], 2, 1,
-                 &table_mb_btype[0][0], 2, 1, 1);
+                 &table_mb_btype[0][0], 2, 1, 64);
         init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
         init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
 
-        init_2d_vlc_rl(&ff_rl_mpeg1, 1);
-        init_2d_vlc_rl(&ff_rl_mpeg2, 1);
+        INIT_2D_VLC_RL(ff_rl_mpeg1, 680);
+        INIT_2D_VLC_RL(ff_rl_mpeg2, 674);
     }
 }
 
@@ -1966,8 +1969,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx,
 
     width = get_bits(&s->gb, 12);
     height = get_bits(&s->gb, 12);
-    if (width <= 0 || height <= 0 ||
-        (width % 2) != 0 || (height % 2) != 0)
+    if (width <= 0 || height <= 0)
         return -1;
     s->aspect_ratio_info= get_bits(&s->gb, 4);
     if (s->aspect_ratio_info == 0) {
@@ -2154,7 +2156,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
     int drop_frame_flag;
     int time_code_hours, time_code_minutes;
     int time_code_seconds, time_code_pictures;
-    int broken_link;
+    int closed_gop, broken_link;
 
     init_get_bits(&s->gb, buf, buf_size*8);
 
@@ -2166,15 +2168,16 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
     time_code_seconds = get_bits(&s->gb,6);
     time_code_pictures = get_bits(&s->gb,6);
 
+    closed_gop  = get_bits1(&s->gb);
     /*broken_link indicate that after editing the
       reference frames of the first B-Frames after GOP I-Frame
       are missing (open gop)*/
     broken_link = get_bits1(&s->gb);
 
     if(s->avctx->debug & FF_DEBUG_PICT_INFO)
-        av_log(s->avctx, AV_LOG_DEBUG, "GOP (%2d:%02d:%02d.[%02d]) broken_link=%d\n",
+        av_log(s->avctx, AV_LOG_DEBUG, "GOP (%2d:%02d:%02d.[%02d]) closed_gop=%d broken_link=%d\n",
             time_code_hours, time_code_minutes, time_code_seconds,
-            time_code_pictures, broken_link);
+            time_code_pictures, closed_gop, broken_link);
 }
 /**
  * finds the end of the current frame in the bitstream.
@@ -2442,6 +2445,7 @@ AVCodec mpeg1video_decoder = {
     mpeg_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
     .flush= ff_mpeg_flush,
+    .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
 };
 
 AVCodec mpeg2video_decoder = {
@@ -2455,6 +2459,7 @@ AVCodec mpeg2video_decoder = {
     mpeg_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
     .flush= ff_mpeg_flush,
+    .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"),
 };
 
 //legacy decoder
@@ -2469,6 +2474,7 @@ AVCodec mpegvideo_decoder = {
     mpeg_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
     .flush= ff_mpeg_flush,
+    .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
 };
 
 #ifdef HAVE_XVMC
@@ -2502,6 +2508,7 @@ AVCodec mpeg_xvmc_decoder = {
     mpeg_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED| CODEC_CAP_HWACCEL | CODEC_CAP_DELAY,
     .flush= ff_mpeg_flush,
+    .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video XvMC (X-Video Motion Compensation)"),
 };
 
 #endif