On Sun, Nov 02, 2014 at 07:19:14PM +0100, Lukasz Marek wrote:
> 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);

shouldnt all these values be checked to be within the allowed ranges
for the corresponding AVOptions?

being able to set so many field so arbitrarily could be usefull to
some kind of exploit ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides

Attachment: signature.asc
Description: Digital signature

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

Reply via email to