]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12enc.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / mpeg12enc.c
index 21b957c8cc15e887e1c442c381ad559613b3c649..71c26fa34b31d8bba73162425ce886a2c2bf872b 100644 (file)
@@ -75,11 +75,12 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
     for(i=0; i<128; i++){
         int level= i-64;
         int run;
+        if (!level)
+            continue;
         for(run=0; run<64; run++){
-            int len, bits, code;
+            int len, code;
 
             int alevel= FFABS(level);
-            int sign= (level>>31)&1;
 
             if (alevel > rl->max_level[0][run])
                 code= 111; /*rl->n*/
@@ -87,25 +88,15 @@ static void init_uni_ac_vlc(RLTable *rl, uint8_t *uni_ac_vlc_len){
                 code= rl->index_run[0][run] + alevel - 1;
 
             if (code < 111 /* rl->n */) {
-                /* store the vlc & sign at once */
+                /* length of vlc and sign */
                 len=   rl->table_vlc[code][1]+1;
-                bits= (rl->table_vlc[code][0]<<1) + sign;
             } else {
                 len=  rl->table_vlc[111/*rl->n*/][1]+6;
-                bits= rl->table_vlc[111/*rl->n*/][0]<<6;
 
-                bits|= run;
                 if (alevel < 128) {
-                    bits<<=8; len+=8;
-                    bits|= level & 0xff;
+                    len += 8;
                 } else {
-                    bits<<=16; len+=16;
-                    bits|= level & 0xff;
-                    if (level < 0) {
-                        bits|= 0x8001 + level + 255;
-                    } else {
-                        bits|= level & 0xffff;
-                    }
+                    len += 16;
                 }
             }
 
@@ -144,13 +135,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if(MPV_encode_init(avctx) < 0)
         return -1;
 
-#if FF_API_MPEGVIDEO_GLOBAL_OPTS
-    if (avctx->flags2 & CODEC_FLAG2_DROP_FRAME_TIMECODE)
-        s->drop_frame_timecode = 1;
-    if (avctx->flags & CODEC_FLAG_SVCD_SCAN_OFFSET)
-        s->scan_offset = 1;
-#endif
-
     if(find_frame_rate_index(s) < 0){
         if(s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL){
             av_log(avctx, AV_LOG_ERROR, "MPEG1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num);
@@ -191,9 +175,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
     if (s->tc.str) {
         s->tc.rate = avpriv_frame_rate_tab[s->frame_rate_index];
-        if (ff_init_smtpe_timecode(s, &s->tc) < 0)
+        if (avpriv_init_smpte_timecode(s, &s->tc) < 0)
             return -1;
+        s->drop_frame_timecode = s->tc.drop;
         s->avctx->timecode_frame_start = s->tc.start;
+    } else {
+        s->avctx->timecode_frame_start = 0; // default is -1
     }
     return 0;
 }
@@ -310,7 +297,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
             s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
             av_assert0(s->drop_frame_timecode == s->tc.drop);
             if (s->tc.drop)
-                time_code = ff_framenum_to_drop_timecode(time_code);
+                time_code = avpriv_framenum_to_drop_timecode(time_code);
             put_bits(&s->pb, 5, (uint32_t)((time_code / (fps * 3600)) % 24));
             put_bits(&s->pb, 6, (uint32_t)((time_code / (fps * 60)) % 60));
             put_bits(&s->pb, 1, 1);
@@ -980,7 +967,7 @@ AVCodec ff_mpeg1video_encoder = {
     .close          = MPV_encode_end,
     .supported_framerates= avpriv_frame_rate_tab+1,
     .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
-    .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
+    .capabilities= CODEC_CAP_DELAY,
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
     .priv_class     = &mpeg1_class,
 };