diff mbox series

[FFmpeg-devel,13/17] avformat/evcdec: simplify probe function

Message ID 20230618234332.1370-3-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] avcodec/evc_frame_merge: use av_fast_realloc() | 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

James Almer June 18, 2023, 11:43 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/evcdec.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

Comments

Michael Niedermayer June 19, 2023, 8:29 p.m. UTC | #1
On Sun, Jun 18, 2023 at 08:43:28PM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/evcdec.c | 29 +++++++----------------------
>  1 file changed, 7 insertions(+), 22 deletions(-)

This or the previous might cause "Invalid NAL unit header" noise
from tools/probetest 256 4096
(not 100% sure as some patches didnt apply so maybe my tree was
broken) just reporting (please ignore if it doesnt reproduce)

thx

[...]
James Almer June 19, 2023, 8:42 p.m. UTC | #2
On 6/19/2023 5:29 PM, Michael Niedermayer wrote:
> On Sun, Jun 18, 2023 at 08:43:28PM -0300, James Almer wrote:
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavformat/evcdec.c | 29 +++++++----------------------
>>   1 file changed, 7 insertions(+), 22 deletions(-)
> 
> This or the previous might cause "Invalid NAL unit header" noise
> from tools/probetest 256 4096
> (not 100% sure as some patches didnt apply so maybe my tree was
> broken) just reporting (please ignore if it doesnt reproduce)
> 
> thx

It was patch 11/17. Forgot to add a logctx in evc_get_nalu_type().
Fixed locally.
diff mbox series

Patch

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 0f17edd371..7a783e9809 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -34,14 +34,6 @@ 
 
 #define RAW_PACKET_SIZE 1024
 
-typedef struct EVCParserContext {
-    int got_sps;
-    int got_pps;
-    int got_idr;
-    int got_nonidr;
-
-} EVCParserContext;
-
 typedef struct EVCDemuxContext {
     const AVClass *class;
     AVRational framerate;
@@ -65,10 +57,11 @@  static const AVClass evc_demuxer_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev)
+static int annexb_probe(const AVProbeData *p)
 {
     int nalu_type;
     size_t nalu_size;
+    int got_sps = 0, got_pps = 0, got_idr = 0, got_nonidr = 0;
     unsigned char *bits = (unsigned char *)p->buf;
     int bytes_to_read = p->buf_size;
 
@@ -85,27 +78,19 @@  static int parse_nal_units(const AVProbeData *p, EVCParserContext *ev)
         nalu_type = evc_get_nalu_type(bits, bytes_to_read, NULL);
 
         if (nalu_type == EVC_SPS_NUT)
-            ev->got_sps++;
+            got_sps++;
         else if (nalu_type == EVC_PPS_NUT)
-            ev->got_pps++;
+            got_pps++;
         else if (nalu_type == EVC_IDR_NUT )
-            ev->got_idr++;
+            got_idr++;
         else if (nalu_type == EVC_NOIDR_NUT)
-            ev->got_nonidr++;
+            got_nonidr++;
 
         bits += nalu_size;
         bytes_to_read -= nalu_size;
     }
 
-    return 0;
-}
-
-static int annexb_probe(const AVProbeData *p)
-{
-    EVCParserContext ev = {0};
-    int ret = parse_nal_units(p, &ev);
-
-    if (ret == 0 && ev.got_sps && ev.got_pps && (ev.got_idr || ev.got_nonidr > 3))
+    if (got_sps && got_pps && (got_idr || got_nonidr > 3))
         return AVPROBE_SCORE_EXTENSION + 1;  // 1 more than .mpg
 
     return 0;