Ticket #7470: libquicktime-1.2.4-ffmpeg3.patch

File libquicktime-1.2.4-ffmpeg3.patch, 33.2 KB (added by Armin K, 5 years ago)

libquicktime patch

  • plugins/ffmpeg/audio.c

    a b  
    4545#define ENCODE_AUDIO 1
    4646#endif
    4747
     48#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
     49/* from libavcodec/avcodec.h dated Dec 23 2012 */
     50#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
     51#endif
     52
    4853/* The following code was ported from gmerlin_avdecoder (http://gmerlin.sourceforge.net) */
    4954
    5055/* MPEG Audio header parsing code */
     
    626631    {
    627632    /* If the codec is mp3, make sure to decode the very last frame */
    628633
    629     if((codec->avctx->codec_id == CODEC_ID_MP3) &&
     634    if((codec->avctx->codec_id == AV_CODEC_ID_MP3) &&
    630635       (codec->bytes_in_chunk_buffer >= 4))
    631636      {
    632637      if(!mpa_decode_header(&mph, codec->chunk_buffer, (const mpa_header*)0))
     
    695700   
    696701    /* Some really broken mp3 files have the header bytes split across 2 chunks */
    697702
    698     if(codec->avctx->codec_id == CODEC_ID_MP3)
     703    if(codec->avctx->codec_id == AV_CODEC_ID_MP3)
    699704      {
    700705      if(codec->bytes_in_chunk_buffer < 4)
    701706        {
     
    806811   
    807812    if(bytes_decoded < 0)
    808813      {
    809       if(codec->avctx->codec_id == CODEC_ID_MP3)
     814      if(codec->avctx->codec_id == AV_CODEC_ID_MP3)
    810815        {
    811816        /* For mp3, bytes_decoded < 0 means, that the frame should be muted */
    812817        memset(&codec->sample_buffer[track_map->channels * (codec->sample_buffer_end -
     
    866871  quicktime_audio_map_t *track_map = &file->atracks[track];
    867872  quicktime_ffmpeg_audio_codec_t *codec = track_map->codec->priv;
    868873
    869   if((codec->decoder->id == CODEC_ID_MP2) ||
    870      (codec->decoder->id == CODEC_ID_MP3))
     874  if((codec->decoder->id == AV_CODEC_ID_MP2) ||
     875     (codec->decoder->id == AV_CODEC_ID_MP3))
    871876    {
    872877    mpa_header h;
    873878    uint32_t header;
     
    909914    else
    910915      track_map->ci.bitrate = h.bitrate;
    911916    }
    912   else if(codec->decoder->id == CODEC_ID_AC3)
     917  else if(codec->decoder->id == AV_CODEC_ID_AC3)
    913918    {
    914919    a52_header h;
    915920    uint8_t * ptr;
     
    986991#endif
    987992    /* Some codecs need extra stuff */
    988993
    989     if(codec->decoder->id == CODEC_ID_ALAC)
     994    if(codec->decoder->id == AV_CODEC_ID_ALAC)
    990995      {
    991996      header = quicktime_wave_get_user_atom(track_map->track, "alac", &header_len);
    992997      if(header)
     
    9951000        codec->avctx->extradata_size = header_len;
    9961001        }
    9971002      }
    998     if(codec->decoder->id == CODEC_ID_QDM2)
     1003    if(codec->decoder->id == AV_CODEC_ID_QDM2)
    9991004      {
    10001005      header = quicktime_wave_get_user_atom(track_map->track, "QDCA", &header_len);
    10011006      if(header)
     
    12611266    pkt.data = codec->chunk_buffer;
    12621267    pkt.size = codec->chunk_buffer_alloc;
    12631268
    1264     avcodec_get_frame_defaults(&f);
     1269    av_frame_unref(&f);
    12651270    f.nb_samples = codec->avctx->frame_size;
    12661271   
    12671272    avcodec_fill_audio_frame(&f, channels, codec->avctx->sample_fmt,
     
    14951500    codec_base->decode_audio = lqt_ffmpeg_decode_audio;
    14961501  codec_base->set_parameter = set_parameter;
    14971502
    1498   if((decoder->id == CODEC_ID_MP3) || (decoder->id == CODEC_ID_MP2))
     1503  if((decoder->id == AV_CODEC_ID_MP3) || (decoder->id == AV_CODEC_ID_MP2))
    14991504    codec_base->read_packet = read_packet_mpa;
    1500   else if(decoder->id == CODEC_ID_AC3)
     1505  else if(decoder->id == AV_CODEC_ID_AC3)
    15011506    {
    15021507    codec_base->write_packet = write_packet_ac3;
    15031508    codec_base->read_packet = read_packet_ac3;
  • plugins/ffmpeg/ffmpeg.h

    a b  
    2727
    2828#include <quicktime/qtprivate.h>
    2929#include AVCODEC_HEADER
     30#include <libavutil/mem.h>
    3031
    3132void quicktime_init_video_codec_ffmpeg(quicktime_codec_t * codec,
    3233                                       quicktime_video_map_t *vtrack,
  • plugins/ffmpeg/lqt_ffmpeg.c

    a b  
    386386struct CODECIDMAP codecidmap_v[] =
    387387  {
    388388    {
    389       .id = CODEC_ID_MPEG1VIDEO,
     389      .id = AV_CODEC_ID_MPEG1VIDEO,
    390390      .index = -1,
    391391      .encoder = NULL,
    392392      .decoder = NULL,
     
    397397      .wav_ids = { LQT_WAV_ID_NONE }
    398398    },
    399399    {
    400       .id = CODEC_ID_MPEG4,
     400      .id = AV_CODEC_ID_MPEG4,
    401401      .index = -1,
    402402      .encoder = NULL,
    403403      .decoder = NULL,
     
    415415      .compression_id = LQT_COMPRESSION_MPEG4_ASP,
    416416    },
    417417    {
    418       .id = CODEC_ID_MSMPEG4V1,
     418      .id = AV_CODEC_ID_MSMPEG4V1,
    419419      .index = -1,
    420420      .encoder = NULL,
    421421      .decoder = NULL,
     
    426426      .wav_ids = { LQT_WAV_ID_NONE },
    427427    },
    428428    {
    429       .id = CODEC_ID_MSMPEG4V2,
     429      .id = AV_CODEC_ID_MSMPEG4V2,
    430430      .index = -1,
    431431      .encoder = NULL,
    432432      .decoder = NULL,
     
    437437      .wav_ids = { LQT_WAV_ID_NONE },
    438438    },
    439439    {
    440       .id = CODEC_ID_MSMPEG4V3,
     440      .id = AV_CODEC_ID_MSMPEG4V3,
    441441      .index = -1,
    442442      .encoder = NULL,
    443443      .decoder = NULL,
     
    453453      .do_encode = 1,
    454454    },
    455455    {
    456       .id = CODEC_ID_MSMPEG4V3,
     456      .id = AV_CODEC_ID_MSMPEG4V3,
    457457      .index = -1,
    458458      .encoder = NULL,
    459459      .decoder = NULL,
     
    468468    },
    469469#if 0
    470470    {
    471       .id = CODEC_ID_WMV1,
     471      .id = AV_CODEC_ID_WMV1,
    472472      .index = -1,
    473473      .encoder = NULL,
    474474      .decoder = NULL,
     
    481481    },
    482482#endif
    483483    {
    484       .id = CODEC_ID_H263,
     484      .id = AV_CODEC_ID_H263,
    485485      .index = -1,
    486486      .encoder = NULL,
    487487      .decoder = NULL,
     
    493493      .compatibility_flags = LQT_FILE_QT_OLD | LQT_FILE_QT | LQT_FILE_MP4 | LQT_FILE_3GP,
    494494    },
    495495    {
    496       .id = CODEC_ID_H263,
     496      .id = AV_CODEC_ID_H263,
    497497      .index = -1,
    498498      .encoder = NULL,
    499499      .decoder = NULL,
     
    508508      .do_encode = 1,
    509509    },
    510510    {
    511       .id = CODEC_ID_H264,
     511      .id = AV_CODEC_ID_H264,
    512512      .index = -1,
    513513      .encoder = NULL,
    514514      .decoder = NULL,
     
    519519      .wav_ids = { LQT_WAV_ID_NONE },
    520520    },
    521521    {
    522       .id = CODEC_ID_H263P,
     522      .id = AV_CODEC_ID_H263P,
    523523      .index = -1,
    524524      .encoder = NULL,
    525525      .decoder = NULL,
     
    533533      .do_encode = 1,
    534534    },
    535535    {
    536       .id = CODEC_ID_H263I,
     536      .id = AV_CODEC_ID_H263I,
    537537      .index = -1,
    538538      .encoder = NULL,
    539539      .decoder = NULL,
     
    544544      .wav_ids = { LQT_WAV_ID_NONE },
    545545    },
    546546    {
    547       .id = CODEC_ID_SVQ1,
     547      .id = AV_CODEC_ID_SVQ1,
    548548      .index = -1,
    549549      .encoder = NULL,
    550550      .decoder = NULL,
     
    555555      .wav_ids = { LQT_WAV_ID_NONE },
    556556    },
    557557    {
    558       .id = CODEC_ID_SVQ3,
     558      .id = AV_CODEC_ID_SVQ3,
    559559      .index = -1,
    560560      .encoder = NULL,
    561561      .decoder = NULL,
     
    566566      .wav_ids = { LQT_WAV_ID_NONE },
    567567    },
    568568    {
    569       .id = CODEC_ID_MJPEG,
     569      .id = AV_CODEC_ID_MJPEG,
    570570      .index = -1,
    571571      .encoder = NULL,
    572572      .decoder = NULL,
     
    580580      .do_encode = 1,
    581581    },
    582582    {
    583       .id = CODEC_ID_MJPEGB,
     583      .id = AV_CODEC_ID_MJPEGB,
    584584      .index = -1,
    585585      .encoder = NULL,
    586586      .decoder = NULL,
     
    594594    },
    595595#if LIBAVCODEC_BUILD >= 3346688
    596596    {
    597       .id = CODEC_ID_TARGA,
     597      .id = AV_CODEC_ID_TARGA,
    598598      .index = -1,
    599599      .encoder = NULL,
    600600      .decoder = NULL,
     
    606606#endif
    607607#if LIBAVCODEC_BUILD >= 3347456
    608608    {
    609       .id = CODEC_ID_TIFF,
     609      .id = AV_CODEC_ID_TIFF,
    610610      .index = -1,
    611611      .encoder = NULL,
    612612      .decoder = NULL,
     
    617617    },
    618618#endif
    619619    {
    620       .id = CODEC_ID_8BPS,
     620      .id = AV_CODEC_ID_8BPS,
    621621      .index = -1,
    622622      .encoder = NULL,
    623623      .decoder = NULL,
     
    627627      .wav_ids = { LQT_WAV_ID_NONE },
    628628    },
    629629    {
    630       .id = CODEC_ID_INDEO3,
     630      .id = AV_CODEC_ID_INDEO3,
    631631      .index = -1,
    632632      .encoder = NULL,
    633633      .decoder = NULL,
     
    638638      .wav_ids = { LQT_WAV_ID_NONE },
    639639    },
    640640    {
    641       .id = CODEC_ID_RPZA,
     641      .id = AV_CODEC_ID_RPZA,
    642642      .index = -1,
    643643      .encoder = NULL,
    644644      .decoder = NULL,
     
    648648      .wav_ids = { LQT_WAV_ID_NONE },
    649649    },
    650650    {
    651       .id = CODEC_ID_SMC,
     651      .id = AV_CODEC_ID_SMC,
    652652      .index = -1,
    653653      .encoder = NULL,
    654654      .decoder = NULL,
     
    658658      .wav_ids = { LQT_WAV_ID_NONE },
    659659    },
    660660    {
    661       .id = CODEC_ID_CINEPAK,
     661      .id = AV_CODEC_ID_CINEPAK,
    662662      .index = -1,
    663663      .encoder = NULL,
    664664      .decoder = NULL,
     
    669669      .wav_ids = { LQT_WAV_ID_NONE },
    670670    },
    671671    {
    672       .id = CODEC_ID_CYUV,
     672      .id = AV_CODEC_ID_CYUV,
    673673      .index = -1,
    674674      .encoder = NULL,
    675675      .decoder = NULL,
     
    680680      .wav_ids = { LQT_WAV_ID_NONE },
    681681    },
    682682    {
    683       .id = CODEC_ID_QTRLE,
     683      .id = AV_CODEC_ID_QTRLE,
    684684      .index = -1,
    685685      .encoder = NULL,
    686686      .decoder = NULL,
     
    693693      .encoding_colormodels = (int[]){ BC_RGB888, BC_RGBA8888, LQT_COLORMODEL_NONE },
    694694    },
    695695    {
    696       .id = CODEC_ID_MSRLE,
     696      .id = AV_CODEC_ID_MSRLE,
    697697      .index = -1,
    698698      .encoder = NULL,
    699699      .decoder = NULL,
     
    703703      .wav_ids = { LQT_WAV_ID_NONE },
    704704    },
    705705    {
    706       .id = CODEC_ID_DVVIDEO,
     706      .id = AV_CODEC_ID_DVVIDEO,
    707707      .index = -1,
    708708      .encoder = NULL,
    709709      .decoder = NULL,
     
    719719      .image_sizes = image_sizes_dv,
    720720    },
    721721    {
    722       .id = CODEC_ID_DVVIDEO,
     722      .id = AV_CODEC_ID_DVVIDEO,
    723723      .index = -1,
    724724      .encoder = NULL,
    725725      .decoder = NULL,
     
    735735      .image_sizes = image_sizes_dv,
    736736    },
    737737    {
    738       .id = CODEC_ID_DVVIDEO,
     738      .id = AV_CODEC_ID_DVVIDEO,
    739739      .index = -1,
    740740      .encoder = NULL,
    741741      .decoder = NULL,
     
    751751    },
    752752    /* DVCPRO HD (decoding only for now) */
    753753    {
    754       .id = CODEC_ID_DVVIDEO,
     754      .id = AV_CODEC_ID_DVVIDEO,
    755755      .index = -1,
    756756      .encoder = NULL,
    757757      .decoder = NULL,
     
    772772      // .do_encode = 1
    773773    },
    774774    {
    775       .id = CODEC_ID_FFVHUFF,
     775      .id = AV_CODEC_ID_FFVHUFF,
    776776      .index = -1,
    777777      .encoder = NULL,
    778778      .decoder = NULL,
     
    785785      .do_encode = 1
    786786    },
    787787    {
    788       .id = CODEC_ID_FFV1,
     788      .id = AV_CODEC_ID_FFV1,
    789789      .index = -1,
    790790      .encoder = NULL,
    791791      .decoder = NULL,
     
    801801    },
    802802#if LIBAVCODEC_BUILD >= 3352576
    803803    {
    804       .id = CODEC_ID_DNXHD,
     804      .id = AV_CODEC_ID_DNXHD,
    805805      .index = -1,
    806806      .encoder = NULL,
    807807      .decoder = NULL,
     
    817817    },
    818818#endif
    819819    {
    820       .id = CODEC_ID_MPEG2VIDEO,
     820      .id = AV_CODEC_ID_MPEG2VIDEO,
    821821      .index = -1,
    822822      .encoder = NULL,
    823823      .decoder = NULL,
     
    839839struct CODECIDMAP codecidmap_a[] =
    840840  {
    841841    {
    842       .id = CODEC_ID_MP3,
     842      .id = AV_CODEC_ID_MP3,
    843843      .index = -1,
    844844      .encoder = NULL,
    845845      .decoder = NULL,
     
    851851      .wav_ids = { 0x50, 0x55, LQT_WAV_ID_NONE },
    852852    },
    853853    {
    854       .id = CODEC_ID_MP2,
     854      .id = AV_CODEC_ID_MP2,
    855855      .index = -1,
    856856      .encoder = NULL,
    857857      .decoder = NULL,
     
    866866      .compression_id = LQT_COMPRESSION_MP2,
    867867    },
    868868    {
    869       .id = CODEC_ID_AC3,
     869      .id = AV_CODEC_ID_AC3,
    870870      .index = -1,
    871871      .encoder = NULL,
    872872      .decoder = NULL,
     
    881881      .compression_id = LQT_COMPRESSION_AC3,
    882882    },
    883883    {
    884       .id = CODEC_ID_QDM2,
     884      .id = AV_CODEC_ID_QDM2,
    885885      .index = -1,
    886886      .encoder = NULL,
    887887      .decoder = NULL,
     
    896896#if 1
    897897    /* Doesn't work as long as audio chunks are not split into VBR "Samples" */
    898898    {
    899       .id = CODEC_ID_ALAC,
     899      .id = AV_CODEC_ID_ALAC,
    900900      .index = -1,
    901901      .encoder = NULL,
    902902      .decoder = NULL,
     
    909909#if 1
    910910    /* Sounds ugly */
    911911    {
    912       .id = CODEC_ID_ADPCM_MS,
     912      .id = AV_CODEC_ID_ADPCM_MS,
    913913      .index = -1,
    914914      .encoder = NULL,
    915915      .decoder = NULL,
     
    922922#if 1
    923923    /* Sounds ugly */
    924924    {
    925       .id = CODEC_ID_ADPCM_IMA_WAV,
     925      .id = AV_CODEC_ID_ADPCM_IMA_WAV,
    926926      .index = -1,
    927927      .encoder = NULL,
    928928      .decoder = NULL,
  • plugins/ffmpeg/params.c

    a b  
    101101    }                                           \
    102102  }
    103103
     104#define PARAM_DICT_INT(name, dict_name)             \
     105  {                                                 \
     106  if(!strcasecmp(name, key))                        \
     107    {                                               \
     108    char buf[128];                                  \
     109    snprintf(buf, sizeof(buf), "%d", *(int*)value); \
     110    av_dict_set(options, dict_name, buf, 0);        \
     111    found = 1;                                      \
     112    }                                               \
     113  }
     114
    104115#define PARAM_DICT_FLAG(name, dict_name)        \
    105116  {                                             \
    106117  if(!strcasecmp(name, key))                    \
     
    202213  PARAM_INT("ff_max_b_frames",max_b_frames);
    203214  PARAM_FLOAT("ff_b_quant_factor",b_quant_factor);
    204215  PARAM_INT("ff_b_frame_strategy",b_frame_strategy);
     216
     217#if LIBAVCODEC_VERSION_MAJOR >= 55
     218  PARAM_DICT_INT("ff_luma_elim_threshold","luma_elim_threshold");
     219  PARAM_DICT_INT("ff_chroma_elim_threshold","chroma_elim_threshold");
     220#else
    205221  PARAM_INT("ff_luma_elim_threshold",luma_elim_threshold);
    206222  PARAM_INT("ff_chroma_elim_threshold",chroma_elim_threshold);
     223#endif
     224
    207225  PARAM_INT("ff_strict_std_compliance",strict_std_compliance);
    208226  PARAM_QP2LAMBDA("ff_b_quant_offset",b_quant_offset);
    209227  PARAM_INT("ff_rc_min_rate",rc_min_rate);
     
    241259  PARAM_QP2LAMBDA("ff_lmax", lmax);
    242260  PARAM_INT("ff_noise_reduction",noise_reduction);
    243261  PARAM_INT_SCALE("ff_rc_initial_buffer_occupancy",rc_initial_buffer_occupancy,1000);
     262
     263#if LIBAVCODEC_VERSION_MAJOR >= 55
     264  PARAM_DICT_INT("ff_inter_threshold","inter_threshold");
     265  PARAM_DICT_INT("ff_quantizer_noise_shaping","quantizer_noise_shaping");
     266#else
    244267  PARAM_INT("ff_inter_threshold",inter_threshold);
    245268  PARAM_INT("ff_quantizer_noise_shaping",quantizer_noise_shaping);
     269#endif
     270
    246271  PARAM_INT("ff_thread_count",thread_count);
    247272  PARAM_INT("ff_me_threshold",me_threshold);
    248273  PARAM_INT("ff_mb_threshold",mb_threshold);
     
    272297  PARAM_FLAG("ff_flag_bitexact",CODEC_FLAG_BITEXACT);
    273298  PARAM_FLAG("ff_flag_ac_pred",CODEC_FLAG_AC_PRED);
    274299  //  PARAM_FLAG("ff_flag_h263p_umv",CODEC_FLAG_H263P_UMV); // Unused
     300
     301#if LIBAVCODEC_VERSION_MAJOR >= 55
     302  PARAM_DICT_FLAG("ff_flag_cbp_rd","cbp_rd");
     303  PARAM_DICT_FLAG("ff_flag_qp_rd","qp_rd");
     304  PARAM_DICT_FLAG("ff_flag2_strict_gop","strict_gop");
     305#else
    275306  PARAM_FLAG("ff_flag_cbp_rd",CODEC_FLAG_CBP_RD);
    276307  PARAM_FLAG("ff_flag_qp_rd",CODEC_FLAG_QP_RD);
     308  PARAM_FLAG2("ff_flag2_strict_gop",CODEC_FLAG2_STRICT_GOP);
     309#endif
    277310
    278311#if LIBAVCODEC_VERSION_MAJOR >= 54
    279312  PARAM_DICT_FLAG("ff_flag_h263p_aiv", "aiv");
     
    288321  PARAM_FLAG("ff_flag_loop_filter",CODEC_FLAG_LOOP_FILTER);
    289322  PARAM_FLAG("ff_flag_closed_gop",CODEC_FLAG_CLOSED_GOP);
    290323  PARAM_FLAG2("ff_flag2_fast",CODEC_FLAG2_FAST);
    291   PARAM_FLAG2("ff_flag2_strict_gop",CODEC_FLAG2_STRICT_GOP);
    292324  PARAM_ENUM("ff_coder_type",coder_type,coder_type);
    293325 
    294326  }
  • plugins/ffmpeg/video.c

    a b  
    3737#endif
    3838
    3939
    40 #ifdef  PIX_FMT_YUV422P10
    41 #define PIX_FMT_YUV422P10_OR_DUMMY PIX_FMT_YUV422P10
     40#ifdef  AV_PIX_FMT_YUV422P10
     41#define AV_PIX_FMT_YUV422P10_OR_DUMMY AV_PIX_FMT_YUV422P10
    4242#else
    43 #define PIX_FMT_YUV422P10_OR_DUMMY -1234
     43#define AV_PIX_FMT_YUV422P10_OR_DUMMY -1234
    4444#endif
    4545
    4646#if LIBAVCODEC_VERSION_INT >= ((54<<16)|(1<<8)|0)
     
    9090  int imx_bitrate;
    9191  int imx_strip_vbi;
    9292
    93   /* In some cases FFMpeg would report something like PIX_FMT_YUV422P, while
    94      we would like to treat it as PIX_FMT_YUVJ422P. It's only used for decoding */
    95   enum PixelFormat reinterpret_pix_fmt;
     93  /* In some cases FFMpeg would report something like AV_PIX_FMT_YUV422P, while
     94     we would like to treat it as AV_PIX_FMT_YUVJ422P. It's only used for decoding */
     95  enum AVPixelFormat reinterpret_pix_fmt;
    9696 
    9797  int is_imx;
    9898  int y_offset;
     
    137137
    138138static const struct
    139139  {
    140   enum PixelFormat ffmpeg_id;
     140  enum AVPixelFormat ffmpeg_id;
    141141  int              lqt_id;
    142142  int              exact;
    143143  }
    144144colormodels[] =
    145145  {
    146     { PIX_FMT_YUV420P,   BC_YUV420P,   1 }, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
     146    { AV_PIX_FMT_YUV420P,   BC_YUV420P,   1 }, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
    147147#if LIBAVUTIL_VERSION_INT < (50<<16)
    148     { PIX_FMT_YUV422,    BC_YUV422,    1 },
     148    { AV_PIX_FMT_YUV422,    BC_YUV422,    1 },
    149149#else
    150     { PIX_FMT_YUYV422,   BC_YUV422,    1 },
     150    { AV_PIX_FMT_YUYV422,   BC_YUV422,    1 },
    151151#endif
    152     { PIX_FMT_RGB24,     BC_RGB888,    1 }, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
    153     { PIX_FMT_BGR24,     BC_BGR888,    1 }, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
    154     { PIX_FMT_YUV422P,   BC_YUV422P,   1 }, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
    155     { PIX_FMT_YUV444P,   BC_YUV444P,   1 }, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
    156     { PIX_FMT_YUV411P,   BC_YUV411P,   1 }, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
    157     { PIX_FMT_YUV422P16, BC_YUV422P16, 1 }, ///< Planar 16 bit YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
    158 #ifdef PIX_FMT_YUV422P10
    159     { PIX_FMT_YUV422P10, BC_YUV422P10, 1 }, ///< 10 bit samples in uint16_t containers, planar 4:2:2
    160 #endif
    161     { PIX_FMT_RGB565,    BC_RGB565,    1 }, ///< always stored in cpu endianness
    162     { PIX_FMT_YUVJ420P,  BC_YUVJ420P,  1 }, ///< Planar YUV 4:2:0 full scale (jpeg)
    163     { PIX_FMT_YUVJ422P,  BC_YUVJ422P,  1 }, ///< Planar YUV 4:2:2 full scale (jpeg)
    164     { PIX_FMT_YUVJ444P,  BC_YUVJ444P,  1 }, ///< Planar YUV 4:4:4 full scale (jpeg)
     152    { AV_PIX_FMT_RGB24,     BC_RGB888,    1 }, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
     153    { AV_PIX_FMT_BGR24,     BC_BGR888,    1 }, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
     154    { AV_PIX_FMT_YUV422P,   BC_YUV422P,   1 }, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
     155    { AV_PIX_FMT_YUV444P,   BC_YUV444P,   1 }, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
     156    { AV_PIX_FMT_YUV411P,   BC_YUV411P,   1 }, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
     157    { AV_PIX_FMT_YUV422P16, BC_YUV422P16, 1 }, ///< Planar 16 bit YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
     158#ifdef AV_PIX_FMT_YUV422P10
     159    { AV_PIX_FMT_YUV422P10, BC_YUV422P10, 1 }, ///< 10 bit samples in uint16_t containers, planar 4:2:2
     160#endif
     161    { AV_PIX_FMT_RGB565,    BC_RGB565,    1 }, ///< always stored in cpu endianness
     162    { AV_PIX_FMT_YUVJ420P,  BC_YUVJ420P,  1 }, ///< Planar YUV 4:2:0 full scale (jpeg)
     163    { AV_PIX_FMT_YUVJ422P,  BC_YUVJ422P,  1 }, ///< Planar YUV 4:2:2 full scale (jpeg)
     164    { AV_PIX_FMT_YUVJ444P,  BC_YUVJ444P,  1 }, ///< Planar YUV 4:4:4 full scale (jpeg)
    165165#if LIBAVUTIL_VERSION_INT < (50<<16)
    166     { PIX_FMT_RGBA32,    BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
     166    { AV_PIX_FMT_RGBA32,    BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
    167167#else
    168     { PIX_FMT_RGB32,     BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
     168    { AV_PIX_FMT_RGB32,     BC_RGBA8888,  0 }, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
    169169#endif
    170     { PIX_FMT_RGB555,    BC_RGB888,    0 }, ///< always stored in cpu endianness, most significant bit to 1
    171     { PIX_FMT_GRAY8,     BC_RGB888,    0 },
    172     { PIX_FMT_MONOWHITE, BC_RGB888,    0 }, ///< 0 is white
    173     { PIX_FMT_MONOBLACK, BC_RGB888,    0 }, ///< 0 is black
    174     { PIX_FMT_PAL8,      BC_RGB888,    0 }, ///< 8 bit with RGBA palette
    175     { PIX_FMT_YUV410P,   BC_YUV420P,   0 }, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
     170    { AV_PIX_FMT_RGB555,    BC_RGB888,    0 }, ///< always stored in cpu endianness, most significant bit to 1
     171    { AV_PIX_FMT_GRAY8,     BC_RGB888,    0 },
     172    { AV_PIX_FMT_MONOWHITE, BC_RGB888,    0 }, ///< 0 is white
     173    { AV_PIX_FMT_MONOBLACK, BC_RGB888,    0 }, ///< 0 is black
     174    { AV_PIX_FMT_PAL8,      BC_RGB888,    0 }, ///< 8 bit with RGBA palette
     175    { AV_PIX_FMT_YUV410P,   BC_YUV420P,   0 }, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
    176176  };
    177177
    178178static const struct
     
    343343  if (!codec->pix_fmts)
    344344    return 0;
    345345
    346   for (i = 0; codec->pix_fmts[i] != PIX_FMT_NONE; ++i)
     346  for (i = 0; codec->pix_fmts[i] != AV_PIX_FMT_NONE; ++i)
    347347    {
    348     if (codec->pix_fmts[i] == PIX_FMT_YUV422P10_OR_DUMMY)
     348    if (codec->pix_fmts[i] == AV_PIX_FMT_YUV422P10_OR_DUMMY)
    349349      return 1;
    350350    }
    351351
    352352  return 0;
    353353  }
    354354
    355 static enum PixelFormat lqt_ffmpeg_get_ffmpeg_colormodel(int id)
     355static enum AVPixelFormat lqt_ffmpeg_get_ffmpeg_colormodel(int id)
    356356  {
    357357  int i;
    358358
     
    361361    if(colormodels[i].lqt_id == id)
    362362      return colormodels[i].ffmpeg_id;
    363363    }
    364   return PIX_FMT_NB;
     364  return AV_PIX_FMT_NB;
    365365  }
    366366
    367 static int lqt_ffmpeg_get_lqt_colormodel(enum PixelFormat id, int * exact)
     367static int lqt_ffmpeg_get_lqt_colormodel(enum AVPixelFormat id, int * exact)
    368368  {
    369369  int i;
    370370
     
    400400  codec->reinterpret_pix_fmt = codec->avctx->pix_fmt;
    401401
    402402  /* First we try codec-specific colormodel matching. */
    403   if(codec->decoder->id == CODEC_ID_DNXHD)
     403  if(codec->decoder->id == AV_CODEC_ID_DNXHD)
    404404    {
    405     /* FFMpeg supports PIX_FMT_YUV422P and PIX_FMT_YUV422P10 for DNxHD, which
    406        we sometimes interpret as PIX_FMT_YUVJ422P and PIX_FMT_YUVJ422P10. */
    407     if (codec->avctx->pix_fmt == PIX_FMT_YUV422P || codec->avctx->pix_fmt == PIX_FMT_YUV422P10_OR_DUMMY)
     405    /* FFMpeg supports AV_PIX_FMT_YUV422P and AV_PIX_FMT_YUV422P10 for DNxHD, which
     406       we sometimes interpret as AV_PIX_FMT_YUVJ422P and AV_PIX_FMT_YUVJ422P10. */
     407    if (codec->avctx->pix_fmt == AV_PIX_FMT_YUV422P || codec->avctx->pix_fmt == AV_PIX_FMT_YUV422P10_OR_DUMMY)
    408408      {
    409       int p10 = (codec->avctx->pix_fmt == PIX_FMT_YUV422P10_OR_DUMMY);
     409      int p10 = (codec->avctx->pix_fmt == AV_PIX_FMT_YUV422P10_OR_DUMMY);
    410410      *exact = 1;
    411411      if (lqt_ffmpeg_get_avid_yuv_range(vtrack->track) == AVID_FULL_YUV_RANGE)
    412412        {
    413413        vtrack->stream_cmodel = p10 ? BC_YUVJ422P10 : BC_YUVJ422P;
    414         codec->reinterpret_pix_fmt = p10 ? PIX_FMT_YUV422P10_OR_DUMMY : PIX_FMT_YUVJ422P;
    415         // Note: reinterpret_pix_fmt should really be PIX_FMT_YUVJ422P10, except
     414        codec->reinterpret_pix_fmt = p10 ? AV_PIX_FMT_YUV422P10_OR_DUMMY : AV_PIX_FMT_YUVJ422P;
     415        // Note: reinterpret_pix_fmt should really be AV_PIX_FMT_YUVJ422P10, except
    416416        // there is no such colormodel in FFMpeg. Fortunately, it's not a problem
    417417        // in this case, as reinterpret_pix_fmt is only used when *exact == 0.
    418418        }
    419419      else
    420420        {
    421421        vtrack->stream_cmodel = p10 ? BC_YUV422P10 : BC_YUV422P;
    422         codec->reinterpret_pix_fmt = p10 ? PIX_FMT_YUV422P10_OR_DUMMY : PIX_FMT_YUV422P;
     422        codec->reinterpret_pix_fmt = p10 ? AV_PIX_FMT_YUV422P10_OR_DUMMY : AV_PIX_FMT_YUV422P;
    423423        }
    424424      return;
    425425      }
     
    438438  quicktime_ffmpeg_video_codec_t *codec = vtrack->codec->priv;
    439439  codec->avctx->pix_fmt = lqt_ffmpeg_get_ffmpeg_colormodel(vtrack->stream_cmodel);
    440440
    441   if (codec->encoder->id == CODEC_ID_DNXHD)
     441  if (codec->encoder->id == AV_CODEC_ID_DNXHD)
    442442    {
    443     /* FFMpeg's DNxHD encoder only supports PIX_FMT_YUV422P and PIX_FMT_YUV422P10
    444        and doesn't know anything about PIX_FMT_YUVJ422P and PIX_FMT_YUVJ422P10
     443    /* FFMpeg's DNxHD encoder only supports AV_PIX_FMT_YUV422P and AV_PIX_FMT_YUV422P10
     444       and doesn't know anything about AV_PIX_FMT_YUVJ422P and AV_PIX_FMT_YUVJ422P10
    445445       (in fact, the latter doesn't even exist) */
    446     codec->avctx->pix_fmt = PIX_FMT_YUV422P;
     446    codec->avctx->pix_fmt = AV_PIX_FMT_YUV422P;
    447447    if (vtrack->stream_cmodel == BC_YUV422P10 || vtrack->stream_cmodel == BC_YUVJ422P10)
    448448      {
    449449      if (lqt_tenbit_dnxhd_supported(codec->encoder))
    450         codec->avctx->pix_fmt = PIX_FMT_YUV422P10_OR_DUMMY;
     450        codec->avctx->pix_fmt = AV_PIX_FMT_YUV422P10_OR_DUMMY;
    451451      }
    452452    }
    453453  }
     
    458458/* From avcodec.h: */
    459459
    460460/*
    461  * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
     461 * AV_PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
    462462 * color is put together as:
    463463 *  (A << 24) | (R << 16) | (G << 8) | B
    464464 * This is stored as BGRA on little endian CPU architectures and ARGB on
     
    530530 */
    531531
    532532static void convert_image_decode(quicktime_ffmpeg_video_codec_t *codec,
    533                                  AVFrame * in_frame, enum PixelFormat in_format,
     533                                 AVFrame * in_frame, enum AVPixelFormat in_format,
    534534                                 unsigned char ** out_frame, int out_format,
    535535                                 int width, int height, int row_span, int row_span_uv)
    536536  {
     
    547547   *  RGBA format like in ffmpeg??
    548548   */
    549549#if LIBAVUTIL_VERSION_INT < (50<<16)
    550   if((in_format == PIX_FMT_RGBA32) && (out_format == BC_RGBA8888))
     550  if((in_format == AV_PIX_FMT_RGBA32) && (out_format == BC_RGBA8888))
    551551#else
    552     if((in_format == PIX_FMT_RGB32) && (out_format == BC_RGBA8888))
     552    if((in_format == AV_PIX_FMT_RGB32) && (out_format == BC_RGBA8888))
    553553#endif
    554554      {
    555555      convert_image_decode_rgba(in_frame, out_frame, width, height, codec->y_offset);
     
    728728
    729729    /* Set extradata: It's done differently for each codec */
    730730
    731     if(codec->decoder->id == CODEC_ID_SVQ3)
     731    if(codec->decoder->id == AV_CODEC_ID_SVQ3)
    732732      {
    733733      extradata       = trak->mdia.minf.stbl.stsd.table[0].table_raw + 4;
    734734      extradata_size  = trak->mdia.minf.stbl.stsd.table[0].table_raw_size - 4;
    735735     
    736736      }
    737     else if(codec->decoder->id == CODEC_ID_H264)
     737    else if(codec->decoder->id == AV_CODEC_ID_H264)
    738738      {
    739739      user_atom = quicktime_stsd_get_user_atom(trak, "avcC", &user_atom_len);
    740740
     
    753753        }
    754754     
    755755      }
    756     else if(codec->decoder->id == CODEC_ID_MPEG4)
     756    else if(codec->decoder->id == AV_CODEC_ID_MPEG4)
    757757      {
    758758      if(trak->mdia.minf.stbl.stsd.table[0].has_esds)
    759759        {
     
    829829    if(avcodec_open2(codec->avctx, codec->decoder, NULL) != 0)
    830830      return -1;
    831831#endif
    832     codec->frame = avcodec_alloc_frame();
     832    codec->frame = av_frame_alloc();
    833833    vtrack->stream_cmodel = LQT_COLORMODEL_NONE;
    834834    codec->initialized = 1;
    835835    }
     
    929929#ifdef HAVE_LIBSWSCALE
    930930
    931931#if LIBAVUTIL_VERSION_INT < (50<<16)
    932       if(!((codec->avctx->pix_fmt == PIX_FMT_RGBA32) &&
     932      if(!((codec->avctx->pix_fmt == AV_PIX_FMT_RGBA32) &&
    933933           (vtrack->stream_cmodel == BC_RGBA8888)))
    934934#else
    935         if(!((codec->avctx->pix_fmt == PIX_FMT_RGB32) &&
     935        if(!((codec->avctx->pix_fmt == AV_PIX_FMT_RGB32) &&
    936936             (vtrack->stream_cmodel == BC_RGBA8888)))
    937937#endif
    938938          {
     
    947947          }
    948948#endif
    949949      }
    950     if(codec->decoder->id == CODEC_ID_DVVIDEO)
     950    if(codec->decoder->id == AV_CODEC_ID_DVVIDEO)
    951951      {
    952952      if(vtrack->stream_cmodel == BC_YUV420P)
    953953        vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_DVPAL;
    954954      vtrack->interlace_mode = LQT_INTERLACE_BOTTOM_FIRST;
    955955      vtrack->ci.id = LQT_COMPRESSION_DV;
    956956      }
    957     else if((codec->decoder->id == CODEC_ID_MPEG4) ||
    958             (codec->decoder->id == CODEC_ID_H264))
     957    else if((codec->decoder->id == AV_CODEC_ID_MPEG4) ||
     958            (codec->decoder->id == AV_CODEC_ID_H264))
    959959      {
    960960      if(vtrack->stream_cmodel == BC_YUV420P)
    961961        vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_MPEG2;
     
    12991299    {
    13001300    if(vtrack->stream_cmodel == BC_YUV420P)
    13011301      {
    1302       if(codec->encoder->id == CODEC_ID_MPEG4)
     1302      if(codec->encoder->id == AV_CODEC_ID_MPEG4)
    13031303        {
    13041304        vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_MPEG2;
    13051305        /* enable interlaced encoding */
    13061306        vtrack->interlace_mode = LQT_INTERLACE_NONE;
    13071307        }
    1308       else if(codec->encoder->id == CODEC_ID_DVVIDEO)
     1308      else if(codec->encoder->id == AV_CODEC_ID_DVVIDEO)
    13091309        {
    13101310        vtrack->chroma_placement = LQT_CHROMA_PLACEMENT_DVPAL;
    13111311        }
     
    13181318       
    13191319  if(!codec->initialized)
    13201320    {
    1321     codec->frame = avcodec_alloc_frame();
     1321    codec->frame = av_frame_alloc();
    13221322
    13231323    /* time_base is 1/framerate for constant framerate */
    13241324         
     
    13401340    codec->avctx->sample_aspect_ratio.num = pixel_width;
    13411341    codec->avctx->sample_aspect_ratio.den = pixel_height;
    13421342    /* Use global headers for mp4v */
    1343     if(codec->encoder->id == CODEC_ID_MPEG4)
     1343    if(codec->encoder->id == AV_CODEC_ID_MPEG4)
    13441344      {
    13451345      if(!(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)))
    13461346        {
     
    13641364        }
    13651365#endif
    13661366      }
    1367     else if((codec->encoder->id == CODEC_ID_MSMPEG4V3) && (trak->strl) &&
     1367    else if((codec->encoder->id == AV_CODEC_ID_MSMPEG4V3) && (trak->strl) &&
    13681368            !strncmp(trak->strl->strf.bh.biCompression, "DIV3", 4))
    13691369      {
    13701370      strncpy(trak->strl->strh.fccHandler, "div3", 4);
    13711371      }
    1372     else if((codec->encoder->id == CODEC_ID_H263) &&
     1372    else if((codec->encoder->id == AV_CODEC_ID_H263) &&
    13731373            (file->file_type & (LQT_FILE_MP4|LQT_FILE_3GP)))
    13741374      {
    13751375      uint8_t d263_data[] =
     
    13831383      strncpy(trak->mdia.minf.stbl.stsd.table[0].format,
    13841384              "s263", 4);
    13851385      }
    1386     else if(codec->encoder->id == CODEC_ID_FFVHUFF)
     1386    else if(codec->encoder->id == AV_CODEC_ID_FFVHUFF)
    13871387      {
    13881388      if(!(file->file_type & (LQT_FILE_AVI|LQT_FILE_AVI_ODML)))
    13891389        {
     
    13911391        codec->write_global_header = 1;
    13921392        }
    13931393      }
    1394     else if(codec->encoder->id == CODEC_ID_QTRLE)
     1394    else if(codec->encoder->id == AV_CODEC_ID_QTRLE)
    13951395      {
    13961396      if(vtrack->stream_cmodel == BC_RGBA8888)
    13971397        {
    13981398        /* Libquicktime doesn't natively support a color model equivalent
    1399            to PIX_FMT_ARGB, which is required for QTRLE with alpha channel.
     1399           to AV_PIX_FMT_ARGB, which is required for QTRLE with alpha channel.
    14001400           So, we use BC_RGBA8888 and do ad hoc conversion below. */
    1401         codec->avctx->pix_fmt = PIX_FMT_ARGB;
     1401        codec->avctx->pix_fmt = AV_PIX_FMT_ARGB;
    14021402        vtrack->track->mdia.minf.stbl.stsd.table[0].depth = 32;
    14031403        }
    14041404      }
    1405     else if(codec->encoder->id == CODEC_ID_DVVIDEO)
     1405    else if(codec->encoder->id == AV_CODEC_ID_DVVIDEO)
    14061406      {
    14071407      set_dv_fourcc(width, height, vtrack->stream_cmodel, trak);
    14081408      }
    1409     else if(codec->encoder->id == CODEC_ID_DNXHD)
     1409    else if(codec->encoder->id == AV_CODEC_ID_DNXHD)
    14101410      {
    14111411      if(vtrack->interlace_mode != LQT_INTERLACE_NONE)
    14121412        {
     
    14671467    }
    14681468  //        codec->lqt_colormodel = ffmepg_2_lqt(codec->com.ffcodec_enc);
    14691469
    1470   if(codec->y_offset != 0 || codec->avctx->pix_fmt == PIX_FMT_ARGB)
     1470  if(codec->y_offset != 0 || codec->avctx->pix_fmt == AV_PIX_FMT_ARGB)
    14711471    {
    14721472    if(!codec->tmp_rows)
    14731473      {
     
    14921492                        vtrack->stream_cmodel,
    14931493                        0, 0, 0, codec->y_offset);
    14941494      }
    1495     else if(codec->avctx->pix_fmt == PIX_FMT_ARGB)
     1495    else if(codec->avctx->pix_fmt == AV_PIX_FMT_ARGB)
    14961496      {
    14971497      convert_rgba_to_argb(row_pointers[0], vtrack->stream_row_span,
    14981498                           codec->tmp_rows[0], codec->tmp_row_span,
     
    15581558 
    15591559#endif
    15601560 
    1561   if(!was_initialized && codec->encoder->id == CODEC_ID_DNXHD)
     1561  if(!was_initialized && codec->encoder->id == AV_CODEC_ID_DNXHD)
    15621562    setup_avid_atoms(file, vtrack, codec->buffer, bytes_encoded);
    15631563 
    15641564  if(bytes_encoded)
    15651565    {
    1566     if (pts == AV_NOPTS_VALUE || (codec->encoder->id == CODEC_ID_DNXHD && pts == 0))
     1566    if (pts == AV_NOPTS_VALUE || (codec->encoder->id == AV_CODEC_ID_DNXHD && pts == 0))
    15671567      {
    15681568      /* Some codecs don't bother generating presentation timestamps.
    15691569         FFMpeg's DNxHD encoder doesn't even bother to set it to AV_NOPTS_VALUE. */
     
    15901590
    15911591  if(codec->write_global_header && !codec->global_header_written)
    15921592    {
    1593     if(codec->encoder->id == CODEC_ID_FFVHUFF)
     1593    if(codec->encoder->id == AV_CODEC_ID_FFVHUFF)
    15941594      {
    15951595      quicktime_user_atoms_add_atom(&trak->mdia.minf.stbl.stsd.table[0].user_atoms,
    15961596                                    "glbl",
    15971597                                    codec->avctx->extradata, codec->avctx->extradata_size );
    15981598      }
    1599     else if(codec->encoder->id == CODEC_ID_MPEG4)
     1599    else if(codec->encoder->id == AV_CODEC_ID_MPEG4)
    16001600      {
    16011601      int advanced = 0;
    16021602      if(codec->avctx->max_b_frames ||
     
    19031903    codec_base->encode_video = lqt_ffmpeg_encode_video;
    19041904    codec_base->set_pass = set_pass_ffmpeg;
    19051905
    1906     if(encoder->id == CODEC_ID_MPEG4)
     1906    if(encoder->id == AV_CODEC_ID_MPEG4)
    19071907      {
    19081908      codec_base->writes_compressed = writes_compressed_mpeg4;
    19091909      codec_base->init_compressed   = init_compressed_mpeg4;
    19101910      codec_base->write_packet = write_packet_mpeg4;
    19111911      }
    1912     else if(encoder->id == CODEC_ID_MPEG2VIDEO)
     1912    else if(encoder->id == AV_CODEC_ID_MPEG2VIDEO)
    19131913      {
    19141914      codec_base->writes_compressed = writes_compressed_imx;
    19151915      codec_base->init_compressed   = init_compressed_imx;
    19161916      }
    1917     else if(encoder->id == CODEC_ID_DVVIDEO)
     1917    else if(encoder->id == AV_CODEC_ID_DVVIDEO)
    19181918      {
    19191919      codec_base->init_compressed = init_compressed_dv;
    19201920      }
     
    19221922    }
    19231923  if(decoder)
    19241924    {
    1925     if(decoder->id == CODEC_ID_H264)
     1925    if(decoder->id == AV_CODEC_ID_H264)
    19261926      codec_base->read_packet = read_packet_h264;
    19271927    codec_base->decode_video = lqt_ffmpeg_decode_video;
    19281928    }