[FFmpeg-cvslog] lavc: Add trace_headers bitstream filter
ffmpeg | branch: master | Mark Thompson| Thu May 4 23:06:20 2017 +0100| [f11d8a5e8b185340cc50fcbc8a1437b0fbe7e931] | committer: Mark Thompson lavc: Add trace_headers bitstream filter Supports all streams that the coded bitstream infrastructure does (currently H.264 and H.265). > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f11d8a5e8b185340cc50fcbc8a1437b0fbe7e931 --- configure | 1 + doc/bitstream_filters.texi | 8 +++ libavcodec/Makefile| 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/trace_headers_bsf.c | 125 + 5 files changed, 136 insertions(+) diff --git a/configure b/configure index 535862fcaf..13dd7f54e2 100755 --- a/configure +++ b/configure @@ -2324,6 +2324,7 @@ vc1_parser_select="vc1dsp" # bitstream_filters aac_adtstoasc_bsf_select="adts_header" mjpeg2jpeg_bsf_select="jpegtables" +trace_headers_bsf_select="cbs_h264 cbs_h265" # external libraries avisynth_deps="LoadLibrary" diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 64f91f4b54..119a2267af 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -95,6 +95,14 @@ This bitstream filter passes the packets through unchanged. @section remove_extradata +@section trace_headers + +Log trace output containing all syntax elements in the coded stream +headers (everything above the level of individual coded blocks). +This can be useful for debugging low-level stream issues. + +Supports H.264 and H.265. + @section vp9_superframe Combine VP9 frames into superframes. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9791fb342e..09772a85f7 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -786,6 +786,7 @@ OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o OBJS-$(CONFIG_NULL_BSF) += null_bsf.o OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o +OBJS-$(CONFIG_TRACE_HEADERS_BSF) += trace_headers_bsf.o OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += vp9_superframe_split_bsf.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index 79ce40f9ed..2e423acaf0 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -38,6 +38,7 @@ extern const AVBitStreamFilter ff_null_bsf; extern const AVBitStreamFilter ff_text2movsub_bsf; extern const AVBitStreamFilter ff_noise_bsf; extern const AVBitStreamFilter ff_remove_extradata_bsf; +extern const AVBitStreamFilter ff_trace_headers_bsf; extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; extern const AVBitStreamFilter ff_vp9_superframe_bsf; extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c new file mode 100644 index 00..2d1fe636c2 --- /dev/null +++ b/libavcodec/trace_headers_bsf.c @@ -0,0 +1,125 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/avstring.h" +#include "libavutil/common.h" +#include "libavutil/log.h" + +#include "bsf.h" +#include "cbs.h" + + +typedef struct TraceHeadersContext { +CodedBitstreamContext cbc; +} TraceHeadersContext; + + +static int trace_headers_init(AVBSFContext *bsf) +{ +TraceHeadersContext *ctx = bsf->priv_data; +int err; + +err = ff_cbs_init(>cbc, bsf->par_in->codec_id, bsf); +if (err < 0) +return err; + +ctx->cbc.trace_enable = 1; +ctx->cbc.trace_level = AV_LOG_INFO; + +if (bsf->par_in->extradata) { +CodedBitstreamFragment ps; + +av_log(bsf, AV_LOG_INFO, "Extradata\n"); + +err = ff_cbs_read_extradata(>cbc, , bsf->par_in); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); +return err; +} + +ff_cbs_fragment_uninit(>cbc, ); +} + +return 0; +} + +static void trace_headers_close(AVBSFContext *bsf) +{ +TraceHeadersContext *ctx = bsf->priv_data; + +ff_cbs_close(>cbc); +} + +static int
[FFmpeg-cvslog] lavc: Add trace_headers bitstream filter
ffmpeg | branch: master | Mark Thompson| Thu May 4 23:06:20 2017 +0100| [9c7d70b49b64aa5571772a7cdb9bc426174261e0] | committer: Mark Thompson lavc: Add trace_headers bitstream filter Supports all streams that the coded bitstream infrastructure does (currently H.264, H.265 and MPEG-2). (cherry picked from commit f11d8a5e8b185340cc50fcbc8a1437b0fbe7e931) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9c7d70b49b64aa5571772a7cdb9bc426174261e0 --- configure | 1 + doc/bitstream_filters.texi | 8 +++ libavcodec/Makefile| 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/trace_headers_bsf.c | 126 + 5 files changed, 137 insertions(+) diff --git a/configure b/configure index bb0a748f9e..74aac3a4f4 100755 --- a/configure +++ b/configure @@ -2914,6 +2914,7 @@ vc1_parser_select="vc1dsp" # bitstream_filters mjpeg2jpeg_bsf_select="jpegtables" +trace_headers_bsf_select="cbs_h264 cbs_h265 cbs_mpeg2" # external libraries aac_at_decoder_deps="audiotoolbox" diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 2dffe021f9..990b4f3c58 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -275,6 +275,14 @@ codec) with metadata headers. See also the @ref{mov2textsub} filter. +@section trace_headers + +Log trace output containing all syntax elements in the coded stream +headers (everything above the level of individual coded blocks). +This can be useful for debugging low-level stream issues. + +Supports H.264, H.265 and MPEG-2. + @section vp9_superframe Merge VP9 invisible (alt-ref) frames back into VP9 superframes. This diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0265c92130..5e09889bc6 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1028,6 +1028,7 @@ OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o OBJS-$(CONFIG_NULL_BSF) += null_bsf.o OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o OBJS-$(CONFIG_TEXT2MOVSUB_BSF)+= movsub_bsf.o +OBJS-$(CONFIG_TRACE_HEADERS_BSF) += trace_headers_bsf.o OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF) += vp9_superframe_split_bsf.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index ce34de640d..dd0247182b 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -41,6 +41,7 @@ extern const AVBitStreamFilter ff_noise_bsf; extern const AVBitStreamFilter ff_null_bsf; extern const AVBitStreamFilter ff_remove_extradata_bsf; extern const AVBitStreamFilter ff_text2movsub_bsf; +extern const AVBitStreamFilter ff_trace_headers_bsf; extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; extern const AVBitStreamFilter ff_vp9_superframe_bsf; extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c new file mode 100644 index 00..93d04cb509 --- /dev/null +++ b/libavcodec/trace_headers_bsf.c @@ -0,0 +1,126 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/avstring.h" +#include "libavutil/common.h" +#include "libavutil/log.h" + +#include "bsf.h" +#include "cbs.h" + + +typedef struct TraceHeadersContext { +CodedBitstreamContext *cbc; +} TraceHeadersContext; + + +static int trace_headers_init(AVBSFContext *bsf) +{ +TraceHeadersContext *ctx = bsf->priv_data; +int err; + +err = ff_cbs_init(>cbc, bsf->par_in->codec_id, bsf); +if (err < 0) +return err; + +ctx->cbc->trace_enable = 1; +ctx->cbc->trace_level = AV_LOG_INFO; + +if (bsf->par_in->extradata) { +CodedBitstreamFragment ps; + +av_log(bsf, AV_LOG_INFO, "Extradata\n"); + +err = ff_cbs_read_extradata(ctx->cbc, , bsf->par_in); +if (err < 0) { +av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); +return err; +} + +ff_cbs_fragment_uninit(ctx->cbc, ); +} + +return 0; +} + +static void trace_headers_close(AVBSFContext *bsf) +{ +