[FFmpeg-cvslog] Merge commit 'b667252a41fbf5a3f6ea8c67fdbc03db3d748977'
Derek Buitenhuis
git at videolan.org
Tue Apr 26 15:08:11 CEST 2016
ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Tue Apr 26 14:07:03 2016 +0100| [438ed974b832634c544facaf6de3a23e9e7d774a] | committer: Derek Buitenhuis
Merge commit 'b667252a41fbf5a3f6ea8c67fdbc03db3d748977'
* commit 'b667252a41fbf5a3f6ea8c67fdbc03db3d748977':
h2645_parse: add support for parsing h264
Merged-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=438ed974b832634c544facaf6de3a23e9e7d774a
---
libavcodec/h2645_parse.c | 24 ++++++++++++++++++++++--
libavcodec/h2645_parse.h | 14 +++++++++++++-
libavcodec/hevc.c | 2 +-
libavcodec/hevc_parser.c | 3 ++-
4 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index fc22ec6..6e24ea3 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -204,9 +204,26 @@ static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
return nuh_layer_id == 0;
}
+static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+ GetBitContext *gb = &nal->gb;
+
+ if (get_bits1(gb) != 0)
+ return AVERROR_INVALIDDATA;
+
+ nal->ref_idc = get_bits(gb, 2);
+ nal->type = get_bits(gb, 5);
+
+ av_log(logctx, AV_LOG_DEBUG,
+ "nal_unit_type: %d, nal_ref_idc: %d\n",
+ nal->type, nal->ref_idc);
+
+ return 1;
+}
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
- void *logctx, int is_nalff, int nal_length_size)
+ void *logctx, int is_nalff, int nal_length_size,
+ enum AVCodecID codec_id)
{
int consumed, ret = 0;
@@ -279,7 +296,10 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
if (ret < 0)
return ret;
- ret = hevc_parse_nal_header(nal, logctx);
+ if (codec_id == AV_CODEC_ID_HEVC)
+ ret = hevc_parse_nal_header(nal, logctx);
+ else
+ ret = h264_parse_nal_header(nal, logctx);
if (ret <= 0) {
if (ret < 0) {
av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
index cbf07a2..ce889db 100644
--- a/libavcodec/h2645_parse.h
+++ b/libavcodec/h2645_parse.h
@@ -38,12 +38,23 @@ typedef struct H2645NAL {
GetBitContext gb;
+ /**
+ * NAL unit type
+ */
int type;
+
+ /**
+ * HEVC only, nuh_temporal_id_plus_1 - 1
+ */
int temporal_id;
int skipped_bytes;
int skipped_bytes_pos_size;
int *skipped_bytes_pos;
+ /**
+ * H264 only, nal_ref_idc
+ */
+ int ref_idc;
} H2645NAL;
/* an input packet split into unescaped NAL units */
@@ -63,7 +74,8 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int length,
* Split an input packet into NAL units.
*/
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
- void *logctx, int is_nalff, int nal_length_size);
+ void *logctx, int is_nalff, int nal_length_size,
+ enum AVCodecID codec_id);
/**
* Free all the allocated memory in the packet.
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 27b1640..d1aa0b0 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2867,7 +2867,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
/* split the input packet into NAL units, so we know the upper bound on the
* number of slices in the frame */
ret = ff_h2645_packet_split(&s->pkt, buf, length, s->avctx, s->is_nalff,
- s->nal_length_size);
+ s->nal_length_size, s->avctx->codec_id);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Error splitting the input into NAL units.\n");
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 458a2eb..f4b65b5 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -89,7 +89,8 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
HEVCParserContext *ctx = s->priv_data;
int ret, i;
- ret = ff_h2645_split_packet(&ctx->pkt, buf, buf_size, avctx, 0, 0);
+ ret = ff_h2645_split_packet(&ctx->pkt, buf, buf_size, avctx, 0, 0,
+ AV_CODEC_ID_HEVC);
if (ret < 0)
return ret;
======================================================================
diff --cc libavcodec/h2645_parse.h
index cbf07a2,148ccf3..ce889db
--- a/libavcodec/h2645_parse.h
+++ b/libavcodec/h2645_parse.h
@@@ -38,12 -38,20 +38,23 @@@ typedef struct H2645NAL
GetBitContext gb;
+ /**
+ * NAL unit type
+ */
int type;
+
+ /**
+ * HEVC only, nuh_temporal_id_plus_1 - 1
+ */
int temporal_id;
+ int skipped_bytes;
+ int skipped_bytes_pos_size;
+ int *skipped_bytes_pos;
+ /**
+ * H264 only, nal_ref_idc
+ */
+ int ref_idc;
} H2645NAL;
/* an input packet split into unescaped NAL units */
diff --cc libavcodec/hevc_parser.c
index 458a2eb,dc5fffc..f4b65b5
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@@ -89,7 -82,8 +89,8 @@@ static int parse_nal_units(AVCodecParse
HEVCParserContext *ctx = s->priv_data;
int ret, i;
- ret = ff_h2645_split_packet(&ctx->pkt, buf, buf_size, avctx, 0, 0);
- ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0,
++ ret = ff_h2645_split_packet(&ctx->pkt, buf, buf_size, avctx, 0, 0,
+ AV_CODEC_ID_HEVC);
if (ret < 0)
return ret;
More information about the ffmpeg-cvslog
mailing list