]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/hevc_parser.c
avformat/mpegtsenc: move is_dvb_subtitle/is_dvb_teletext initialization upwards
[ffmpeg] / libavcodec / hevc_parser.c
index 5af4b788d501c0427132b3a166d8c39395b81b58..c944a6aacd8d2e7143d60f73412bcbdae54461f2 100644 (file)
@@ -136,7 +136,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
     for (i = 0; i < ps->pps->num_extra_slice_header_bits; i++)
         skip_bits(gb, 1); // slice_reserved_undetermined_flag[]
 
-    slice_type = get_ue_golomb(gb);
+    slice_type = get_ue_golomb_31(gb);
     if (!(slice_type == HEVC_SLICE_I || slice_type == HEVC_SLICE_P ||
           slice_type == HEVC_SLICE_B)) {
         av_log(avctx, AV_LOG_ERROR, "Unknown slice type: %d.\n",
@@ -336,39 +336,6 @@ static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
     return next;
 }
 
-// Split after the parameter sets at the beginning of the stream if they exist.
-static int hevc_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
-{
-    const uint8_t *ptr = buf, *end = buf + buf_size;
-    uint32_t state = -1;
-    int has_vps = 0;
-    int has_sps = 0;
-    int has_pps = 0;
-    int nut;
-
-    while (ptr < end) {
-        ptr = avpriv_find_start_code(ptr, end, &state);
-        if ((state >> 8) != START_CODE)
-            break;
-        nut = (state >> 1) & 0x3F;
-        if (nut == HEVC_NAL_VPS)
-            has_vps = 1;
-        else if (nut == HEVC_NAL_SPS)
-            has_sps = 1;
-        else if (nut == HEVC_NAL_PPS)
-            has_pps = 1;
-        else if ((nut != HEVC_NAL_SEI_PREFIX || has_pps) &&
-                  nut != HEVC_NAL_AUD) {
-            if (has_vps && has_sps) {
-                while (ptr - 4 > buf && ptr[-5] == 0)
-                    ptr--;
-                return ptr - 4 - buf;
-            }
-        }
-    }
-    return 0;
-}
-
 static void hevc_parser_close(AVCodecParserContext *s)
 {
     HEVCParserContext *ctx = s->priv_data;
@@ -380,10 +347,9 @@ static void hevc_parser_close(AVCodecParserContext *s)
     av_freep(&ctx->pc.buffer);
 }
 
-AVCodecParser ff_hevc_parser = {
+const AVCodecParser ff_hevc_parser = {
     .codec_ids      = { AV_CODEC_ID_HEVC },
     .priv_data_size = sizeof(HEVCParserContext),
     .parser_parse   = hevc_parse,
     .parser_close   = hevc_parser_close,
-    .split          = hevc_split,
 };