[FFmpeg-devel] [PATCH] avcodec/h264_parser: Skip Redundant Slice Info Attached Behind Frames.
mypopy at gmail.com
mypopy at gmail.com
Thu Oct 25 10:40:36 EEST 2018
On Thu, Oct 25, 2018 at 2:59 PM Linjie Fu <linjie.fu at intel.com> wrote:
>
> Skip redundant slice info attached behind frames (PPS for eaxmple) to
> parse timestamp correctly and produce the segment format successfully.
>
> When PPS info is attached behind frame data whin one PES packet,
> h264_find_frame_end for PPS slice returns END_NOT_FOUND,and causes the
> following IDR frame to returning END_NOT_FOUND too. And this leads to
> the failure of parsing pts and operation of segment.
>
> Skip redundant slice info to ensure the h264_parser to find the correct
> frame_end of following frame, and make sure parse_packet could parse the
> pts and dts.
>
> Fix the pts issue for single segment.ts and the segment format
> failure issue for http live stream in ticket #7207.
>
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
> libavcodec/h264_parser.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
> index 5f9a9c46ef..bcc97d6260 100644
> --- a/libavcodec/h264_parser.c
> +++ b/libavcodec/h264_parser.c
> @@ -577,6 +577,7 @@ static int h264_parse(AVCodecParserContext *s,
> H264ParseContext *p = s->priv_data;
> ParseContext *pc = &p->pc;
> int next;
> + int input_bufsize = buf_size;
>
> if (!p->got_first) {
> p->got_first = 1;
> @@ -644,7 +645,10 @@ static int h264_parse(AVCodecParserContext *s,
>
> *poutbuf = buf;
> *poutbuf_size = buf_size;
> - return next;
> + if (next > 0 && next <input_bufsize)
> + return input_bufsize;
> + else
> + return next;
> }
>
You can use FFMIN(next, input_bufsize) in this case.
More information about the ffmpeg-devel
mailing list