diff mbox series

[FFmpeg-devel] Support for Frame Duplication (Doubling/Tripling) by FFMPEG's HEVC Decoder by parsing the picture_struct SEI value(Requirement:http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html)

Message ID MA1PR01MB386595B74D97F0AE73690B90C7390@MA1PR01MB3865.INDPRD01.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel] Support for Frame Duplication (Doubling/Tripling) by FFMPEG's HEVC Decoder by parsing the picture_struct SEI value(Requirement:http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html)
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Praveen Kumar Jan. 9, 2020, 10:09 a.m. UTC
Hi,

Re-sending the patch after incorporating the review comments over the previous patch sent yesterday.

This patch has the implementation for supporting frame duplication (doubling/ tripling) by FFmpeg's HEVC decoder based on the picture_structre SEI value present in the encoded video.
picture_structure value of 7 implies doubling and 8 implies tripling. The value of picture_structure is set while encoding.

This addresses the requirement mentioned in the thread http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html

Thanks & Regards,
Praveen
From a118cb7b050a29ef6ca6724e44d82c8c519e9a05 Mon Sep 17 00:00:00 2001
From: Praveen Karadugattu <praveenkumar@outlook.com>
Date: Thu, 9 Jan 2020 15:23:41 +0530
Subject: [PATCH] Support for Frame Duplication (Doubling/Tripling) by FFMPEG's
 HEVC Decoder by parsing the picture_struct SEI
 value(Requirement:http://ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245521.html)

---
 libavcodec/hevc_parser.c | 8 ++++++++
 libavcodec/hevc_sei.c    | 6 ++++++
 libavcodec/hevc_sei.h    | 5 +++++
 3 files changed, 19 insertions(+)

Comments

Kieran Kunhya Jan. 9, 2020, 1:16 p.m. UTC | #1
On Thu, 9 Jan 2020 at 10:09, Praveen Kumar <praveenkumar@outlook.com> wrote:

> Hi,
>
> Re-sending the patch after incorporating the review comments over the
> previous patch sent yesterday.
>

Hi,

Leave ticks_per_frame alone. I don't see why you are changing it.

Kieran
diff mbox series

Patch

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index b444b99..ebb683d 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -30,6 +30,7 @@ 
 #include "h2645_parse.h"
 #include "internal.h"
 #include "parser.h"
+#include "mpegutils.h"
 
 #define START_CODE 0x000001 ///< start_code_prefix_one_3bytes
 
@@ -232,6 +233,13 @@  static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf,
         case HEVC_NAL_RADL_R:
         case HEVC_NAL_RASL_N:
         case HEVC_NAL_RASL_R:
+            if (ctx->sei.picture_timing.picture_struct == HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING) {
+                avctx->ticks_per_frame = 2;
+                s->repeat_pict = 3;
+            } else if (ctx->sei.picture_timing.picture_struct == HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING) {
+                avctx->ticks_per_frame = 2;
+                s->repeat_pict = 5;
+            }
             ret = hevc_parse_slice_header(s, nal, avctx);
             if (ret)
                 return ret;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 562ce8b..6057069 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -144,6 +144,12 @@  static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb, const HEVCPa
         } else if (pic_struct == 1 || pic_struct == 9 || pic_struct == 11) {
             av_log(logctx, AV_LOG_DEBUG, "TOP Field\n");
             h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD;
+        } else if (pic_struct == 7) {
+            av_log(logctx, AV_LOG_DEBUG, "Frame/Field Doubling\n");
+            h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING;
+        } else if (pic_struct == 8) {
+            av_log(logctx, AV_LOG_DEBUG, "Frame/Field Tripling\n");
+            h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING;
         }
         get_bits(gb, 2);                   // source_scan_type
         get_bits(gb, 1);                   // duplicate_flag
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
index 2769d41..a44ccca 100644
--- a/libavcodec/hevc_sei.h
+++ b/libavcodec/hevc_sei.h
@@ -59,6 +59,11 @@  typedef enum {
     HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO                   = 165,
 } HEVC_SEI_Type;
 
+typedef enum {
+        HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING = 7,
+        HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING = 8
+} HEVC_SEI_PicStructType;
+
 typedef struct HEVCSEIPictureHash {
     uint8_t       md5[3][16];
     uint8_t is_md5;