Skip to content

Commit b76053d

Browse files
committed
avformat/flvdec: add support for legacy HEVC files
1 parent 5cd49e1 commit b76053d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

libavformat/flv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ enum {
117117
FLV_CODECID_H264 = 7,
118118
FLV_CODECID_REALH263= 8,
119119
FLV_CODECID_MPEG4 = 9,
120+
121+
// non-standard protocol extension that is in use in the wild
122+
FLV_CODECID_X_HEVC = 12,
120123
};
121124

122125
enum {

libavformat/flvdec.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)
381381
return 1;
382382

383383
switch (flv_codecid) {
384+
case FLV_CODECID_X_HEVC:
384385
case MKBETAG('h', 'v', 'c', '1'):
385386
return vpar->codec_id == AV_CODEC_ID_HEVC;
386387
case MKBETAG('a', 'v', '0', '1'):
@@ -414,6 +415,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,
414415
enum AVCodecID old_codec_id = vstream->codecpar->codec_id;
415416

416417
switch (flv_codecid) {
418+
case FLV_CODECID_X_HEVC:
417419
case MKBETAG('h', 'v', 'c', '1'):
418420
par->codec_id = AV_CODEC_ID_HEVC;
419421
vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
@@ -1660,8 +1662,8 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
16601662
}
16611663

16621664
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
1663-
(st->codecpar->codec_id == AV_CODEC_ID_H264 && (!enhanced_flv || type == PacketTypeCodedFrames)) ||
1664-
(st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) {
1665+
((st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC) &&
1666+
(!enhanced_flv || type == PacketTypeCodedFrames))) {
16651667
// sign extension
16661668
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
16671669
pts = av_sat_add64(dts, cts);

libavformat/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "version_major.h"
3333

3434
#define LIBAVFORMAT_VERSION_MINOR 9
35-
#define LIBAVFORMAT_VERSION_MICRO 104
35+
#define LIBAVFORMAT_VERSION_MICRO 105
3636

3737
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3838
LIBAVFORMAT_VERSION_MINOR, \

0 commit comments

Comments
 (0)