diff mbox series

[FFmpeg-devel,08/17] avformat/mxfenc: Improve returned error codes

Message ID AM7PR03MB666018432F95603BD360D7A28F929@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,01/17] avformat/mxfenc: Auto-insert h264_mp4toannexb BSF if needed
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 9, 2021, 6:01 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/mxfenc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Tomas Härdin Nov. 9, 2021, 9:23 p.m. UTC | #1
tis 2021-11-09 klockan 19:01 +0100 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/mxfenc.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

Aha, this one does exactly what I just suggested with return values.
D'oh!

Looks OK of course

/Tomas
Andreas Rheinhardt Nov. 10, 2021, 1:07 p.m. UTC | #2
Tomas Härdin:
> tis 2021-11-09 klockan 19:01 +0100 skrev Andreas Rheinhardt:
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavformat/mxfenc.c | 16 ++++++++--------
>>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> Aha, this one does exactly what I just suggested with return values.
> D'oh!
> 

No. It only does this with the errors from init, not from write_packet.
The reason for this is that the other errors often blur the line between
AVERROR(EINVAL) and AVERROR_INVALIDDATA, so I decided to do nothing
about them.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index c20ba9bfca..cf63340313 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2509,7 +2509,7 @@  static int mxf_init(AVFormatContext *s)
 
     if (s->oformat == &ff_mxf_opatom_muxer && s->nb_streams !=1) {
         av_log(s, AV_LOG_ERROR, "there must be exactly one stream for mxf opatom\n");
-        return -1;
+        return AVERROR(EINVAL);
     }
 
     if (!av_dict_get(s->metadata, "comment_", NULL, AV_DICT_IGNORE_SUFFIX))
@@ -2525,7 +2525,7 @@  static int mxf_init(AVFormatContext *s)
 
         if (((i == 0) ^ (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) && s->oformat != &ff_mxf_opatom_muxer) {
             av_log(s, AV_LOG_ERROR, "there must be exactly one video stream and it must be the first one\n");
-            return -1;
+            return AVERROR(EINVAL);
         }
 
         if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -2590,7 +2590,7 @@  static int mxf_init(AVFormatContext *s)
                     ul_index = 4+ntsc;
                 } else {
                     av_log(s, AV_LOG_ERROR, "error MXF D-10 only support 30/40/50 mbit/s\n");
-                    return -1;
+                    return AVERROR(EINVAL);
                 }
 
                 sc->codec_ul = &mxf_d10_codec_uls[ul_index];
@@ -2607,13 +2607,13 @@  static int mxf_init(AVFormatContext *s)
             char bsf_arg[32];
             if (st->codecpar->sample_rate != 48000) {
                 av_log(s, AV_LOG_ERROR, "only 48khz is implemented\n");
-                return -1;
+                return AVERROR_PATCHWELCOME;
             }
             avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
             if (s->oformat == &ff_mxf_d10_muxer) {
                 if (st->index != 1) {
                     av_log(s, AV_LOG_ERROR, "MXF D-10 only support one audio track\n");
-                    return -1;
+                    return AVERROR(EINVAL);
                 }
                 if (st->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE &&
                     st->codecpar->codec_id != AV_CODEC_ID_PCM_S24LE) {
@@ -2657,11 +2657,11 @@  static int mxf_init(AVFormatContext *s)
                 sc->index = INDEX_S436M;
             } else {
                 av_log(s, AV_LOG_ERROR, "track %d: unsupported data type\n", i);
-                return -1;
+                return AVERROR(EINVAL);
             }
             if (st->index != s->nb_streams - 1) {
                 av_log(s, AV_LOG_ERROR, "data track must be placed last\n");
-                return -1;
+                return AVERROR(EINVAL);
             }
         }
 
@@ -2670,7 +2670,7 @@  static int mxf_init(AVFormatContext *s)
             if (sc->index == -1) {
                 av_log(s, AV_LOG_ERROR, "track %d: could not find essence container ul, "
                        "codec not currently supported in container\n", i);
-                return -1;
+                return AVERROR(EINVAL);
             }
         }