]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12enc.c
mips: intreadwrite: fix inline asm for gcc 4.8
[ffmpeg] / libavcodec / mpeg12enc.c
index 738af99d681bd04751883671ddefa1ae7e472760..b0175b1fc8359b2246835f2960f493c073610146 100644 (file)
@@ -74,11 +74,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*/
@@ -86,25 +87,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;
                 }
             }
 
@@ -140,16 +131,9 @@ static av_cold int encode_init(AVCodecContext *avctx)
 {
     MpegEncContext *s = avctx->priv_data;
 
-    if(MPV_encode_init(avctx) < 0)
+    if(ff_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);
@@ -192,7 +176,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
 static void put_header(MpegEncContext *s, int header)
 {
-    align_put_bits(&s->pb);
+    avpriv_align_put_bits(&s->pb);
     put_bits(&s->pb, 16, header>>16);
     put_sbits(&s->pb, 16, header);
 }
@@ -347,7 +331,7 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s){
     put_bits(&s->pb, 1, 0); /* slice extra information */
 }
 
-void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
+void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
 {
     mpeg1_encode_sequence_header(s);
 
@@ -672,7 +656,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
     }
 }
 
-void mpeg1_encode_mb(MpegEncContext *s, DCTELEM block[6][64], int motion_x, int motion_y)
+void ff_mpeg1_encode_mb(MpegEncContext *s, DCTELEM block[6][64], int motion_x, int motion_y)
 {
     if (s->chroma_format == CHROMA_420) mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 6);
     else                                mpeg1_encode_mb_internal(s, block, motion_x, motion_y, 8);
@@ -731,8 +715,8 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
         int i;
 
         done=1;
-        init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
-        init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
+        ff_init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
+        ff_init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
 
         for(i=0; i<64; i++)
         {
@@ -943,6 +927,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
 
 static const AVOption mpeg1_options[] = {
     COMMON_OPTS
+    FF_MPV_COMMON_OPTS
     { NULL },
 };
 
@@ -950,6 +935,7 @@ static const AVOption mpeg2_options[] = {
     COMMON_OPTS
     { "non_linear_quant",    "Use nonlinear quantizer.",          OFFSET(q_scale_type),         AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
     { "alternate_scan",      "Enable alternate scantable.",       OFFSET(alternate_scan),       AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },
+    FF_MPV_COMMON_OPTS
     { NULL },
 };
 
@@ -965,31 +951,34 @@ mpeg12_class(1)
 mpeg12_class(2)
 
 AVCodec ff_mpeg1video_encoder = {
-    .name           = "mpeg1video",
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_MPEG1VIDEO,
-    .priv_data_size = sizeof(MpegEncContext),
-    .init           = encode_init,
-    .encode         = MPV_encode_picture,
-    .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,
-    .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
-    .priv_class     = &mpeg1_class,
+    .name                 = "mpeg1video",
+    .type                 = AVMEDIA_TYPE_VIDEO,
+    .id                   = CODEC_ID_MPEG1VIDEO,
+    .priv_data_size       = sizeof(MpegEncContext),
+    .init                 = encode_init,
+    .encode2              = ff_MPV_encode_picture,
+    .close                = ff_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,
+    .long_name            = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
+    .priv_class           = &mpeg1_class,
 };
 
 AVCodec ff_mpeg2video_encoder = {
-    .name           = "mpeg2video",
-    .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_MPEG2VIDEO,
-    .priv_data_size = sizeof(MpegEncContext),
-    .init           = encode_init,
-    .encode         = MPV_encode_picture,
-    .close          = MPV_encode_end,
-    .supported_framerates= avpriv_frame_rate_tab+1,
-    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE},
-    .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
-    .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"),
-    .priv_class     = &mpeg2_class,
+    .name                 = "mpeg2video",
+    .type                 = AVMEDIA_TYPE_VIDEO,
+    .id                   = CODEC_ID_MPEG2VIDEO,
+    .priv_data_size       = sizeof(MpegEncContext),
+    .init                 = encode_init,
+    .encode2              = ff_MPV_encode_picture,
+    .close                = ff_MPV_encode_end,
+    .supported_framerates = avpriv_frame_rate_tab + 1,
+    .pix_fmts             = (const enum PixelFormat[]){
+        PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE
+    },
+    .capabilities         = CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
+    .long_name            = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
+    .priv_class           = &mpeg2_class,
 };