diff mbox series

[FFmpeg-devel,v3,2/5] avcodec/avs2_parser: split data into frames

Message ID tencent_8168C67CC2AF823959C1E1B4E86AA602310A@qq.com
State New
Headers show
Series [FFmpeg-devel,v3,1/5] avcodec/avs2: add AVS2 related definitions | expand

Checks

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

Commit Message

zhilizhao(赵志立) June 13, 2022, 3:36 a.m. UTC
Before the patch, the parser split data into units, not frames.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
 libavcodec/avs2.h        | 2 +-
 libavcodec/avs2_parser.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/avs2.h b/libavcodec/avs2.h
index 7b66f51998..f342ba52a0 100644
--- a/libavcodec/avs2.h
+++ b/libavcodec/avs2.h
@@ -36,6 +36,6 @@  enum {
 };
 
 #define AVS2_ISPIC(x)  ((x) == AVS2_INTRA_PIC_START_CODE || (x) == AVS2_INTER_PIC_START_CODE)
-#define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || (x) == AVS2_SEQ_END_CODE || (x) == AVS2_USER_DATA_START_CODE || AVS2_ISPIC(x))
+#define AVS2_ISUNIT(x) ((x) == AVS2_SEQ_START_CODE || AVS2_ISPIC(x))
 
 #endif
diff --git a/libavcodec/avs2_parser.c b/libavcodec/avs2_parser.c
index 3755dbd78c..71cf442903 100644
--- a/libavcodec/avs2_parser.c
+++ b/libavcodec/avs2_parser.c
@@ -31,7 +31,7 @@  static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_siz
     if (!pic_found) {
         for (; cur < buf_size; ++cur) {
             state = (state << 8) | buf[cur];
-            if (AVS2_ISUNIT(buf[cur])){
+            if ((state & 0xFFFFFF00) == 0x100 && AVS2_ISPIC(buf[cur])) {
                 cur++;
                 pic_found = 1;
                 break;
@@ -44,7 +44,7 @@  static int avs2_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_siz
             return END_NOT_FOUND;
         for (; cur < buf_size; cur++) {
             state = (state << 8) | buf[cur];
-            if ((state & 0xFFFFFF00) == 0x100 && state > AVS2_SLICE_MAX_START_CODE) {
+            if ((state & 0xFFFFFF00) == 0x100 && AVS2_ISUNIT(buf[cur])) {
                 pc->frame_start_found = 0;
                 pc->state = -1;
                 return cur - 3;