]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12enc.c
libavutil: drop offsetof() fallback definition
[ffmpeg] / libavcodec / mpeg12enc.c
index 90da1ee34c7de9c8e5c57c2fb6f2ff3020d3dd58..a96a23dd6bebeb1481b23a371987057cf0666107 100644 (file)
@@ -131,7 +131,7 @@ 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(find_frame_rate_index(s) < 0){
@@ -205,7 +205,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 
             for(i=1; i<15; i++){
                 float error= aspect_ratio;
-                if(s->codec_id == CODEC_ID_MPEG1VIDEO || i <=1)
+                if(s->codec_id == AV_CODEC_ID_MPEG1VIDEO || i <=1)
                     error-= 1.0/ff_mpeg1_aspect[i];
                 else
                     error-= av_q2d(ff_mpeg2_aspect[i])*s->height/s->width;
@@ -223,7 +223,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
 
             if(s->avctx->rc_max_rate){
                 v = (s->avctx->rc_max_rate + 399) / 400;
-                if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
+                if (v > 0x3ffff && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
                     v = 0x3ffff;
             }else{
                 v= 0x3FFFF;
@@ -248,14 +248,14 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
                 s->avctx->me_range && s->avctx->me_range < 128 &&
                 vbv_buffer_size <= 20 &&
                 v <= 1856000/400 &&
-                s->codec_id == CODEC_ID_MPEG1VIDEO;
+                s->codec_id == AV_CODEC_ID_MPEG1VIDEO;
 
             put_bits(&s->pb, 1, constraint_parameter_flag);
 
             ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
             ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix);
 
-            if(s->codec_id == CODEC_ID_MPEG2VIDEO){
+            if(s->codec_id == AV_CODEC_ID_MPEG2VIDEO){
                 put_header(s, EXT_START_CODE);
                 put_bits(&s->pb, 4, 1); //seq ext
 
@@ -350,7 +350,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
     // RAL: Forward f_code also needed for B frames
     if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) {
         put_bits(&s->pb, 1, 0); /* half pel coordinates */
-        if(s->codec_id == CODEC_ID_MPEG1VIDEO)
+        if(s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
             put_bits(&s->pb, 3, s->f_code); /* forward_f_code */
         else
             put_bits(&s->pb, 3, 7); /* forward_f_code */
@@ -359,7 +359,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
     // RAL: Backward f_code necessary for B frames
     if (s->pict_type == AV_PICTURE_TYPE_B) {
         put_bits(&s->pb, 1, 0); /* half pel coordinates */
-        if(s->codec_id == CODEC_ID_MPEG1VIDEO)
+        if(s->codec_id == AV_CODEC_ID_MPEG1VIDEO)
             put_bits(&s->pb, 3, s->b_code); /* backward_f_code */
         else
             put_bits(&s->pb, 3, 7); /* backward_f_code */
@@ -368,7 +368,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
     put_bits(&s->pb, 1, 0); /* extra bit picture */
 
     s->frame_pred_frame_dct = 1;
-    if(s->codec_id == CODEC_ID_MPEG2VIDEO){
+    if(s->codec_id == AV_CODEC_ID_MPEG2VIDEO){
         put_header(s, EXT_START_CODE);
         put_bits(&s->pb, 4, 8); //pic ext
         if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) {
@@ -449,7 +449,7 @@ static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
     }
 
     if (cbp == 0 && !first_mb && s->mv_type == MV_TYPE_16X16 &&
-        (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == CODEC_ID_MPEG1VIDEO)) &&
+        (mb_x != s->mb_width - 1 || (mb_y != s->mb_height - 1 && s->codec_id == AV_CODEC_ID_MPEG1VIDEO)) &&
         ((s->pict_type == AV_PICTURE_TYPE_P && (motion_x | motion_y) == 0) ||
         (s->pict_type == AV_PICTURE_TYPE_B && s->mv_dir == s->last_mv_dir && (((s->mv_dir & MV_DIR_FORWARD) ? ((s->mv[0][0][0] - s->last_mv[0][0][0])|(s->mv[0][0][1] - s->last_mv[0][0][1])) : 0) |
         ((s->mv_dir & MV_DIR_BACKWARD) ? ((s->mv[1][0][0] - s->last_mv[1][0][0])|(s->mv[1][0][1] - s->last_mv[1][0][1])) : 0)) == 0))) {
@@ -783,7 +783,7 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
     }
     s->me.mv_penalty= mv_penalty;
     s->fcode_tab= fcode_tab;
-    if(s->codec_id == CODEC_ID_MPEG1VIDEO){
+    if(s->codec_id == AV_CODEC_ID_MPEG1VIDEO){
         s->min_qcoeff=-255;
         s->max_qcoeff= 255;
     }else{
@@ -885,7 +885,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
             run = i - last_non_zero - 1;
 
             alevel= level;
-            MASK_ABS(sign, alevel)
+            MASK_ABS(sign, alevel);
             sign&=1;
 
             if (alevel <= mpeg1_max_level[0][run]){
@@ -897,7 +897,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
                 put_bits(&s->pb, table_vlc[111][1], table_vlc[111][0]);
                 /* escape: only clip in this case */
                 put_bits(&s->pb, 6, run);
-                if(s->codec_id == CODEC_ID_MPEG1VIDEO){
+                if(s->codec_id == AV_CODEC_ID_MPEG1VIDEO){
                     if (alevel < 128) {
                         put_sbits(&s->pb, 8, level);
                     } else {
@@ -927,6 +927,7 @@ static void mpeg1_encode_block(MpegEncContext *s,
 
 static const AVOption mpeg1_options[] = {
     COMMON_OPTS
+    FF_MPV_COMMON_OPTS
     { NULL },
 };
 
@@ -934,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 },
 };
 
@@ -949,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                   = AV_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                   = AV_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,
 };