diff mbox series

[FFmpeg-devel] avformat/s337m: Use av_get_packet() to read packet

Message ID 20210320034301.2818115-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 84b02bbb78b5aaec0a9de1d0859c4cf7f339a564
Headers show
Series [FFmpeg-devel] avformat/s337m: Use av_get_packet() to read packet
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 20, 2021, 3:43 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/s337m.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

Comments

Andreas Rheinhardt March 22, 2021, 7:14 p.m. UTC | #1
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/s337m.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/libavformat/s337m.c b/libavformat/s337m.c
> index 9e3c8ed1ba..9d1b52eb61 100644
> --- a/libavformat/s337m.c
> +++ b/libavformat/s337m.c
> @@ -147,7 +147,6 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
>      uint64_t state = 0;
>      int ret, data_type, data_size, offset;
>      enum AVCodecID codec;
> -    int64_t pos;
>  
>      while (!IS_LE_MARKER(state)) {
>          state = (state << 8) | avio_r8(pb);
> @@ -163,19 +162,11 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
>          data_size = avio_rl24(pb);
>      }
>  
> -    pos = avio_tell(pb);
> -
>      if ((ret = s337m_get_offset_and_codec(s, state, data_type, data_size, &offset, &codec)) < 0)
>          return ret;
>  
> -    if ((ret = av_new_packet(pkt, offset)) < 0)
> -        return ret;
> -
> -    pkt->pos = pos;
> -
> -    if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
> -        return AVERROR_EOF;
> -    }
> +    if ((ret = av_get_packet(pb, pkt, offset)) != offset)
> +        return ret < 0 ? ret : AVERROR_EOF;
>  
>      if (IS_16LE_MARKER(state))
>          ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
> 
Will apply tonight unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 9e3c8ed1ba..9d1b52eb61 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -147,7 +147,6 @@  static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
     uint64_t state = 0;
     int ret, data_type, data_size, offset;
     enum AVCodecID codec;
-    int64_t pos;
 
     while (!IS_LE_MARKER(state)) {
         state = (state << 8) | avio_r8(pb);
@@ -163,19 +162,11 @@  static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
         data_size = avio_rl24(pb);
     }
 
-    pos = avio_tell(pb);
-
     if ((ret = s337m_get_offset_and_codec(s, state, data_type, data_size, &offset, &codec)) < 0)
         return ret;
 
-    if ((ret = av_new_packet(pkt, offset)) < 0)
-        return ret;
-
-    pkt->pos = pos;
-
-    if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
-        return AVERROR_EOF;
-    }
+    if ((ret = av_get_packet(pb, pkt, offset)) != offset)
+        return ret < 0 ? ret : AVERROR_EOF;
 
     if (IS_16LE_MARKER(state))
         ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);