diff mbox series

[FFmpeg-devel,13/18] lavf/dv: return a meaningful error code from avpriv_dv_produce_packet()

Message ID 20220824084318.333-13-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/18] tests/fate/mov: add a test for dv audio demuxed through dv demuxer | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

Anton Khirnov Aug. 24, 2022, 8:43 a.m. UTC
---
 libavdevice/iec61883.c | 2 +-
 libavformat/dv.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Andreas Rheinhardt Aug. 24, 2022, 1:07 p.m. UTC | #1
Anton Khirnov:
> ---
>  libavdevice/iec61883.c | 2 +-
>  libavformat/dv.c       | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
> index 7223ba2e64..a4b4ce2ef8 100644
> --- a/libavdevice/iec61883.c
> +++ b/libavdevice/iec61883.c
> @@ -209,7 +209,7 @@ static int iec61883_parse_queue_dv(struct iec61883_data *dv, AVPacket *pkt)
>      dv->packets--;
>  
>      if (size < 0)
> -        return -1;
> +        return size;

Did you test this? iec61883_read_packet() explicitly checks for -1 and
not for < 0 for failure. It should work if you also modify
iec61883_read_packet(), but I never changed this because I don't like to
change code that I can't test.

- Andreas

>  
>      if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
>          av_freep(&pkt->data);
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index f88fe62349..c888111789 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -404,7 +404,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
>      if (buf_size < DV_PROFILE_BYTES ||
>          !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) ||
>          buf_size < c->sys->frame_size) {
> -        return -1;   /* Broken frame, or not enough data */
> +        return AVERROR_INVALIDDATA;
>      }
>  
>      /* Queueing audio packet */
diff mbox series

Patch

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 7223ba2e64..a4b4ce2ef8 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -209,7 +209,7 @@  static int iec61883_parse_queue_dv(struct iec61883_data *dv, AVPacket *pkt)
     dv->packets--;
 
     if (size < 0)
-        return -1;
+        return size;
 
     if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
         av_freep(&pkt->data);
diff --git a/libavformat/dv.c b/libavformat/dv.c
index f88fe62349..c888111789 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -404,7 +404,7 @@  int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
     if (buf_size < DV_PROFILE_BYTES ||
         !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) ||
         buf_size < c->sys->frame_size) {
-        return -1;   /* Broken frame, or not enough data */
+        return AVERROR_INVALIDDATA;
     }
 
     /* Queueing audio packet */