diff mbox

[FFmpeg-devel,2/3] avformat/mxfenc: Check that the video codec in D-10 is MPEG-2

Message ID 20170829001321.1319-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Aug. 29, 2017, 12:13 a.m. UTC
Others do not work, but nothing rejects them prior to this patch if the
parameters otherwise match

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mxfenc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Matthieu Bouron Aug. 29, 2017, 8:10 a.m. UTC | #1
On Tue, Aug 29, 2017 at 02:13:20AM +0200, Michael Niedermayer wrote:
> Others do not work, but nothing rejects them prior to this patch if the
> parameters otherwise match
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/mxfenc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index ccfa0d6341..71f4b5b905 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -2104,6 +2104,10 @@ static int mxf_write_header(AVFormatContext *s)
>  
>              sc->video_bit_rate = st->codecpar->bit_rate;
>              if (s->oformat == &ff_mxf_d10_muxer) {
> +                if (st->codecpar->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
> +                    av_log(s, AV_LOG_ERROR, "error MXF D-10 only support MPEG-2 Video\n");
> +                    return -1;
> +                }

Shouldn't it be AVERROR(EINVAL) instead of -1 ? Otherwise LGTM.

[...]
Michael Niedermayer Aug. 29, 2017, 6:41 p.m. UTC | #2
On Tue, Aug 29, 2017 at 10:10:36AM +0200, Matthieu Bouron wrote:
> On Tue, Aug 29, 2017 at 02:13:20AM +0200, Michael Niedermayer wrote:
> > Others do not work, but nothing rejects them prior to this patch if the
> > parameters otherwise match
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/mxfenc.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> > index ccfa0d6341..71f4b5b905 100644
> > --- a/libavformat/mxfenc.c
> > +++ b/libavformat/mxfenc.c
> > @@ -2104,6 +2104,10 @@ static int mxf_write_header(AVFormatContext *s)
> >  
> >              sc->video_bit_rate = st->codecpar->bit_rate;
> >              if (s->oformat == &ff_mxf_d10_muxer) {
> > +                if (st->codecpar->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
> > +                    av_log(s, AV_LOG_ERROR, "error MXF D-10 only support MPEG-2 Video\n");
> > +                    return -1;
> > +                }
> 
> Shouldn't it be AVERROR(EINVAL) instead of -1 ? Otherwise LGTM.

EINVAL is more correct i will change to that, i used -1 because thats
what most of the function uses

will apply with that change

thanks

[...]
diff mbox

Patch

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index ccfa0d6341..71f4b5b905 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2104,6 +2104,10 @@  static int mxf_write_header(AVFormatContext *s)
 
             sc->video_bit_rate = st->codecpar->bit_rate;
             if (s->oformat == &ff_mxf_d10_muxer) {
+                if (st->codecpar->codec_id != AV_CODEC_ID_MPEG2VIDEO) {
+                    av_log(s, AV_LOG_ERROR, "error MXF D-10 only support MPEG-2 Video\n");
+                    return -1;
+                }
                 if ((sc->video_bit_rate == 50000000) && (mxf->time_base.den == 25)) {
                     sc->index = 3;
                 } else if ((sc->video_bit_rate == 49999840 || sc->video_bit_rate == 50000000) && (mxf->time_base.den != 25)) {