[FFmpeg-devel] [PATCH 1/3] avformat/flv: add support for h265 streams
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Thu Jul 1 17:27:11 EEST 2021
James Almer:
> From: Matthieu Patou <mpatou at fb.com>
>
> Suggested-by: ffmpeg at fb.com
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> libavformat/flv.h | 1 +
> libavformat/flvdec.c | 14 ++++++++++++--
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/flv.h b/libavformat/flv.h
> index 3571b90279..7a026d3217 100644
> --- a/libavformat/flv.h
> +++ b/libavformat/flv.h
> @@ -110,6 +110,7 @@ enum {
> FLV_CODECID_H264 = 7,
> FLV_CODECID_REALH263= 8,
> FLV_CODECID_MPEG4 = 9,
> + FLV_CODECID_H265 = 10,
> };
Is there an official source for these numbers?
>
> enum {
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 60d1a5c654..ba60d71196 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -321,6 +321,8 @@ static int flv_same_video_codec(AVCodecParameters *vpar, int flags)
> return vpar->codec_id == AV_CODEC_ID_VP6A;
> case FLV_CODECID_H264:
> return vpar->codec_id == AV_CODEC_ID_H264;
> + case FLV_CODECID_H265:
> + return vpar->codec_id == AV_CODEC_ID_H265;
> default:
> return vpar->codec_tag == flv_codecid;
> }
> @@ -366,6 +368,11 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
> vstream->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
> ret = 3; // not 4, reading packet type will consume one byte
> break;
> + case FLV_CODECID_H265:
> + par->codec_id = AV_CODEC_ID_H265;
> + vstream->internal->need_parsing = AVSTREAM_PARSE_HEADERS;
> + ret = 3; // not 4, reading packet type will consume one byte
> + break;
> case FLV_CODECID_MPEG4:
> par->codec_id = AV_CODEC_ID_MPEG4;
> ret = 3;
> @@ -1241,6 +1248,7 @@ retry_duration:
>
> if (st->codecpar->codec_id == AV_CODEC_ID_AAC ||
> st->codecpar->codec_id == AV_CODEC_ID_H264 ||
> + st->codecpar->codec_id == AV_CODEC_ID_H265 ||
> st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
> int type = avio_r8(s->pb);
> size--;
> @@ -1250,7 +1258,9 @@ retry_duration:
> goto leave;
> }
>
> - if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
> + if (st->codecpar->codec_id == AV_CODEC_ID_H264 ||
> + st->codecpar->codec_id == AV_CODEC_ID_H265 ||
> + st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
> // sign extension
> int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
> pts = av_sat_add64(dts, cts);
> @@ -1266,7 +1276,7 @@ retry_duration:
> }
> }
> if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
> - st->codecpar->codec_id == AV_CODEC_ID_H264)) {
> + st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_H265)) {
> AVDictionaryEntry *t;
>
> if (st->codecpar->extradata) {
>
More information about the ffmpeg-devel
mailing list