diff mbox

[FFmpeg-devel,10/11] avcodec/h264_parser: Don't keep full DSP Context

Message ID 20190816030531.4775-10-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt Aug. 16, 2019, 3:05 a.m. UTC
We only need the function to search for start codes from it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/h264_parser.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 604cddada5..68eb5939db 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -50,10 +50,10 @@ 
 typedef struct H264ParseContext {
     ParseContext pc;
     H264ParamSets ps;
-    H264DSPContext h264dsp;
     H264POCContext poc;
     H264SEIContext sei;
     H2645RBSP rbsp;
+    int (*startcode_find_candidate)(const uint8_t *buf, int size);
     int is_avc;
     int nal_length_size;
     int got_first;
@@ -97,7 +97,7 @@  static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
         }
 
         if (state == 7) {
-            i += p->h264dsp.startcode_find_candidate(buf + i, next_avc - i);
+            i += p->startcode_find_candidate(buf + i, next_avc - i);
             if (i < next_avc)
                 state = 2;
         } else if (state <= 2) {
@@ -705,10 +705,13 @@  static void h264_close(AVCodecParserContext *s)
 static av_cold int init(AVCodecParserContext *s)
 {
     H264ParseContext *p = s->priv_data;
+    H264DSPContext h264dsp;
+
+    ff_h264dsp_init(&h264dsp, 8, 1);
+    p->startcode_find_candidate = h264dsp.startcode_find_candidate;
 
     p->reference_dts = AV_NOPTS_VALUE;
     p->last_frame_num = INT_MAX;
-    ff_h264dsp_init(&p->h264dsp, 8, 1);
     return 0;
 }