---
 libavformat/movenc.c     | 481 +++++++++++++++++++++++------------------------
 libavformat/movenc.h     |   2 +-
 libavformat/movenchint.c |  12 +-
 3 files changed, 246 insertions(+), 249 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index deb37f2..98cae27 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -290,8 +290,8 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack 
*track)
  */
 static int mov_write_extradata_tag(AVIOContext *pb, MOVTrack *track)
 {
-    avio_write(pb, track->enc->extradata, track->enc->extradata_size);
-    return track->enc->extradata_size;
+    avio_write(pb, track->par->extradata, track->par->extradata_size);
+    return track->par->extradata_size;
 }
 
 static void put_descr(AVIOContext *pb, int tag, unsigned int size)
@@ -322,18 +322,18 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack 
*track) // Basic
     put_descr(pb, 0x04, 13 + decoder_specific_info_len);
 
     // Object type indication
-    if ((track->enc->codec_id == AV_CODEC_ID_MP2 ||
-         track->enc->codec_id == AV_CODEC_ID_MP3) &&
-        track->enc->sample_rate > 24000)
+    if ((track->par->codec_id == AV_CODEC_ID_MP2 ||
+         track->par->codec_id == AV_CODEC_ID_MP3) &&
+        track->par->sample_rate > 24000)
         avio_w8(pb, 0x6B); // 11172-3
     else
-        avio_w8(pb, ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id));
+        avio_w8(pb, ff_codec_get_tag(ff_mp4_obj_type, track->par->codec_id));
 
     // the following fields is made of 6 bits to identify the streamtype (4 
for video, 5 for audio)
     // plus 1 bit to indicate upstream and 1 bit set to 1 (reserved)
-    if (track->enc->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
+    if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
         avio_w8(pb, (0x38 << 2) | 1); // flags (= NeroSubpicStream)
-    else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+    else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
         avio_w8(pb, 0x15); // flags (= Audiostream)
     else
         avio_w8(pb, 0x11); // flags (= Visualstream)
@@ -343,7 +343,7 @@ static int mov_write_esds_tag(AVIOContext *pb, MOVTrack 
*track) // Basic
 
     avio_wb24(pb, props ? props->buffer_size / 8 : 0); // Buffersize DB
 
-    avio_wb32(pb, props ? FFMAX(props->max_bitrate, props->avg_bitrate) : 
track->enc->bit_rate); // maxbitrate (FIXME should be max rate in any 1 sec 
window)
+    avio_wb32(pb, props ? FFMAX(props->max_bitrate, props->avg_bitrate) : 
track->par->bit_rate); // maxbitrate (FIXME should be max rate in any 1 sec 
window)
     if (!props || !props->min_bitrate || props->max_bitrate != 
props->min_bitrate)
         avio_wb32(pb, 0); // vbr
     else
@@ -366,7 +366,7 @@ static int mov_write_ms_tag(AVFormatContext *s, AVIOContext 
*pb, MOVTrack *track
     int64_t pos = avio_tell(pb);
     avio_wb32(pb, 0);
     avio_wl32(pb, track->tag); // store it byteswapped
-    track->enc->codec_tag = av_bswap16(track->tag >> 16);
+    track->par->codec_tag = av_bswap16(track->tag >> 16);
     ff_put_wav_header(s, pb, track->st->codecpar);
     return update_size(pb, pos);
 }
@@ -380,16 +380,16 @@ static int mov_write_wfex_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
     return update_size(pb, pos);
 }
 
-static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
 {
     uint32_t layout_tag, bitmap;
     int64_t pos = avio_tell(pb);
 
-    layout_tag = ff_mov_get_channel_layout_tag(track->enc->codec_id,
-                                               track->enc->channel_layout,
+    layout_tag = ff_mov_get_channel_layout_tag(track->par->codec_id,
+                                               track->par->channel_layout,
                                                &bitmap);
     if (!layout_tag) {
-        av_log(track->enc, AV_LOG_WARNING, "not writing 'chan' tag due to "
+        av_log(s, AV_LOG_WARNING, "not writing 'chan' tag due to "
                "lack of channel information\n");
         return 0;
     }
@@ -416,20 +416,20 @@ static int mov_write_wave_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
     ffio_wfourcc(pb, "frma");
     avio_wl32(pb, track->tag);
 
-    if (track->enc->codec_id == AV_CODEC_ID_AAC) {
+    if (track->par->codec_id == AV_CODEC_ID_AAC) {
         /* useless atom needed by mplayer, ipod, not needed by quicktime */
         avio_wb32(pb, 12); /* size */
         ffio_wfourcc(pb, "mp4a");
         avio_wb32(pb, 0);
         mov_write_esds_tag(pb, track);
-    } else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB) {
+    } else if (track->par->codec_id == AV_CODEC_ID_AMR_NB) {
         mov_write_amr_tag(pb, track);
-    } else if (track->enc->codec_id == AV_CODEC_ID_AC3) {
+    } else if (track->par->codec_id == AV_CODEC_ID_AC3) {
         mov_write_ac3_tag(pb, track);
-    } else if (track->enc->codec_id == AV_CODEC_ID_ALAC) {
+    } else if (track->par->codec_id == AV_CODEC_ID_ALAC) {
         mov_write_extradata_tag(pb, track);
-    } else if (track->enc->codec_id == AV_CODEC_ID_ADPCM_MS ||
-               track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
+    } else if (track->par->codec_id == AV_CODEC_ID_ADPCM_MS ||
+               track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) {
         mov_write_ms_tag(s, pb, track);
     }
 
@@ -616,7 +616,7 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tr
     uint32_t tag = track->tag;
 
     if (track->mode == MODE_MOV) {
-        if (mov_get_lpcm_flags(track->enc->codec_id))
+        if (mov_get_lpcm_flags(track->par->codec_id))
             tag = AV_RL32("lpcm");
         version = 2;
     }
@@ -639,11 +639,11 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tr
         avio_wb16(pb, 0);
         avio_wb32(pb, 0x00010000);
         avio_wb32(pb, 72);
-        avio_wb64(pb, av_double2int(track->enc->sample_rate));
-        avio_wb32(pb, track->enc->channels);
+        avio_wb64(pb, av_double2int(track->par->sample_rate));
+        avio_wb32(pb, track->par->channels);
         avio_wb32(pb, 0x7F000000);
-        avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
-        avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
+        avio_wb32(pb, av_get_bits_per_sample(track->par->codec_id));
+        avio_wb32(pb, mov_get_lpcm_flags(track->par->codec_id));
         avio_wb32(pb, track->sample_size);
         avio_wb32(pb, get_samples_per_packet(track));
     } else {
@@ -653,34 +653,34 @@ static int mov_write_audio_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tr
         avio_wb16(pb, 0);
 
         avio_wb16(pb, 0); /* packet size (= 0) */
-        avio_wb16(pb, track->enc->sample_rate <= UINT16_MAX ?
-                      track->enc->sample_rate : 0);
+        avio_wb16(pb, track->par->sample_rate <= UINT16_MAX ?
+                      track->par->sample_rate : 0);
         avio_wb16(pb, 0); /* Reserved */
     }
 
     if (track->mode == MODE_MOV &&
-        (track->enc->codec_id == AV_CODEC_ID_AAC           ||
-         track->enc->codec_id == AV_CODEC_ID_AC3           ||
-         track->enc->codec_id == AV_CODEC_ID_AMR_NB        ||
-         track->enc->codec_id == AV_CODEC_ID_ALAC          ||
-         track->enc->codec_id == AV_CODEC_ID_ADPCM_MS      ||
-         track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV))
+        (track->par->codec_id == AV_CODEC_ID_AAC           ||
+         track->par->codec_id == AV_CODEC_ID_AC3           ||
+         track->par->codec_id == AV_CODEC_ID_AMR_NB        ||
+         track->par->codec_id == AV_CODEC_ID_ALAC          ||
+         track->par->codec_id == AV_CODEC_ID_ADPCM_MS      ||
+         track->par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV))
         mov_write_wave_tag(s, pb, track);
     else if (track->tag == MKTAG('m','p','4','a'))
         mov_write_esds_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB)
+    else if (track->par->codec_id == AV_CODEC_ID_AMR_NB)
         mov_write_amr_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_AC3)
+    else if (track->par->codec_id == AV_CODEC_ID_AC3)
         mov_write_ac3_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_ALAC)
+    else if (track->par->codec_id == AV_CODEC_ID_ALAC)
         mov_write_extradata_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_WMAPRO)
+    else if (track->par->codec_id == AV_CODEC_ID_WMAPRO)
         mov_write_wfex_tag(s, pb, track);
     else if (track->vos_len > 0)
         mov_write_glbl_tag(pb, track);
 
-    if (track->mode == MODE_MOV && track->enc->codec_type == 
AVMEDIA_TYPE_AUDIO)
-        mov_write_chan_tag(pb, track);
+    if (track->mode == MODE_MOV && track->par->codec_type == 
AVMEDIA_TYPE_AUDIO)
+        mov_write_chan_tag(s, pb, track);
 
     return update_size(pb, pos);
 }
@@ -753,18 +753,18 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack 
*track)
     ffio_wfourcc(pb, "ARES");
     ffio_wfourcc(pb, "0001");
     avio_wb32(pb, AV_RB32(track->vos_data + 0x28)); /* dnxhd cid, some id ? */
-    avio_wb32(pb, track->enc->width);
+    avio_wb32(pb, track->par->width);
     /* values below are based on samples created with quicktime and avid 
codecs */
     if (track->vos_data[5] & 2) { // interlaced
-        avio_wb32(pb, track->enc->height / 2);
+        avio_wb32(pb, track->par->height / 2);
         avio_wb32(pb, 2); /* unknown */
         avio_wb32(pb, 0); /* unknown */
         avio_wb32(pb, 4); /* unknown */
     } else {
-        avio_wb32(pb, track->enc->height);
+        avio_wb32(pb, track->par->height);
         avio_wb32(pb, 1); /* unknown */
         avio_wb32(pb, 0); /* unknown */
-        if (track->enc->height == 1080)
+        if (track->par->height == 1080)
             avio_wb32(pb, 5); /* unknown */
         else
             avio_wb32(pb, 6); /* unknown */
@@ -780,20 +780,20 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack 
*track)
 
 static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
 {
-    int tag = track->enc->codec_tag;
+    int tag = track->par->codec_tag;
 
-    if (!ff_codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
+    if (!ff_codec_get_tag(ff_mp4_obj_type, track->par->codec_id))
         return 0;
 
-    if      (track->enc->codec_id == AV_CODEC_ID_H264)      tag = 
MKTAG('a','v','c','1');
-    else if (track->enc->codec_id == AV_CODEC_ID_HEVC)      tag = 
MKTAG('h','e','v','1');
-    else if (track->enc->codec_id == AV_CODEC_ID_AC3)       tag = 
MKTAG('a','c','-','3');
-    else if (track->enc->codec_id == AV_CODEC_ID_DIRAC)     tag = 
MKTAG('d','r','a','c');
-    else if (track->enc->codec_id == AV_CODEC_ID_MOV_TEXT)  tag = 
MKTAG('t','x','3','g');
-    else if (track->enc->codec_id == AV_CODEC_ID_VC1)       tag = 
MKTAG('v','c','-','1');
-    else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)  tag = 
MKTAG('m','p','4','v');
-    else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)  tag = 
MKTAG('m','p','4','a');
-    else if (track->enc->codec_id == AV_CODEC_ID_DVD_SUBTITLE)  tag = 
MKTAG('m','p','4','s');
+    if      (track->par->codec_id == AV_CODEC_ID_H264)      tag = 
MKTAG('a','v','c','1');
+    else if (track->par->codec_id == AV_CODEC_ID_HEVC)      tag = 
MKTAG('h','e','v','1');
+    else if (track->par->codec_id == AV_CODEC_ID_AC3)       tag = 
MKTAG('a','c','-','3');
+    else if (track->par->codec_id == AV_CODEC_ID_DIRAC)     tag = 
MKTAG('d','r','a','c');
+    else if (track->par->codec_id == AV_CODEC_ID_MOV_TEXT)  tag = 
MKTAG('t','x','3','g');
+    else if (track->par->codec_id == AV_CODEC_ID_VC1)       tag = 
MKTAG('v','c','-','1');
+    else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO)  tag = 
MKTAG('m','p','4','v');
+    else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)  tag = 
MKTAG('m','p','4','a');
+    else if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)  tag = 
MKTAG('m','p','4','s');
 
     return tag;
 }
@@ -811,13 +811,13 @@ static const AVCodecTag codec_ipod_tags[] = {
 
 static int ipod_get_codec_tag(AVFormatContext *s, MOVTrack *track)
 {
-    int tag = track->enc->codec_tag;
+    int tag = track->par->codec_tag;
 
     // keep original tag for subs, ipod supports both formats
-    if (!(track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+    if (!(track->par->codec_type == AVMEDIA_TYPE_SUBTITLE &&
           (tag == MKTAG('t', 'x', '3', 'g') ||
            tag == MKTAG('t', 'e', 'x', 't'))))
-        tag = ff_codec_get_tag(codec_ipod_tags, track->enc->codec_id);
+        tag = ff_codec_get_tag(codec_ipod_tags, track->par->codec_id);
 
     if (!av_match_ext(s->filename, "m4a") && !av_match_ext(s->filename, "m4v"))
         av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
@@ -830,17 +830,17 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 {
     int tag;
 
-    if (track->enc->width == 720) /* SD */
-        if (track->enc->height == 480) /* NTSC */
-            if  (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = 
MKTAG('d','v','5','n');
+    if (track->par->width == 720) /* SD */
+        if (track->par->height == 480) /* NTSC */
+            if  (track->par->format  == AV_PIX_FMT_YUV422P) tag = 
MKTAG('d','v','5','n');
             else                                            tag = 
MKTAG('d','v','c',' ');
-        else if (track->enc->pix_fmt == AV_PIX_FMT_YUV422P) tag = 
MKTAG('d','v','5','p');
-        else if (track->enc->pix_fmt == AV_PIX_FMT_YUV420P) tag = 
MKTAG('d','v','c','p');
+        else if (track->par->format  == AV_PIX_FMT_YUV422P) tag = 
MKTAG('d','v','5','p');
+        else if (track->par->format  == AV_PIX_FMT_YUV420P) tag = 
MKTAG('d','v','c','p');
         else                                                tag = 
MKTAG('d','v','p','p');
-    else if (track->enc->height == 720) /* HD 720 line */
+    else if (track->par->height == 720) /* HD 720 line */
         if  (track->st->time_base.den == 50)                tag = 
MKTAG('d','v','h','q');
         else                                                tag = 
MKTAG('d','v','h','p');
-    else if (track->enc->height == 1080) /* HD 1080 line */
+    else if (track->par->height == 1080) /* HD 1080 line */
         if  (track->st->time_base.den == 25)                tag = 
MKTAG('d','v','h','5');
         else                                                tag = 
MKTAG('d','v','h','6');
     else {
@@ -874,13 +874,13 @@ static const struct {
 
 static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
 {
-    int tag = track->enc->codec_tag;
+    int tag = track->par->codec_tag;
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(mov_pix_fmt_tags); i++) {
-        if (track->enc->pix_fmt == mov_pix_fmt_tags[i].pix_fmt) {
+        if (track->par->format == mov_pix_fmt_tags[i].pix_fmt) {
             tag = mov_pix_fmt_tags[i].tag;
-            track->enc->bits_per_coded_sample = mov_pix_fmt_tags[i].bps;
+            track->par->bits_per_coded_sample = mov_pix_fmt_tags[i].bps;
             break;
         }
     }
@@ -890,37 +890,37 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 
 static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
 {
-    int tag = track->enc->codec_tag;
+    int tag = track->par->codec_tag;
 
     if (!tag || (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
-                 (track->enc->codec_id == AV_CODEC_ID_DVVIDEO ||
-                  track->enc->codec_id == AV_CODEC_ID_RAWVIDEO ||
-                  track->enc->codec_id == AV_CODEC_ID_H263 ||
-                  av_get_bits_per_sample(track->enc->codec_id)))) { // pcm 
audio
-        if (track->enc->codec_id == AV_CODEC_ID_DVVIDEO)
+                 (track->par->codec_id == AV_CODEC_ID_DVVIDEO ||
+                  track->par->codec_id == AV_CODEC_ID_RAWVIDEO ||
+                  track->par->codec_id == AV_CODEC_ID_H263 ||
+                  av_get_bits_per_sample(track->par->codec_id)))) { // pcm 
audio
+        if (track->par->codec_id == AV_CODEC_ID_DVVIDEO)
             tag = mov_get_dv_codec_tag(s, track);
-        else if (track->enc->codec_id == AV_CODEC_ID_RAWVIDEO)
+        else if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO)
             tag = mov_get_rawvideo_codec_tag(s, track);
-        else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
-            tag = ff_codec_get_tag(ff_codec_movvideo_tags, 
track->enc->codec_id);
+        else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+            tag = ff_codec_get_tag(ff_codec_movvideo_tags, 
track->par->codec_id);
             if (!tag) { // if no mac fcc found, try with Microsoft tags
-                tag = ff_codec_get_tag(ff_codec_bmp_tags, 
track->enc->codec_id);
+                tag = ff_codec_get_tag(ff_codec_bmp_tags, 
track->par->codec_id);
                 if (tag)
                     av_log(s, AV_LOG_WARNING, "Using MS style video codec tag, 
"
                            "the file may be unplayable!\n");
             }
-        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
-            tag = ff_codec_get_tag(ff_codec_movaudio_tags, 
track->enc->codec_id);
+        } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
+            tag = ff_codec_get_tag(ff_codec_movaudio_tags, 
track->par->codec_id);
             if (!tag) { // if no mac fcc found, try with Microsoft tags
-                int ms_tag = ff_codec_get_tag(ff_codec_wav_tags, 
track->enc->codec_id);
+                int ms_tag = ff_codec_get_tag(ff_codec_wav_tags, 
track->par->codec_id);
                 if (ms_tag) {
                     tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 
0xff));
                     av_log(s, AV_LOG_WARNING, "Using MS style audio codec tag, 
"
                            "the file may be unplayable!\n");
                 }
             }
-        } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)
-            tag = ff_codec_get_tag(ff_codec_movsubtitle_tags, 
track->enc->codec_id);
+        } else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE)
+            tag = ff_codec_get_tag(ff_codec_movsubtitle_tags, 
track->par->codec_id);
     }
 
     return tag;
@@ -954,14 +954,14 @@ static int mov_find_codec_tag(AVFormatContext *s, 
MOVTrack *track)
         tag = mp4_get_codec_tag(s, track);
     else if (track->mode == MODE_ISM) {
         tag = mp4_get_codec_tag(s, track);
-        if (!tag && track->enc->codec_id == AV_CODEC_ID_WMAPRO)
+        if (!tag && track->par->codec_id == AV_CODEC_ID_WMAPRO)
             tag = MKTAG('w', 'm', 'a', ' ');
     } else if (track->mode == MODE_IPOD)
         tag = ipod_get_codec_tag(s, track);
     else if (track->mode & MODE_3GP)
-        tag = ff_codec_get_tag(codec_3gp_tags, track->enc->codec_id);
+        tag = ff_codec_get_tag(codec_3gp_tags, track->par->codec_id);
     else if (track->mode == MODE_F4V)
-        tag = ff_codec_get_tag(codec_f4v_tags, track->enc->codec_id);
+        tag = ff_codec_get_tag(codec_f4v_tags, track->par->codec_id);
     else
         tag = mov_get_codec_tag(s, track);
 
@@ -991,8 +991,8 @@ static const uint16_t fiel_data[] = {
 static int mov_write_fiel_tag(AVIOContext *pb, MOVTrack *track)
 {
     unsigned mov_field_order = 0;
-    if (track->enc->field_order < FF_ARRAY_ELEMS(fiel_data))
-        mov_field_order = fiel_data[track->enc->field_order];
+    if (track->par->field_order < FF_ARRAY_ELEMS(fiel_data))
+        mov_field_order = fiel_data[track->par->field_order];
     else
         return 0;
     avio_wb32(pb, 10);
@@ -1010,10 +1010,10 @@ static int mov_write_subtitle_tag(AVIOContext *pb, 
MOVTrack *track)
     avio_wb16(pb, 0);    /* Reserved */
     avio_wb16(pb, 1);    /* Data-reference index */
 
-    if (track->enc->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
+    if (track->par->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
         mov_write_esds_tag(pb, track);
-    else if (track->enc->extradata_size)
-        avio_write(pb, track->enc->extradata, track->enc->extradata_size);
+    else if (track->par->extradata_size)
+        avio_write(pb, track->par->extradata, track->par->extradata_size);
 
     return update_size(pb, pos);
 }
@@ -1021,8 +1021,8 @@ static int mov_write_subtitle_tag(AVIOContext *pb, 
MOVTrack *track)
 static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack *track)
 {
     AVRational sar;
-    av_reduce(&sar.num, &sar.den, track->enc->sample_aspect_ratio.num,
-              track->enc->sample_aspect_ratio.den, INT_MAX);
+    av_reduce(&sar.num, &sar.den, track->par->sample_aspect_ratio.num,
+              track->par->sample_aspect_ratio.den, INT_MAX);
 
     avio_wb32(pb, 16);
     ffio_wfourcc(pb, "pasp");
@@ -1047,7 +1047,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack 
*track)
     avio_wb16(pb, 0); /* Codec stream revision (=0) */
     if (track->mode == MODE_MOV) {
         ffio_wfourcc(pb, "FFMP"); /* Vendor */
-        if (track->enc->codec_id == AV_CODEC_ID_RAWVIDEO) {
+        if (track->par->codec_id == AV_CODEC_ID_RAWVIDEO) {
             avio_wb32(pb, 0); /* Temporal Quality */
             avio_wb32(pb, 0x400); /* Spatial Quality = lossless*/
         } else {
@@ -1059,7 +1059,7 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack 
*track)
         avio_wb32(pb, 0); /* Reserved */
         avio_wb32(pb, 0); /* Reserved */
     }
-    avio_wb16(pb, track->enc->width); /* Video width */
+    avio_wb16(pb, track->par->width); /* Video width */
     avio_wb16(pb, track->height); /* Video height */
     avio_wb32(pb, 0x00480000); /* Horizontal resolution 72dpi */
     avio_wb32(pb, 0x00480000); /* Vertical resolution 72dpi */
@@ -1073,38 +1073,38 @@ static int mov_write_video_tag(AVIOContext *pb, 
MOVTrack *track)
     avio_w8(pb, strlen(compressor_name));
     avio_write(pb, compressor_name, 31);
 
-    if (track->mode == MODE_MOV && track->enc->bits_per_coded_sample)
-        avio_wb16(pb, track->enc->bits_per_coded_sample);
+    if (track->mode == MODE_MOV && track->par->bits_per_coded_sample)
+        avio_wb16(pb, track->par->bits_per_coded_sample);
     else
         avio_wb16(pb, 0x18); /* Reserved */
     avio_wb16(pb, 0xffff); /* Reserved */
     if (track->tag == MKTAG('m','p','4','v'))
         mov_write_esds_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_H263)
+    else if (track->par->codec_id == AV_CODEC_ID_H263)
         mov_write_d263_tag(pb);
-    else if (track->enc->codec_id == AV_CODEC_ID_SVQ3)
+    else if (track->par->codec_id == AV_CODEC_ID_SVQ3)
         mov_write_svq3_tag(pb);
-    else if (track->enc->codec_id == AV_CODEC_ID_DNXHD)
+    else if (track->par->codec_id == AV_CODEC_ID_DNXHD)
         mov_write_avid_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_HEVC)
+    else if (track->par->codec_id == AV_CODEC_ID_HEVC)
         mov_write_hvcc_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_H264) {
+    else if (track->par->codec_id == AV_CODEC_ID_H264) {
         mov_write_avcc_tag(pb, track);
         if (track->mode == MODE_IPOD)
             mov_write_uuid_tag_ipod(pb);
-    } else if (track->enc->field_order != AV_FIELD_UNKNOWN)
+    } else if (track->par->field_order != AV_FIELD_UNKNOWN)
         mov_write_fiel_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
+    else if (track->par->codec_id == AV_CODEC_ID_VC1 && track->vos_len > 0)
         mov_write_dvc1_tag(pb, track);
-    else if (track->enc->codec_id == AV_CODEC_ID_VP6F ||
-             track->enc->codec_id == AV_CODEC_ID_VP6A) {
+    else if (track->par->codec_id == AV_CODEC_ID_VP6F ||
+             track->par->codec_id == AV_CODEC_ID_VP6A) {
         /* Don't write any potential extradata here - the cropping
          * is signalled via the normal width/height fields. */
     } else if (track->vos_len > 0)
         mov_write_glbl_tag(pb, track);
 
-    if (track->enc->sample_aspect_ratio.den && 
track->enc->sample_aspect_ratio.num &&
-        track->enc->sample_aspect_ratio.den != 
track->enc->sample_aspect_ratio.num) {
+    if (track->par->sample_aspect_ratio.den && 
track->par->sample_aspect_ratio.num &&
+        track->par->sample_aspect_ratio.den != 
track->par->sample_aspect_ratio.num) {
         mov_write_pasp_tag(pb, track);
     }
 
@@ -1139,8 +1139,8 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack 
*track)
     ffio_wfourcc(pb, "tmcd");               /* Data format */
     avio_wb32(pb, 0);                       /* Reserved */
     avio_wb32(pb, 1);                       /* Data reference index */
-    if (track->enc->extradata_size)
-        avio_write(pb, track->enc->extradata, track->enc->extradata_size);
+    if (track->par->extradata_size)
+        avio_write(pb, track->par->extradata, track->par->extradata_size);
     return update_size(pb, pos);
 }
 
@@ -1151,15 +1151,15 @@ static int mov_write_stsd_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
     ffio_wfourcc(pb, "stsd");
     avio_wb32(pb, 0); /* version & flags */
     avio_wb32(pb, 1); /* entry count */
-    if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
+    if (track->par->codec_type == AVMEDIA_TYPE_VIDEO)
         mov_write_video_tag(pb, track);
-    else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+    else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
         mov_write_audio_tag(s, pb, track);
-    else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)
+    else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE)
         mov_write_subtitle_tag(pb, track);
-    else if (track->enc->codec_tag == MKTAG('r','t','p',' '))
+    else if (track->par->codec_tag == MKTAG('r','t','p',' '))
         mov_write_rtp_tag(pb, track);
-    else if (track->enc->codec_tag == MKTAG('t','m','c','d'))
+    else if (track->par->codec_tag == MKTAG('t','m','c','d'))
         mov_write_tmcd_tag(pb, track);
     return update_size(pb, pos);
 }
@@ -1207,7 +1207,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack 
*track)
     uint32_t atom_size;
     int i;
 
-    if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) {
+    if (track->par->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) {
         stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */
         if (!stts_entries)
             return AVERROR(ENOMEM);
@@ -1266,13 +1266,13 @@ static int mov_write_stbl_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
     ffio_wfourcc(pb, "stbl");
     mov_write_stsd_tag(s, pb, track);
     mov_write_stts_tag(pb, track);
-    if ((track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
-         track->enc->codec_tag == MKTAG('r','t','p',' ')) &&
+    if ((track->par->codec_type == AVMEDIA_TYPE_VIDEO ||
+         track->par->codec_tag == MKTAG('r','t','p',' ')) &&
         track->has_keyframes && track->has_keyframes < track->entry)
         mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
     if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS)
         mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);
-    if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO &&
+    if (track->par->codec_type == AVMEDIA_TYPE_VIDEO &&
         track->flags & MOV_TRACK_CTTS && track->entry)
         mov_write_ctts_tag(pb, track);
     mov_write_stsc_tag(pb, track);
@@ -1339,7 +1339,7 @@ static int is_clcp_track(MOVTrack *track)
            track->tag == MKTAG('c','6','0','8');
 }
 
-static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack *track)
+static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track)
 {
     const char *hdlr, *descr = NULL, *hdlr_type = NULL;
     int64_t pos = avio_tell(pb);
@@ -1350,13 +1350,13 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack 
*track)
 
     if (track) {
         hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";
-        if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+        if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
             hdlr_type = "vide";
             descr     = "VideoHandler";
-        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+        } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
             hdlr_type = "soun";
             descr     = "SoundHandler";
-        } else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+        } else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
             if (track->tag == MKTAG('t','x','3','g')) {
                 hdlr_type = "sbtl";
             } else if (track->tag == MKTAG('m','p','4','s')) {
@@ -1367,20 +1367,20 @@ static int mov_write_hdlr_tag(AVIOContext *pb, MOVTrack 
*track)
                 hdlr_type = "text";
             }
             descr = "SubtitleHandler";
-        } else if (track->enc->codec_tag == MKTAG('r','t','p',' ')) {
+        } else if (track->par->codec_tag == MKTAG('r','t','p',' ')) {
             hdlr_type = "hint";
             descr     = "HintHandler";
-        } else if (track->enc->codec_tag == MKTAG('t','m','c','d')) {
+        } else if (track->par->codec_tag == MKTAG('t','m','c','d')) {
             hdlr_type = "tmcd";
             descr = "TimeCodeHandler";
         } else {
             char tag_buf[32];
             av_get_codec_tag_string(tag_buf, sizeof(tag_buf),
-                                    track->enc->codec_tag);
+                                    track->par->codec_tag);
 
-            av_log(track->enc, AV_LOG_WARNING,
+            av_log(s, AV_LOG_WARNING,
                    "Unknown hldr_type for %s / 0x%04X, writing dummy values\n",
-                   tag_buf, track->enc->codec_tag);
+                   tag_buf, track->par->codec_tag);
         }
         if (track->st) {
             // hdlr.name is used by some players to identify the content title
@@ -1429,11 +1429,11 @@ static int mov_write_minf_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
     int64_t pos = avio_tell(pb);
     avio_wb32(pb, 0); /* size */
     ffio_wfourcc(pb, "minf");
-    if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
+    if (track->par->codec_type == AVMEDIA_TYPE_VIDEO)
         mov_write_vmhd_tag(pb);
-    else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+    else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
         mov_write_smhd_tag(pb);
-    else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+    else if (track->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
         if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) {
             mov_write_gmhd_tag(pb);
         } else {
@@ -1445,7 +1445,7 @@ static int mov_write_minf_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
         mov_write_gmhd_tag(pb);
     }
     if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
-        mov_write_hdlr_tag(pb, NULL);
+        mov_write_hdlr_tag(s, pb, NULL);
     mov_write_dinf_tag(pb);
     mov_write_stbl_tag(s, pb, track);
     return update_size(pb, pos);
@@ -1497,7 +1497,7 @@ static int mov_write_mdia_tag(AVFormatContext *s, 
AVIOContext *pb,
     avio_wb32(pb, 0); /* size */
     ffio_wfourcc(pb, "mdia");
     mov_write_mdhd_tag(pb, mov, track);
-    mov_write_hdlr_tag(pb, track);
+    mov_write_hdlr_tag(s, pb, track);
     mov_write_minf_tag(s, pb, track);
     return update_size(pb, pos);
 }
@@ -1518,7 +1518,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
         if (mov->per_stream_grouping)
             group = st->index;
         else
-            group = st->codec->codec_type;
+            group = st->codecpar->codec_type;
 
         display_matrix = (uint32_t*)av_stream_get_side_data(st, 
AV_PKT_DATA_DISPLAYMATRIX,
                                                             
&display_matrix_size);
@@ -1557,7 +1557,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
     avio_wb16(pb, 0); /* layer */
     avio_wb16(pb, group); /* alternate group) */
     /* Volume, only for audio */
-    if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
+    if (track->par->codec_type == AVMEDIA_TYPE_AUDIO)
         avio_wb16(pb, 0x0100);
     else
         avio_wb16(pb, 0);
@@ -1580,16 +1580,16 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
     }
 
     /* Track width and height, for visual only */
-    if (st && (track->enc->codec_type == AVMEDIA_TYPE_VIDEO ||
-               track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
+    if (st && (track->par->codec_type == AVMEDIA_TYPE_VIDEO ||
+               track->par->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
         if (track->mode == MODE_MOV) {
-            avio_wb32(pb, track->enc->width << 16);
+            avio_wb32(pb, track->par->width << 16);
             avio_wb32(pb, track->height << 16);
         } else {
             double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
-            if (!sample_aspect_ratio || track->height != track->enc->height)
+            if (!sample_aspect_ratio || track->height != track->par->height)
                 sample_aspect_ratio = 1;
-            avio_wb32(pb, sample_aspect_ratio * track->enc->width * 0x10000);
+            avio_wb32(pb, sample_aspect_ratio * track->par->width * 0x10000);
             avio_wb32(pb, track->height * 0x10000);
         }
     } else {
@@ -1601,8 +1601,8 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
 
 static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track)
 {
-    int32_t width = av_rescale(track->enc->sample_aspect_ratio.num, 
track->enc->width,
-                               track->enc->sample_aspect_ratio.den);
+    int32_t width = av_rescale(track->par->sample_aspect_ratio.num, 
track->par->width,
+                               track->par->sample_aspect_ratio.den);
 
     int64_t pos = avio_tell(pb);
 
@@ -1613,19 +1613,19 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack 
*track)
     ffio_wfourcc(pb, "clef");
     avio_wb32(pb, 0);
     avio_wb32(pb, width << 16);
-    avio_wb32(pb, track->enc->height << 16);
+    avio_wb32(pb, track->par->height << 16);
 
     avio_wb32(pb, 20);
     ffio_wfourcc(pb, "prof");
     avio_wb32(pb, 0);
     avio_wb32(pb, width << 16);
-    avio_wb32(pb, track->enc->height << 16);
+    avio_wb32(pb, track->par->height << 16);
 
     avio_wb32(pb, 20);
     ffio_wfourcc(pb, "enof");
     avio_wb32(pb, 0);
-    avio_wb32(pb, track->enc->width << 16);
-    avio_wb32(pb, track->enc->height << 16);
+    avio_wb32(pb, track->par->width << 16);
+    avio_wb32(pb, track->par->height << 16);
 
     return update_size(pb, pos);
 }
@@ -1822,7 +1822,7 @@ static int mov_write_trak_tag(AVIOContext *pb, 
MOVMuxContext *mov,
     if (track->tag == MKTAG('r','t','p',' '))
         mov_write_udta_sdp(pb, track);
     if (track->mode == MODE_MOV) {
-        if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+        if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
             double sample_aspect_ratio = av_q2d(st->sample_aspect_ratio);
             if ((0.0 != sample_aspect_ratio && 1.0 != sample_aspect_ratio)) {
                 mov_write_tapt_tag(pb, track);
@@ -1845,8 +1845,8 @@ static int mov_write_iods_tag(AVIOContext *pb, 
MOVMuxContext *mov)
     int video_profile = mov->iods_video_profile;
     for (i = 0; i < mov->nb_streams; i++) {
         if (mov->tracks[i].entry > 0 || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) {
-            has_audio |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_AUDIO;
-            has_video |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_VIDEO;
+            has_audio |= mov->tracks[i].par->codec_type == AVMEDIA_TYPE_AUDIO;
+            has_video |= mov->tracks[i].par->codec_type == AVMEDIA_TYPE_VIDEO;
         }
     }
     if (audio_profile < 0)
@@ -2292,7 +2292,7 @@ static int mov_write_moov_tag(AVIOContext *pb, 
MOVMuxContext *mov,
         if (track->tag == MKTAG('r','t','p',' ')) {
             track->tref_tag = MKTAG('h','i','n','t');
             track->tref_id = mov->tracks[track->src_track].track_id;
-        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+        } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
             int * fallback, size;
             fallback = (int*)av_stream_get_side_data(track->st,
                                                      
AV_PKT_DATA_FALLBACK_TRACK,
@@ -2373,53 +2373,53 @@ static int mov_write_isml_manifest(AVIOContext *pb, 
MOVMuxContext *mov)
          * here yet */
         int track_id = i + 1;
 
-        if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
+        if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
             type = "video";
-        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+        } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) {
             type = "audio";
         } else {
             continue;
         }
         avio_printf(pb, "<%s systemBitrate=\"%d\">\n", type,
-                                                       track->enc->bit_rate);
-        param_write_int(pb, "systemBitrate", track->enc->bit_rate);
+                                                       track->par->bit_rate);
+        param_write_int(pb, "systemBitrate", track->par->bit_rate);
         param_write_int(pb, "trackID", track_id);
-        if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) {
-            if (track->enc->codec_id == AV_CODEC_ID_H264) {
+        if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+            if (track->par->codec_id == AV_CODEC_ID_H264) {
                 uint8_t *ptr;
-                int size = track->enc->extradata_size;
-                if (!ff_avc_write_annexb_extradata(track->enc->extradata, &ptr,
+                int size = track->par->extradata_size;
+                if (!ff_avc_write_annexb_extradata(track->par->extradata, &ptr,
                                                    &size)) {
                     param_write_hex(pb, "CodecPrivateData",
-                                    ptr ? ptr : track->enc->extradata,
+                                    ptr ? ptr : track->par->extradata,
                                     size);
                     av_free(ptr);
                 }
                 param_write_string(pb, "FourCC", "H264");
-            } else if (track->enc->codec_id == AV_CODEC_ID_VC1) {
+            } else if (track->par->codec_id == AV_CODEC_ID_VC1) {
                 param_write_string(pb, "FourCC", "WVC1");
-                param_write_hex(pb, "CodecPrivateData", track->enc->extradata,
-                                track->enc->extradata_size);
+                param_write_hex(pb, "CodecPrivateData", track->par->extradata,
+                                track->par->extradata_size);
             }
-            param_write_int(pb, "MaxWidth", track->enc->width);
-            param_write_int(pb, "MaxHeight", track->enc->height);
-            param_write_int(pb, "DisplayWidth", track->enc->width);
-            param_write_int(pb, "DisplayHeight", track->enc->height);
+            param_write_int(pb, "MaxWidth", track->par->width);
+            param_write_int(pb, "MaxHeight", track->par->height);
+            param_write_int(pb, "DisplayWidth", track->par->width);
+            param_write_int(pb, "DisplayHeight", track->par->height);
         } else {
-            if (track->enc->codec_id == AV_CODEC_ID_AAC) {
+            if (track->par->codec_id == AV_CODEC_ID_AAC) {
                 param_write_string(pb, "FourCC", "AACL");
-            } else if (track->enc->codec_id == AV_CODEC_ID_WMAPRO) {
+            } else if (track->par->codec_id == AV_CODEC_ID_WMAPRO) {
                 param_write_string(pb, "FourCC", "WMAP");
             }
-            param_write_hex(pb, "CodecPrivateData", track->enc->extradata,
-                            track->enc->extradata_size);
+            param_write_hex(pb, "CodecPrivateData", track->par->extradata,
+                            track->par->extradata_size);
             param_write_int(pb, "AudioTag", ff_codec_get_tag(ff_codec_wav_tags,
-                                                             
track->enc->codec_id));
-            param_write_int(pb, "Channels", track->enc->channels);
-            param_write_int(pb, "SamplingRate", track->enc->sample_rate);
+                                                             
track->par->codec_id));
+            param_write_int(pb, "Channels", track->par->channels);
+            param_write_int(pb, "SamplingRate", track->par->sample_rate);
             param_write_int(pb, "BitsPerSample", 16);
-            param_write_int(pb, "PacketSize", track->enc->block_align ?
-                                              track->enc->block_align : 4);
+            param_write_int(pb, "PacketSize", track->par->block_align ?
+                                              track->par->block_align : 4);
         }
         avio_printf(pb, "</%s>\n", type);
     }
@@ -2496,7 +2496,7 @@ static int mov_write_tfhd_tag(AVIOContext *pb, 
MOVMuxContext *mov,
             track->default_sample_flags = get_sample_flags(track, 
&track->cluster[1]);
         else
             track->default_sample_flags =
-                track->enc->codec_type == AVMEDIA_TYPE_VIDEO ?
+                track->par->codec_type == AVMEDIA_TYPE_VIDEO ?
                 (MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES | 
MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC) :
                 MOV_FRAG_SAMPLE_FLAG_DEPENDS_NO;
         avio_wb32(pb, track->default_sample_flags);
@@ -2932,9 +2932,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
-        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
             has_video = 1;
-        if (st->codec->codec_id == AV_CODEC_ID_H264)
+        if (st->codecpar->codec_id == AV_CODEC_ID_H264)
             has_h264 = 1;
     }
 
@@ -3000,13 +3000,13 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 static void mov_write_uuidprof_tag(AVIOContext *pb, AVFormatContext *s)
 {
     AVStream       *video_st    = s->streams[0];
-    AVCodecContext *video_codec = s->streams[0]->codec;
-    AVCodecContext *audio_codec = s->streams[1]->codec;
-    int audio_rate = audio_codec->sample_rate;
+    AVCodecParameters *video_par = s->streams[0]->codecpar;
+    AVCodecParameters *audio_par = s->streams[1]->codecpar;
+    int audio_rate = audio_par->sample_rate;
     // TODO: should be avg_frame_rate
     int frame_rate = ((video_st->time_base.den) * (0x10000)) / 
(video_st->time_base.num);
-    int audio_kbitrate = audio_codec->bit_rate / 1000;
-    int video_kbitrate = FFMIN(video_codec->bit_rate / 1000, 800 - 
audio_kbitrate);
+    int audio_kbitrate = audio_par->bit_rate / 1000;
+    int video_kbitrate = FFMIN(video_par->bit_rate / 1000, 800 - 
audio_kbitrate);
 
     avio_wb32(pb, 0x94); /* size */
     ffio_wfourcc(pb, "uuid");
@@ -3035,13 +3035,13 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, 
AVFormatContext *s)
     avio_wb32(pb, audio_kbitrate);
     avio_wb32(pb, audio_kbitrate);
     avio_wb32(pb, audio_rate);
-    avio_wb32(pb, audio_codec->channels);
+    avio_wb32(pb, audio_par->channels);
 
     avio_wb32(pb, 0x34);  /* size */
     ffio_wfourcc(pb, "VPRF");   /* video */
     avio_wb32(pb, 0x0);
     avio_wb32(pb, 0x1);    /* TrackID */
-    if (video_codec->codec_id == AV_CODEC_ID_H264) {
+    if (video_par->codec_id == AV_CODEC_ID_H264) {
         ffio_wfourcc(pb, "avc1");
         avio_wb16(pb, 0x014D);
         avio_wb16(pb, 0x0015);
@@ -3055,8 +3055,8 @@ static void mov_write_uuidprof_tag(AVIOContext *pb, 
AVFormatContext *s)
     avio_wb32(pb, video_kbitrate);
     avio_wb32(pb, frame_rate);
     avio_wb32(pb, frame_rate);
-    avio_wb16(pb, video_codec->width);
-    avio_wb16(pb, video_codec->height);
+    avio_wb16(pb, video_par->width);
+    avio_wb16(pb, video_par->height);
     avio_wb32(pb, 0x010001); /* ? */
 }
 
@@ -3376,7 +3376,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
     MOVMuxContext *mov = s->priv_data;
     AVIOContext *pb = s->pb;
     MOVTrack *trk = &mov->tracks[pkt->stream_index];
-    AVCodecContext *enc = trk->enc;
+    AVCodecParameters *par = trk->par;
     unsigned int samples_in_chunk = 0;
     int size = pkt->size, ret = 0;
     uint8_t *reformatted_data = NULL;
@@ -3405,7 +3405,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
-    if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
+    if (par->codec_id == AV_CODEC_ID_AMR_NB) {
         /* We must find out how many AMR blocks there are in one packet */
         static uint16_t packed_size[16] =
             {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1};
@@ -3425,17 +3425,17 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
         samples_in_chunk = 1;
 
     /* copy extradata if it exists */
-    if (trk->vos_len == 0 && enc->extradata_size > 0) {
-        trk->vos_len  = enc->extradata_size;
+    if (trk->vos_len == 0 && par->extradata_size > 0) {
+        trk->vos_len  = par->extradata_size;
         trk->vos_data = av_malloc(trk->vos_len);
         if (!trk->vos_data) {
             ret = AVERROR(ENOMEM);
             goto err;
         }
-        memcpy(trk->vos_data, enc->extradata, trk->vos_len);
+        memcpy(trk->vos_data, par->extradata, trk->vos_len);
     }
 
-    if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t 
*)trk->vos_data != 1) {
+    if (par->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t 
*)trk->vos_data != 1) {
         /* from x264 or from bytestream h264 */
         /* nal reformating needed */
         if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
@@ -3445,7 +3445,7 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         } else {
             size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
         }
-    } else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
+    } else if (par->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
                (AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
         /* extradata is Annex B, assume the bitstream is too and convert it */
         if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
@@ -3458,8 +3458,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         avio_write(pb, pkt->data, size);
     }
 
-    if ((enc->codec_id == AV_CODEC_ID_DNXHD ||
-         enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
+    if ((par->codec_id == AV_CODEC_ID_DNXHD ||
+         par->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
         /* copy frame to create needed atoms */
         trk->vos_len  = size;
         trk->vos_data = av_malloc(size);
@@ -3560,10 +3560,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
                                            trk->cluster[trk->entry].cts +
                                            pkt->duration);
 
-    if (enc->codec_id == AV_CODEC_ID_VC1) {
+    if (par->codec_id == AV_CODEC_ID_VC1) {
         mov_parse_vc1_frame(pkt, trk);
     } else if (pkt->flags & AV_PKT_FLAG_KEY) {
-        if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
+        if (mov->mode == MODE_MOV && par->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
             trk->entry > 0) { // force sync sample for the first key frame
             mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags);
             if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE)
@@ -3595,7 +3595,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
     } else {
         MOVMuxContext *mov = s->priv_data;
         MOVTrack *trk = &mov->tracks[pkt->stream_index];
-        AVCodecContext *enc = trk->enc;
+        AVCodecParameters *par = trk->par;
         int64_t frag_duration = 0;
         int size = pkt->size;
 
@@ -3626,7 +3626,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
              frag_duration >= mov->max_fragment_duration) ||
              (mov->max_fragment_size && mov->mdat_size + size >= 
mov->max_fragment_size) ||
              (mov->flags & FF_MOV_FLAG_FRAG_KEYFRAME &&
-              enc->codec_type == AVMEDIA_TYPE_VIDEO &&
+              par->codec_type == AVMEDIA_TYPE_VIDEO &&
               trk->entry && pkt->flags & AV_PKT_FLAG_KEY)) {
             if (frag_duration >= mov->min_fragment_duration) {
                 // Set the duration of this track to line up with the next
@@ -3657,15 +3657,15 @@ static int mov_create_chapter_track(AVFormatContext *s, 
int tracknum)
     track->mode = mov->mode;
     track->tag = MKTAG('t','e','x','t');
     track->timescale = MOV_TIMESCALE;
-    track->enc = avcodec_alloc_context3(NULL);
-    if (!track->enc)
+    track->par = avcodec_parameters_alloc();
+    if (!track->par)
         return AVERROR(ENOMEM);
-    track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
-    track->enc->extradata = av_malloc(sizeof(chapter_properties));
-    if (!track->enc->extradata)
+    track->par->codec_type = AVMEDIA_TYPE_SUBTITLE;
+    track->par->extradata = av_malloc(sizeof(chapter_properties));
+    if (!track->par->extradata)
         return AVERROR(ENOMEM);
-    track->enc->extradata_size = sizeof(chapter_properties);
-    memcpy(track->enc->extradata, chapter_properties, 
sizeof(chapter_properties));
+    track->par->extradata_size = sizeof(chapter_properties);
+    memcpy(track->par->extradata, chapter_properties, 
sizeof(chapter_properties));
 
     for (i = 0; i < s->nb_chapters; i++) {
         AVChapter *c = s->chapters[i];
@@ -3722,15 +3722,15 @@ static void enable_tracks(AVFormatContext *s)
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
 
-        if (st->codec->codec_type <= AVMEDIA_TYPE_UNKNOWN ||
-            st->codec->codec_type >= AVMEDIA_TYPE_NB)
+        if (st->codecpar->codec_type <= AVMEDIA_TYPE_UNKNOWN ||
+            st->codecpar->codec_type >= AVMEDIA_TYPE_NB)
             continue;
 
-        if (first[st->codec->codec_type] < 0)
-            first[st->codec->codec_type] = i;
+        if (first[st->codecpar->codec_type] < 0)
+            first[st->codecpar->codec_type] = i;
         if (st->disposition & AV_DISPOSITION_DEFAULT) {
             mov->tracks[i].flags |= MOV_TRACK_ENABLED;
-            enabled[st->codec->codec_type]++;
+            enabled[st->codecpar->codec_type]++;
         }
     }
 
@@ -3753,11 +3753,8 @@ static void mov_free(AVFormatContext *s)
     MOVMuxContext *mov = s->priv_data;
     int i;
 
-    if (mov->chapter_track) {
-        if (mov->tracks[mov->chapter_track].enc)
-            av_free(mov->tracks[mov->chapter_track].enc->extradata);
-        av_freep(&mov->tracks[mov->chapter_track].enc);
-    }
+    if (mov->chapter_track)
+        avcodec_parameters_free(&mov->tracks[mov->chapter_track].par);
 
     for (i = 0; i < mov->nb_streams; i++) {
         if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
@@ -3794,7 +3791,7 @@ static int 
mov_create_dvd_sub_decoder_specific_info(MOVTrack *track,
     int i, width = 720, height = 480;
     int have_palette = 0, have_size = 0;
     uint32_t palette[16];
-    char *cur = st->codec->extradata;
+    char *cur = st->codecpar->extradata;
 
     while (cur && *cur) {
         if (strncmp("palette:", cur, 8) == 0) {
@@ -3831,8 +3828,8 @@ static int 
mov_create_dvd_sub_decoder_specific_info(MOVTrack *track,
         }
         track->vos_len = 16 * 4;
     }
-    st->codec->width = width;
-    st->codec->height = track->height = height;
+    st->codecpar->width = width;
+    st->codecpar->height = track->height = height;
 
     return 0;
 }
@@ -3935,8 +3932,8 @@ static int mov_write_header(AVFormatContext *s)
         hint_track = mov->nb_streams;
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
-            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
-                st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+            if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+                st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
                 mov->nb_streams++;
             }
         }
@@ -3954,7 +3951,7 @@ static int mov_write_header(AVFormatContext *s)
         AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", 
NULL,0);
 
         track->st  = st;
-        track->enc = st->codec;
+        track->par = st->codecpar;
         track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", 
mov->mode!=MODE_MOV);
         if (track->language < 0)
             track->language = 0;
@@ -3971,11 +3968,11 @@ static int mov_write_header(AVFormatContext *s)
         track->start_dts  = AV_NOPTS_VALUE;
         track->start_cts  = AV_NOPTS_VALUE;
         track->end_pts    = AV_NOPTS_VALUE;
-        if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
             if (track->tag == MKTAG('m','x','3','p') || track->tag == 
MKTAG('m','x','3','n') ||
                 track->tag == MKTAG('m','x','4','p') || track->tag == 
MKTAG('m','x','4','n') ||
                 track->tag == MKTAG('m','x','5','p') || track->tag == 
MKTAG('m','x','5','n')) {
-                if (st->codec->width != 720 || (st->codec->height != 608 && 
st->codec->height != 512)) {
+                if (st->codecpar->width != 720 || (st->codecpar->height != 608 
&& st->codecpar->height != 512)) {
                     av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 
720x512 video resolution\n");
                     goto error;
                 }
@@ -3987,34 +3984,34 @@ static int mov_write_header(AVFormatContext *s)
                        "WARNING codec timebase is very high. If duration is 
too long,\n"
                        "file may not be playable by quicktime. Specify a 
shorter timebase\n"
                        "or choose different container.\n");
-        } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
-            track->timescale = st->codec->sample_rate;
+        } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+            track->timescale = st->codecpar->sample_rate;
             /* set sample_size for PCM and ADPCM */
-            if (av_get_bits_per_sample(st->codec->codec_id) ||
-                st->codec->codec_id == AV_CODEC_ID_ILBC) {
-                if (!st->codec->block_align) {
+            if (av_get_bits_per_sample(st->codecpar->codec_id) ||
+                st->codecpar->codec_id == AV_CODEC_ID_ILBC) {
+                if (!st->codecpar->block_align) {
                     av_log(s, AV_LOG_ERROR, "track %d: codec block align is 
not set\n", i);
                     goto error;
                 }
-                track->sample_size = st->codec->block_align;
+                track->sample_size = st->codecpar->block_align;
             }
             /* set audio_vbr for compressed audio */
-            if (av_get_bits_per_sample(st->codec->codec_id) < 8) {
+            if (av_get_bits_per_sample(st->codecpar->codec_id) < 8) {
                 track->audio_vbr = 1;
             }
             if (track->mode != MODE_MOV &&
-                track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 
16000) {
+                track->par->codec_id == AV_CODEC_ID_MP3 && track->timescale < 
16000) {
                 av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not 
supported\n",
-                       i, track->enc->sample_rate);
+                       i, track->par->sample_rate);
                 goto error;
             }
-        } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+        } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
             track->timescale = st->time_base.den;
-        } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+        } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
             track->timescale = st->time_base.den;
         }
         if (!track->height)
-            track->height = st->codec->height;
+            track->height = st->codecpar->height;
         /* The ism specific timescale isn't mandatory, but is assumed by
          * some tools, such as mp4split. */
         if (mov->mode == MODE_ISM)
@@ -4023,15 +4020,15 @@ static int mov_write_header(AVFormatContext *s)
         avpriv_set_pts_info(st, 64, 1, track->timescale);
 
         /* copy extradata if it exists */
-        if (st->codec->extradata_size) {
-            if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
+        if (st->codecpar->extradata_size) {
+            if (st->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
                 mov_create_dvd_sub_decoder_specific_info(track, st);
             else {
-                track->vos_len  = st->codec->extradata_size;
+                track->vos_len  = st->codecpar->extradata_size;
                 track->vos_data = av_malloc(track->vos_len);
                 if (!track->vos_data)
                     goto error;
-                memcpy(track->vos_data, st->codec->extradata, track->vos_len);
+                memcpy(track->vos_data, st->codecpar->extradata, 
track->vos_len);
             }
         }
     }
@@ -4063,8 +4060,8 @@ static int mov_write_header(AVFormatContext *s)
         /* Initialize the hint tracks for each audio and video stream */
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
-            if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
-                st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+            if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+                st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
                 ff_mov_init_hinting(s, hint_track, i);
                 hint_track++;
             }
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 22b8832..fccf1f3 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -93,7 +93,7 @@ typedef struct MOVTrack {
     int         track_id;
     int         tag; ///< stsd fourcc
     AVStream        *st;
-    AVCodecContext *enc;
+    AVCodecParameters *par;
 
     int         vos_len;
     uint8_t     *vos_data;
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index 73498e4..58ad9e4 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -37,11 +37,11 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int 
src_index)
     track->tag = MKTAG('r','t','p',' ');
     track->src_track = src_index;
 
-    track->enc = avcodec_alloc_context3(NULL);
-    if (!track->enc)
+    track->par = avcodec_parameters_alloc();
+    if (!track->par)
         goto fail;
-    track->enc->codec_type = AVMEDIA_TYPE_DATA;
-    track->enc->codec_tag  = track->tag;
+    track->par->codec_type = AVMEDIA_TYPE_DATA;
+    track->par->codec_tag  = track->tag;
 
     ret = ff_rtp_chain_mux_open(&track->rtp_ctx, s, src_st, NULL,
                                 RTP_MAX_PACKET_SIZE, src_index);
@@ -58,7 +58,7 @@ int ff_mov_init_hinting(AVFormatContext *s, int index, int 
src_index)
 fail:
     av_log(s, AV_LOG_WARNING,
            "Unable to initialize hinting of stream %d\n", src_index);
-    av_freep(&track->enc);
+    avcodec_parameters_free(&track->par);
     /* Set a default timescale, to avoid crashes in av_dump_format */
     track->timescale = 90000;
     return ret;
@@ -459,7 +459,7 @@ void ff_mov_close_hinting(MOVTrack *track)
 {
     AVFormatContext *rtp_ctx = track->rtp_ctx;
 
-    av_freep(&track->enc);
+    avcodec_parameters_free(&track->par);
     sample_queue_free(&track->sample_queue);
     if (!rtp_ctx)
         return;
-- 
2.0.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to