linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 00/24] H.264 Field Decoding Support for Frame-based Decoders
@ 2022-03-28 19:59 Nicolas Dufresne
  2022-03-28 19:59 ` [PATCH v1 01/24] media: h264: Increase reference lists size to 32 Nicolas Dufresne
                   ` (23 more replies)
  0 siblings, 24 replies; 64+ messages in thread
From: Nicolas Dufresne @ 2022-03-28 19:59 UTC (permalink / raw)
  Cc: kernel, linux-kernel

Until now, only Cedrus (a slice base decoder) supported interlaced decoding.
In order to support field decoding in our frame-based decoder, the v4l2-h264
library needed adaptation to produce the appropriate reference lists.

This patch extends the v4l2-h264 library to produce the larger references list
needed to represent fields separately. Hantro, MTK-VCODEC and RKVDEC drivers
have been adapted to accommodate the larger lists. Though, only Hantro and
RKVDEC actually have HW support for field decoding. So only these two
have been updated to make use of the larger lists. All this work has been
done using the H.264 specification, LibreELEC downstream kernel patches,
Rockchip MPP reference software and Hantro reference software.

All this work have been tested using GStreamer mainline implementation but also
with FFMPEG LibreELEC fork using the testing tool fluster running through the
ITU-T H.264 (2016-02) AVCv2 set of bitstream. Before this patch, the scores
were:

Hantro:
  FFMPEG:
  GSteamer:
RKVDEC:
  FFMPEG:
  GSteamer:

And after these changes:

Hantro:
  FFMPEG:   118/135
  GSteamer: 129/135
RKVDEC:
  FFMPEG:   118/135
  GSteamer: 129/135

Note that a bug in FFMPEG / LibreELEC fork was noticed and fixed with the
following change:

diff --git a/libavcodec/v4l2_request_h264.c b/libavcodec/v4l2_request_h264.c
index 88da8f0a2d..394bae0550 100644
--- a/libavcodec/v4l2_request_h264.c
+++ b/libavcodec/v4l2_request_h264.c
@@ -66,7 +66,7 @@ static void fill_dpb_entry(struct v4l2_h264_dpb_entry *entry, const H264Picture
 {
     entry->reference_ts = ff_v4l2_request_get_capture_timestamp(pic->f);
     entry->pic_num = pic->pic_id;
-    entry->frame_num = pic->frame_num;
+    entry->frame_num = pic->long_ref ? pic->pic_id : pic->frame_num;
     entry->fields = pic->reference & V4L2_H264_FRAME_REF;
     entry->flags = V4L2_H264_DPB_ENTRY_FLAG_VALID;
     if (entry->fields)

Some useful links:

Detailed Hantro Results:     https://gitlab.freedesktop.org/-/snippets/5189
Detailed RKVDEC Results:     https://gitlab.freedesktop.org/-/snippets/5253
ITU-T H.264 (2016-02) AVCv2: https://www.itu.int/net/itu-t/sigdb/spevideo/VideoForm-s.aspx?val=102002641
Fluster:                     https://github.com/fluendo/fluster
GStreamer:                   https://gitlab.freedesktop.org/gstreamer/gstreamer/
FFMPEG Fork:                 https://github.com/jernejsk/FFmpeg/tree/v4l2-request-hwaccel-4.4
Rockchip MPP:                https://github.com/rockchip-linux/mpp

Alex Bee (1):
  media: rkvdec-h264: Don't hardcode SPS/PPS parameters

Jonas Karlman (5):
  media: rkvdec: h264: Fix reference frame_num wrap for second field
  media: rkvdec: Ensure decoded resolution fit coded resolution
  media: rkvdec: h264: Validate and use pic width and height in mbs
  media: rkvdec: h264: Fix bit depth wrap in pps packet
  media: hantro: h264: Make dpb entry management more robust

Nicolas Dufresne (17):
  media: h264: Increase reference lists size to 32
  media: doc: Document dual use of H.264 pic_num/frame_num
  media: h264: Avoid wrapping long_term_frame_idx
  media: h264: Store current picture fields
  media: h264: Store all fields into the unordered list
  media: v4l2: Trace calculated p/b0/b1 initial reflist
  media: h264: Sort p/b reflist using frame_num
  media: v4l2: Reorder field reflist
  media: v4l2-mem2mem: Fix typo in trace message
  media: v4l2-mem2mem: Trace on implicit un-hold
  media: rkvdec: Stop overclocking the decoder
  media: rkvdec: h264: Fix dpb_valid implementation
  media: rkvdec: Enable capture buffer holding for H264
  media: rkvdec-h264: Add field decoding support
  media: hantro: Enable HOLD_CAPTURE_BUF for H.264
  media: hantro: Stop using H.264 parameter pic_num
  media: hantro: Add H.264 field decoding support

Sebastian Fricke (1):
  media: videobuf2-v4l2: Warn on holding buffers without support

 .../media/v4l/ext-ctrls-codec-stateless.rst   |  10 +-
 .../media/common/videobuf2/videobuf2-v4l2.c   |   7 +-
 drivers/media/v4l2-core/v4l2-h264.c           | 238 +++++++++++++++---
 drivers/media/v4l2-core/v4l2-mem2mem.c        |   3 +-
 drivers/staging/media/hantro/hantro_h264.c    | 119 +++++++--
 drivers/staging/media/hantro/hantro_hw.h      |   7 +-
 drivers/staging/media/hantro/hantro_v4l2.c    |  25 ++
 drivers/staging/media/rkvdec/rkvdec-h264.c    | 104 ++++----
 drivers/staging/media/rkvdec/rkvdec.c         |  22 +-
 drivers/staging/media/rkvdec/rkvdec.h         |   1 +
 include/media/v4l2-h264.h                     |  20 +-
 11 files changed, 431 insertions(+), 125 deletions(-)

base-commit: 51d86122ff02ac2ceef5c0a1cf28f0b5ed580ddd
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2022-03-31 18:25 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 19:59 [PATCH v1 00/24] H.264 Field Decoding Support for Frame-based Decoders Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 01/24] media: h264: Increase reference lists size to 32 Nicolas Dufresne
2022-03-29  8:25   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 02/24] media: doc: Document dual use of H.264 pic_num/frame_num Nicolas Dufresne
2022-03-29  8:32   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 03/24] media: h264: Avoid wrapping long_term_frame_idx Nicolas Dufresne
2022-03-29  8:35   ` Sebastian Fricke
2022-03-31 16:28     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 04/24] media: h264: Store current picture fields Nicolas Dufresne
2022-03-29  9:07   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 05/24] media: h264: Store all fields into the unordered list Nicolas Dufresne
2022-03-29 12:57   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 06/24] media: v4l2: Trace calculated p/b0/b1 initial reflist Nicolas Dufresne
2022-03-29 15:08   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 07/24] media: h264: Sort p/b reflist using frame_num Nicolas Dufresne
2022-03-29 13:34   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 08/24] media: v4l2: Reorder field reflist Nicolas Dufresne
2022-03-29 13:54   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 09/24] media: v4l2-mem2mem: Fix typo in trace message Nicolas Dufresne
2022-03-29 13:57   ` Sebastian Fricke
2022-03-30 14:57     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 10/24] media: v4l2-mem2mem: Trace on implicit un-hold Nicolas Dufresne
2022-03-29 13:58   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 11/24] media: videobuf2-v4l2: Warn on holding buffers without support Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 12/24] media: rkvdec: Stop overclocking the decoder Nicolas Dufresne
2022-03-29 15:15   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 13/24] media: rkvdec: h264: Fix reference frame_num wrap for second field Nicolas Dufresne
2022-03-29 15:17   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 14/24] media: rkvdec: h264: Fix dpb_valid implementation Nicolas Dufresne
2022-03-29 15:27   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 15/24] media: rkvdec: Enable capture buffer holding for H264 Nicolas Dufresne
2022-03-29 15:34   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 16/24] media: rkvdec: Ensure decoded resolution fit coded resolution Nicolas Dufresne
2022-03-29 15:39   ` Sebastian Fricke
2022-03-30  9:06     ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 17/24] media: rkvdec: h264: Validate and use pic width and height in mbs Nicolas Dufresne
2022-03-30  6:48   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 18/24] media: rkvdec: h264: Fix bit depth wrap in pps packet Nicolas Dufresne
2022-03-30  6:59   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 19/24] media: rkvdec-h264: Add field decoding support Nicolas Dufresne
2022-03-29  8:13   ` Dan Carpenter
2022-03-29 20:54     ` Nicolas Dufresne
2022-03-30  5:15       ` Dan Carpenter
2022-03-30 13:39         ` Nicolas Dufresne
2022-03-30 15:16           ` Dan Carpenter
2022-03-31 13:40             ` Nicolas Dufresne
2022-03-30  7:10   ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 20/24] media: hantro: Enable HOLD_CAPTURE_BUF for H.264 Nicolas Dufresne
2022-03-30  7:36   ` Sebastian Fricke
2022-03-31 18:25     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 21/24] media: hantro: Stop using H.264 parameter pic_num Nicolas Dufresne
2022-03-30  7:42   ` Sebastian Fricke
2022-03-30 15:08     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 22/24] media: hantro: h264: Make dpb entry management more robust Nicolas Dufresne
2022-03-30  7:59   ` Sebastian Fricke
2022-03-30 15:15     ` Nicolas Dufresne
2022-03-30 23:43       ` Ezequiel Garcia
2022-03-31  6:54         ` Sebastian Fricke
2022-03-28 19:59 ` [PATCH v1 23/24] media: hantro: Add H.264 field decoding support Nicolas Dufresne
2022-03-30  9:03   ` Sebastian Fricke
2022-03-30 15:25     ` Nicolas Dufresne
2022-03-28 19:59 ` [PATCH v1 24/24] media: rkvdec-h264: Don't hardcode SPS/PPS parameters Nicolas Dufresne
2022-03-29  7:22   ` Sebastian Fricke
2022-03-30 15:27     ` Nicolas Dufresne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).