[FFmpeg-devel] [PATCH] lavd/v4l2: add HEVC streams support

Dima Buzdyk dima.buzdyk at gmail.com
Wed Nov 9 21:40:15 EET 2022


Signed-off-by: Dima Buzdyk <dima.buzdyk at gmail.com>
---
 libavcodec/hevc_parser.c  | 4 ++++
 libavdevice/v4l2-common.c | 3 +++
 libavdevice/v4l2.c        | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 59f9a0ff3e..8f99a277a1 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -330,6 +330,10 @@ static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx,
     if (!is_dummy_buf)
         parse_nal_units(s, buf, buf_size, avctx);
 
+    if (s->flags & PARSER_FLAG_ONCE) {
+        s->flags &= PARSER_FLAG_COMPLETE_FRAMES;
+    }
+
     *poutbuf      = buf;
     *poutbuf_size = buf_size;
     return next;
diff --git a/libavdevice/v4l2-common.c b/libavdevice/v4l2-common.c
index b5b4448a31..353e83efdd 100644
--- a/libavdevice/v4l2-common.c
+++ b/libavdevice/v4l2-common.c
@@ -55,6 +55,9 @@ const struct fmt_map ff_fmt_conversion_table[] = {
 #ifdef V4L2_PIX_FMT_H264
     { AV_PIX_FMT_NONE,    AV_CODEC_ID_H264,     V4L2_PIX_FMT_H264    },
 #endif
+#ifdef V4L2_PIX_FMT_HEVC
+    { AV_PIX_FMT_NONE,    AV_CODEC_ID_HEVC,     V4L2_PIX_FMT_HEVC    },
+#endif
 #ifdef V4L2_PIX_FMT_MPEG4
     { AV_PIX_FMT_NONE,    AV_CODEC_ID_MPEG4,    V4L2_PIX_FMT_MPEG4   },
 #endif
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 5e85d1a2b3..5558435827 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -972,7 +972,7 @@ static int v4l2_read_header(AVFormatContext *ctx)
     if (codec_id == AV_CODEC_ID_RAWVIDEO)
         st->codecpar->codec_tag =
             avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
-    else if (codec_id == AV_CODEC_ID_H264) {
+    else if (codec_id == AV_CODEC_ID_H264 || codec_id == AV_CODEC_ID_HEVC) {
         avpriv_stream_set_need_parsing(st, AVSTREAM_PARSE_FULL_ONCE);
     }
     if (desired_format == V4L2_PIX_FMT_YVU420)
-- 
2.37.2



More information about the ffmpeg-devel mailing list