Annotation of pkgsrc/multimedia/transcode/patches/patch-export_export_ffmpeg.c, revision 1.4

1.4     ! wiz         1: $NetBSD: patch-export_export_ffmpeg.c,v 1.3 2019/12/29 10:23:53 markd Exp $
1.1       markd       2: 
1.3       markd       3: Fixes building against FFmpeg version >= 4.0.0 (gentoo patch).
1.1       markd       4: 
                      5: --- export/export_ffmpeg.c.orig        2011-11-19 16:50:27.000000000 +0000
                      6: +++ export/export_ffmpeg.c
1.4     ! wiz         7: @@ -122,6 +122,7 @@ static AVCodec             *lavc_venc_codec = NULL;
1.1       markd       8:  static AVFrame             *lavc_convert_frame = NULL;
                      9:  
                     10:  static AVCodec             *lavc_venc_codec = NULL;
1.2       adam       11: +static AVDictionary        *lavc_venc_opts = NULL;
1.1       markd      12:  static AVFrame             *lavc_venc_frame = NULL;
                     13:  static AVCodecContext      *lavc_venc_context;
                     14:  static avi_t               *avifile = NULL;
1.4     ! wiz        15: @@ -180,7 +181,7 @@ static char *tc_strchrnul(const char *s, int c) {
1.1       markd      16:  
                     17:  
                     18:  /* START: COPIED FROM ffmpeg-0.5_p22846(ffmpeg.c, cmdutils.c) */
                     19: -#include <libavcodec/opt.h>
                     20: +#include <libavutil/opt.h>
                     21:  #include <libavutil/avstring.h>
                     22:  #include <libswscale/swscale.h>
                     23:  
1.4     ! wiz        24: @@ -249,9 +250,9 @@ int opt_default(const char *opt, const char *arg){
1.3       markd      25:      for(type=0; type<AVMEDIA_TYPE_NB && ret>= 0; type++){
                     26:                /* GLUE: +if */
                     27:                if (type == AVMEDIA_TYPE_VIDEO) {
                     28: -        const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
                     29: -        if(o2)
                     30: -            ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
                     31: +        o = av_opt_find(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
                     32: +        if(o)
                     33: +            ret = av_opt_set(avcodec_opts[type], opt, arg, 0);
                     34:                /* GLUE: +if */
                     35:                }
                     36:      }
1.4     ! wiz        37: @@ -266,7 +267,10 @@ int opt_default(const char *opt, const char *arg){
1.3       markd      38:          if(opt[0] == 'a')
                     39:              ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o);
                     40:          else */ if(opt[0] == 'v')
                     41: -            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o);
                     42: +      {
                     43: +          o = av_opt_find(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, NULL, 0, 0);
                     44: +            ret = av_opt_set(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 0);
                     45: +      }
                     46:                /* GLUE: disabling
                     47:          else if(opt[0] == 's')
                     48:              ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o);
                     49: @@ -470,7 +474,6 @@ MOD_init
1.1       markd      50:      }
                     51:  
                     52:      TC_LOCK_LIBAVCODEC;
                     53: -    avcodec_init();
                     54:      avcodec_register_all();
                     55:      TC_UNLOCK_LIBAVCODEC;
                     56:  
1.3       markd      57: @@ -486,11 +489,11 @@ MOD_init
1.2       adam       58:                            codec->name, codec->fourCC, codec->comments);
                     59:      }
                     60:  
                     61: -    lavc_venc_context = avcodec_alloc_context();
1.3       markd      62: -    lavc_venc_frame   = avcodec_alloc_frame();
1.2       adam       63: +    lavc_venc_context = avcodec_alloc_context3(lavc_venc_codec);
1.3       markd      64: +    lavc_venc_frame   = av_frame_alloc();
                     65:  
                     66: -    lavc_convert_frame= avcodec_alloc_frame();
                     67: -    size = avpicture_get_size(PIX_FMT_RGB24, vob->ex_v_width, vob->ex_v_height);
                     68: +    lavc_convert_frame= av_frame_alloc();
                     69: +    size = avpicture_get_size(AV_PIX_FMT_RGB24, vob->ex_v_width, vob->ex_v_height);
                     70:      enc_buffer = tc_malloc(size);
1.2       adam       71:  
1.3       markd      72:      if (lavc_venc_context == NULL || !enc_buffer || !lavc_convert_frame) {
                     73: @@ -634,7 +637,7 @@ MOD_init
1.1       markd      74:          lavc_param_rc_max_rate = 2516;
                     75:          lavc_param_rc_buffer_size = 224 * 8;
                     76:          lavc_param_rc_buffer_aggressivity = 99;
                     77: -        lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
                     78: +        lavc_param_scan_offset = 1;
                     79:  
                     80:          break;
                     81:  
1.3       markd      82: @@ -674,7 +677,7 @@ MOD_init
1.1       markd      83:  
                     84:          lavc_param_rc_buffer_size = 224 * 8;
                     85:          lavc_param_rc_buffer_aggressivity = 99;
                     86: -        lavc_param_scan_offset = CODEC_FLAG_SVCD_SCAN_OFFSET;
                     87: +        lavc_param_scan_offset = 1;
                     88:  
                     89:          break;
                     90:  
1.3       markd      91: @@ -828,18 +831,35 @@ MOD_init
                     92:  
                     93:      lavc_venc_context->bit_rate           = vob->divxbitrate * 1000;
                     94:      lavc_venc_context->bit_rate_tolerance = lavc_param_vrate_tolerance * 1000;
                     95: -    lavc_venc_context->lmin= (int)(FF_QP2LAMBDA * lavc_param_lmin + 0.5);
                     96: -    lavc_venc_context->lmax= (int)(FF_QP2LAMBDA * lavc_param_lmax + 0.5);
                     97:      lavc_venc_context->max_qdiff          = lavc_param_vqdiff;
                     98:      lavc_venc_context->qcompress          = lavc_param_vqcompress;
                     99:      lavc_venc_context->qblur              = lavc_param_vqblur;
                    100:      lavc_venc_context->max_b_frames       = lavc_param_vmax_b_frames;
                    101:      lavc_venc_context->b_quant_factor     = lavc_param_vb_qfactor;
                    102: -    lavc_venc_context->rc_strategy        = lavc_param_vrc_strategy;
1.2       adam      103:      lavc_venc_context->b_frame_strategy   = lavc_param_vb_strategy;
                    104:      lavc_venc_context->b_quant_offset     = lavc_param_vb_qoffset;
                    105: -    lavc_venc_context->luma_elim_threshold= lavc_param_luma_elim_threshold;
                    106: -    lavc_venc_context->chroma_elim_threshold= lavc_param_chroma_elim_threshold;
                    107: +
                    108: +    char buf[1024];
                    109: +#define set_dict_opt(val, opt) \
                    110: +      snprintf(buf, sizeof(buf), "%i", val); \
                    111: +      av_dict_set(&lavc_venc_opts, opt, buf, 0)
1.3       markd     112: +#define set_dict_float_opt(val, opt) \
                    113: +      snprintf(buf, sizeof(buf), "%f", val); \
                    114: +      av_dict_set(&lavc_venc_opts, opt, buf, 0)
1.2       adam      115: +    set_dict_opt(lavc_param_luma_elim_threshold, "luma_elim_threshold");
                    116: +    set_dict_opt(lavc_param_chroma_elim_threshold, "chroma_elim_threshold");
1.3       markd     117: +    set_dict_opt((int)(FF_QP2LAMBDA * lavc_param_lmin + 0.5), "lmin");
                    118: +    set_dict_opt((int)(FF_QP2LAMBDA * lavc_param_lmax + 0.5), "lmax");
                    119: +    set_dict_opt(lavc_param_vrc_strategy, "rc_strategy");
                    120: +    set_dict_float_opt(lavc_param_rc_qsquish, "qsquish");
                    121: +    set_dict_float_opt(lavc_param_rc_qmod_amp, "rc_qmod_amp");
                    122: +    set_dict_opt(lavc_param_rc_qmod_freq, "rc_qmod_freq");
                    123: +    set_dict_opt(lavc_param_rc_eq, "rc_eq");
                    124: +    set_dict_opt(lavc_param_vme, "me_method");
                    125: +    set_dict_opt(lavc_param_ibias, "ibias");
                    126: +    set_dict_opt(lavc_param_pbias, "pbias");
                    127: +    set_dict_float_opt(lavc_param_rc_buffer_aggressivity, "rc_buf_aggressivity");
                    128: +    set_dict_float_opt(lavc_param_rc_initial_cplx, "rc_init_cplx");
1.2       adam      129:      lavc_venc_context->rtp_payload_size   = lavc_param_packet_size;
                    130:  #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)   
                    131:      if (lavc_param_packet_size)
1.3       markd     132: @@ -848,15 +868,9 @@ MOD_init
                    133:      lavc_venc_context->strict_std_compliance= lavc_param_strict;
                    134:      lavc_venc_context->i_quant_factor     = lavc_param_vi_qfactor;
                    135:      lavc_venc_context->i_quant_offset     = lavc_param_vi_qoffset;
                    136: -    lavc_venc_context->rc_qsquish         = lavc_param_rc_qsquish;
                    137: -    lavc_venc_context->rc_qmod_amp        = lavc_param_rc_qmod_amp;
                    138: -    lavc_venc_context->rc_qmod_freq       = lavc_param_rc_qmod_freq;
                    139: -    lavc_venc_context->rc_eq              = lavc_param_rc_eq;
                    140:      lavc_venc_context->rc_max_rate        = lavc_param_rc_max_rate * 1000;
                    141:      lavc_venc_context->rc_min_rate        = lavc_param_rc_min_rate * 1000;
                    142:      lavc_venc_context->rc_buffer_size     = lavc_param_rc_buffer_size * 1024;
                    143: -    lavc_venc_context->rc_buffer_aggressivity= lavc_param_rc_buffer_aggressivity;
                    144: -    lavc_venc_context->rc_initial_cplx    = lavc_param_rc_initial_cplx;
                    145:      lavc_venc_context->debug              = lavc_param_debug;
                    146:      lavc_venc_context->last_predictor_count= lavc_param_last_pred;
                    147:      lavc_venc_context->pre_me             = lavc_param_pre_me;
                    148: @@ -864,13 +878,11 @@ MOD_init
                    149:      lavc_venc_context->pre_dia_size       = lavc_param_pre_dia_size;
                    150:      lavc_venc_context->me_subpel_quality  = lavc_param_me_subpel_quality;
                    151:      lavc_venc_context->me_range           = lavc_param_me_range;
                    152: -    lavc_venc_context->intra_quant_bias   = lavc_param_ibias;
                    153: -    lavc_venc_context->inter_quant_bias   = lavc_param_pbias;
                    154:      lavc_venc_context->coder_type         = lavc_param_coder;
1.2       adam      155:      lavc_venc_context->context_model      = lavc_param_context;
                    156:      lavc_venc_context->scenechange_threshold= lavc_param_sc_threshold;
                    157:      lavc_venc_context->noise_reduction    = lavc_param_noise_reduction;
                    158: -    lavc_venc_context->inter_threshold    = lavc_param_inter_threshold;
                    159: +    set_dict_opt(lavc_param_inter_threshold, "inter_threshold");
                    160:      lavc_venc_context->intra_dc_precision = lavc_param_intra_dc_precision;
                    161:      lavc_venc_context->skip_top           = lavc_param_skip_top;
                    162:      lavc_venc_context->skip_bottom        = lavc_param_skip_bottom;
1.3       markd     163: @@ -887,7 +899,7 @@ MOD_init
1.1       markd     164:                    lavc_venc_context->thread_count);
                    165:      }
                    166:  
                    167: -    avcodec_thread_init(lavc_venc_context, lavc_param_threads);
                    168: +    lavc_venc_context->thread_count = lavc_param_threads;
                    169:  
                    170:      if (lavc_param_intra_matrix) {
                    171:          char *tmp;
1.3       markd     172: @@ -1061,19 +1073,20 @@ MOD_init
                    173:      lavc_venc_context->ildct_cmp  = lavc_param_ildct_cmp;
                    174:      lavc_venc_context->dia_size   = lavc_param_dia_size;
                    175:      lavc_venc_context->flags |= lavc_param_qpel;
                    176: -    lavc_venc_context->flags |= lavc_param_gmc;
                    177: +    if(lavc_param_gmc)
                    178: +        av_dict_set(&lavc_venc_opts, "gmc", "1", 0);
1.1       markd     179:      lavc_venc_context->flags |= lavc_param_closedgop;
                    180:      lavc_venc_context->flags |= lavc_param_trunc;
                    181:      lavc_venc_context->flags |= lavc_param_aic;
                    182: -    lavc_venc_context->flags |= lavc_param_umv;
                    183:      lavc_venc_context->flags |= lavc_param_v4mv;
                    184: -    lavc_venc_context->flags |= lavc_param_data_partitioning;
1.2       adam      185: -    lavc_venc_context->flags |= lavc_param_cbp;
1.3       markd     186: -    lavc_venc_context->flags |= lavc_param_mv0;
1.2       adam      187: -    lavc_venc_context->flags |= lavc_param_qp_rd;
1.1       markd     188: -    lavc_venc_context->flags |= lavc_param_scan_offset;
                    189: -    lavc_venc_context->flags |= lavc_param_ss;
                    190: -    lavc_venc_context->flags |= lavc_param_alt;
1.3       markd     191: +    if(lavc_param_cbp)
                    192: +      av_dict_set(&lavc_venc_opts, "mpv_flags", "+cbp_rd", 0);
                    193: +    if(lavc_param_mv0)
                    194: +        av_dict_set(&lavc_venc_opts, "mpv_flags", "+mv0", 0);
1.2       adam      195: +    if(lavc_param_qp_rd)
                    196: +      av_dict_set(&lavc_venc_opts, "mpv_flags", "+qp_rd", 0);
1.3       markd     197: +    if (lavc_param_normalize_aqp)
                    198: +      av_dict_set(&lavc_venc_opts, "mpv_flags", "+naq", 0);
1.1       markd     199:      lavc_venc_context->flags |= lavc_param_ilme;
                    200:  #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)   
                    201:      lavc_venc_context->flags |= lavc_param_trell;
1.3       markd     202: @@ -1082,9 +1095,7 @@ MOD_init
                    203:  #endif
1.1       markd     204:  
1.3       markd     205:      if (lavc_param_gray)
                    206: -        lavc_venc_context->flags |= CODEC_FLAG_GRAY;
                    207: -    if (lavc_param_normalize_aqp)
                    208: -        lavc_venc_context->flags |= CODEC_FLAG_NORMALIZE_AQP;
                    209: +        lavc_venc_context->flags |= AV_CODEC_FLAG_GRAY;
                    210:  
                    211:      switch(vob->encode_fields) {
                    212:      case TC_ENCODE_FIELDS_TOP_FIRST:
                    213: @@ -1102,9 +1113,9 @@ MOD_init
                    214:      }
                    215:  
                    216:      lavc_venc_context->flags |= interlacing_active ?
                    217: -        CODEC_FLAG_INTERLACED_DCT : 0;
                    218: +        AV_CODEC_FLAG_INTERLACED_DCT : 0;
                    219:      lavc_venc_context->flags |= interlacing_active ?
                    220: -        CODEC_FLAG_INTERLACED_ME : 0;
                    221: +        AV_CODEC_FLAG_INTERLACED_ME : 0;
                    222:  
                    223:      lavc_venc_context->flags |= lavc_param_psnr;
                    224:      do_psnr = lavc_param_psnr;
                    225: @@ -1112,7 +1123,7 @@ MOD_init
                    226:      lavc_venc_context->prediction_method = lavc_param_prediction_method;
                    227:  
                    228:      if(is_huffyuv)
                    229: -        lavc_venc_context->pix_fmt = PIX_FMT_YUV422P;
                    230: +        lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P;
                    231:      else
                    232:      {
                    233:          switch(pix_fmt)
                    234: @@ -1121,18 +1132,18 @@ MOD_init
                    235:              case CODEC_RGB:
                    236:              {
                    237:                  if(is_mjpeg)
                    238: -                    lavc_venc_context->pix_fmt = PIX_FMT_YUVJ420P;
                    239: +                    lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ420P;
                    240:                  else
                    241: -                    lavc_venc_context->pix_fmt = PIX_FMT_YUV420P;
                    242: +                    lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV420P;
                    243:                  break;
                    244:              }
                    245:  
                    246:              case CODEC_YUV422:
                    247:              {
                    248:                  if(is_mjpeg)
                    249: -                    lavc_venc_context->pix_fmt = PIX_FMT_YUVJ422P;
                    250: +                    lavc_venc_context->pix_fmt = AV_PIX_FMT_YUVJ422P;
                    251:                  else
                    252: -                    lavc_venc_context->pix_fmt = PIX_FMT_YUV422P;
                    253: +                    lavc_venc_context->pix_fmt = AV_PIX_FMT_YUV422P;
                    254:                  break;
                    255:              }
                    256:  
                    257: @@ -1151,7 +1162,7 @@ MOD_init
                    258:                    "encoding.");
                    259:            return TC_EXPORT_ERROR;
                    260:          }
                    261: -        lavc_venc_context->flags |= CODEC_FLAG_PASS1;
                    262: +        lavc_venc_context->flags |= AV_CODEC_FLAG_PASS1;
                    263:          stats_file = fopen(vob->divxlogfile, "w");
                    264:          if (stats_file == NULL){
                    265:            tc_log_warn(MOD_NAME, "Could not create 2pass log file \"%s\".",
                    266: @@ -1165,7 +1176,7 @@ MOD_init
                    267:                    "encoding.");
                    268:            return TC_EXPORT_ERROR;
                    269:          }
                    270: -        lavc_venc_context->flags |= CODEC_FLAG_PASS2;
                    271: +        lavc_venc_context->flags |= AV_CODEC_FLAG_PASS2;
                    272:          stats_file= fopen(vob->divxlogfile, "r");
                    273:          if (stats_file==NULL){
                    274:            tc_log_warn(MOD_NAME, "Could not open 2pass log file \"%s\" for "
                    275: @@ -1196,16 +1207,14 @@ MOD_init
                    276:          break;
                    277:        case 3:
                    278:          /* fixed qscale :p */
                    279: -        lavc_venc_context->flags   |= CODEC_FLAG_QSCALE;
                    280: +        lavc_venc_context->flags   |= AV_CODEC_FLAG_QSCALE;
                    281:          lavc_venc_frame->quality  = vob->divxbitrate;
                    282:          break;
                    283:      }
1.1       markd     284:  
1.3       markd     285: -    lavc_venc_context->me_method = ME_ZERO + lavc_param_vme;
1.4     ! wiz       286:  
1.1       markd     287: -
                    288:        /* FIXME: transcode itself contains "broken ffmpeg default settings", thus we need to override them! */
1.2       adam      289: -      if (lavc_param_video_preset) {
                    290: +      if (lavc_param_video_preset && strcmp(lavc_param_video_preset, "none")) {
1.1       markd     291:                avcodec_opts[AVMEDIA_TYPE_VIDEO] = lavc_venc_context;
1.2       adam      292:                video_codec_name = ffmpeg_codec_name(codec->name);
                    293:  
1.3       markd     294: @@ -1241,20 +1250,39 @@ MOD_init
1.1       markd     295:                }
                    296:        }
                    297:  
                    298: +    if (lavc_param_scan_offset) {
1.2       adam      299: +      av_dict_set(&lavc_venc_opts, "scan_offset", "1", 0);
1.1       markd     300: +    }
1.4     ! wiz       301:  
1.1       markd     302: +    if (lavc_param_ss) {
1.2       adam      303: +      av_dict_set(&lavc_venc_opts, "structured_slices", "1", 0);
1.1       markd     304: +    }
                    305: +
                    306: +    if (lavc_param_alt) {
1.2       adam      307: +      av_dict_set(&lavc_venc_opts, "alternate_scan", "1", 0);
1.1       markd     308: +    }
                    309: +
                    310: +    if (lavc_param_umv) {
1.2       adam      311: +      av_dict_set(&lavc_venc_opts, "umv", "1", 0);
1.1       markd     312: +    }
                    313: +
                    314: +    if (lavc_param_data_partitioning) {
1.2       adam      315: +      av_dict_set(&lavc_venc_opts, "vdpart", "1", 0);
1.1       markd     316: +    }
1.4     ! wiz       317: +
1.1       markd     318:      //-- open codec --
                    319:      //----------------
                    320:      TC_LOCK_LIBAVCODEC;
                    321: -    ret = avcodec_open(lavc_venc_context, lavc_venc_codec);
1.2       adam      322: +    ret = avcodec_open2(lavc_venc_context, lavc_venc_codec, &lavc_venc_opts);
1.1       markd     323:      TC_UNLOCK_LIBAVCODEC;
                    324:      if (ret < 0) {
                    325:        tc_log_warn(MOD_NAME, "could not open FFMPEG codec");
                    326:        return TC_EXPORT_ERROR;
                    327:      }
                    328:  
                    329: -    if (lavc_venc_context->codec->encode == NULL) {
                    330: +    if (av_codec_is_encoder(lavc_venc_context->codec) == 0) {
                    331:        tc_log_warn(MOD_NAME, "could not open FFMPEG codec "
                    332: -              "(lavc_venc_context->codec->encode == NULL)");
                    333: +              "(av_codec_is_encoder(lavc_venc_context->codec) == 0)");
                    334:        return TC_EXPORT_ERROR;
                    335:      }
                    336:  
1.3       markd     337: @@ -1574,6 +1602,8 @@ MOD_encode
                    338:  
                    339:    int out_size;
                    340:    const char pict_type_char[5]= {'?', 'I', 'P', 'B', 'S'};
                    341: +  AVPacket pkt;
                    342: +  int ret, got_packet = 0;
                    343:  
                    344:    if (param->flag == TC_VIDEO) {
                    345:  
                    346: @@ -1598,7 +1628,7 @@ MOD_encode
                    347:                        YUV_INIT_PLANES(src, param->buffer, IMG_YUV_DEFAULT,
                    348:                                                lavc_venc_context->width, lavc_venc_context->height);
                    349:                  avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer,
                    350: -                               PIX_FMT_YUV422P, lavc_venc_context->width,
                    351: +                               AV_PIX_FMT_YUV422P, lavc_venc_context->width,
                    352:                                 lavc_venc_context->height);
                    353:                        /* FIXME: can't use tcv_convert (see decode_lavc.c) */
                    354:                  ac_imgconvert(src, IMG_YUV_DEFAULT,
                    355: @@ -1628,7 +1658,7 @@ MOD_encode
                    356:                                                lavc_venc_context->width,
                    357:                                  lavc_venc_context->height);
                    358:                  avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer,
                    359: -                               PIX_FMT_YUV420P, lavc_venc_context->width,
                    360: +                               AV_PIX_FMT_YUV420P, lavc_venc_context->width,
                    361:                                 lavc_venc_context->height);
                    362:                  ac_imgconvert(src, IMG_YUV422P,
                    363:                                lavc_venc_frame->data, IMG_YUV420P,
                    364: @@ -1639,7 +1669,7 @@ MOD_encode
                    365:  
                    366:          case CODEC_RGB:
                    367:              avpicture_fill((AVPicture *)lavc_venc_frame, img_buffer,
                    368: -                           PIX_FMT_YUV420P, lavc_venc_context->width,
                    369: +                           AV_PIX_FMT_YUV420P, lavc_venc_context->width,
                    370:                             lavc_venc_context->height);
                    371:            ac_imgconvert(&param->buffer, IMG_RGB_DEFAULT,
                    372:                                lavc_venc_frame->data, IMG_YUV420P,
1.4     ! wiz       373: @@ -1652,12 +1682,16 @@ MOD_encode
1.3       markd     374:                return TC_EXPORT_ERROR;
                    375:      }
                    376:  
                    377: +    av_init_packet(&pkt);
                    378: +    pkt.data = enc_buffer;
                    379: +    pkt.size = size;
                    380:  
                    381:      TC_LOCK_LIBAVCODEC;
                    382: -    out_size = avcodec_encode_video(lavc_venc_context,
                    383: -                                    enc_buffer, size,
                    384: -                                    lavc_venc_frame);
                    385: +    ret = avcodec_encode_video2(lavc_venc_context, &pkt,
                    386: +                                    lavc_venc_frame, &got_packet);
                    387:      TC_UNLOCK_LIBAVCODEC;
1.4     ! wiz       388: +
        !           389: +    out_size = ret ? ret : pkt.size;
1.3       markd     390:  
                    391:      if (out_size < 0) {
                    392:        tc_log_warn(MOD_NAME, "encoder error: size (%d)", out_size);

CVSweb <webmaster@jp.NetBSD.org>