TODO: bump micro

Many common codec options are not via ffm protocol.
This commit adds common A/V encoding options to protocol.

Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com>
---
 libavformat/ffmdec.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/ffmenc.c | 60 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 138 insertions(+)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index e95c139..8f5338f 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -233,6 +233,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
     return 0;
 }
 
+static void ffm_report_old_version(AVFormatContext *s)
+{
+    av_log(s, AV_LOG_WARNING,
+           "Old version of feed file detected. Consider deleting feed 
files.\n");
+}
+
 static int ffm2_read_header(AVFormatContext *s)
 {
     FFMContext *ffm = s->priv_data;
@@ -294,6 +300,17 @@ static int ffm2_read_header(AVFormatContext *s)
                 if (ff_get_extradata(codec, pb, avio_rb32(pb)) < 0)
                     return AVERROR(ENOMEM);
             }
+            if (avio_tell(pb) < next) {
+                codec->slices = avio_r8(pb);
+                codec->thread_type = avio_r8(pb);
+                codec->compression_level = avio_rb32(pb);
+                codec->global_quality = avio_rb32(pb);
+                codec->ticks_per_frame = avio_rb32(pb);
+                codec->trellis = avio_rb32(pb);
+                codec->profile = avio_rb32(pb);
+            }
+            if (avio_tell(pb) < next)
+                ffm_report_old_version(s);
             avio_seek(pb, next, SEEK_SET);
             id = avio_rb32(pb);
             size = avio_rb32(pb);
@@ -348,11 +365,72 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 codec->qblur = av_int2double(avio_rb64(pb));
                 codec->max_qdiff = avio_rb32(pb);
                 codec->refs = avio_rb32(pb);
+                if (avio_tell(pb) < next) {
+                    codec->bidir_refine = avio_rb32(pb);
+                    codec->brd_scale = avio_rb32(pb);
+                    codec->b_sensitivity = avio_rb32(pb);
+                    codec->chromaoffset = avio_rb32(pb);
+                    codec->chroma_sample_location = avio_r8(pb);
+                    codec->color_primaries = avio_r8(pb);
+                    codec->color_range = avio_r8(pb);
+                    codec->colorspace = avio_r8(pb);
+                    codec->color_trc = avio_r8(pb);
+                    codec->context_model = avio_rb32(pb);
+                    codec->dia_size = avio_rb32(pb);
+                    codec->field_order = avio_r8(pb);
+                    codec->frame_skip_exp = avio_rb32(pb);
+                    codec->frame_skip_factor = avio_rb32(pb);
+                    codec->frame_skip_threshold = avio_rb32(pb);
+                    codec->idct_algo = avio_rb16(pb);
+                    codec->ildct_cmp = avio_rb16(pb);
+                    codec->inter_quant_bias = avio_rb32(pb);
+                    codec->intra_quant_bias = avio_rb32(pb);
+                    codec->last_predictor_count = avio_rb32(pb);
+                    codec->mb_cmp = avio_rb32(pb);
+                    codec->mb_lmin = avio_rb16(pb);
+                    codec->mb_lmax = avio_rb16(pb);
+                    codec->lumi_masking = av_int2double(avio_rb64(pb));
+                    codec->dark_masking = av_int2double(avio_rb64(pb));
+                    codec->me_penalty_compensation = avio_rb32(pb);
+                    codec->me_pre_cmp = avio_rb32(pb);
+                    codec->me_sub_cmp = avio_rb32(pb);
+                    codec->mv0_threshold = avio_rb32(pb);
+                    codec->noise_reduction = avio_rb32(pb);
+                    codec->p_masking = av_int2double(avio_rb32(pb));
+                    codec->pre_dia_size = avio_rb32(pb);
+                    codec->prediction_method = avio_r8(pb);
+                    codec->pre_me = avio_rb32(pb);
+                    codec->rc_initial_buffer_occupancy = avio_rb32(pb);
+                    codec->rc_max_available_vbv_use = 
av_int2double(avio_rb32(pb));
+                    codec->rc_min_vbv_overflow_use = 
av_int2double(avio_rb32(pb));
+                    codec->rtp_payload_size = avio_rb32(pb);
+                    codec->sample_aspect_ratio.num = avio_rb32(pb);
+                    codec->sample_aspect_ratio.den = avio_rb32(pb);
+                    codec->spatial_cplx_masking = av_int2double(avio_rb32(pb));
+                    codec->temporal_cplx_masking = 
av_int2double(avio_rb32(pb));
+                    codec->timecode_frame_start = avio_rb64(pb);
+                }
+                if (avio_tell(pb) < next)
+                    ffm_report_old_version(s);
                 break;
             case MKBETAG('S', 'T', 'A', 'U'):
                 codec->sample_rate = avio_rb32(pb);
                 codec->channels = avio_rl16(pb);
                 codec->frame_size = avio_rl16(pb);
+                if (avio_tell(pb) < next) {
+                    codec->thread_count = avio_r8(pb);
+                    codec->strict_std_compliance = avio_rb32(pb);
+                    codec->rc_max_rate = avio_rb32(pb);
+                    codec->rc_min_rate = avio_rb32(pb);
+                    codec->rc_buffer_size = avio_rb32(pb);
+                    codec->audio_service_type = avio_r8(pb);
+                    codec->channel_layout = avio_rb64(pb);
+                    codec->max_prediction_order = avio_rb32(pb);
+                    codec->min_prediction_order = avio_rb32(pb);
+                    codec->cutoff = avio_rb32(pb);
+                }
+                if (avio_tell(pb) < next)
+                    ffm_report_old_version(s);
                 break;
             }
             break;
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index 7528dbf..3b16feb 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -148,6 +148,13 @@ static int ffm_write_header(AVFormatContext *s)
             avio_wb32(pb, codec->extradata_size);
             avio_write(pb, codec->extradata, codec->extradata_size);
         }
+        avio_w8(pb, codec->slices);
+        avio_w8(pb, codec->thread_type);
+        avio_wb32(pb, codec->compression_level);
+        avio_wb32(pb, codec->global_quality);
+        avio_wb32(pb, codec->ticks_per_frame);
+        avio_wb32(pb, codec->trellis);
+        avio_wb32(pb, codec->profile);
         write_header_chunk(s->pb, pb, MKBETAG('C', 'O', 'M', 'M'));
         if(avio_open_dyn_buf(&pb) < 0)
             return AVERROR(ENOMEM);
@@ -201,12 +208,65 @@ FF_ENABLE_DEPRECATION_WARNINGS
             avio_wb64(pb, av_double2int(codec->qblur));
             avio_wb32(pb, codec->max_qdiff);
             avio_wb32(pb, codec->refs);
+            avio_wb32(pb, codec->bidir_refine);
+            avio_wb32(pb, codec->brd_scale);
+            avio_wb32(pb, codec->b_sensitivity);
+            avio_wb32(pb, codec->chromaoffset);
+            avio_w8(pb, codec->chroma_sample_location);
+            avio_w8(pb, codec->color_primaries);
+            avio_w8(pb, codec->color_range);
+            avio_w8(pb, codec->colorspace);
+            avio_w8(pb, codec->color_trc);
+            avio_wb32(pb, codec->context_model);
+            avio_wb32(pb, codec->dia_size);
+            avio_w8(pb, codec->field_order);
+            avio_wb32(pb, codec->frame_skip_exp);
+            avio_wb32(pb, codec->frame_skip_factor);
+            avio_wb32(pb, codec->frame_skip_threshold);
+            avio_wb16(pb, codec->idct_algo);
+            avio_wb16(pb, codec->ildct_cmp);
+            avio_wb32(pb, codec->inter_quant_bias);
+            avio_wb32(pb, codec->intra_quant_bias);
+            avio_wb32(pb, codec->last_predictor_count);
+            avio_wb32(pb, codec->mb_cmp);
+            avio_wb16(pb, codec->mb_lmin);
+            avio_wb16(pb, codec->mb_lmax);
+            avio_wb64(pb, av_double2int(codec->lumi_masking));
+            avio_wb64(pb, av_double2int(codec->dark_masking));
+            avio_wb32(pb, codec->me_penalty_compensation);
+            avio_wb32(pb, codec->me_pre_cmp);
+            avio_wb32(pb, codec->me_sub_cmp);
+            avio_wb32(pb, codec->mv0_threshold);
+            avio_wb32(pb, codec->noise_reduction);
+            avio_wb32(pb, av_double2int(codec->p_masking));
+            avio_wb32(pb, codec->pre_dia_size);
+            avio_w8(pb, codec->prediction_method);
+            avio_wb32(pb, codec->pre_me);
+            avio_wb32(pb, codec->rc_initial_buffer_occupancy);
+            avio_wb32(pb, av_double2int(codec->rc_max_available_vbv_use));
+            avio_wb32(pb, av_double2int(codec->rc_min_vbv_overflow_use));
+            avio_wb32(pb, codec->rtp_payload_size);
+            avio_wb32(pb, codec->sample_aspect_ratio.num);
+            avio_wb32(pb, codec->sample_aspect_ratio.den);
+            avio_wb32(pb, av_double2int(codec->spatial_cplx_masking));
+            avio_wb32(pb, av_double2int(codec->temporal_cplx_masking));
+            avio_wb64(pb, codec->timecode_frame_start);
             write_header_chunk(s->pb, pb, MKBETAG('S', 'T', 'V', 'I'));
             break;
         case AVMEDIA_TYPE_AUDIO:
             avio_wb32(pb, codec->sample_rate);
             avio_wl16(pb, codec->channels);
             avio_wl16(pb, codec->frame_size);
+            avio_w8(pb, codec->thread_count);
+            avio_wb32(pb, codec->strict_std_compliance);
+            avio_wb32(pb, codec->rc_max_rate);
+            avio_wb32(pb, codec->rc_min_rate);
+            avio_wb32(pb, codec->rc_buffer_size);
+            avio_w8(pb, codec->audio_service_type);
+            avio_wb64(pb, codec->channel_layout);
+            avio_wb32(pb, codec->max_prediction_order);
+            avio_wb32(pb, codec->min_prediction_order);
+            avio_wb32(pb, codec->cutoff);
             write_header_chunk(s->pb, pb, MKBETAG('S', 'T', 'A', 'U'));
             break;
         default:
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to