[FFmpeg-devel] [PATCH] libavformat: avidec depends on dv for avpriv_dv_produce_packet

2021-01-25 Thread Peter Ross
---
 libavformat/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3a8fbcbe5f..c4ce6ceb9b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -120,7 +120,7 @@ OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
 OBJS-$(CONFIG_AST_MUXER) += ast.o astenc.o
 OBJS-$(CONFIG_AU_DEMUXER)+= au.o pcm.o
 OBJS-$(CONFIG_AU_MUXER)  += au.o rawenc.o
-OBJS-$(CONFIG_AVI_DEMUXER)   += avidec.o
+OBJS-$(CONFIG_AVI_DEMUXER)   += avidec.o dv.o
 OBJS-$(CONFIG_AVI_MUXER) += avienc.o mpegtsenc.o avlanguage.o 
rawutils.o
 OBJS-$(CONFIG_AVM2_MUXER)+= swfenc.o swf.o
 OBJS-$(CONFIG_AVR_DEMUXER)   += avr.o pcm.o
-- 
2.29.2

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] EXT-X-PROGRAM-DATE-TIME value drifts behind the actual time on the start of the corresponding segment video

2021-01-25 Thread Vignesh Ravichandran
Friendly ping. Would greatly appreciate some input on this.

Thanks,
Vignesh

On Fri, Jan 22, 2021 at 3:35 PM Vignesh Ravichandran <
vignesh.ravichandra...@gmail.com> wrote:

> I am trying to create a video by stitching multiple HLS segments  (.ts
> files)  together based on a start time and end time.  Basically, create a
> video of a particular timeline in the HLS stream.
>
> My setup has a camera pointing to a monitor that displays the system clock
> (The camera control and the ffmpeg command run, is on the same system).
> The frame rate of the camera is not constant but is capped at 25 FPS. The
> frames captured from the camera are passed on to the following ffmpeg
> command:
> ```
> /usr/bin/ffmpeg -vaapi_device /dev/dri/renderD128 -y -v 9 -loglevel 99 -f
> rawvideo -vcodec rawvideo -s 1920x1200 -pix_fmt uyvy422 -i - -an -r 25
> -vcodec h264_vaapi -vf format=nv12,hwupload -force_key_frames
> expr:gte(t,n_forced*1) -f hls -hls_list_size 10080 -hls_time 10 -hls_flags
> delete_segments -hls_flags second_level_segment_index -hls_flags
> +append_list+discont_start+program_date_time -strftime 1 -strftime_mkdir 1
> -hls_segment_filename %Y/%m/%d/%%04d.ts playlist.m3u8
> ```
>
> I parse the playlist file created and then pick up a set of .ts files that
> lie between the given start and end time. This is done by comparing the
> “#EXT-X-PROGRAM-DATE-TIME” value of each file in the playlist. Then, I
> stitch these files together and trim to produce the final output video file.
>
> Problem Encountered:
> I noticed that the “#EXT-X-PROGRAM-DATE-TIME” value in the playlist file
> for most segments and the system time shown in the start (00:00:00) of the
> corresponding segment video is different. The “#EXT-X-PROGRAM-DATE-TIME” is
> behind. For example, for below entry:
> ```
> #EXTINF:10.00,
> #EXT-X-PROGRAM-DATE-TIME:2021-01-21T23:17:05.000+1100
> 2021/01/21/0085.ts
> ```
> the value shown on the system clock in the video is
> "2021-01-21T23:18:12.000+1100" which is more than a minute ahead.
> This causes the final video created to contain incorrect timeline from the
> stream.
>
> My observation and conclusion:
> Since the FPS of the camera is not constant and can vary between 0 to 25,
> ffmpeg would have to duplicate frames when the input FPS drops below 25.
> But I don’t see any mention of this happening in the logs. So I think
> ffmpeg is filling in the current segment with frames outside the segment
> duration i.e., with frames which are supposed to be in the next segment.
> And the experiment mentioned above verifies it.
>
> Looking at the code, the “do_video_out” function in “ffmpeg.c” file has
> logic to duplicate frames if needed. But not sure why this is not
> happening. Would greatly appreciate some help in debugging and resolving
> this issue. I have also attached the log file from my test here.
>
> Thanks,
> Vignesh
>
>  ffmpeg.log
> 
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 10/10] libavcodec/qsvdec: move unref before get_format

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Qsv decoder needs to call preinit() twice to get NumFrameSuggest
to config init_pool_size. The hw_frame_ctx is released at the
second time calling preinit(). The hw_frame_ctx is AVBufferRef, so
it release the source when the last unref is called. When the old
context is released, the new one is already created, and somehow the device
memory is stil be taken, even if the destory memory function is called.
Moving unref before creating new context can solve this problem.

Signed-off-by Wenbin Chen 
---
 libavcodec/qsvdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index fba7d9cee6..23494c217d 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -179,6 +179,8 @@ static int qsv_decode_preinit(AVCodecContext *avctx, 
QSVContext *q, enum AVPixel
 pix_fmt,/* system memory format obtained from bitstream parser 
*/
 AV_PIX_FMT_NONE };
 
+av_buffer_unref(>frames_ctx.mids_buf);
+av_buffer_unref(>frames_ctx.hw_frames_ctx);
 ret = ff_get_format(avctx, pix_fmts);
 if (ret < 0) {
 q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 09/10] libavcodec/qsvdec: using suggested num to set init_pool_size

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

The init_pool_size is set to be 64 and it is too many.
Use IOSurfQuery to get NumFrameSuggest which is the suggested
number of frame that needed to be allocated when initial the decoder
Considering the hevc_qsv encoder's async is 4 (default)
and max_b_frames is 8 (default) and decoder may followed by VPP,
use NumFrameSuggest + 16 to set init_pool_size.

Sigend-off-by Wenbin Chen 
---
 fftools/ffmpeg_qsv.c |  9 -
 libavcodec/qsvdec.c  | 28 +++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 960c88b69d..3862dc1e7d 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -74,6 +74,7 @@ int qsv_init(AVCodecContext *s)
 InputStream *ist = s->opaque;
 AVHWFramesContext *frames_ctx;
 AVQSVFramesContext *frames_hwctx;
+int suggest_pool_size;
 int ret;
 
 if (!hw_device_ctx) {
@@ -82,6 +83,12 @@ int qsv_init(AVCodecContext *s)
 return ret;
 }
 
+suggest_pool_size = 0;
+if (ist->hw_frames_ctx) {
+frames_ctx = (AVHWFramesContext *)ist->hw_frames_ctx->data;
+suggest_pool_size = frames_ctx->initial_pool_size;
+}
+
 av_buffer_unref(>hw_frames_ctx);
 ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx);
 if (!ist->hw_frames_ctx)
@@ -94,7 +101,7 @@ int qsv_init(AVCodecContext *s)
 frames_ctx->height= FFALIGN(s->coded_height, 32);
 frames_ctx->format= AV_PIX_FMT_QSV;
 frames_ctx->sw_format = s->sw_pix_fmt;
-frames_ctx->initial_pool_size = 64 + s->extra_hw_frames;
+frames_ctx->initial_pool_size = suggest_pool_size + 16 + 
s->extra_hw_frames;
 frames_hwctx->frame_type  = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET;
 
 ret = av_hwframe_ctx_init(ist->hw_frames_ctx);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 5cb49cfb4a..fba7d9cee6 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -720,6 +720,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 AVFrame *frame, int *got_frame, AVPacket *pkt)
 {
 int ret;
+int first_init;
 mfxVideoParam param = { 0 };
 enum AVPixelFormat pix_fmt = AV_PIX_FMT_NV12;
 
@@ -738,12 +739,20 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 if (!avctx->coded_height)
 avctx->coded_height = 720;
 
+first_init = 0;
+if (!q->session)
+first_init = 1;
+
 ret = qsv_decode_header(avctx, q, pkt, pix_fmt, );
 
 if (ret >= 0 && (q->orig_pix_fmt != 
ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC) ||
 avctx->coded_width  != param.mfx.FrameInfo.Width ||
-avctx->coded_height != param.mfx.FrameInfo.Height)) {
+avctx->coded_height != param.mfx.FrameInfo.Height ||
+first_init == 1)) {
 AVPacket zero_pkt = {0};
+mfxFrameAllocRequest request;
+AVHWFramesContext *hw_frames_ctx;
+memset(, 0, sizeof(request));
 
 if (q->buffered_count) {
 q->reinit_flag = 1;
@@ -758,6 +767,23 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 avctx->coded_width  = param.mfx.FrameInfo.Width;
 avctx->coded_height = param.mfx.FrameInfo.Height;
 
+if (first_init == 0) {
+hw_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
+hw_frames_ctx->initial_pool_size = 0;
+ret = qsv_decode_preinit(avctx, q, pix_fmt, );
+if (ret < 0)
+goto reinit_fail;
+}
+
+ret = MFXVideoDECODE_QueryIOSurf(q->session, , );
+if (ret < 0)
+return ff_qsv_print_error(avctx, ret, "Error querying IO surface");
+
+if (avctx->hw_frames_ctx) {
+hw_frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
+hw_frames_ctx->initial_pool_size = request.NumFrameSuggested;
+}
+
 ret = qsv_decode_preinit(avctx, q, pix_fmt, );
 if (ret < 0)
 goto reinit_fail;
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 08/10] libavcodec/qsvenc: add horizontal intra refresh and refresh cycle dist

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Add an new intra refresh type: "horizontal", and an new param
ref_cycle_dist. This param specify the distance between the
beginnings of the intra-refresh cycles in frames.

Signed-off-by: Wenbin Chen 
---
 libavcodec/qsvenc.c  | 13 +++--
 libavcodec/qsvenc.h  |  1 +
 libavcodec/qsvenc_h264.c |  5 -
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 4b345aca0a..d16f1094c8 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -217,8 +217,10 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 
 #if QSV_HAVE_CO2
 av_log(avctx, AV_LOG_VERBOSE,
-   "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: 
%"PRIu16"; IntRefQPDelta: %"PRId16"\n",
-   print_threestate(co->RecoveryPointSEI), co2->IntRefType, 
co2->IntRefCycleSize, co2->IntRefQPDelta);
+   "RecoveryPointSEI: %s IntRefType: %"PRIu16"; IntRefCycleSize: 
%"PRIu16
+   "; IntRefQPDelta: %"PRId16"; IntRefCycleDist: %"PRId16"\n",
+   print_threestate(co->RecoveryPointSEI), co2->IntRefType, 
co2->IntRefCycleSize,
+   co2->IntRefQPDelta, co3->IntRefCycleDist);
 
 av_log(avctx, AV_LOG_VERBOSE, "MaxFrameSize: %d; ", co2->MaxFrameSize);
 #if QSV_HAVE_MAX_SLICE_SIZE
@@ -822,6 +824,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(avctx, AV_LOG_WARNING, "Please set max_b_frames(-bf) to 0 
to enable P-pyramid\n");
 }
 
+#if QSV_VERSION_ATLEAST(1, 16)
+if (avctx->codec_id == AV_CODEC_ID_H264) {
+if (q->int_ref_cycle_dist)
+q->extco3.IntRefCycleDist = q->int_ref_cycle_dist;
+}
+#endif
+
 if (avctx->codec_id == AV_CODEC_ID_HEVC) {
 #if QSV_VERSION_ATLEAST(1, 26)
 q->extco3.TransformSkip  = q->transform_skip ? MFX_CODINGOPTION_ON 
: MFX_CODINGOPTION_OFF;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index d1de914724..99befefde1 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -192,6 +192,7 @@ typedef struct QSVEncContext {
 int int_ref_type;
 int int_ref_cycle_size;
 int int_ref_qp_delta;
+int int_ref_cycle_dist;
 int recovery_point_sei;
 
 int repeat_pps;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index ddafc45ec3..47583621b4 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -129,10 +129,13 @@ static const AVOption options[] = {
 { "int_ref_type", "Intra refresh type",
  OFFSET(qsv.int_ref_type),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 
UINT16_MAX, VE, "int_ref_type" },
 { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, 
"int_ref_type" },
 { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, 
"int_ref_type" },
+{ "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, 
"int_ref_type" },
 { "int_ref_cycle_size", "Number of frames in the intra refresh cycle", 
  OFFSET(qsv.int_ref_cycle_size),  AV_OPT_TYPE_INT, { .i64 = -1 },  
 -1, UINT16_MAX, VE },
 { "int_ref_qp_delta",   "QP difference for the refresh MBs",   
  OFFSET(qsv.int_ref_qp_delta),AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, 
INT16_MIN,  INT16_MAX, VE },
 { "recovery_point_sei", "Insert recovery point SEI messages",  
  OFFSET(qsv.recovery_point_sei),  AV_OPT_TYPE_INT, { .i64 = -1 },  
 -1,  1, VE },
-
+#if QSV_VERSION_ATLEAST(1, 16)
+{ "int_ref_cycle_dist",   "Distance between the beginnings of the 
intra-refresh cycles in frames",  OFFSET(qsv.int_ref_cycle_dist),  
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX, VE },
+#endif
 { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = 
MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" },
 { "unknown" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN 
 }, INT_MIN, INT_MAX, VE, "profile" },
 { "baseline", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
MFX_PROFILE_AVC_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 06/10] libavcodec/qsvenc.c: add ROI support to qsv encoder

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Use the mfxEncoderCtrl parameter to enable ROI. Get side data 
"AVRegionOfInterest"
from filter "addroi" and use it to configure "mfxExtEncoderROI" which is
the MediaSDK's ROI configuration.
It is the first time to use encoderCtrl feature in ffmpeg-qsv,
so add allocate and free process as well.

Sigend-off-by: Wenbin Chen 
---
 libavcodec/qsv_internal.h |  3 ++
 libavcodec/qsvenc.c   | 74 +++
 2 files changed, 77 insertions(+)

diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index aa3da97c99..d846a2741a 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -51,6 +51,9 @@
 #define ASYNC_DEPTH_DEFAULT 4   // internal parallelism
 
 #define QSV_MAX_ENC_PAYLOAD 2   // # of mfxEncodeCtrl payloads supported
+#define QSV_MAX_ENC_EXTPARAM 2
+
+#define QSV_MAX_ROI_NUM 256
 
 #define QSV_PAYLOAD_SIZE 1024
 
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index f2fcd09ae0..addc61bf89 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1291,6 +1291,13 @@ static void clear_unused_frames(QSVEncContext *q)
 QSVFrame *cur = q->work_frames;
 while (cur) {
 if (cur->used && !cur->surface.Data.Locked) {
+
+for (int i = 0; i < cur->enc_ctrl.NumExtParam; i++) {
+if (cur->enc_ctrl.ExtParam[i])
+av_freep(&(cur->enc_ctrl.ExtParam[i]));
+}
+cur->enc_ctrl.NumExtParam = 0;
+
 free_encoder_ctrl_payloads(>enc_ctrl);
 if (cur->frame->format == AV_PIX_FMT_QSV) {
 av_frame_unref(cur->frame);
@@ -1333,6 +1340,12 @@ static int get_free_frame(QSVEncContext *q, QSVFrame **f)
 av_freep();
 return AVERROR(ENOMEM);
 }
+frame->enc_ctrl.ExtParam = av_mallocz(sizeof(mfxExtBuffer*) * 
QSV_MAX_ENC_EXTPARAM);
+if (!frame->enc_ctrl.ExtParam) {
+av_free(frame->enc_ctrl.Payload);
+av_freep();
+return AVERROR(ENOMEM);
+}
 *last = frame;
 
 *f = frame;
@@ -1436,6 +1449,7 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 const AVFrame *frame)
 {
 AVPacket new_pkt = { 0 };
+AVFrameSideData *sd;
 mfxBitstream *bs;
 #if QSV_VERSION_ATLEAST(1, 26)
 mfxExtAVCEncodedFrameInfo *enc_info;
@@ -1446,6 +1460,7 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 mfxSyncPoint *sync = NULL;
 QSVFrame *qsv_frame = NULL;
 mfxEncodeCtrl* enc_ctrl = NULL;
+mfxExtEncoderROI *enc_roi = NULL;
 int ret;
 
 if (frame) {
@@ -1480,6 +1495,8 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 bs->Data  = new_pkt.data;
 bs->MaxLength = new_pkt.size;
 
+enc_info = NULL;
+enc_buf = NULL;
 #if QSV_VERSION_ATLEAST(1, 26)
 if (avctx->codec_id == AV_CODEC_ID_H264) {
 enc_info = av_mallocz(sizeof(*enc_info));
@@ -1502,6 +1519,62 @@ static int encode_frame(AVCodecContext *avctx, 
QSVEncContext *q,
 q->set_encode_ctrl_cb(avctx, frame, _frame->enc_ctrl);
 }
 
+#if QSV_VERSION_ATLEAST(1, 22)
+sd = NULL;
+if (frame) {
+sd = av_frame_get_side_data(frame,
+AV_FRAME_DATA_REGIONS_OF_INTEREST);
+}
+if (sd) {
+AVRegionOfInterest *roi;
+uint32_t roi_size;
+int nb_roi, i;
+
+enc_roi = (mfxExtEncoderROI *)av_mallocz(sizeof(*enc_roi));
+if (!enc_roi) {
+av_packet_unref(_pkt);
+if (bs)
+av_freep(bs);
+if (enc_info)
+av_freep(_info);
+if (enc_buf)
+av_freep(_buf);
+return AVERROR(ENOMEM);
+}
+roi = (AVRegionOfInterest *)sd->data;
+roi_size = roi->self_size;
+av_assert0(roi_size && sd->size % roi_size == 0);
+nb_roi = sd->size / roi_size;
+if (nb_roi > QSV_MAX_ROI_NUM) {
+av_log(avctx, AV_LOG_WARNING, "More ROIs set than "
+"supported by driver (%d > %d).\n",
+nb_roi, QSV_MAX_ROI_NUM);
+nb_roi = QSV_MAX_ROI_NUM;
+}
+enc_roi->Header.BufferId = MFX_EXTBUFF_ENCODER_ROI;
+enc_roi->Header.BufferSz = sizeof(*enc_roi);
+enc_roi->NumROI  = nb_roi;
+enc_roi->ROIMode = MFX_ROI_MODE_QP_DELTA;
+// For overlapping regions, the first in the array takes priority.
+for (i = 0; i < nb_roi; i++) {
+roi = (AVRegionOfInterest*)(sd->data + roi_size * i);
+av_assert0(roi->qoffset.den != 0);
+
+enc_roi->ROI[i].Top = roi->top & 0xfff0;
+enc_roi->ROI[i].Bottom = roi->bottom & 0xfff0;
+enc_roi->ROI[i].Left = (roi->left & 0xfff0) + 0x10;
+enc_roi->ROI[i].Right = (roi->right & 0xfff0) + 0x10;
+enc_roi->ROI[i].DeltaQP =
+roi->qoffset.num * 51 / roi->qoffset.den;
+  

[FFmpeg-devel] [PATCH 07/10] libavocdec/qsvenc_hevc: encode RGB format rawvideo

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Add support for hevc_qsv to input RGB format frame. It will
transform frame to yuv inside MediaSDK instead of using auto
scale. Hevc_qsv supports directly encoding BGRA and X2RGB10Le format.
X2RGB10Le is only supported in VDENC (-low_power 1).
The X2RGB10Le correspond to the A2RGB20 format in MediaSDK, and for
A2RGB10 the two MSBs is A channels while this two bits in X2RGB10Le is
undefined. MediaSDK team is discussing about this, so I leave an interface
here.

Sigend-of-by: Wenbin Chen 
---
 libavcodec/qsv.c | 16 
 libavcodec/qsvenc.c  | 19 +--
 libavcodec/qsvenc_hevc.c |  6 ++
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 6e3154e1a3..7ade53e278 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -196,6 +196,12 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
 enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
 {
 switch (fourcc) {
+#if QSV_VERSION_ATLEAST(1, 9)
+case MFX_FOURCC_A2RGB10: return AV_PIX_FMT_X2RGB10LE;
+#endif
+#if QSV_VERSION_ATLEAST(1, 17)
+case MFX_FOURCC_RGB4: return AV_PIX_FMT_BGRA;
+#endif
 case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
 case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
 case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
@@ -222,6 +228,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t 
*fourcc)
 *fourcc = MFX_FOURCC_P010;
 return AV_PIX_FMT_P010;
 #if CONFIG_VAAPI
+#if QSV_VERSION_ATLEAST(1, 9)
+case AV_PIX_FMT_BGRA:
+*fourcc = MFX_FOURCC_RGB4;
+return AV_PIX_FMT_BGRA;
+#endif
+#if QSV_VERSION_ATLEAST(1, 17)
+case AV_PIX_FMT_X2RGB10LE:
+*fourcc = MFX_FOURCC_A2RGB10;
+return AV_PIX_FMT_X2RGB10LE;
+#endif
 case AV_PIX_FMT_YUV422P:
 case AV_PIX_FMT_YUYV422:
 *fourcc = MFX_FOURCC_YUY2;
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index addc61bf89..4b345aca0a 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -613,6 +613,13 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 brc_param_multiplier   = (FFMAX(FFMAX3(target_bitrate_kbps, 
max_bitrate_kbps, buffer_size_in_kilobytes),
   initial_delay_in_kilobytes) + 0x1) / 
0x1;
 
+#if QSV_VERSION_ATLEAST(1, 9)
+if (sw_format == AV_PIX_FMT_X2RGB10LE && q->low_power != 1) {
+av_log(avctx, AV_LOG_ERROR, "Only VDENC support encoding x2rgb10\n");
+return AVERROR(EINVAL);
+}
+#endif
+
 switch (q->param.mfx.RateControlMethod) {
 case MFX_RATECONTROL_CBR:
 case MFX_RATECONTROL_VBR:
@@ -1422,8 +1429,16 @@ static int submit_frame(QSVEncContext *q, const AVFrame 
*frame,
 qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
 
 qf->surface.Data.PitchLow  = qf->frame->linesize[0];
-qf->surface.Data.Y = qf->frame->data[0];
-qf->surface.Data.UV= qf->frame->data[1];
+if (frame->format == AV_PIX_FMT_X2RGB10LE ||
+frame->format == AV_PIX_FMT_BGRA) {
+qf->surface.Data.B = qf->frame->data[0];
+qf->surface.Data.G = qf->frame->data[0] + 1;
+qf->surface.Data.R = qf->frame->data[0] + 2;
+qf->surface.Data.A = qf->frame->data[0] + 3;
+} else {
+qf->surface.Data.Y = qf->frame->data[0];
+qf->surface.Data.UV= qf->frame->data[1];
+}
 }
 
 qf->surface.Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, 
(AVRational){1, 9});
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 07a7e3b2be..18e110d140 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -289,6 +289,12 @@ AVCodec ff_hevc_qsv_encoder = {
 .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
 AV_PIX_FMT_P010,
 AV_PIX_FMT_QSV,
+#if QSV_VERSION_ATLEAST(1, 17)
+AV_PIX_FMT_BGRA,
+#endif
+#if QSV_VERSION_ATLEAST(1, 9)
+AV_PIX_FMT_X2RGB10LE,
+#endif
 AV_PIX_FMT_NONE },
 .priv_class = ,
 .defaults   = qsv_enc_defaults,
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 05/10] libavcodec/qsvenc: Add transform skip for hevc_qsv

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Add transform skip option for hevc_qsv. Command line option
is "transform_skip". By enabling this option, the
transform_skip_enabled_flag in PPS will be set to 1. This option
is only supported in the platform newer than ICL.

Signed-off-by Wenbin Chen 
---
 libavcodec/qsvenc.c  | 10 --
 libavcodec/qsvenc.h  |  1 +
 libavcodec/qsvenc_hevc.c |  3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index a811d06329..f2fcd09ae0 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -304,7 +304,9 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN);
 
 av_log(avctx, AV_LOG_VERBOSE, "DisableDeblockingIdc: %"PRIu32" \n", 
co2->DisableDeblockingIdc);
-
+#if QSV_VERSION_ATLEAST(1, 26)
+av_log(avctx, AV_LOG_VERBOSE, "TransformSkip: %s \n", 
print_threestate(co3->TransformSkip));
+#endif
 }
 
 static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
@@ -813,10 +815,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
 av_log(avctx, AV_LOG_WARNING, "Please set max_b_frames(-bf) to 0 
to enable P-pyramid\n");
 }
 
+if (avctx->codec_id == AV_CODEC_ID_HEVC) {
+#if QSV_VERSION_ATLEAST(1, 26)
+q->extco3.TransformSkip  = q->transform_skip ? MFX_CODINGOPTION_ON 
: MFX_CODINGOPTION_OFF;
+#endif
 #if QSV_HAVE_GPB
-if (avctx->codec_id == AV_CODEC_ID_HEVC)
 q->extco3.GPB  = q->gpb ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
 #endif
+}
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco3;
 #endif
 }
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 7da6e0a50f..d1de914724 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -197,6 +197,7 @@ typedef struct QSVEncContext {
 int repeat_pps;
 int low_power;
 int gpb;
+int transform_skip;
 
 int a53_cc;
 
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 347f30655e..07a7e3b2be 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -246,6 +246,9 @@ static const AVOption options[] = {
 
 { "tile_cols",  "Number of columns for tiled encoding",   
OFFSET(qsv.tile_cols),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE },
 { "tile_rows",  "Number of rows for tiled encoding",  
OFFSET(qsv.tile_rows),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE },
+#if QSV_VERSION_ATLEAST(1, 26)
+{ "transform_skip", "Turn this option ON to enable transformskip",   
OFFSET(qsv.transform_skip),  AV_OPT_TYPE_INT,{ .i64 = -1},   -1, 1, 
 VE},
+#endif
 
 { NULL },
 };
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 04/10] libavcodec/qsvdec.c: extract frame packing arrangement data

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Use h264_sei to parse SEI data got from MediaSDK. Extract frame
packing arrangement information from SEI data and config AVStereo3D
side data for decoded frame.

Sigend-off-by: Wenbin Chen 
---
 libavcodec/qsv_internal.h |   2 +
 libavcodec/qsvdec.c   | 149 ++
 libavcodec/qsvdec.h   |   6 ++
 3 files changed, 157 insertions(+)

diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 6b2fbbe252..aa3da97c99 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -52,6 +52,8 @@
 
 #define QSV_MAX_ENC_PAYLOAD 2   // # of mfxEncodeCtrl payloads supported
 
+#define QSV_PAYLOAD_SIZE 1024
+
 #define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
 (MFX_VERSION_MAJOR > (MAJOR) || \
  MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index d10f90a0db..5cb49cfb4a 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -36,10 +36,12 @@
 #include "libavutil/pixfmt.h"
 #include "libavutil/time.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/stereo3d.h"
 
 #include "avcodec.h"
 #include "internal.h"
 #include "decode.h"
+#include "get_bits.h"
 #include "qsv.h"
 #include "qsv_internal.h"
 #include "qsvdec.h"
@@ -398,6 +400,147 @@ static QSVFrame *find_frame(QSVContext *q, 
mfxFrameSurface1 *surf)
 return NULL;
 }
 
+static int h264_decode_fpa(H264SEIFramePacking *fpa, AVFrame *frame)
+{
+if (!fpa || !frame) {
+return AVERROR(EINVAL);
+}
+
+if (!fpa->arrangement_cancel_flag &&
+fpa->arrangement_type <= 6 &&
+fpa->content_interpretation_type > 0 &&
+fpa->content_interpretation_type < 3) {
+AVStereo3D *stereo = av_stereo3d_create_side_data(frame);
+if (stereo) {
+switch (fpa->arrangement_type) {
+case 0:
+stereo->type = AV_STEREO3D_CHECKERBOARD;
+break;
+case 1:
+stereo->type = AV_STEREO3D_COLUMNS;
+break;
+case 2:
+stereo->type = AV_STEREO3D_LINES;
+break;
+case 3:
+if (fpa->quincunx_sampling_flag)
+stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+else
+stereo->type = AV_STEREO3D_SIDEBYSIDE;
+break;
+case 4:
+stereo->type = AV_STEREO3D_TOPBOTTOM;
+break;
+case 5:
+stereo->type = AV_STEREO3D_FRAMESEQUENCE;
+if (fpa->current_frame_is_frame0_flag)
+stereo->view = AV_STEREO3D_VIEW_LEFT;
+else
+stereo->view = AV_STEREO3D_VIEW_RIGHT;
+break;
+case 6:
+stereo->type = AV_STEREO3D_2D;
+break;
+}
+
+if (fpa->content_interpretation_type == 2)
+stereo->flags = AV_STEREO3D_FLAG_INVERT;
+}
+}
+return 0;
+}
+
+static int h264_parse_side_data(AVCodecContext *avctx, QSVContext *q, AVFrame 
*frame)
+{
+GetBitContext gb_payload;
+uint8_t *sei_buffer;
+int sei_buffer_index;
+int ret;
+
+/* remove emulation prevention bytes */
+sei_buffer = (uint8_t *)av_mallocz(q->payload.NumBit / 8);
+if (!sei_buffer) {
+av_freep(_buffer);
+return AVERROR(ENOMEM);
+}
+sei_buffer_index = 0;
+for (int i = 0; i < q->payload.NumBit / 8; i++) {
+if (q->payload.Data[i] == 3)
+i++;
+sei_buffer[sei_buffer_index] = q->payload.Data[i];
+sei_buffer_index += 1;
+}
+
+ret = init_get_bits8(_payload, sei_buffer, sei_buffer_index+1);
+if (ret < 0) {
+av_freep(_buffer);
+return ret;
+}
+
+ret = ff_h264_sei_decode(>sei, _payload, >ps, avctx);
+if (ret < 0) {
+av_freep(_buffer);
+return ret;
+}
+
+switch (q->payload.Type) {
+case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
+ret = h264_decode_fpa(>sei.frame_packing, frame);
+break;
+default:
+break;
+}
+
+av_freep(_buffer);
+return ret;
+}
+
+static int extract_frame_side_data(AVCodecContext *avctx, QSVContext *q, 
AVFrame *frame)
+{
+mfxU64 ts;
+mfxStatus sts;
+int ret;
+
+if (q->payload.BufSize == 0) {
+q->payload.Data = av_mallocz(QSV_PAYLOAD_SIZE);
+if (!q->payload.Data) {
+av_freep(>payload.Data);
+return AVERROR(ENOMEM);
+}
+q->payload.BufSize = QSV_PAYLOAD_SIZE;
+}
+
+sts = MFX_ERR_NONE;
+while (sts == MFX_ERR_NONE) {
+
+sts = MFXVideoDECODE_GetPayload(q->session, , >payload);
+
+if (sts == MFX_ERR_NOT_ENOUGH_BUFFER) {
+av_log(avctx, AV_LOG_WARNING, "Space for SEI is not enough. One 
SEI will be skipped\n");
+continue;
+} else if (sts != MFX_ERR_NONE || 

[FFmpeg-devel] [PATCH 03/10] libavcodec/qsvenc: add low latency P-pyramid support for qsv

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

Add low latency P-pyramid support for qsv, and it relates to a new
command line parameter "-p_strategy". To enable this flag, user also
need to set "-bf" to 0. P-strategy has two modes "1-simple" and "2-pyramid".
The details of the two models refer to
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#PRefType

Signed-off-by Wenbin Chen 
---
 libavcodec/qsvenc.c | 30 ++
 libavcodec/qsvenc.h |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2434feb660..a811d06329 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -268,6 +268,14 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 case MFX_B_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid");   break;
 default:av_log(avctx, AV_LOG_VERBOSE, "auto");  break;
 }
+
+av_log(avctx, AV_LOG_VERBOSE, "; PRefType: ");
+switch (co3->PRefType) {
+case MFX_P_REF_DEFAULT: av_log(avctx, AV_LOG_VERBOSE, "default");   break;
+case MFX_P_REF_SIMPLE:  av_log(avctx, AV_LOG_VERBOSE, "simple");break;
+case MFX_P_REF_PYRAMID: av_log(avctx, AV_LOG_VERBOSE, "pyramid");   break;
+default:av_log(avctx, AV_LOG_VERBOSE, "unknown");   break;
+}
 av_log(avctx, AV_LOG_VERBOSE, "\n");
 #endif
 
@@ -783,6 +791,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #if QSV_HAVE_CO3
 q->extco3.Header.BufferId  = MFX_EXTBUFF_CODING_OPTION3;
 q->extco3.Header.BufferSz  = sizeof(q->extco3);
+
+switch (q->p_strategy) {
+case 0:
+q->extco3.PRefType = MFX_P_REF_DEFAULT;
+break;
+case 1:
+q->extco3.PRefType = MFX_P_REF_SIMPLE;
+break;
+case 2:
+q->extco3.PRefType = MFX_P_REF_PYRAMID;
+break;
+default:
+q->extco3.PRefType = MFX_P_REF_DEFAULT;
+av_log(avctx, AV_LOG_WARNING, "invalid p_strategy, set to 
default\n");
+break;
+}
+if ((q->extco3.PRefType == MFX_P_REF_SIMPLE ||
+q->extco3.PRefType == MFX_P_REF_PYRAMID) &&
+avctx->max_b_frames != 0) {
+av_log(avctx, AV_LOG_WARNING, "Please set max_b_frames(-bf) to 0 
to enable P-pyramid\n");
+}
+
 #if QSV_HAVE_GPB
 if (avctx->codec_id == AV_CODEC_ID_HEVC)
 q->extco3.GPB  = q->gpb ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 3720320789..7da6e0a50f 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -95,6 +95,7 @@
 { "extbrc", "Extended bitrate control",   
OFFSET(qsv.extbrc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
 { "adaptive_i", "Adaptive I-frame placement", 
OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
 { "adaptive_b", "Adaptive B-frame placement", 
OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
+{ "p_strategy", "enable P-pyramid 0-default 1-simple 2-pyramid",
OFFSET(qsv.p_strategy), AV_OPT_TYPE_INT,{ .i64 = 0}, 0,2, VE }, 
\
 { "b_strategy", "Strategy to choose between I/P/B-frames", 
OFFSET(qsv.b_strategy),AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
 { "forced_idr", "Forcing I frames as IDR frames", 
OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,  1, VE 
}, \
 { "low_power", "enable low power mode(experimental: many limitations by mfx 
version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 
0}, 0, 1, VE},\
@@ -185,6 +186,7 @@ typedef struct QSVEncContext {
 int adaptive_i;
 int adaptive_b;
 int b_strategy;
+int p_strategy;
 int cavlc;
 
 int int_ref_type;
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 02/10] libavcodec/qsvenc: add DisableDeblockingIdc support for qsv

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

MediaSDK already has a flag to control deblocking (DisableDeblockingIdc). Add 
dblk_idc parameter in ffmpeg to expose this flag to user.

Sigend-off-by: Wenbin Chen 
---
 libavcodec/qsvenc.c | 6 ++
 libavcodec/qsvenc.h | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 0bca4f30e3..2434feb660 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -295,6 +295,8 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 av_log(avctx, AV_LOG_VERBOSE, "FrameRateExtD: %"PRIu32"; FrameRateExtN: 
%"PRIu32" \n",
info->FrameInfo.FrameRateExtD, info->FrameInfo.FrameRateExtN);
 
+av_log(avctx, AV_LOG_VERBOSE, "DisableDeblockingIdc: %"PRIu32" \n", 
co2->DisableDeblockingIdc);
+
 }
 
 static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q)
@@ -710,6 +712,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (q->max_slice_size >= 0)
 q->extco2.MaxSliceSize = q->max_slice_size;
 #endif
+#if QSV_HAVE_DISABLEDEBLOCKIDC
+if(q->dblk_idc >= 0)
+q->extco2.DisableDeblockingIdc = q->dblk_idc;
+#endif
 
 #if QSV_HAVE_TRELLIS
 if (avctx->trellis >= 0)
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 6d305f87dd..3720320789 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -44,6 +44,7 @@
 
 #define QSV_HAVE_TRELLIS QSV_VERSION_ATLEAST(1, 8)
 #define QSV_HAVE_MAX_SLICE_SIZE QSV_VERSION_ATLEAST(1, 9)
+#define QSV_HAVE_DISABLEDEBLOCKIDC QSV_VERSION_ATLEAST(1, 9)
 #define QSV_HAVE_BREF_TYPE  QSV_VERSION_ATLEAST(1, 8)
 
 #define QSV_HAVE_LA QSV_VERSION_ATLEAST(1, 7)
@@ -97,6 +98,7 @@
 { "b_strategy", "Strategy to choose between I/P/B-frames", 
OFFSET(qsv.b_strategy),AV_OPT_TYPE_INT, { .i64 = -1 }, -1,  1, VE 
}, \
 { "forced_idr", "Forcing I frames as IDR frames", 
OFFSET(qsv.forced_idr), AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,  1, VE 
}, \
 { "low_power", "enable low power mode(experimental: many limitations by mfx 
version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 
0}, 0, 1, VE},\
+{ "dblk_idc", "value of DisableDeblockingIdc (default is 0), in range [0,2]",  
 OFFSET(qsv.dblk_idc),   AV_OPT_TYPE_INT,{ .i64 = 0 },   0,  2,  VE},\
 
 extern const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[];
 
@@ -167,6 +169,7 @@ typedef struct QSVEncContext {
 int rdo;
 int max_frame_size;
 int max_slice_size;
+int dblk_idc;
 
 int tile_cols;
 int tile_rows;
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 01/10] libavcodec/qsvenc.c: add max_frame_size support for hevc_qsv

2021-01-25 Thread wenbin . chen
From: Wenbinc-Bin 

The max_frame_size parameter is set only when codec is h264. Now I add hevc in 
that conditional statement.

Signed-off-by: Wenbin Chen 
---
 libavcodec/qsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 566a5c8552..0bca4f30e3 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -691,7 +691,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco;
 
 #if QSV_HAVE_CO2
-if (avctx->codec_id == AV_CODEC_ID_H264) {
+if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_HEVC) {
 if (q->int_ref_type >= 0)
 q->extco2.IntRefType = q->int_ref_type;
 if (q->int_ref_cycle_size >= 0)
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] dnn_backend_openvino.c: remove extra semicolon

2021-01-25 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_openvino.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 9329891c3f..beca256390 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -485,7 +485,7 @@ static DNNReturnType get_output_ov(void *model, const char 
*input_name, int inpu
 if (init_model_ov(ov_model) != DNN_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network 
or inference request\n");
 return DNN_ERROR;
-};
+}
 }
 
 task.done = 0;
@@ -601,7 +601,7 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel 
*model, const char *input_n
 if (init_model_ov(ov_model) != DNN_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network 
or inference request\n");
 return DNN_ERROR;
-};
+}
 }
 
 task.done = 0;
@@ -648,7 +648,7 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel 
*model, const char *i
 if (init_model_ov(ov_model) != DNN_SUCCESS) {
 av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network 
or inference request\n");
 return DNN_ERROR;
-};
+}
 }
 
 task->done = 0;
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/3] dnn: remove type cast which is not necessary

2021-01-25 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/dnn/dnn_backend_native.c | 10 +-
 .../dnn/dnn_backend_native_layer_avgpool.c   |  2 +-
 .../dnn/dnn_backend_native_layer_conv2d.c|  4 ++--
 libavfilter/dnn/dnn_backend_native_layer_dense.c |  2 +-
 .../dnn/dnn_backend_native_layer_depth2space.c   |  2 +-
 .../dnn/dnn_backend_native_layer_mathbinary.c|  2 +-
 .../dnn/dnn_backend_native_layer_mathunary.c |  2 +-
 .../dnn/dnn_backend_native_layer_maximum.c   |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_pad.c   |  2 +-
 libavfilter/dnn/dnn_backend_openvino.c   | 16 
 libavfilter/dnn/dnn_backend_tf.c | 16 
 11 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 1f89ee4110..87f3568cc2 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -50,7 +50,7 @@ static DNNReturnType execute_model_native(const DNNModel 
*model, const char *inp
 
 static DNNReturnType get_input_native(void *model, DNNData *input, const char 
*input_name)
 {
-NativeModel *native_model = (NativeModel *)model;
+NativeModel *native_model = model;
 NativeContext *ctx = _model->ctx;
 
 for (int i = 0; i < native_model->operands_num; ++i) {
@@ -78,7 +78,7 @@ static DNNReturnType get_output_native(void *model, const 
char *input_name, int
const char *output_name, int 
*output_width, int *output_height)
 {
 DNNReturnType ret;
-NativeModel *native_model = (NativeModel *)model;
+NativeModel *native_model = model;
 NativeContext *ctx = _model->ctx;
 AVFrame *in_frame = av_frame_alloc();
 AVFrame *out_frame = NULL;
@@ -269,7 +269,7 @@ static DNNReturnType execute_model_native(const DNNModel 
*model, const char *inp
   const char **output_names, uint32_t 
nb_output, AVFrame *out_frame,
   int do_ioproc)
 {
-NativeModel *native_model = (NativeModel *)model->model;
+NativeModel *native_model = model->model;
 NativeContext *ctx = _model->ctx;
 int32_t layer;
 DNNData input, output;
@@ -382,7 +382,7 @@ static DNNReturnType execute_model_native(const DNNModel 
*model, const char *inp
 DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char 
*input_name, AVFrame *in_frame,
   const char **output_names, uint32_t 
nb_output, AVFrame *out_frame)
 {
-NativeModel *native_model = (NativeModel *)model->model;
+NativeModel *native_model = model->model;
 NativeContext *ctx = _model->ctx;
 
 if (!in_frame) {
@@ -428,7 +428,7 @@ void ff_dnn_free_model_native(DNNModel **model)
 if (*model)
 {
 if ((*model)->model) {
-native_model = (NativeModel *)(*model)->model;
+native_model = (*model)->model;
 if (native_model->layers) {
 for (layer = 0; layer < native_model->layers_num; ++layer){
 if (native_model->layers[layer].type == DLT_CONV2D){
diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c 
b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
index 8164bb45a6..dcfb8c816f 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
@@ -66,7 +66,7 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const 
int32_t *input_ope
 int width = operands[input_operand_index].dims[2];
 int channel = operands[input_operand_index].dims[3];
 const float *input = operands[input_operand_index].data;
-const AvgPoolParams *avgpool_params = (const AvgPoolParams *)parameters;
+const AvgPoolParams *avgpool_params = parameters;
 
 int kernel_strides = avgpool_params->strides;
 int src_linesize = width * channel;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 210db7c77e..b5c2c394ef 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -116,7 +116,7 @@ static void * dnn_execute_layer_conv2d_thread(void 
*threadarg)
 int width = operands[input_operand_index].dims[2];
 int channel = operands[input_operand_index].dims[3];
 const float *input = operands[input_operand_index].data;
-const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(thread_common_param->parameters);
+const ConvolutionalParams *conv_params = thread_common_param->parameters;
 
 int radius = conv_params->kernel_size >> 1;
 int src_linesize = width * conv_params->input_num;
@@ -192,7 +192,7 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_opera
 #endif
 ThreadParam **thread_param = av_malloc_array(thread_num, 
sizeof(*thread_param));
 

[FFmpeg-devel] [PATCH 1/3] tests/dnn: enable unit test dense

2021-01-25 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 tests/dnn/Makefile   | 1 +
 tests/dnn/dnn-layer-dense-test.c | 2 +-
 tests/fate/dnn.mak   | 5 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
index 8afdfab5d3..ef827520de 100644
--- a/tests/dnn/Makefile
+++ b/tests/dnn/Makefile
@@ -1,6 +1,7 @@
 DNNTESTPROGS += dnn-layer-pad
 DNNTESTPROGS += dnn-layer-conv2d
 DNNTESTPROGS += dnn-layer-depth2space
+DNNTESTPROGS += dnn-layer-dense
 DNNTESTPROGS += dnn-layer-mathbinary
 DNNTESTPROGS += dnn-layer-maximum
 DNNTESTPROGS += dnn-layer-mathunary
diff --git a/tests/dnn/dnn-layer-dense-test.c b/tests/dnn/dnn-layer-dense-test.c
index 755d3ebb31..696f7505e5 100644
--- a/tests/dnn/dnn-layer-dense-test.c
+++ b/tests/dnn/dnn-layer-dense-test.c
@@ -59,7 +59,7 @@ static int test(void)
 print(list(output.flatten()))
 */
 
-ConvolutionalParams params;
+DenseParams params;
 DnnOperand operands[2];
 int32_t input_indexes[1];
 float input[1*5*6*3] = {
diff --git a/tests/fate/dnn.mak b/tests/fate/dnn.mak
index c5e458708e..ef07ee45f8 100644
--- a/tests/fate/dnn.mak
+++ b/tests/fate/dnn.mak
@@ -8,6 +8,11 @@ fate-dnn-layer-conv2d: 
$(DNNTESTSDIR)/dnn-layer-conv2d-test$(EXESUF)
 fate-dnn-layer-conv2d: CMD = run $(DNNTESTSDIR)/dnn-layer-conv2d-test$(EXESUF)
 fate-dnn-layer-conv2d: CMP = null
 
+FATE_DNN += fate-dnn-layer-dense
+fate-dnn-layer-dense: $(DNNTESTSDIR)/dnn-layer-dense-test$(EXESUF)
+fate-dnn-layer-dense: CMD = run $(DNNTESTSDIR)/dnn-layer-dense-test$(EXESUF)
+fate-dnn-layer-dense: CMP = null
+
 FATE_DNN += fate-dnn-layer-depth2space
 fate-dnn-layer-depth2space: $(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
 fate-dnn-layer-depth2space: CMD = run 
$(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashdec: Avoid segfault when URL template is unexpectedly missing

2021-01-25 Thread Steven Liu
sfan5  于2021年1月25日周一 下午11:25写道:
>
> This isn't supposed to happen, but unfinished support for non-templated
> manifests and lack of e.g. presentationTimeOffset handling can provoke
> such a situation even with well-formed input.
> ---
>   libavformat/dashdec.c | 10 +-
>   1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index dc56e89f11..c4e6c3da16 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -1625,8 +1625,15 @@ static struct fragment
> *get_current_fragment(struct representation *pls)
>   }
>   }
>   if (seg) {
> -char *tmpfilename= av_mallocz(c->max_url_size);
> +char *tmpfilename;
> +if (!pls->url_template) {
> +av_log(pls->parent, AV_LOG_ERROR, "Cannot get fragment,
> missing template URL\n");
> +av_free(seg);
> +return NULL;
> +}
> +tmpfilename = av_mallocz(c->max_url_size);
>   if (!tmpfilename) {
> +av_free(seg);
>   return NULL;
>   }
>   ff_dash_fill_tmpl_params(tmpfilename, c->max_url_size,
> pls->url_template, 0, pls->cur_seq_no, 0,
> get_segment_start_time_based_on_timeline(pls, pls->cur_seq_no));
> @@ -1637,6 +1644,7 @@ static struct fragment
> *get_current_fragment(struct representation *pls)
>   if (!seg->url) {
>   av_log(pls->parent, AV_LOG_ERROR, "Cannot resolve
> template url '%s'\n", pls->url_template);
>   av_free(tmpfilename);
> +av_free(seg);
>   return NULL;
>   }
>   }
> --
> 2.30.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

LGTM

Thanks
Steven
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avformat/dashdec: Fix missing NULL check

2021-01-25 Thread Steven Liu
sfan5  于2021年1月25日周一 下午11:25写道:
>
> ---
>   libavformat/dashdec.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 693fc7372b..dc56e89f11 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -161,7 +161,7 @@ typedef struct DASHContext {
>   static int ishttp(char *url)
>   {
>   const char *proto_name = avio_find_protocol_name(url);
> -return av_strstart(proto_name, "http", NULL);
> +return proto_name && av_strstart(proto_name, "http", NULL);
>   }
>static int aligned(int val)
> --
> 2.30.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

LGTM

Thanks
Steven
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread James Almer

On 1/25/2021 8:20 PM, Nicolas George wrote:

Mark Thompson (12021-01-25):

Merging the libraries (in source form, orthogonal to merging the
binaries) only makes sense if we are going to continue using the
libavformat internals, and that is exactly the thing we are trying to
get rid of.

"We"?

It seems to me that many people here have an agenda about libavdevice
while they have no reason to.


If by agenda you mean trying to solve the hacky state of the library, 
then sure. Otherwise, please get rid of any potential slanderous 
thoughts you may be have about it, because it sounds like you may be 
having trouble distinguishing expressed personal opinions with actual 
unrelated coding efforts.


So again, focus on working with people to find a solution and a future 
for the library, in whatever form we ultimately decide is best, instead 
of attacking them for not sharing your opinions. So far, I've seen 
plenty of the latter and nothing of the former.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-25 Thread Marton Balint



On Mon, 25 Jan 2021, emco...@ffastrans.com wrote:


Am 2021-01-20 16:41, schrieb Tomas Härdin:

ons 2021-01-20 klockan 00:27 +0100 skrev Marton Balint:


On Tue, 19 Jan 2021, Tobias Rapp wrote:

> On 18.01.2021 23:53, Tomas Härdin wrote:
> > lör 2021-01-16 klockan 08:43 +0800 skrev lance.lmw...@gmail.com:
> > > On Fri, Jan 15, 2021 at 09:43:58PM +0100, Marton Balint wrote:
> > > > On Fri, 15 Jan 2021, Tomas Härdin wrote:
> > > > > Again, why? If you have a company that maintains a fork of 

FFmpeg then
> > > > > compile that info in here instead. Compare with FFmbc which 

always puts

> > > > > "FFmbc" as CompanyName.
> > > >
> > > > And how can a product based on libavformat set the company name, 

product
> > > > name and product version? It seems a valid use case for me that 

these are

> > > > overridable. Also note that this product version is only the "user
> friendly"
> > > > version string, for the numeric version still LIBAVFORMAT_VERSION 

values

> are
> > > > used.
> > >
> > > Yes, my use case is the product is using libavformat as library, so 

it's

> > > prefer to have way to override these information as requirements.
> >
> > What I'm worried about here is that we're going to get files which
> > claim to have been written by something other than libavformat. I've
> > had situations like this before, and it is a source of headache. For
> > example, if mxfenc writes some field incorrectly then this might cause
> > us to hack mxfdec to accept that field instead of fixing mxfenc.
>
> I agree that especially for the MXF format with its flexible structure
> it is more relevant to know the muxing library rather than the hosting
> application. Have seen MXF output files of other commercial products
> that also contain library identifiers like "libMXF" or "MXFtk" here.
>
> Other formats in FFmpeg use the "encoder" metadata key for embedding
> library information in the output file. A quick test with AVI output
> shows that this metadata is generated internally and cannot be
> overridden on the command-line.

If your concern is being able to identify our mxf muxer, then why not 
use

the Platform metadata item for this?

"Human readable name of the toolkit and operating system used. Best
practice is to use the form “SDK name (OS name)”"


Uhm guys, it is very bad practice: if you just insert a different 
manufacturer name then you just cheat. SMPTE 377 has a clear statement 
about what goes to the identification, you cannot just write the infos 
from a different program there.


Libavformat is a library/SDK, not an application. For most identification 
fields SMPTE 377 talks about the application which created the file, which 
can be anything using libavformat libraries. Feel free to quote if you 
have a more exact specification.




What you can do instead is to push both identifications, the old one and 
the one from the current program into the identification array, this way 
the processing chain can be reconstructed. Unforutnately i have never 
seen anyone doing this besides Opencube.


Also, note that broadcasters currently are using the identification 
string, looking for "ffmpeg" in order to sort out non compatible XDCAMHD
mxf: ffmpeg does not write some mandatory metadata fields as mentioned 
here: https://trac.ffmpeg.org/ticket/5097 this leads to sony devices not 
accepting the ffmpeg mxf container - which again leads to ffmpeg mxf 
wrapper for XDCAMHD not being accepted by our public broadcaster.


Maybe they should post patches instead of having workarounds? And I 
explained, libavformat MXF muxer will still be identifiable, but the 
proper field will be used for identifying the SDK used, not 
Company/Product but Toolkit/Platform.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Nicolas George
Mark Thompson (12021-01-25):
> Merging the libraries (in source form, orthogonal to merging the
> binaries) only makes sense if we are going to continue using the
> libavformat internals, and that is exactly the thing we are trying to
> get rid of.

"We"?

It seems to me that many people here have an agenda about libavdevice
while they have no reason to.

> If we replace the libavdevice API with a proper one oriented towards
> devices rather than being hacked on to the libavformat API then we
> actively don't want that merger.
> 
> So, what do people actually want here?  The situation as I see it is
> (please correct me on anything you feel is in error here):
> 
> * The features which libavdevice offers are useful to a lot of people.

Thank you for acknowledging it.

> * Many of those are using it via the ffmpeg utility, but not all.
> * The libavdevice API is the libavformat API because it was originally
> split out from libavformat, and it has the nice property that devices
> and files end up being interchangable in some contexts.
> * The libavdevice API, being the libavformat API for files, is not
> particularly well-suited in other contexts, because devices may not
> have the same properties as files.
> * Some odd things like the completely-unused capabilities API and the
> almost-never-used message API are hacked on top of that to try to
> avoid some libavformat issues, but are not actually useful to anyone
> (hence the lack of use).
> * To implement devices as AVInputFormat/AVOutputFormat instances,
> libavdevice currently needs access to the internals of libavformat.
> * Many developers want to get rid of that dependency on libavformat
> internals, because it creates a corresponding ugliness on the
> libavformat side which has to leave those parts exposed in an
> ABI-constrained way.
> 
> What might we do about this:
> 
> * Delete libavdevice, with a statement that its capabilities are
> outside the scope of ffmpeg.  Obviously this isn't sensible, the
> ffmpeg utility would then need to depend on some external library to
> offer the same features it does now.
> * Merge libavdevice into the ffmpeg utility.  Since it is the primary
> user this would neatly sidestep the previous objection, but now
> external users are in the same boat so again unacceptable.

One of the main reasons the fork failed while original ffmpeg kept going
was that while ffmpeg has a policy of being useful, the fork had an
unspoken rule about code purity that lead to removing many useful
features. IIRC, Anton was one of the most vocal proponent of this
harmful unspoken rule.

I find worrisome to see the same attitude start to appear here. We need
to be very careful.

Also, if the project actually starts removing features for purity, like
some people discussed here, I'll stop bothering about this dying
project.

> * Merge libavdevice into libavformat.  This works to eliminate the
> dependency problem, but it only really makes sense if we accept that
> libavdevice is finished and will never want new API which isn't
> repurposed libavformat.
> * Make a new libavdevice-specific API and switch to that.  The
> eliminates the dependency problem, but there is a nasty transition
> period and it would break the interchangability of the two libraries.
> It also would be the most work, but leave libavdevice in the best
> state for doing more things with in future.

One of the important features of libavdevice, as you mentioned earlier,
is that devices can be a drop-in replacement for demuxers and muxers. An
application that is not designed for devices can be made to use them,
and that is immensely convenient. It does not work always, but it work
often enough to be, I repeat, immensely useful.

If a solution does not have this feature, we can just skip it.

> * Nothing.  People will continue to be annoyed about the problems above.

Duh. People often are annoyed at the wrong things, let them be annoyed.
I have had proof in the past that some of the annoyance on this subject
was actually a deep misunderstanding of how linking works.

There is another option:

* Stop imposing ourselves constraints that bring absolutely no benefit.
Having internals is useful for a library because we can change them
without bothering about compatibility: if we change the internals, we
can change all places that use them at the same time, and everything
keeps working.

It is a good hygiene that the fftools are written to use no internals,
because that proves the public API is complete enough to build powerful
tools.

But for the libraries, it makes no sense to have this constraint. What
benefit is there in it? Nobody has been able to answer this question,
because there are none. Libraries should be able to use each other
internals (typical example: sharing header decoding and format-specific
utility functions between lavc and lavf).

> Opinions?
> 
> Personally, I think the right option here is to make a new
> libavdevice-specific API and cut the connection to 

Re: [FFmpeg-devel] [PATCH] avformat/utils: always preserve container dimensions for all streams

2021-01-25 Thread James Almer

On 1/25/2021 7:46 PM, Michael Niedermayer wrote:

On Sun, Jan 24, 2021 at 11:41:13AM -0300, James Almer wrote:

If a decoder is used for probing it may change the dimensions reported by the
demuxer, either by the lowres factor or because of assorted frames reporting
different dimensions, and in a codec copy scenario, the last dimensions
arbitrarily set by it could end up being propagated to the muxer.

Signed-off-by: James Almer 
---
  libavformat/utils.c | 10 ++
  tests/ref/fate/cbs-vp9-vp90-2-05-resize |  2 +-
  tests/ref/fate/redcode-demux|  2 +-
  tests/ref/fate/wtv-demux|  4 ++--
  4 files changed, 10 insertions(+), 8 deletions(-)



breaks:

./ffmpeg -i tickets/2892/MPEG_tbn_test.mov  -c:v copy -c:a copy -vtag mx3n 
-timecode 10:00:00:00 -vframes 3 file.mov
...
[mov @ 0x558785108e00] D-10/IMX must use 720x608 or 720x512 video resolution


So the source mov is faulty and reports a wrong resolution? And trying 
to pass it through instead of letting a decoder change it makes it fail 
to mux because the muxer refuses to create non compliant files.
That means if there's no decoder in the build, you'd get the same result 
as without this patch.


The mere existence of this code here means that letting decoders set the 
resolution in a codec copy scenario is not ideal, as shown by the fact 
one can tell it to make up an arbitrary resolution like it's the case of 
lowres, or it can just pick up one from an arbitrary frame. Hence 
prioritizing what the demuxer reads from the container feels like the 
correct thing to do. But of course, broken files are a thing.


I don't know, maybe a new AVFMT_FLAG_ flag to choose between giving 
priority to what the container reports or what a decoder sets, if any is 
present, could work around this?
Or maybe it's the library user the one that should look at what the 
demuxer read from the container and decide if a parser or decoder should 
give its opinion about it.



Could not write header for output file #0 (incorrect codec parameters ?): 
Invalid argument
Error initializing output stream 0:1 --

[...]


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] libavcodec/ccaption_dec.c: Fixed indentation overwriting text in the cea608 caption decoder.

2021-01-25 Thread Levi Dooley
There was an assumption in the existing code that indentation would not
occur more than once on the same row.
This was a bad assumption. There are examples of 608 streams which call
handle_pac multiple times on the same row with different indentation.
As the code was before this change, the new indentation would overwrite
existing text with spaces.
These changes make indentation skip over columns instead. Text gets cleared
with spaces on handle_edm.
Instead of relying on the null character, trailing spaces are trimmed off
the end of a row.
This is necessary so that a null character doesn't end up between two words.

Signed-off-by: Levi Dooley 

Here's a link to a sample file that will reproduce this issue.
https://snapstream-dev-test-public.s3.us-east-1.amazonaws.com/ffmpeg-caption-issue/cleveland-clip.ts

The issue can be reproduced by running the following command:

> ffmpeg -f lavfi -i "movie=cleveland-clip.ts[out0+subcc]" -map s
> cleveland-clip.ass


I've gone ahead and ran this command both before and after my code changes.
The following output files demonstrate that there are some clear cases of
missing words or sentences in the beforepatch file, and it is entirely
fixed by this patch in the afterpatch file.

Before this patch:
https://snapstream-dev-test-public.s3.us-east-1.amazonaws.com/ffmpeg-caption-issue/cleveland-clip-beforepatch.ass

After this patch:
https://snapstream-dev-test-public.s3.us-east-1.amazonaws.com/ffmpeg-caption-issue/cleveland-clip-afterpatch.ass

And here is the full sample video in case anyone wants to play around with
a larger example with many more caption errors. The above video sample
"cleveland-clip.ts" is just a 60 second clip of the following.
https://snapstream-dev-test-public.s3.us-east-1.amazonaws.com/ffmpeg-caption-issue/The%20Cleveland%20Show%20-%20%28Brown%20Magic%29-2018-12-14-0.ts

The full patch file is attached to this email.
From fe1a817dbbcbee3b96696bebe5a8900f83393249 Mon Sep 17 00:00:00 2001
From: Levi Dooley 
Date: Fri, 22 Jan 2021 17:55:22 -0600
Subject: [PATCH] libavcodec/ccaption_dec.c: Fixed indentation overwriting text in the cea608 caption decoder.

There was an assumption in the existing code that indentation would not occur more than once on the same row.
This was a bad assumption. There are examples of 608 streams which call handle_pac multiple times on the same row with different indentation.
As the code was before this change, the new indentation would overwrite existing text with spaces.
These changes make indentation skip over columns instead. Text gets cleared with spaces on handle_edm.
Instead of relying on the null character, trailing spaces are trimmed off the end of a row.
This is necessary so that a null character doesn't end up between two words.

Signed-off-by: Levi Dooley 
---
 libavcodec/ccaption_dec.c | 39 ---
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index a208e19b95..6a3018dd4e 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -459,6 +459,7 @@ static int capture_screen(CCaptionSubContext *ctx)
 if (CHECK_FLAG(screen->row_used, i)) {
 const char *row = screen->characters[i];
 const char *charset = screen->charsets[i];
+
 j = 0;
 while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN)
 j++;
@@ -476,13 +477,19 @@ static int capture_screen(CCaptionSubContext *ctx)
 const char *color = screen->colors[i];
 const char *charset = screen->charsets[i];
 const char *override;
-int x, y, seen_char = 0;
+int x, y, row_end, seen_char = 0;
 j = 0;
 
 /* skip leading space */
 while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN && j < tab)
 j++;
 
+/* skip trailing space */
+row_end = SCREEN_COLUMNS-1;
+while (row_end >= 0 && row[row_end] == ' ' && charset[row_end] == CCSET_BASIC_AMERICAN) {
+row_end--;
+}
+
 x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
 y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
 av_bprintf(>buffer[bidx], "{\\an7}{\\pos(%d,%d)}", x, y);
@@ -490,7 +497,7 @@ static int capture_screen(CCaptionSubContext *ctx)
 for (; j < SCREEN_COLUMNS; j++) {
 const char *e_tag = "", *s_tag = "", *c_tag = "", *b_tag = "";
 
-if (row[j] == 0)
+if (j > row_end || row[j] == 0)
 break;
 
 if (prev_font != font[j]) {
@@ -624,7 +631,8 @@ static void handle_textattr(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo)
 ctx->cursor_font = pac2_attribs[i][1];
 
 SET_FLAG(screen->row_used, ctx->cursor_row);
-write_char(ctx, screen, ' ');
+
+ctx->cursor_column++;
 }
 
 static void handle_pac(CCaptionSubContext *ctx, 

Re: [FFmpeg-devel] [PATCH] avformat/utils: always preserve container dimensions for all streams

2021-01-25 Thread Michael Niedermayer
On Sun, Jan 24, 2021 at 11:41:13AM -0300, James Almer wrote:
> If a decoder is used for probing it may change the dimensions reported by the
> demuxer, either by the lowres factor or because of assorted frames reporting
> different dimensions, and in a codec copy scenario, the last dimensions
> arbitrarily set by it could end up being propagated to the muxer.
> 
> Signed-off-by: James Almer 
> ---
>  libavformat/utils.c | 10 ++
>  tests/ref/fate/cbs-vp9-vp90-2-05-resize |  2 +-
>  tests/ref/fate/redcode-demux|  2 +-
>  tests/ref/fate/wtv-demux|  4 ++--
>  4 files changed, 10 insertions(+), 8 deletions(-)
> 

breaks:

./ffmpeg -i tickets/2892/MPEG_tbn_test.mov  -c:v copy -c:a copy -vtag mx3n 
-timecode 10:00:00:00 -vframes 3 file.mov
...
[mov @ 0x558785108e00] D-10/IMX must use 720x608 or 720x512 video resolution
Could not write header for output file #0 (incorrect codec parameters ?): 
Invalid argument
Error initializing output stream 0:1 -- 

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/2] fate: Add test for namespace prefixes in libraries

2021-01-25 Thread Andreas Rheinhardt
Mark Thompson:
> Ensures that external symbols in the built static libraries either have
> correct namespace prefixes or are on a known list of exceptions.
> ---
>  tests/Makefile  |  1 +
>  tests/fate/namespace.mak| 19 ++
>  tests/fate/namespace.sh | 15 
>  tests/ref/fate/namespace-avcodec|  0
>  tests/ref/fate/namespace-avdevice   |  0
>  tests/ref/fate/namespace-avfilter   |  0
>  tests/ref/fate/namespace-avformat   |  0
>  tests/ref/fate/namespace-avutil |  0
>  tests/ref/fate/namespace-postproc   |  0
>  tests/ref/fate/namespace-swresample |  0
>  tests/ref/fate/namespace-swscale| 58 +
>  11 files changed, 93 insertions(+)
>  create mode 100644 tests/fate/namespace.mak
>  create mode 100755 tests/fate/namespace.sh
>  create mode 100644 tests/ref/fate/namespace-avcodec
>  create mode 100644 tests/ref/fate/namespace-avdevice
>  create mode 100644 tests/ref/fate/namespace-avfilter
>  create mode 100644 tests/ref/fate/namespace-avformat
>  create mode 100644 tests/ref/fate/namespace-avutil
>  create mode 100644 tests/ref/fate/namespace-postproc
>  create mode 100644 tests/ref/fate/namespace-swresample
>  create mode 100644 tests/ref/fate/namespace-swscale
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index 7844901e53..94057eb81d 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -173,6 +173,7 @@ include $(SRC_PATH)/tests/fate/mpeg4.mak
>  include $(SRC_PATH)/tests/fate/mpegps.mak
>  include $(SRC_PATH)/tests/fate/mpegts.mak
>  include $(SRC_PATH)/tests/fate/mxf.mak
> +include $(SRC_PATH)/tests/fate/namespace.mak
>  include $(SRC_PATH)/tests/fate/opus.mak
>  include $(SRC_PATH)/tests/fate/pcm.mak
>  include $(SRC_PATH)/tests/fate/pixfmt.mak
> diff --git a/tests/fate/namespace.mak b/tests/fate/namespace.mak
> new file mode 100644
> index 00..0021e7152d
> --- /dev/null
> +++ b/tests/fate/namespace.mak
> @@ -0,0 +1,19 @@
> +
> +define FATE_NAMESPACE
> +# (library_name, config_option)
> +FATE_NAMESPACE-$(call ALLYES, STATIC $(2)) += fate-namespace-$(1)
> +fate-namespace-$(1): lib$(1)/$(LIBPREF)$(1)$(LIBSUF)
> +fate-namespace-$(1): CMD = runlocal fate/namespace.sh "$(NM_CMD) -P 
> lib$(1)/$(LIBPREF)$(1)$(LIBSUF)"
> +endef
> +
> +$(eval $(call FATE_NAMESPACE,avutil, AVUTIL))
> +$(eval $(call FATE_NAMESPACE,avcodec,AVCODEC))
> +$(eval $(call FATE_NAMESPACE,avformat,   AVFORMAT))
> +$(eval $(call FATE_NAMESPACE,avfilter,   AVFILTER))
> +$(eval $(call FATE_NAMESPACE,avdevice,   AVDEVICE))
> +$(eval $(call FATE_NAMESPACE,swscale,SWSCALE))
> +$(eval $(call FATE_NAMESPACE,swresample, SWRESAMPLE))
> +$(eval $(call FATE_NAMESPACE,postproc,   POSTPROC))
> +
> +FATE += $(FATE_NAMESPACE-yes)
> +fate-namespace: $(FATE_NAMESPACE-yes)
> diff --git a/tests/fate/namespace.sh b/tests/fate/namespace.sh
> new file mode 100755
> index 00..16d306eafc
> --- /dev/null
> +++ b/tests/fate/namespace.sh
> @@ -0,0 +1,15 @@
> +#!/bin/sh
> +
> +$1 |
> +   grep ' [TDBR] ' | # Filter to all global text/data/bss symbols.
> +   grep -v '^ff_' | # Internal-only globals.
> +   grep -v '^av'  | # libav* external API.
> +   grep -v '^sws' | # libswscale external API.
> +   grep -v '^swr' | # libswresample external API.
> +   grep -v '^\(postproc\|pp\)_' | # libpostproc external API.
> +   grep -v '^\(ffio\|ffurl\)_'  | # libavformat internal ffio/ffurl APIs.
> +   grep -v '^rgb2rgb_init_' | # libswscale arch-specific init function.
> +   sed 's/ .*//'  | # Remove everything except the symbol name.
> +   sort # Sort to allow deterministic comparison.
> +
> +exit 0
> diff --git a/tests/ref/fate/namespace-avcodec 
> b/tests/ref/fate/namespace-avcodec
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-avdevice 
> b/tests/ref/fate/namespace-avdevice
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-avfilter 
> b/tests/ref/fate/namespace-avfilter
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-avformat 
> b/tests/ref/fate/namespace-avformat
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-avutil b/tests/ref/fate/namespace-avutil
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-postproc 
> b/tests/ref/fate/namespace-postproc
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-swresample 
> b/tests/ref/fate/namespace-swresample
> new file mode 100644
> index 00..e69de29bb2
> diff --git a/tests/ref/fate/namespace-swscale 
> b/tests/ref/fate/namespace-swscale
> new file mode 100644
> index 00..a7aa4504ae
> --- /dev/null
> +++ b/tests/ref/fate/namespace-swscale
> @@ -0,0 +1,58 @@
> +deinterleaveBytes
> +interleaveBytes
> +planar2x
> +rgb12to15
> +rgb12tobgr12
> +rgb15to16
> +rgb15to24
> +rgb15to32
> +rgb15tobgr15
> +rgb15tobgr16

[FFmpeg-devel] [PATCH v3 2/2] fate: Add test for namespace prefixes in libraries

2021-01-25 Thread Mark Thompson
Ensures that external symbols in the built static libraries either have
correct namespace prefixes or are on a known list of exceptions.
---
 tests/Makefile  |  1 +
 tests/fate/namespace.mak| 19 ++
 tests/fate/namespace.sh | 15 
 tests/ref/fate/namespace-avcodec|  0
 tests/ref/fate/namespace-avdevice   |  0
 tests/ref/fate/namespace-avfilter   |  0
 tests/ref/fate/namespace-avformat   |  0
 tests/ref/fate/namespace-avutil |  0
 tests/ref/fate/namespace-postproc   |  0
 tests/ref/fate/namespace-swresample |  0
 tests/ref/fate/namespace-swscale| 58 +
 11 files changed, 93 insertions(+)
 create mode 100644 tests/fate/namespace.mak
 create mode 100755 tests/fate/namespace.sh
 create mode 100644 tests/ref/fate/namespace-avcodec
 create mode 100644 tests/ref/fate/namespace-avdevice
 create mode 100644 tests/ref/fate/namespace-avfilter
 create mode 100644 tests/ref/fate/namespace-avformat
 create mode 100644 tests/ref/fate/namespace-avutil
 create mode 100644 tests/ref/fate/namespace-postproc
 create mode 100644 tests/ref/fate/namespace-swresample
 create mode 100644 tests/ref/fate/namespace-swscale

diff --git a/tests/Makefile b/tests/Makefile
index 7844901e53..94057eb81d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -173,6 +173,7 @@ include $(SRC_PATH)/tests/fate/mpeg4.mak
 include $(SRC_PATH)/tests/fate/mpegps.mak
 include $(SRC_PATH)/tests/fate/mpegts.mak
 include $(SRC_PATH)/tests/fate/mxf.mak
+include $(SRC_PATH)/tests/fate/namespace.mak
 include $(SRC_PATH)/tests/fate/opus.mak
 include $(SRC_PATH)/tests/fate/pcm.mak
 include $(SRC_PATH)/tests/fate/pixfmt.mak
diff --git a/tests/fate/namespace.mak b/tests/fate/namespace.mak
new file mode 100644
index 00..0021e7152d
--- /dev/null
+++ b/tests/fate/namespace.mak
@@ -0,0 +1,19 @@
+
+define FATE_NAMESPACE
+# (library_name, config_option)
+FATE_NAMESPACE-$(call ALLYES, STATIC $(2)) += fate-namespace-$(1)
+fate-namespace-$(1): lib$(1)/$(LIBPREF)$(1)$(LIBSUF)
+fate-namespace-$(1): CMD = runlocal fate/namespace.sh "$(NM_CMD) -P 
lib$(1)/$(LIBPREF)$(1)$(LIBSUF)"
+endef
+
+$(eval $(call FATE_NAMESPACE,avutil, AVUTIL))
+$(eval $(call FATE_NAMESPACE,avcodec,AVCODEC))
+$(eval $(call FATE_NAMESPACE,avformat,   AVFORMAT))
+$(eval $(call FATE_NAMESPACE,avfilter,   AVFILTER))
+$(eval $(call FATE_NAMESPACE,avdevice,   AVDEVICE))
+$(eval $(call FATE_NAMESPACE,swscale,SWSCALE))
+$(eval $(call FATE_NAMESPACE,swresample, SWRESAMPLE))
+$(eval $(call FATE_NAMESPACE,postproc,   POSTPROC))
+
+FATE += $(FATE_NAMESPACE-yes)
+fate-namespace: $(FATE_NAMESPACE-yes)
diff --git a/tests/fate/namespace.sh b/tests/fate/namespace.sh
new file mode 100755
index 00..16d306eafc
--- /dev/null
+++ b/tests/fate/namespace.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+$1 |
+   grep ' [TDBR] ' | # Filter to all global text/data/bss symbols.
+   grep -v '^ff_' | # Internal-only globals.
+   grep -v '^av'  | # libav* external API.
+   grep -v '^sws' | # libswscale external API.
+   grep -v '^swr' | # libswresample external API.
+   grep -v '^\(postproc\|pp\)_' | # libpostproc external API.
+   grep -v '^\(ffio\|ffurl\)_'  | # libavformat internal ffio/ffurl APIs.
+   grep -v '^rgb2rgb_init_' | # libswscale arch-specific init function.
+   sed 's/ .*//'  | # Remove everything except the symbol name.
+   sort # Sort to allow deterministic comparison.
+
+exit 0
diff --git a/tests/ref/fate/namespace-avcodec b/tests/ref/fate/namespace-avcodec
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-avdevice 
b/tests/ref/fate/namespace-avdevice
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-avfilter 
b/tests/ref/fate/namespace-avfilter
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-avformat 
b/tests/ref/fate/namespace-avformat
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-avutil b/tests/ref/fate/namespace-avutil
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-postproc 
b/tests/ref/fate/namespace-postproc
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-swresample 
b/tests/ref/fate/namespace-swresample
new file mode 100644
index 00..e69de29bb2
diff --git a/tests/ref/fate/namespace-swscale b/tests/ref/fate/namespace-swscale
new file mode 100644
index 00..a7aa4504ae
--- /dev/null
+++ b/tests/ref/fate/namespace-swscale
@@ -0,0 +1,58 @@
+deinterleaveBytes
+interleaveBytes
+planar2x
+rgb12to15
+rgb12tobgr12
+rgb15to16
+rgb15to24
+rgb15to32
+rgb15tobgr15
+rgb15tobgr16
+rgb15tobgr24
+rgb15tobgr32
+rgb16to15
+rgb16to24
+rgb16to32
+rgb16tobgr15
+rgb16tobgr16
+rgb16tobgr24
+rgb16tobgr32
+rgb24to15
+rgb24to16
+rgb24to32
+rgb24tobgr15
+rgb24tobgr16
+rgb24tobgr24
+rgb24tobgr32
+rgb32to15
+rgb32to16
+rgb32to24
+rgb32tobgr15
+rgb32tobgr16

[FFmpeg-devel] [PATCH v3 1/2] vc2enc: Add missing static to local variables

2021-01-25 Thread Mark Thompson
---
 libavcodec/vc2enc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index bab9d0f3d5..7bd2e4c2ab 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -423,7 +423,7 @@ static void encode_slice_params(VC2EncContext *s)
 }
 
 /* 1st idx = LL, second - vertical, third - horizontal, fourth - total */
-const uint8_t vc2_qm_col_tab[][4] = {
+static const uint8_t vc2_qm_col_tab[][4] = {
 {20,  9, 15,  4},
 { 0,  6,  6,  4},
 { 0,  3,  3,  5},
@@ -431,7 +431,7 @@ const uint8_t vc2_qm_col_tab[][4] = {
 { 0, 11, 10, 11}
 };
 
-const uint8_t vc2_qm_flat_tab[][4] = {
+static const uint8_t vc2_qm_flat_tab[][4] = {
 { 0,  0,  0,  0},
 { 0,  0,  0,  0},
 { 0,  0,  0,  0},
-- 
2.29.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 4/9] avcodec: add cbs for h266/vvc

2021-01-25 Thread James Almer

On 1/25/2021 2:12 PM, James Almer wrote:
Did you add this just to set active_vps? I thought the 
idea was to remove all that since it's not a concept defined in h266.


The following should get rid of active_*, but the actual fields can't be 
removed from CodedBitstreamH266Context unless we duplicate the 
cbs_h2645_replace_ps() macro to remove the relevant lines it shares with 
the other two codecs.



diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index da541407cf..2516481015 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1690,10 +1690,6 @@ static void cbs_h266_flush(CodedBitstreamContext *ctx)
 }
 av_buffer_unref(>ph_ref);
 h266->ph = NULL;
-
-h266->active_vps = NULL;
-h266->active_sps = NULL;
-h266->active_pps = NULL;
 }


diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h
index 8ce29be3fa..bf15a14d85 100644
--- a/libavcodec/cbs_h266.h
+++ b/libavcodec/cbs_h266.h
@@ -800,9 +800,7 @@ typedef struct CodedBitstreamH266Context {
 H266RawPPS  *pps[VVC_MAX_PPS_COUNT];
 H266RawPH   *ph;

-// The currently active parameter sets.  These are updated when any
-// NAL unit refers to the relevant parameter set.  These pointers
-// must also be present in the arrays above.
+// Unused, added to keep compatibility with the cbs_h2645_replace_ps() 
macro
 const H266RawVPS *active_vps;
 const H266RawSPS *active_sps;
 const H266RawPPS *active_pps;
diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index c030766c34..3e1a8be5d9 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -463,11 +463,9 @@ static int FUNC(ref_pic_list_struct)(CodedBitstreamContext 
*ctx, RWContext *rw,
 }

 static int FUNC(ref_pic_lists)(CodedBitstreamContext *ctx, RWContext *rw,
-   H266RefPicLists *current)
+   H266RefPicLists *current,
+   const H266RawSPS *sps, const H266RawPPS *pps)
 {
-CodedBitstreamH266Context *h266 = ctx->priv_data;
-const H266RawSPS *sps = h266->active_sps;
-const H266RawPPS *pps = h266->active_pps;
 const H266RefPicListStruct *ref_list;
 int err, i, j, num_ltrp_entries;
 for (i = 0; i < 2; i++) {
@@ -974,7 +972,6 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext 
*rw,
 vps->vps_layer_id[0] = current->nal_unit_header.nuh_layer_id;
 h266->vps_ref[0] = ref;
 h266->vps[0] = vps;
-h266->active_vps = vps;
 }

 u(3, sps_max_sublayers_minus1, 0, VVC_MAX_SUBLAYERS - 1);
@@ -1528,7 +1525,6 @@ static int FUNC(pps)(CodedBitstreamContext *ctx, 
RWContext *rw,
current->pps_seq_parameter_set_id);
 return AVERROR_INVALIDDATA;
 }
-h266->active_sps = sps;

 flag(pps_mixed_nalu_types_in_pic_flag);
 ue(pps_pic_width_in_luma_samples,
@@ -2194,9 +2190,6 @@ static int FUNC(picture_header)(CodedBitstreamContext 
*ctx, RWContext *rw,
sps->sps_video_parameter_set_id);
 return AVERROR_INVALIDDATA;
 }
-h266->active_sps = sps;
-h266->active_pps = pps;
-h266->active_vps = vps;

 ub(sps->sps_log2_max_pic_order_cnt_lsb_minus4 + 4, ph_pic_order_cnt_lsb);
 if (current->ph_gdr_pic_flag)
@@ -2292,7 +2285,7 @@ static int FUNC(picture_header)(CodedBitstreamContext 
*ctx, RWContext *rw,
 else
 infer(ph_pic_output_flag, 1);
 if (pps->pps_rpl_info_in_ph_flag) {
-CHECK(FUNC(ref_pic_lists)(ctx, rw, >ph_ref_pic_lists));
+CHECK(FUNC(ref_pic_lists)(ctx, rw, >ph_ref_pic_lists, sps, 
pps));
 }
 if (sps->sps_partition_constraints_override_enabled_flag)
 flag(ph_partition_constraints_override_flag);
@@ -2591,17 +2584,13 @@ static int FUNC(slice_header)(CodedBitstreamContext 
*ctx, RWContext *rw,
 h266->ph = (H266RawPH*)h266->ph_ref->data;
 memcpy(h266->ph, >sh_picture_header, sizeof(H266RawPH));
 }
-sps = h266->active_sps;
-pps = h266->active_pps;
 ph  = h266->ph;
-
 if (!ph) {
 av_log(ctx->log_ctx, AV_LOG_ERROR, "Picture header not available.\n");
 return AVERROR_INVALIDDATA;
 }
-//sps and pps checked in picture_header(), just assert them.
-av_assert0(sps);
-av_assert0(pps);
+pps = h266->pps[ph->ph_pic_parameter_set_id];
+sps = h266->sps[pps->pps_seq_parameter_set_id];

 if (sps->sps_subpic_info_present_flag) {
 ub(sps->sps_subpic_id_len_minus1 + 1, sh_subpic_id);
@@ -2722,7 +2711,7 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, 
RWContext *rw,
 ((nal_unit_type != VVC_IDR_W_RADL &&
 nal_unit_type != VVC_IDR_N_LP) ||
 sps->sps_idr_rpl_present_flag)) {
-CHECK(FUNC(ref_pic_lists)(ctx, rw, >sh_ref_pic_lists));
+CHECK(FUNC(ref_pic_lists)(ctx, rw, >sh_ref_pic_lists, sps, 
pps));
 ref_pic_lists = >sh_ref_pic_lists;
 } else {
 ref_pic_lists = 

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Mark Thompson

On 25/01/2021 17:11, James Almer wrote:

Mark then suggested to directly replace/extend the API with one that's more 
useful in the long run, instead of removing them as Anton suggested since you 
and some other devs stated they in fact do have users, and you agreed to that. 
So how about we try to move in that direction?


Yes.


The first step is merging the libraries, ...


?  I don't see how this follows at all.

Merging the libraries (in source form, orthogonal to merging the binaries) only 
makes sense if we are going to continue using the libavformat internals, and 
that is exactly the thing we are trying to get rid of.

If we replace the libavdevice API with a proper one oriented towards devices 
rather than being hacked on to the libavformat API then we actively don't want 
that merger.

So, what do people actually want here?  The situation as I see it is (please 
correct me on anything you feel is in error here):

* The features which libavdevice offers are useful to a lot of people.
* Many of those are using it via the ffmpeg utility, but not all.
* The libavdevice API is the libavformat API because it was originally split 
out from libavformat, and it has the nice property that devices and files end 
up being interchangable in some contexts.
* The libavdevice API, being the libavformat API for files, is not particularly 
well-suited in other contexts, because devices may not have the same properties 
as files.
* Some odd things like the completely-unused capabilities API and the 
almost-never-used message API are hacked on top of that to try to avoid some 
libavformat issues, but are not actually useful to anyone (hence the lack of 
use).
* To implement devices as AVInputFormat/AVOutputFormat instances, libavdevice 
currently needs access to the internals of libavformat.
* Many developers want to get rid of that dependency on libavformat internals, 
because it creates a corresponding ugliness on the libavformat side which has 
to leave those parts exposed in an ABI-constrained way.

What might we do about this:

* Delete libavdevice, with a statement that its capabilities are outside the 
scope of ffmpeg.  Obviously this isn't sensible, the ffmpeg utility would then 
need to depend on some external library to offer the same features it does now.
* Merge libavdevice into the ffmpeg utility.  Since it is the primary user this 
would neatly sidestep the previous objection, but now external users are in the 
same boat so again unacceptable.
* Merge libavdevice into libavformat.  This works to eliminate the dependency 
problem, but it only really makes sense if we accept that libavdevice is 
finished and will never want new API which isn't repurposed libavformat.
* Make a new libavdevice-specific API and switch to that.  The eliminates the 
dependency problem, but there is a nasty transition period and it would break 
the interchangability of the two libraries.  It also would be the most work, 
but leave libavdevice in the best state for doing more things with in future.
* Nothing.  People will continue to be annoyed about the problems above.

Opinions?

Personally, I think the right option here is to make a new libavdevice-specific 
API and cut the connection to libavformat entirely, and I would be prepared to 
do some work towards that goal.  Exactly what form it would take is unclear, 
but I would be happy to talk about that further if people agree that it is the 
right approach.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h265_syntax_template: Better check for num_long_term_sps

2021-01-25 Thread Mark Thompson

On 24/01/2021 21:41, Michael Niedermayer wrote:

On Sat, Nov 21, 2020 at 06:49:55PM +, Mark Thompson wrote:

On 21/11/2020 17:37, Michael Niedermayer wrote:

On Sun, Nov 15, 2020 at 09:37:45PM +, Mark Thompson wrote:

On 14/11/2020 10:18, Michael Niedermayer wrote:

Fixes: index 26 out of bounds for type 'uint8_t [16]'
Fixes: 
24913/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6261760693370880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
libavcodec/cbs_h265_syntax_template.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/libavcodec/cbs_h265_syntax_template.c 
b/libavcodec/cbs_h265_syntax_template.c
index 48fae82d04..8eb6e159f4 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -1405,6 +1405,8 @@ static int 
FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
infer(num_long_term_sps, 0);
idx_size = 0;
}
+if (HEVC_MAX_REFS < current->num_long_term_sps)
+return AVERROR_INVALIDDATA;


Please don't put isolated tests in the middle of the template.  If it 
constrains a value then add it to the constraints on that value.


ue(num_long_term_pics, 0, HEVC_MAX_REFS - 
current->num_long_term_sps);
for (i = 0; i < current->num_long_term_sps +



It would be good if the commit message could include an explanation derived 
from the standard, too.

As far as I can tell the constraint doesn't appear explicitly, but the SPS is 
allowed to define more possible long term frames than are actually allowed to 
be present at any given moment so we need the tighter bound.


Is the change below what you had in mind ?

commit 72c6c46bb2b31b2822331aff461acccd0a4f9159 (HEAD -> master)
Author: Michael Niedermayer 
Date:   Fri Nov 13 23:15:52 2020 +0100

  avcodec/cbs_h265_syntax_template: Better check for num_long_term_sps
  As far as we can tell the constraint doesn't appear explicitly, but the 
SPS is allowed to
  define more possible long term frames than are actually allowed to be 
present at any given moment so we need the tighter bound.


I meant write a commit message which explains where in the standard the 
constraint is coming from.  I wrote that because I didn't see any extra 
constraint written in the standard for num_long_term_sps but 
num_long_term_ref_pics_sps is indeed bigger, so presumably it must be implied 
by something else.


what do you suggest if noone finds that "something else" ?


If you have given up on this then I would try to work out what is going on here 
myself?

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/6] avformat/flvdec: Check for nesting depth in amf_parse_object()

2021-01-25 Thread Michael Niedermayer
On Sun, Jan 24, 2021 at 02:14:43PM +0100, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2021-01-23 23:10:54)
> > Fixes: out of array access
> > Fixes: 
> > 29202/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5112845840809984
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/flvdec.c | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> > index 07ef342278..e15be0a221 100644
> > --- a/libavformat/flvdec.c
> > +++ b/libavformat/flvdec.c
> > @@ -41,6 +41,8 @@
> >  
> >  #define RESYNC_BUFFER_SIZE (1<<20)
> >  
> > +#define MAX_DEPTH 10
> 
> Why 10 specifically.

10 is arbitrary, we could pick 5 or 100 probably


> And which buffer overflows?

stack


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 3/3] avformat/mxfenc: prefer to use the configured metadta

2021-01-25 Thread emcodem

Am 2021-01-20 16:41, schrieb Tomas Härdin:

ons 2021-01-20 klockan 00:27 +0100 skrev Marton Balint:


On Tue, 19 Jan 2021, Tobias Rapp wrote:

> On 18.01.2021 23:53, Tomas Härdin wrote:
> > lör 2021-01-16 klockan 08:43 +0800 skrev lance.lmw...@gmail.com:
> > > On Fri, Jan 15, 2021 at 09:43:58PM +0100, Marton Balint wrote:
> > > > On Fri, 15 Jan 2021, Tomas Härdin wrote:
> > > > > Again, why? If you have a company that maintains a fork of FFmpeg then
> > > > > compile that info in here instead. Compare with FFmbc which always 
puts
> > > > > "FFmbc" as CompanyName.
> > > >
> > > > And how can a product based on libavformat set the company name, product
> > > > name and product version? It seems a valid use case for me that these 
are
> > > > overridable. Also note that this product version is only the "user
> friendly"
> > > > version string, for the numeric version still LIBAVFORMAT_VERSION values
> are
> > > > used.
> > >
> > > Yes, my use case is the product is using libavformat as library, so it's
> > > prefer to have way to override these information as requirements.
> >
> > What I'm worried about here is that we're going to get files which
> > claim to have been written by something other than libavformat. I've
> > had situations like this before, and it is a source of headache. For
> > example, if mxfenc writes some field incorrectly then this might cause
> > us to hack mxfdec to accept that field instead of fixing mxfenc.
>
> I agree that especially for the MXF format with its flexible structure
> it is more relevant to know the muxing library rather than the hosting
> application. Have seen MXF output files of other commercial products
> that also contain library identifiers like "libMXF" or "MXFtk" here.
>
> Other formats in FFmpeg use the "encoder" metadata key for embedding
> library information in the output file. A quick test with AVI output
> shows that this metadata is generated internally and cannot be
> overridden on the command-line.

If your concern is being able to identify our mxf muxer, then why not 
use

the Platform metadata item for this?

"Human readable name of the toolkit and operating system used. Best
practice is to use the form “SDK name (OS name)”"


Uhm guys, it is very bad practice: if you just insert a different 
manufacturer name then you just cheat. SMPTE 377 has a clear statement 
about what goes to the identification, you cannot just write the infos 
from a different program there.


What you can do instead is to push both identifications, the old one and 
the one from the current program into the identification array, this way 
the processing chain can be reconstructed. Unforutnately i have never 
seen anyone doing this besides Opencube.


Also, note that broadcasters currently are using the identification 
string, looking for "ffmpeg" in order to sort out non compatible XDCAMHD 
mxf: ffmpeg does not write some mandatory metadata fields as mentioned 
here: https://trac.ffmpeg.org/ticket/5097 this leads to sony devices not 
accepting the ffmpeg mxf container - which again leads to ffmpeg mxf 
wrapper for XDCAMHD not being accepted by our public broadcaster.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 4/9] avcodec: add cbs for h266/vvc

2021-01-25 Thread James Almer

On 1/25/2021 2:12 PM, James Almer wrote:

On 1/25/2021 11:15 AM, Nuo Mi wrote:
+static int FUNC(ref_pic_list_struct)(CodedBitstreamContext *ctx, 
RWContext *rw,

+ H266RefPicListStruct *current,
+ uint8_t list_idx, uint8_t rpls_idx,
+ const H266RawSPS *sps)
+{
+    CodedBitstreamH266Context *h266 = ctx->priv_data;
+    int err, i, j, general_layer_idx = -1, num_direct_ref_layers = 0;
+    const H266RawVPS *vps = h266->vps[sps->sps_video_parameter_set_id];
+
+    if (!vps) {
+    av_log(ctx->log_ctx, AV_LOG_ERROR,
+   "VPS id %d not available.\n", 
sps->sps_video_parameter_set_id);

+    return AVERROR_INVALIDDATA;


Wont this break all the samples that lack a VPS?

(I thought for that matter that all those samples having this field but 
then no VPS at all was odd).


Right, i see now that vps_video_parameter_set_id in a VPS is meant to 
never be 0, so apparently a VPS with id 0 and default values is implicit 
to always exist while not being coded in the bitstream, and that's what 
these SPS with sps_video_parameter_set_id == 0 reference.


I don't know if allocating it when parsing the first SPS is the best 
idea, but i can't think if a better alternative right now.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Nicolas George
James Almer (12021-01-25):
> And that's why we're trying to merge them. So again, a subdirectory is not
> obligatory for this purpose, and alternative suggestions are welcome.
> Even just saying to keep them in the root folder would be more useful than

That is what leaving it alone implies.

> saying "Work on something else".

As a general principle, I think no member of this project should touch
an area of the code they hate: hate is not compatible with good work. Do
you not agree?

> Saying and thinking that lavd devices with their current capabilities and
> API are not very useful is not being "dismissive of other people's efforts",
> it's giving his opinion.

But saying it is "worse than useless" is dismissive. Double standards.

> Mark then suggested to directly replace/extend the API with one that's more
> useful in the long run, instead of removing them as Anton suggested since
> you and some other devs stated they in fact do have users, and you agreed to
> that. So how about we try to move in that direction? The first step is
> merging the libraries, and not trying to stop any relevant effort.

No. The first step is to acknowledge that libavdevice is useful, already
as it is. I am still waiting for that.

The second step would be to think about how it can be made even more
useful. For that, we need people who understand its usefulness. People
who do not should stay out of it, or at least take second role.

I have detailed thoughts on making libavdevice much more useful. And
they do not involve merging with libavformat; and they require a few
infrastructure steps before they can happen. But I will not discuss them
in this hostile environment, as a defense. If somebody is interested and
sympathetic, I will gladly explain them.

> And for that matter, unlike you, Anton did not resort to ad hominem attacks
> to back his argument.

Unfortunately, this point is significant of a wider attitude towards
features versus purity. It needs to be addressed or the project will
wither.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/mediacodecdec: Do not abort when H264/HEVC extradata extraction fails

2021-01-25 Thread sfan5

Although rare, extradata can be present but empty and extraction will fail.
However Android also supports passing codec-specific data inline and
will likely play such a stream anyway. So there's no reason to abort
initialization before we know for sure.
---
 libavcodec/mediacodecdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index ac1725e466..67adefb530 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -167,8 +167,8 @@ static int h264_set_extradata(AVCodecContext *avctx, 
FFAMediaFormat *format)
 ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, 
data_size);

 av_freep();
 } else {
-av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from 
extradata");

-ret = AVERROR_INVALIDDATA;
+av_log(avctx, AV_LOG_WARNING, "Could not extract PPS/SPS from 
extradata\n");

+ret = 0;
 }
  done:
@@ -254,8 +254,8 @@ static int hevc_set_extradata(AVCodecContext *avctx, 
FFAMediaFormat *format)

  av_freep();
 } else {
-av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from 
extradata");

-ret = AVERROR_INVALIDDATA;
+av_log(avctx, AV_LOG_WARNING, "Could not extract VPS/PPS/SPS 
from extradata\n");

+ret = 0;
 }
  done:
--
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 4/9] avcodec: add cbs for h266/vvc

2021-01-25 Thread James Almer

On 1/25/2021 11:15 AM, Nuo Mi wrote:

+static int FUNC(ref_pic_list_struct)(CodedBitstreamContext *ctx, RWContext *rw,
+ H266RefPicListStruct *current,
+ uint8_t list_idx, uint8_t rpls_idx,
+ const H266RawSPS *sps)
+{
+CodedBitstreamH266Context *h266 = ctx->priv_data;
+int err, i, j, general_layer_idx = -1, num_direct_ref_layers = 0;
+const H266RawVPS *vps = h266->vps[sps->sps_video_parameter_set_id];
+
+if (!vps) {
+av_log(ctx->log_ctx, AV_LOG_ERROR,
+   "VPS id %d not available.\n", sps->sps_video_parameter_set_id);
+return AVERROR_INVALIDDATA;


Wont this break all the samples that lack a VPS?

(I thought for that matter that all those samples having this field but 
then no VPS at all was odd).


[...]


+static int FUNC(picture_header)(CodedBitstreamContext *ctx, RWContext *rw,
+H266RawPH *current)
+{
+CodedBitstreamH266Context *h266 = ctx->priv_data;
+const H266RawVPS *vps;
+const H266RawSPS *sps;
+const H266RawPPS *pps;
+int err, i;
+unsigned int ctb_log2_size_y, min_cb_log2_size_y,
+min_qt_log2_size_intra_y, min_qt_log2_size_inter_y;
+uint8_t qp_bd_offset;
+
+flag(ph_gdr_or_irap_pic_flag);
+flag(ph_non_ref_pic_flag);
+if (current->ph_gdr_or_irap_pic_flag)
+flag(ph_gdr_pic_flag);
+else
+infer(ph_gdr_pic_flag, 0);
+flag(ph_inter_slice_allowed_flag);
+if (current->ph_inter_slice_allowed_flag)
+flag(ph_intra_slice_allowed_flag);
+else
+infer(ph_intra_slice_allowed_flag, 1);
+ue(ph_pic_parameter_set_id, 0, VVC_MAX_PPS_COUNT - 1);
+pps = h266->pps[current->ph_pic_parameter_set_id];
+if (!pps) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "PPS id %d not available.\n",
+   current->ph_pic_parameter_set_id);
+return AVERROR_INVALIDDATA;
+}
+sps = h266->sps[pps->pps_seq_parameter_set_id];
+if (!sps) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
+   pps->pps_seq_parameter_set_id);
+return AVERROR_INVALIDDATA;
+}
+vps = h266->vps[sps->sps_video_parameter_set_id];
+if (!vps) {
+av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available.\n",
+   sps->sps_video_parameter_set_id);
+return AVERROR_INVALIDDATA;


Ditto. But in this case the VPS is not used at all by the 
picture_header. Did you add this just to set active_vps? I thought the 
idea was to remove all that since it's not a concept defined in h266.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread James Almer

On 1/25/2021 1:46 PM, Nicolas George wrote:

James Almer (12021-01-25):

Solving the hacky state of lavd <-> lavf *is* useful.


The only "hacky state" comes from the useless split of the libraries.


And that's why we're trying to merge them. So again, a subdirectory is 
not obligatory for this purpose, and alternative suggestions are welcome.
Even just saying to keep them in the root folder would be more useful 
than saying "Work on something else".





And it would help the
project a lot if you could be a tiny bit less aggressive and dismissive of
other people's personal opinions.


Anton is dismissive of other people's efforts — not just opinions — yet
you said him nothing. Double standards.


Saying and thinking that lavd devices with their current capabilities 
and API are not very useful is not being "dismissive of other people's 
efforts", it's giving his opinion. He did it in fact as a reply to 
Mark's comment that the KMS/DRM output device patch didn't seem like a 
good idea.
Mark then suggested to directly replace/extend the API with one that's 
more useful in the long run, instead of removing them as Anton suggested 
since you and some other devs stated they in fact do have users, and you 
agreed to that. So how about we try to move in that direction? The first 
step is merging the libraries, and not trying to stop any relevant effort.


And for that matter, unlike you, Anton did not resort to ad hominem 
attacks to back his argument.




Regards,


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Nicolas George
James Almer (12021-01-25):
> Solving the hacky state of lavd <-> lavf *is* useful.

The only "hacky state" comes from the useless split of the libraries.

>   And it would help the
> project a lot if you could be a tiny bit less aggressive and dismissive of
> other people's personal opinions.

Anton is dismissive of other people's efforts — not just opinions — yet
you said him nothing. Double standards.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread James Almer

On 1/25/2021 1:38 PM, Nicolas George wrote:

James Almer (12021-01-25):

Suggestions for alternatives are obviously welcome, if you dislike Anton's
current approach


Simple: if you do not have plans to make it better, leave it alone and
work on something useful.


Solving the hacky state of lavd <-> lavf *is* useful. And it would help 
the project a lot if you could be a tiny bit less aggressive and 
dismissive of other people's personal opinions.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Nicolas George
James Almer (12021-01-25):
> Suggestions for alternatives are obviously welcome, if you dislike Anton's
> current approach

Simple: if you do not have plans to make it better, leave it alone and
work on something useful.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread James Almer

On 1/25/2021 1:18 PM, Nicolas George wrote:

Anton Khirnov (12021-01-25):

My plan is currently to move the sources into a subdirectory of
libavformat/.


If that is all, then no. Please spend your time in more useful manners.
As somebody who maintains parts of libavdevice, I do not want tracking
history made more difficult and brittle, I do not to have to type an
extra path component, and I see no benefit.

In fact, since you dislike libavdevice so much, I suggest you add
--disable-avdevice to your configure line, and let the people who do not
hate it work on it in peace.

Thanks in advance.


It being within a subfolder or directly in libavformat's root is 
secondary, really.
Suggestions for alternatives are obviously welcome, if you dislike 
Anton's current approach (admittedly, it reminds me a bit of libmpcodecs 
within libavfilter).

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] libavdevice: Add KMS/DRM output device

2021-01-25 Thread Nicolas George
Anton Khirnov (12021-01-23):
> But does anyone use anything else than ffmpeg.c for that?
> 
> The question here is not whether this functionality should exist at all,
> but whether libavdevice/libavformat is the right place for it.

If something is useful in ffmpeg.c, then it is likely to be useful in
other projects as well. Projects that we do not know about.

All complex features should be in libraries, the fftools should be
minimalistic interfaces.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Nicolas George
Anton Khirnov (12021-01-25):
> My plan is currently to move the sources into a subdirectory of
> libavformat/.

If that is all, then no. Please spend your time in more useful manners.
As somebody who maintains parts of libavdevice, I do not want tracking
history made more difficult and brittle, I do not to have to type an
extra path component, and I see no benefit.

In fact, since you dislike libavdevice so much, I suggest you add
--disable-avdevice to your configure line, and let the people who do not
hate it work on it in peace.

Thanks in advance.

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread Lynne
Jan 25, 2021, 16:39 by jamr...@gmail.com:

> On 1/25/2021 12:35 PM, Lynne wrote:
>
>> Jan 25, 2021, 12:03 by nicolas.gaullier@cji.paris:
>>
 De : ffmpeg-devel  De la part de Paul B 
 Mahol
 Envoyé : jeudi 21 janvier 2021 13:36
 À : FFmpeg development discussions and patches 
 Objet : Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser



 Changes looks trivial enough.

>>>
>>> If no one object, the two patches may be applied now ? I can rebase to make 
>>> it straightforward.
>>> Thank you,
>>> Nicolas
>>>
>>
>> Any objections to renaming dolby_edec.h to dolby_e_tab?
>> It's what it is.
>>
>
> Look at my patch if you can. I moved them to the decoder header.
>
> They could even be moved to dolby_e.c since that's the only user of such 
> tables.
>

Yeah, I just noticed your patch, was looking through the oldest emails
first (tons of emails today on the ML).
It's fine. LGTM.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread James Almer

On 1/25/2021 12:35 PM, Lynne wrote:

Jan 25, 2021, 12:03 by nicolas.gaullier@cji.paris:


De : ffmpeg-devel  De la part de Paul B Mahol
Envoyé : jeudi 21 janvier 2021 13:36
À : FFmpeg development discussions and patches 
Objet : Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser





Changes looks trivial enough.


If no one object, the two patches may be applied now ? I can rebase to make it 
straightforward.
Thank you,
Nicolas



Any objections to renaming dolby_edec.h to dolby_e_tab?
It's what it is.


Look at my patch if you can. I moved them to the decoder header.

They could even be moved to dolby_e.c since that's the only user of such 
tables.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread Lynne
Jan 25, 2021, 12:03 by nicolas.gaullier@cji.paris:

> >De : ffmpeg-devel  De la part de Paul B 
> >Mahol
> >Envoyé : jeudi 21 janvier 2021 13:36
> >À : FFmpeg development discussions and patches 
> >Objet : Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser
>
>>
>>
> >Changes looks trivial enough.
>
> If no one object, the two patches may be applied now ? I can rebase to make 
> it straightforward.
> Thank you,
> Nicolas
>

Any objections to renaming dolby_edec.h to dolby_e_tab?
It's what it is.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/aac_ac3_parser: fix channel information parsing

2021-01-25 Thread Piotr Uracz
Fixes bug https://trac.ffmpeg.org/ticket/7372

Summary of the bug:
When ffmpeg is compiled with ac3 decoder disabled
ffmpeg is unable to extract channel information from ts file.
---
 libavcodec/aac_ac3_parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index e5d4b53339..e84d30aea2 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -89,7 +89,7 @@ get_next:
the frame). */
 if (avctx->codec_id != AV_CODEC_ID_AAC) {
 avctx->sample_rate = s->sample_rate;
-if (avctx->codec_id != AV_CODEC_ID_EAC3) {
+if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
 avctx->channels = s->channels;
 avctx->channel_layout = s->channel_layout;
 }
@@ -99,7 +99,7 @@ get_next:

 /* Calculate the average bit rate */
 s->frame_number++;
-if (avctx->codec_id != AV_CODEC_ID_EAC3) {
+if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
 avctx->bit_rate +=
 (s->bit_rate - avctx->bit_rate) / s->frame_number;
 }
--
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/dashdec: Avoid segfault when URL template is unexpectedly missing

2021-01-25 Thread sfan5

This isn't supposed to happen, but unfinished support for non-templated
manifests and lack of e.g. presentationTimeOffset handling can provoke
such a situation even with well-formed input.
---
 libavformat/dashdec.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index dc56e89f11..c4e6c3da16 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1625,8 +1625,15 @@ static struct fragment 
*get_current_fragment(struct representation *pls)

 }
 }
 if (seg) {
-char *tmpfilename= av_mallocz(c->max_url_size);
+char *tmpfilename;
+if (!pls->url_template) {
+av_log(pls->parent, AV_LOG_ERROR, "Cannot get fragment, 
missing template URL\n");

+av_free(seg);
+return NULL;
+}
+tmpfilename = av_mallocz(c->max_url_size);
 if (!tmpfilename) {
+av_free(seg);
 return NULL;
 }
 ff_dash_fill_tmpl_params(tmpfilename, c->max_url_size, 
pls->url_template, 0, pls->cur_seq_no, 0, 
get_segment_start_time_based_on_timeline(pls, pls->cur_seq_no));
@@ -1637,6 +1644,7 @@ static struct fragment 
*get_current_fragment(struct representation *pls)

 if (!seg->url) {
 av_log(pls->parent, AV_LOG_ERROR, "Cannot resolve 
template url '%s'\n", pls->url_template);

 av_free(tmpfilename);
+av_free(seg);
 return NULL;
 }
 }
--
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avformat/dashdec: Fix missing NULL check

2021-01-25 Thread sfan5

---
 libavformat/dashdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 693fc7372b..dc56e89f11 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -161,7 +161,7 @@ typedef struct DASHContext {
 static int ishttp(char *url)
 {
 const char *proto_name = avio_find_protocol_name(url);
-return av_strstart(proto_name, "http", NULL);
+return proto_name && av_strstart(proto_name, "http", NULL);
 }
  static int aligned(int val)
--
2.30.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 0/9] add vvc raw demuxer, muxer, parser, metadata bsf

2021-01-25 Thread Nuo Mi
On Mon, Jan 25, 2021 at 10:16 PM Nuo Mi  wrote:

> Major Changes since v3:
> Test 61 more new clips from VTM 11, all passed the passthrough test.
> Add and test VPS.
> Use the new SEI framework.
> Use the new CBSBSFContext base class
>
One more: detect au start in vvc_metadata filter.

>
> Misc changes:
> Make h266_ceil as inline function
> Infer vui when it's not existed.
> Infer vui_chroma_sample_loc_type_frame
> Remove sps_subpic, tile_info, and slice_info function
> Ignore value in reserved bits
> Change VVC_MAX_TILE_ROWS to VVC_MAX_TILES_PER_AU
> Change get_bits_count/put_bits_count to bit_position
> Replace VVC_MAX_PLANES with MAX_SAMPLE_ARRAYS
>
> Nuo Mi (9):
>   avcodec/vvc: add shared header for vvc
>   avformat: add vvc raw demux
>   avcodec: add SEI enum for vvc
>   avcodec: add cbs for h266/vvc
>   avcodec/h2645_parse: add nal header parser for h266/vvc
>   avcodec: add vvc parser
>   avformat: add h266/vvc muxer
>   avcodec/cbs_h2645: vvc, do not skip nals for nuh_layer_id > 0
>   avcodec: add vvc metadata bsf
>
>  configure |4 +
>  libavcodec/Makefile   |3 +
>  libavcodec/bitstream_filters.c|1 +
>  libavcodec/cbs.c  |6 +
>  libavcodec/cbs_h2645.c|  425 +++-
>  libavcodec/cbs_h266.h |  812 +++
>  libavcodec/cbs_h266_syntax_template.c | 3006 +
>  libavcodec/cbs_internal.h |3 +-
>  libavcodec/cbs_sei.c  |   29 +
>  libavcodec/h2645_parse.c  |   74 +-
>  libavcodec/h266_metadata_bsf.c|  227 ++
>  libavcodec/parsers.c  |1 +
>  libavcodec/vvc.h  |  142 ++
>  libavcodec/vvc_parser.c   |  299 +++
>  libavcodec/vvc_sei.h  |   47 +
>  libavformat/Makefile  |2 +
>  libavformat/allformats.c  |2 +
>  libavformat/rawenc.c  |   25 +
>  libavformat/vvcdec.c  |   61 +
>  19 files changed, 5163 insertions(+), 6 deletions(-)
>  create mode 100644 libavcodec/cbs_h266.h
>  create mode 100644 libavcodec/cbs_h266_syntax_template.c
>  create mode 100644 libavcodec/h266_metadata_bsf.c
>  create mode 100644 libavcodec/vvc.h
>  create mode 100644 libavcodec/vvc_parser.c
>  create mode 100644 libavcodec/vvc_sei.h
>  create mode 100644 libavformat/vvcdec.c
>
> --
> 2.25.1
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: split decoder and parser more thoroughly

2021-01-25 Thread Paul B Mahol
Probably OK idea, but wait maybe for others few hours.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/dolby_e: split decoder and parser more thoroughly

2021-01-25 Thread James Almer
Neither module should depend on the other, so move shared functions to their
own file for this purpose, and ensure source files are compiled only when the
required modules are enabled.

dolby_e.c/h - Decoder only functions, tables and structures.
dolby_e_parser.c - Parser only functions, tables and structures.
dolby_e_parse.c/h - Shared functions, tables and structures.

Signed-off-by: James Almer 
---
 libavcodec/Makefile   |   4 +-
 libavcodec/dolby_e.c  |   3 +-
 libavcodec/dolby_e.h  | 625 --
 libavcodec/dolby_e_parse.c| 181 +
 ...by_e_parser_internal.h => dolby_e_parse.h} |  68 +-
 libavcodec/dolby_e_parser.c   | 164 +
 libavcodec/dolby_e_parser.h   |  41 --
 libavcodec/dolby_edec.h   | 607 -
 8 files changed, 828 insertions(+), 865 deletions(-)
 create mode 100644 libavcodec/dolby_e_parse.c
 rename libavcodec/{dolby_e_parser_internal.h => dolby_e_parse.h} (50%)
 delete mode 100644 libavcodec/dolby_e_parser.h
 delete mode 100644 libavcodec/dolby_edec.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 633ebc37f8..4e9755e8ce 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -40,7 +40,6 @@ OBJS = ac3_parser.o   
  \
d3d11va.o\
decode.o \
dirac.o  \
-   dolby_e_parser.o \
dv_profile.o \
encode.o \
imgconvert.o \
@@ -286,7 +285,7 @@ OBJS-$(CONFIG_DIRAC_DECODER)   += diracdec.o 
dirac.o diracdsp.o diractab
 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
 OBJS-$(CONFIG_DNXHD_DECODER)   += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += dnxhdenc.o dnxhddata.o
-OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o kbdwin.o
+OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o kbdwin.o dolby_e_parse.o
 OBJS-$(CONFIG_DPX_DECODER) += dpx.o
 OBJS-$(CONFIG_DPX_ENCODER) += dpxenc.o
 OBJS-$(CONFIG_DSD_LSBF_DECODER)+= dsddec.o dsd.o
@@ -1087,6 +1086,7 @@ OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
 OBJS-$(CONFIG_DCA_PARSER)  += dca_parser.o dca_exss.o dca.o
 OBJS-$(CONFIG_DIRAC_PARSER)+= dirac_parser.o
 OBJS-$(CONFIG_DNXHD_PARSER)+= dnxhd_parser.o dnxhddata.o
+OBJS-$(CONFIG_DOLBY_E_PARSER)  += dolby_e_parser.o dolby_e_parse.o
 OBJS-$(CONFIG_DPX_PARSER)  += dpx_parser.o
 OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index 74388f43d1..35b63e672a 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -28,8 +28,7 @@
 #include "put_bits.h"
 #include "parser.h"
 #include "dolby_e.h"
-#include "dolby_edec.h"
-#include "dolby_e_parser_internal.h"
+#include "dolby_e_parse.h"
 #include "fft.h"
 
 static int skip_input(DBEContext *s, int nb_words)
diff --git a/libavcodec/dolby_e.h b/libavcodec/dolby_e.h
index 855d978bc2..4e5ac161d3 100644
--- a/libavcodec/dolby_e.h
+++ b/libavcodec/dolby_e.h
@@ -21,65 +21,588 @@
 #ifndef AVCODEC_DOLBY_E_H
 #define AVCODEC_DOLBY_E_H
 
+#include "libavutil/float_dsp.h"
+#include "libavutil/libm.h"
+#include "libavutil/mem_internal.h"
+
+#include "internal.h"
+#include "dolby_e_parse.h"
 #include "get_bits.h"
+#include "kbdwin.h"
+#include "fft.h"
 
-#define FRAME_SAMPLES   1792
+#define MAX_SEGMENTS2
 
-#define MAX_PROG_CONF   23
-#define MAX_PROGRAMS8
-#define MAX_CHANNELS8
+#define MAX_GROUPS  8
+#define MAX_EXPONENTS   304
+#define MAX_MANTISSAS   1024
 
-/**
- * @struct DBEContext
- * Dolby E reading context used by decoder and parser.
- */
-typedef struct DBEContext {
-void*avctx;
-GetBitContext   gb;
+#define MAX_MSTR_EXP2
+#define MAX_BIAS_EXP50
 
-const uint8_t *input;
-int input_size;
+typedef struct DBEGroup {
+uint8_t nb_exponent;
+uint8_t nb_bias_exp[MAX_MSTR_EXP];
+uint16_texp_ofs;
+uint16_tmnt_ofs;
+const uint8_t   *nb_mantissa;
+uint8_t imdct_idx;
+uint8_t imdct_phs;
+uint16_twin_len;
+uint16_tdst_ofs;
+uint16_twin_ofs;
+uint16_tsrc_ofs;
+} DBEGroup;
 
-int word_bits;
-int word_bytes;
-int key_present;
+typedef struct DBEChannel {
+int gr_code;
+int bw_code;
 
-uint8_t buffer[1024 * 3 + 

[FFmpeg-devel] [PATCH v4 1/9] avcodec/vvc: add shared header for vvc

2021-01-25 Thread Nuo Mi
---
 libavcodec/vvc.h | 142 +++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/vvc.h

diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
new file mode 100644
index 00..ca15297d7a
--- /dev/null
+++ b/libavcodec/vvc.h
@@ -0,0 +1,142 @@
+/*
+ * VVC shared code
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VVC_H
+#define AVCODEC_VVC_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (tiles_enabled_flag and
+// entropy_coding_sync_enabled_flag are both set), entry points can be
+// placed at the beginning of every Ctb row in every tile, giving an
+// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1.
+// Only a 

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/dolby_e: Split decoder/parser files

2021-01-25 Thread James Almer

On 1/25/2021 10:24 AM, James Almer wrote:

On 1/25/2021 9:11 AM, Nicolas Gaullier wrote:

---
  libavcodec/Makefile  |   1 +
  libavcodec/dolby_e.c | 149 +--
  libavcodec/dolby_e.h | 598 +-
  libavcodec/dolby_e_parser.c  | 227 ++
  libavcodec/dolby_e_parser.h  |  41 ++
  libavcodec/dolby_e_parser_internal.h |  46 ++
  libavcodec/dolby_edec.h  | 607 +++
  7 files changed, 932 insertions(+), 737 deletions(-)
  create mode 100644 libavcodec/dolby_e_parser.c
  create mode 100644 libavcodec/dolby_e_parser.h
  create mode 100644 libavcodec/dolby_e_parser_internal.h
  create mode 100644 libavcodec/dolby_edec.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d48fecc5fc..633ebc37f8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -40,6 +40,7 @@ OBJS = 
ac3_parser.o \
 
d3d11va.o    \
 
decode.o \
 
dirac.o  \
+   
dolby_e_parser.o \


Don't compile it unconditionally.

 
dv_profile.o \
 
encode.o \
 
imgconvert.o \


[...]


diff --git a/libavcodec/dolby_e_parser.h b/libavcodec/dolby_e_parser.h
new file mode 100644
index 00..2f9a2b2ebb
--- /dev/null
+++ b/libavcodec/dolby_e_parser.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 foo86
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
02110-1301 USA

+ */
+
+#ifndef AVCODEC_DOLBY_E_PARSER_H
+#define AVCODEC_DOLBY_E_PARSER_H
+
+#include "dolby_e.h"
+
+typedef struct DBEParseContext {
+    ParseContext pc;
+    DBEContext dectx;
+
+    DolbyEHeaderInfo metadata;
+} DBEParseContext;
+
+static const uint8_t nb_programs_tab[MAX_PROG_CONF + 1] = {
+    2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 1, 2, 3, 3, 4, 5, 6, 1, 2, 3, 4, 
1, 1

+};
+
+static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = {
+    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 
8, 8

+};


This header doesn't seem to be needed at all. Just add the struct and 
both arrays to dolby_e_parser.c



+
+#endif
diff --git a/libavcodec/dolby_e_parser_internal.h 
b/libavcodec/dolby_e_parser_internal.h

new file mode 100644
index 00..defd1f97d6
--- /dev/null
+++ b/libavcodec/dolby_e_parser_internal.h


This name is odd, as it implies the other header is public, which is not.
Try to follow instead what codecs like h264, hevc, and mlp do. There's 
the decoder, the parser, and then a separate source file that is shared 
by both. That way, neither the decoder or parser depend on each other.


dolby_e.c/h - Decoder only functions, tables and structures. Compiled 
when the decoder is enabled.
dolby_e_parser.c - Parser only functions, tables and structures. 
Compiled when the parser is enabled.
dolby_e_parse.c/h - Shared functions, tables and structures. Compiled 
when either decoder or parser are enabled.


I see Paul pushed this set already, so i figured I'd just go ahead and 
implement the above myself. Will send it in a minute.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 8/9] avcodec/cbs_h2645: vvc, do not skip nals for nuh_layer_id > 0

2021-01-25 Thread Nuo Mi
On Mon, Jan 25, 2021 at 10:17 PM Nuo Mi  wrote:

> ---
>  libavcodec/cbs_h2645.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 6f3abf6b0b..da541407cf 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -494,8 +494,9 @@ static int
> cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
>  const H2645NAL *nal = >nals[i];
>  AVBufferRef *ref;
>  size_t size = nal->size;
> +enum AVCodecID codec_id = ctx->codec->codec_id;
>
> -if (nal->nuh_layer_id > 0)
> +if (codec_id != AV_CODEC_ID_VVC && nal->nuh_layer_id > 0)
>
Hi Mark,
Could you explain why we need this for other codecs?
thanks

>  continue;
>
>  // Remove trailing zeroes.
> --
> 2.25.1
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 3/9] avcodec: add SEI enum for vvc

2021-01-25 Thread Nuo Mi
---
 libavcodec/vvc_sei.h | 47 
 1 file changed, 47 insertions(+)
 create mode 100644 libavcodec/vvc_sei.h

diff --git a/libavcodec/vvc_sei.h b/libavcodec/vvc_sei.h
new file mode 100644
index 00..90724669de
--- /dev/null
+++ b/libavcodec/vvc_sei.h
@@ -0,0 +1,47 @@
+/*
+ * H.266/VVC Supplementary Enhancement Information messages
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VVC_SEI_H
+#define AVCODEC_VVC_SEI_H
+
+/**
+ * SEI message types
+ */
+typedef enum {
+VVC_SEI_TYPE_BUFFERING_PERIOD = 0,
+VVC_SEI_TYPE_PICTURE_TIMING   = 1,
+VVC_SEI_TYPE_PAN_SCAN_RECT= 2,
+VVC_SEI_TYPE_FILLER_PAYLOAD   = 3,
+VVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35   = 4,
+VVC_SEI_TYPE_USER_DATA_UNREGISTERED   = 5,
+VVC_SEI_TYPE_FILM_GRAIN_CHARACTERISTICS   = 19,
+VVC_SEI_TYPE_FRAME_PACKING= 45,
+VVC_SEI_TYPE_PARAMETER_SETS_INCLUSION_INDICATION  = 129,
+VVC_SEI_TYPE_DECODING_UNIT_INFO   = 130,
+VVC_SEI_TYPE_DECODED_PICTURE_HASH = 132,
+VVC_SEI_TYPE_SCALABLE_NESTING = 133,
+VVC_SEI_TYPE_REGION_REFRESH_INFO  = 134,
+VVC_SEI_TYPE_TIME_CODE= 136,
+VVC_SEI_TYPE_MASTERING_DISPLAY_INFO   = 137,
+VVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
+VVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
+} VVC_SEI_Type;
+
+#endif /* AVCODEC_VVC_SEI_H */
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 0/9] add vvc raw demuxer, muxer, parser, metadata bsf

2021-01-25 Thread Nuo Mi
Major Changes since v3:
Test 61 more new clips from VTM 11, all passed the passthrough test.
Add and test VPS.
Use the new SEI framework.
Use the new CBSBSFContext base class

Misc changes:
Make h266_ceil as inline function
Infer vui when it's not existed.
Infer vui_chroma_sample_loc_type_frame
Remove sps_subpic, tile_info, and slice_info function
Ignore value in reserved bits
Change VVC_MAX_TILE_ROWS to VVC_MAX_TILES_PER_AU
Change get_bits_count/put_bits_count to bit_position
Replace VVC_MAX_PLANES with MAX_SAMPLE_ARRAYS

Nuo Mi (9):
  avcodec/vvc: add shared header for vvc
  avformat: add vvc raw demux
  avcodec: add SEI enum for vvc
  avcodec: add cbs for h266/vvc
  avcodec/h2645_parse: add nal header parser for h266/vvc
  avcodec: add vvc parser
  avformat: add h266/vvc muxer
  avcodec/cbs_h2645: vvc, do not skip nals for nuh_layer_id > 0
  avcodec: add vvc metadata bsf

 configure |4 +
 libavcodec/Makefile   |3 +
 libavcodec/bitstream_filters.c|1 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  425 +++-
 libavcodec/cbs_h266.h |  812 +++
 libavcodec/cbs_h266_syntax_template.c | 3006 +
 libavcodec/cbs_internal.h |3 +-
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   74 +-
 libavcodec/h266_metadata_bsf.c|  227 ++
 libavcodec/parsers.c  |1 +
 libavcodec/vvc.h  |  142 ++
 libavcodec/vvc_parser.c   |  299 +++
 libavcodec/vvc_sei.h  |   47 +
 libavformat/Makefile  |2 +
 libavformat/allformats.c  |2 +
 libavformat/rawenc.c  |   25 +
 libavformat/vvcdec.c  |   61 +
 19 files changed, 5163 insertions(+), 6 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/vvc.h
 create mode 100644 libavcodec/vvc_parser.c
 create mode 100644 libavcodec/vvc_sei.h
 create mode 100644 libavformat/vvcdec.c

-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 9/9] avcodec: add vvc metadata bsf

2021-01-25 Thread Nuo Mi
use following command to test:
ffmpeg -i in.bin  -c:v copy -bsf vvc_metadata -f vvc out.bin

94.51%(293/310) can bit match with original clips
5.48%(17/310) are not bit match, the original clips has redundant emulation 
prevent bytes
---
 configure  |   1 +
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/h266_metadata_bsf.c | 227 +
 4 files changed, 230 insertions(+)
 create mode 100644 libavcodec/h266_metadata_bsf.c

diff --git a/configure b/configure
index 74ff58d7b7..cea5a00119 100755
--- a/configure
+++ b/configure
@@ -3184,6 +3184,7 @@ mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
 trace_headers_bsf_select="cbs"
 vp9_metadata_bsf_select="cbs_vp9"
+vvc_metadata_bsf_select="cbs_h266"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e736c8300a..1b90d61a26 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1169,6 +1169,7 @@ OBJS-$(CONFIG_VP9_METADATA_BSF)   += 
vp9_metadata_bsf.o
 OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
+OBJS-$(CONFIG_VVC_METADATA_BSF)   += h266_metadata_bsf.o
 
 # thread libraries
 OBJS-$(HAVE_LIBC_MSVCRT)   += file_open.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index b26d6a910e..001a7bb3a4 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -60,6 +60,7 @@ extern const AVBitStreamFilter ff_vp9_metadata_bsf;
 extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf;
 extern const AVBitStreamFilter ff_vp9_superframe_bsf;
 extern const AVBitStreamFilter ff_vp9_superframe_split_bsf;
+extern const AVBitStreamFilter ff_vvc_metadata_bsf;
 
 #include "libavcodec/bsf_list.c"
 
diff --git a/libavcodec/h266_metadata_bsf.c b/libavcodec/h266_metadata_bsf.c
new file mode 100644
index 00..1a93aa7e26
--- /dev/null
+++ b/libavcodec/h266_metadata_bsf.c
@@ -0,0 +1,227 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_bsf.h"
+#include "cbs_h266.h"
+#include "vvc.h"
+
+#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= 
VVC_GDR_NUT))
+#define IS_IDR(nut) (nut == VVC_IDR_W_RADL || nut == VVC_IDR_N_LP)
+
+typedef struct VVCMetadataContext {
+CBSBSFContext common;
+
+H266RawAUD aud_nal;
+
+int aud;
+
+uint8_t prev_layer_id;
+int prev_tid0_poc;
+int prev_poc;
+} VVCMetadataContext;
+
+//8.3.1 Decoding process for picture order count.
+//VTM did not follow the spec, and it's much simpler than spec.
+//We follow the VTM.
+static int get_slice_poc(AVBSFContext *bsf, const H266RawPH *ph,
+ const H266RawSliceHeader *slice, int *poc)
+{
+VVCMetadataContext *ctx = bsf->priv_data;
+CodedBitstreamH266Context *h266 = ctx->common.input->priv_data;
+int poc_msb, max_poc_lsb, poc_lsb;
+const H266RawSPS* sps = h266->active_sps;
+
+if (!sps) {
+av_log(bsf, AV_LOG_ERROR, "no pps for pu.\n");
+return AVERROR_INVALIDDATA;
+}
+
+max_poc_lsb = 1 << (sps->sps_log2_max_pic_order_cnt_lsb_minus4 + 4);
+poc_lsb = ph->ph_pic_order_cnt_lsb;
+if (IS_IDR(slice->nal_unit_header.nal_unit_type)) {
+if (ph->ph_poc_msb_cycle_present_flag)
+poc_msb = ph->ph_poc_msb_cycle_val * max_poc_lsb;
+else
+poc_msb = 0;
+} else {
+int prev_poc = ctx->prev_tid0_poc;
+int prev_poc_lsb = prev_poc & (max_poc_lsb - 1);
+int prev_poc_msb = prev_poc - prev_poc_lsb;
+if (ph->ph_poc_msb_cycle_present_flag) {
+ poc_msb = ph->ph_poc_msb_cycle_val * max_poc_lsb;
+} else {
+if ((poc_lsb < prev_poc_lsb) && ((prev_poc_lsb - poc_lsb) >= 
(max_poc_lsb / 2)))
+poc_msb = prev_poc_msb + max_poc_lsb;
+else if ((poc_lsb > prev_poc_lsb) && ((poc_lsb - prev_poc_lsb) > 
(max_poc_lsb / 2)))
+   

[FFmpeg-devel] [PATCH v4 8/9] avcodec/cbs_h2645: vvc, do not skip nals for nuh_layer_id > 0

2021-01-25 Thread Nuo Mi
---
 libavcodec/cbs_h2645.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 6f3abf6b0b..da541407cf 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -494,8 +494,9 @@ static int 
cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
 const H2645NAL *nal = >nals[i];
 AVBufferRef *ref;
 size_t size = nal->size;
+enum AVCodecID codec_id = ctx->codec->codec_id;
 
-if (nal->nuh_layer_id > 0)
+if (codec_id != AV_CODEC_ID_VVC && nal->nuh_layer_id > 0)
 continue;
 
 // Remove trailing zeroes.
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 7/9] avformat: add h266/vvc muxer

2021-01-25 Thread Nuo Mi
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/rawenc.c | 25 +
 3 files changed, 27 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 4a5406da38..0253aa7d5a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -564,6 +564,7 @@ OBJS-$(CONFIG_VPK_DEMUXER)   += vpk.o
 OBJS-$(CONFIG_VPLAYER_DEMUXER)   += vplayerdec.o subtitles.o
 OBJS-$(CONFIG_VQF_DEMUXER)   += vqf.o
 OBJS-$(CONFIG_VVC_DEMUXER)   += vvcdec.o rawdec.o
+OBJS-$(CONFIG_VVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_W64_DEMUXER)   += wavdec.o w64.o pcm.o
 OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o
 OBJS-$(CONFIG_WAV_DEMUXER)   += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index a2182e0603..2ec3eeda7b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -463,6 +463,7 @@ extern AVInputFormat  ff_vpk_demuxer;
 extern AVInputFormat  ff_vplayer_demuxer;
 extern AVInputFormat  ff_vqf_demuxer;
 extern AVInputFormat  ff_vvc_demuxer;
+extern AVOutputFormat ff_vvc_muxer;
 extern AVInputFormat  ff_w64_demuxer;
 extern AVOutputFormat ff_w64_muxer;
 extern AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 32704f9bfd..5eb95f069c 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -372,6 +372,31 @@ AVOutputFormat ff_hevc_muxer = {
 };
 #endif
 
+#if CONFIG_VVC_MUXER
+static int vvc_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+{
+if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
+  AV_RB24(pkt->data) != 0x01) {
+//TODO: fixed this after vvc codec defined in http://mp4ra.org/#/codecs
+av_log(s, AV_LOG_ERROR, "vvc: mp4 to annexb is not supported\n");
+return AVERROR_PATCHWELCOME;
+}
+return 1;
+}
+
+AVOutputFormat ff_vvc_muxer = {
+.name  = "vvc",
+.long_name = NULL_IF_CONFIG_SMALL("raw VVC video"),
+.extensions= "hevc,h266,266",
+.audio_codec   = AV_CODEC_ID_NONE,
+.video_codec   = AV_CODEC_ID_VVC,
+.write_header  = force_one_stream,
+.write_packet  = ff_raw_write_packet,
+.check_bitstream   = vvc_check_bitstream,
+.flags = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_M4V_MUXER
 AVOutputFormat ff_m4v_muxer = {
 .name  = "m4v",
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 5/9] avcodec/h2645_parse: add nal header parser for h266/vvc

2021-01-25 Thread Nuo Mi
---
 libavcodec/h2645_parse.c | 74 ++--
 1 file changed, 71 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index a36ef4f5a0..35f9d035a9 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -1,5 +1,5 @@
 /*
- * H.264/HEVC common parsing code
+ * H.264/HEVC/VVC common parsing code
  *
  * This file is part of FFmpeg.
  *
@@ -27,6 +27,7 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
+#include "vvc.h"
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
@@ -146,6 +147,47 @@ nsc:
 return si;
 }
 
+static const char *const vvc_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *vvc_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return vvc_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -289,6 +331,31 @@ static int get_bit_length(H2645NAL *nal, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = >gb;
+
+if (get_bits1(gb) != 0) //forbidden_zero_bit
+return AVERROR_INVALIDDATA;
+
+skip_bits1(gb); //nuh_reserved_zero_bit
+
+nal->nuh_layer_id = get_bits(gb, 6);
+nal->type = get_bits(gb, 5);
+nal->temporal_id = get_bits(gb, 3) - 1;
+if (nal->temporal_id < 0)
+return AVERROR_INVALIDDATA;
+
+if ((nal->type >= VVC_IDR_W_RADL && nal->type <= VVC_RSV_IRAP_11) && 
nal->temporal_id)
+return AVERROR_INVALIDDATA;
+
+av_log(logctx, AV_LOG_DEBUG,
+  "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
+   nal->type, vvc_nal_unit_name(nal->type), nal->nuh_layer_id, 
nal->temporal_id);
+
+return 0;
+}
+
 static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
 {
 GetBitContext *gb = >gb;
@@ -503,8 +570,9 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t 
*buf, int length,
 
 /* Reset type in case it contains a stale value from a previously 
parsed NAL */
 nal->type = 0;
-
-if (codec_id == AV_CODEC_ID_HEVC)
+if (codec_id == AV_CODEC_ID_VVC)
+ret = vvc_parse_nal_header(nal, logctx);
+else if (codec_id == AV_CODEC_ID_HEVC)
 ret = hevc_parse_nal_header(nal, logctx);
 else
 ret = h264_parse_nal_header(nal, logctx);
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 6/9] avcodec: add vvc parser

2021-01-25 Thread Nuo Mi
---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/parsers.c|   1 +
 libavcodec/vvc_parser.c | 299 
 4 files changed, 302 insertions(+)
 create mode 100644 libavcodec/vvc_parser.c

diff --git a/configure b/configure
index d55cd0a79e..74ff58d7b7 100755
--- a/configure
+++ b/configure
@@ -3167,6 +3167,7 @@ mpegaudio_parser_select="mpegaudioheader"
 mpegvideo_parser_select="mpegvideo"
 mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
 vc1_parser_select="vc1dsp"
+vcc_parser_select="cbs_h266"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0d7a417180..e736c8300a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1126,6 +1126,7 @@ OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o 
vc1.o vc1data.o  \
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
+OBJS-$(CONFIG_VVC_PARSER)  += vvc_parser.o
 OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o
 OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
 
diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c
index 3156b86b03..9c246165c4 100644
--- a/libavcodec/parsers.c
+++ b/libavcodec/parsers.c
@@ -71,6 +71,7 @@ extern AVCodecParser ff_vorbis_parser;
 extern AVCodecParser ff_vp3_parser;
 extern AVCodecParser ff_vp8_parser;
 extern AVCodecParser ff_vp9_parser;
+extern AVCodecParser ff_vvc_parser;
 extern AVCodecParser ff_webp_parser;
 extern AVCodecParser ff_xma_parser;
 
diff --git a/libavcodec/vvc_parser.c b/libavcodec/vvc_parser.c
new file mode 100644
index 00..b160ef9426
--- /dev/null
+++ b/libavcodec/vvc_parser.c
@@ -0,0 +1,299 @@
+/*
+ * VVC parser
+ *
+ * Copyright (C) 2029 Nuo Mi 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "cbs.h"
+#include "cbs_h266.h"
+#include "internal.h"
+#include "parser.h"
+
+#define START_CODE 0x01 ///< start_code_prefix_one_3bytes
+
+#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= 
VVC_GDR_NUT))
+
+typedef struct VVCParserContext {
+ParseContext pc;
+CodedBitstreamContext *cbc;
+CodedBitstreamFragment picture_unit;
+int parsed_extradata;
+} VVCParserContext;
+
+static const enum AVPixelFormat pix_fmts_8bit[] = {
+AV_PIX_FMT_GRAY8, AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P
+};
+
+static const enum AVPixelFormat pix_fmts_10bit[] = {
+AV_PIX_FMT_GRAY10, AV_PIX_FMT_YUV420P10,
+AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10
+};
+
+static int get_format(const H266RawSPS* sps)
+{
+switch (sps->sps_bitdepth_minus8) {
+case 0:
+return pix_fmts_8bit[sps->sps_chroma_format_idc];
+case 2:
+return pix_fmts_10bit[sps->sps_chroma_format_idc];
+}
+return AV_PIX_FMT_NONE;
+}
+
+/**
+ * Find the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or END_NOT_FOUND
+ */
+static int find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
+   int buf_size)
+{
+VVCParserContext *ctx = s->priv_data;
+ParseContext   *pc = >pc;
+int i;
+
+for (i = 0; i < buf_size; i++) {
+int nut;
+
+pc->state64 = (pc->state64 << 8) | buf[i];
+
+if (((pc->state64 >> 3 * 8) & 0xFF) != START_CODE)
+continue;
+
+nut = (pc->state64 >> (8 + 3)) & 0x1F;
+// Beginning of picture unit
+if ((nut >= VVC_OPI_NUT && nut <= VVC_EOB_NUT && nut != VVC_PH_NUT) ||
+nut == VVC_PREFIX_SEI_NUT ||
+(nut >= VVC_RSV_NVCL_26 && nut <= VVC_UNSPEC_31)) {
+if (pc->frame_start_found) {
+pc->frame_start_found = 0;
+return i - 5;
+}
+} else if (nut == VVC_PH_NUT  || IS_SLICE(nut)) {
+int sh_picture_header_in_slice_header_flag = buf[i] >> 7;
+
+if (nut == VVC_PH_NUT || sh_picture_header_in_slice_header_flag) {
+if (!pc->frame_start_found) {
+pc->frame_start_found = 1;
+} else { // First slice of next 

[FFmpeg-devel] [PATCH v4 2/9] avformat: add vvc raw demux

2021-01-25 Thread Nuo Mi
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/vvcdec.c | 61 
 3 files changed, 63 insertions(+)
 create mode 100644 libavformat/vvcdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 3a8fbcbe5f..4a5406da38 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -563,6 +563,7 @@ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o
 OBJS-$(CONFIG_VPK_DEMUXER)   += vpk.o
 OBJS-$(CONFIG_VPLAYER_DEMUXER)   += vplayerdec.o subtitles.o
 OBJS-$(CONFIG_VQF_DEMUXER)   += vqf.o
+OBJS-$(CONFIG_VVC_DEMUXER)   += vvcdec.o rawdec.o
 OBJS-$(CONFIG_W64_DEMUXER)   += wavdec.o w64.o pcm.o
 OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o
 OBJS-$(CONFIG_WAV_DEMUXER)   += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6990af55f4..a2182e0603 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -462,6 +462,7 @@ extern AVOutputFormat ff_voc_muxer;
 extern AVInputFormat  ff_vpk_demuxer;
 extern AVInputFormat  ff_vplayer_demuxer;
 extern AVInputFormat  ff_vqf_demuxer;
+extern AVInputFormat  ff_vvc_demuxer;
 extern AVInputFormat  ff_w64_demuxer;
 extern AVOutputFormat ff_w64_muxer;
 extern AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/vvcdec.c b/libavformat/vvcdec.c
new file mode 100644
index 00..149f39f28e
--- /dev/null
+++ b/libavformat/vvcdec.c
@@ -0,0 +1,61 @@
+/*
+ * RAW VVC video demuxer
+ * Copyright (c) 2020 Nuo Mi 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/vvc.h"
+
+#include "avformat.h"
+#include "rawdec.h"
+
+static int vvc_probe(const AVProbeData *p)
+{
+uint32_t code = -1;
+int sps = 0, pps = 0, irap = 0;
+int i;
+
+for (i = 0; i < p->buf_size - 1; i++) {
+code = (code << 8) + p->buf[i];
+if ((code & 0xff00) == 0x100) {
+uint8_t nal2 = p->buf[i + 1];
+int type = (nal2 & 0xF8) >> 3;
+
+if (code & 0xc0) // forbidden_zero_bit and nuh_reserved_zero_bit
+return 0;
+
+if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1
+return 0;
+
+switch (type) {
+case VVC_SPS_NUT:   sps++;  break;
+case VVC_PPS_NUT:   pps++;  break;
+case VVC_IDR_N_LP:
+case VVC_IDR_W_RADL:
+case VVC_CRA_NUT:
+case VVC_GDR_NUT:   irap++; break;
+}
+}
+}
+
+if (sps && pps && irap)
+return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg
+return 0;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(vvc, "raw VVC video", vvc_probe, "h266,266,vvc", 
AV_CODEC_ID_VVC)
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: remove long dead debug_mv code

2021-01-25 Thread Paul B Mahol
LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/dolby_e: Split decoder/parser files

2021-01-25 Thread James Almer

On 1/25/2021 9:11 AM, Nicolas Gaullier wrote:

---
  libavcodec/Makefile  |   1 +
  libavcodec/dolby_e.c | 149 +--
  libavcodec/dolby_e.h | 598 +-
  libavcodec/dolby_e_parser.c  | 227 ++
  libavcodec/dolby_e_parser.h  |  41 ++
  libavcodec/dolby_e_parser_internal.h |  46 ++
  libavcodec/dolby_edec.h  | 607 +++
  7 files changed, 932 insertions(+), 737 deletions(-)
  create mode 100644 libavcodec/dolby_e_parser.c
  create mode 100644 libavcodec/dolby_e_parser.h
  create mode 100644 libavcodec/dolby_e_parser_internal.h
  create mode 100644 libavcodec/dolby_edec.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d48fecc5fc..633ebc37f8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -40,6 +40,7 @@ OBJS = ac3_parser.o   
  \
 d3d11va.o\
 decode.o \
 dirac.o  \
+   dolby_e_parser.o \


Don't compile it unconditionally.


 dv_profile.o \
 encode.o \
 imgconvert.o \


[...]


diff --git a/libavcodec/dolby_e_parser.h b/libavcodec/dolby_e_parser.h
new file mode 100644
index 00..2f9a2b2ebb
--- /dev/null
+++ b/libavcodec/dolby_e_parser.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 foo86
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_DOLBY_E_PARSER_H
+#define AVCODEC_DOLBY_E_PARSER_H
+
+#include "dolby_e.h"
+
+typedef struct DBEParseContext {
+ParseContext pc;
+DBEContext dectx;
+
+DolbyEHeaderInfo metadata;
+} DBEParseContext;
+
+static const uint8_t nb_programs_tab[MAX_PROG_CONF + 1] = {
+2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 1, 2, 3, 3, 4, 5, 6, 1, 2, 3, 4, 1, 1
+};
+
+static const uint8_t nb_channels_tab[MAX_PROG_CONF + 1] = {
+8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8
+};


This header doesn't seem to be needed at all. Just add the struct and 
both arrays to dolby_e_parser.c



+
+#endif
diff --git a/libavcodec/dolby_e_parser_internal.h 
b/libavcodec/dolby_e_parser_internal.h
new file mode 100644
index 00..defd1f97d6
--- /dev/null
+++ b/libavcodec/dolby_e_parser_internal.h


This name is odd, as it implies the other header is public, which is not.
Try to follow instead what codecs like h264, hevc, and mlp do. There's 
the decoder, the parser, and then a separate source file that is shared 
by both. That way, neither the decoder or parser depend on each other.


dolby_e.c/h - Decoder only functions, tables and structures. Compiled 
when the decoder is enabled.
dolby_e_parser.c - Parser only functions, tables and structures. 
Compiled when the parser is enabled.
dolby_e_parse.c/h - Shared functions, tables and structures. Compiled 
when either decoder or parser are enabled.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Issue with ogg page termination on full last page with even last segment size

2021-01-25 Thread Mark Harris
> > I am thinking that it should be safe to not mux any 0 sized packets in 
> > oggenc given that my understanding above is correct. Updated the patch to 
> > reflect that, let me know what you think.

Theora in Ogg uses zero-length packets to repeat the same video frame.

 - Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Issue with ogg page termination on full last page with even last segment size

2021-01-25 Thread Peter Zebühr
Ping

> On 14 Jan 2021, at 18:13, Peter Zebühr  wrote:
> 
> Hi,
> 
> I had a look at different options on how to fix the regression, though I am 
> not sure what I arrived at is what you had in mind. 
> 
> I tried to read up a bit on opus as well and I assume you are talking about 
> the frame length coding allowing coding of zero-byte frames? If so, my 
> understanding is that it would still not be represented as a zero byte length 
> avpacket input to the oggmuxer?
> 
> I looked at how this is handled for flac, as the regression I see is in flac 
> muxed in ogg). There libavcoded/flacenc that is intentionally just setting 
> extradata in the last avpacket on the last block by no payload 
> (packet_size=0). And libavformat/flacenc:flac_write_audio_packet that does 
> not write any audio data if packet size is 0.
> 
> I am thinking that it should be safe to not mux any 0 sized packets in oggenc 
> given that my understanding above is correct. Updated the patch to reflect 
> that, let me know what you think.
> 
> / Peter
> 
> 
> <0001-Fix-ogg-page-termination-on-even-last-packets.patch>___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/utils: reset event_flags if extradata is not extracted correctly

2021-01-25 Thread Anton Khirnov
Quoting Linjie Fu (2021-01-25 04:49:21)
> On Mon, Jan 25, 2021 at 12:49 AM Anton Khirnov  wrote:
> >
> > Quoting Linjie Fu (2021-01-24 16:05:56)
> > > Regression since 87f0c8280.
> > >
> > > If the extradata of a stream could not be extracted correctly,
> > > codec_info_nb_frames would remain zero, while st->event_flag would still
> > > be marked as AVSTREAM_EVENT_FLAG_NEW_PACKETS.
> > >
> > > The two expressions could be different in this case, hence reset
> > > event_flags and calculate the correct score.
> > >
> > > Fix #9029.
> >
> > The ticket mentions ffplay, but ffplay does not access event_flags.
> >
> 
> You are right, this helps ffmpeg cmdline to copy and dump:
> $ ffmpeg -i sample_cut.flv -c copy -y dump.mp4
> 
> Before 87f0c8280 and after this patch:
> 
> audio streams could be dumped and playable, while video streams still not.
> 
> 87f0c8280..master:
> Error reporting and quits.
> 
> [mp4 @ 0x7fb276809a00] dimensions not set
> Could not write header for output file #0 (incorrect codec parameters
> ?): Invalid argument
> Error initializing output stream 0:1 --
> 
> I'd change the commit message to "#9029 related" for this, since the
> ffplay issue remains the same.

I am still not convinced this is really a regression. You can still
process the file by explicitly mapping only the audio stream.

This file is damaged and the video stream is not readable. IMO it is
better to report an error and let the user decide what to do with it
than silently skip the video stream while pretending everything is fine.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter: add shear video filter

2021-01-25 Thread Paul B Mahol
Will apply soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/concatdec: add support for setting input options

2021-01-25 Thread Nicolas George
Jan Ekström (12021-01-25):
> I knew that would be useful, but opted out of it since:
> 1. For now I didn't yet need it.

That is not a good reason.

> 2. I wanted to keep out of the actual playlist parsing code.

I know, file parsing code is not nice. But this is what needs doing.

> 3. Possible security ramifications (since we already have "safe" /
> "unsafe" playlist entries).

You are right, we need to treat options as unsave.

> 
> It is a relatively simple extension yes, if you ignore the points 2/3.
> You have an AVDictionary per file and after initializing the
> AVDictionary in the opening function and applying global input options
> - copy the contents of the per-file options there, too.

Please, no half-baked solution.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavc: shedule old encoding/decoding API for removal

2021-01-25 Thread James Almer

On 1/25/2021 9:40 AM, Anton Khirnov wrote:

It has been deprecated for 4 years and certain new codecs do not work
with it.

Also include AVCodecContext.refcounted_frames, as it has no effect with
the new API.


LGTM, of course.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-01-25 Thread Nicolas George
Jan Ekström (12021-01-25):
> For now I kept them separate since one is just moving Stefano's code,
> and another adds new functionality that you requested.

Stefano's code was good enough for ffprobe, because it had to perform a
very precise task in a very constrained context, but as is, it is not
good enough for lavu, it needs to be adapted.

> I really have no bigger bone with either naming, I just utilized:
> 1. How the XML spec calls the thing ("AttValue" thus becoming
> ATT_VALUE, "CharData" becoming CHAR_DATA). I slightly would prefer to
> keep this due to this making it easy to point towards what is actually
> meant in the XML spec.

CharData is only used a few times in the abstract syntax of the spec, it
will have meaning only for people who are very familiar with it.

> 2. Single and double quotes are the wording that I am more acquainted
> with, but I have no hard opinion so if you want _QUOT/_APOS, sure.

I am fine with "double_quotes" and "single_quotes" or "dquot" and
"squot" too.

> > Outside attributes, " and ' do not need to be quoted.
> 
> I think this is where I'm slightly going out of my comfort zone. This
> is already existing code, and I just moved it out of ffprobe (where it
> was already successfully merged and existed for a while). Additionally
> the expression for char_data does at least reference single quotes. I
> do see the paragraph at the end of 2.4 that notes

Let us take a few steps back.

The spec says:

- < needs to be always escaped;

- ' needs to be escaped when between ';

- " needs to be escaped when between ".

Common sens and good practice say:

- characters that do not need to be escaped should not be escaped.

(With XML, we make an exception for that last rule for >.)

Therefore, we need three modes:

- one mode to use between ';

- one mode to use between ";

- one mode to use outside.

> > To allow attribute values to contain both single and double quotes, the 
> > apostrophe or single-quote character (') may be represented as "", 
> > and the double-quote character (") as ""."
> 
> Of course, which seems specific to attribute values.

> But at this point I'm 50/50 if it makes even sense for me to continue
> this struggle or if this is an unclear message from you to me that I
> should just utilize libxml2, which is already utilized in the DASH
> demuxer. Mostly because there I at least can relatively surely know
> that (probably) not only escaping, but also removal of invalid UTF-8
> might be handled by it (which we currently do not do either with JSON
> or XML output from ffprobe as far as I know). That way also I don't
> have to attempt to be a nice person and attempt to re-utilize existing
> code from ffprobe, nor do I have to touch ffprobe.

libxml2 has a terrible track records in terms of stability, including
security. We should strive to use it less, not more.

For parsers, we currently have no choice, because parsing XML is tricky.
I still intend to finish the limited XML parser that I started
implementing a few years ago, though.

On the other hand, writing good XML is quite easy, and that is what we
should be doing. Your code is almost ready, it just needs a few tweaks.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavc: shedule old encoding/decoding API for removal

2021-01-25 Thread Anton Khirnov
It has been deprecated for 4 years and certain new codecs do not work
with it.

Also include AVCodecContext.refcounted_frames, as it has no effect with
the new API.
---
 libavcodec/avcodec.h   |  6 ++
 libavcodec/decode.c|  8 
 libavcodec/encode.c|  2 ++
 libavcodec/internal.h  |  5 +
 libavcodec/options_table.h |  2 ++
 libavcodec/utils.c | 25 -
 libavcodec/version.h   |  3 +++
 7 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fdb4276260..595bd0e54c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1345,6 +1345,7 @@ typedef struct AVCodecContext {
  */
 int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
 
+#if FF_API_OLD_ENCDEC
 /**
  * If non-zero, the decoded audio and video frames returned from
  * avcodec_decode_video2() and avcodec_decode_audio4() are 
reference-counted
@@ -1360,6 +1361,7 @@ typedef struct AVCodecContext {
  */
 attribute_deprecated
 int refcounted_frames;
+#endif
 
 /* - encoding parameters */
 float qcompress;  ///< amount of qscale change between easy & hard scenes 
(0.0-1.0)
@@ -2982,6 +2984,7 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum 
AVChromaLocation pos);
  */
 enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
 
+#if FF_API_OLD_ENCDEC
 /**
  * Decode the audio frame of size avpkt->size from avpkt->data into frame.
  *
@@ -3088,6 +3091,7 @@ attribute_deprecated
 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
  int *got_picture_ptr,
  const AVPacket *avpkt);
+#endif
 
 /**
  * Decode a subtitle message.
@@ -3625,6 +3629,7 @@ void av_parser_close(AVCodecParserContext *s);
  * @{
  */
 
+#if FF_API_OLD_ENCDEC
 /**
  * Encode a frame of audio.
  *
@@ -3707,6 +3712,7 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket 
*avpkt,
 attribute_deprecated
 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
   const AVFrame *frame, int *got_packet_ptr);
+#endif
 
 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
 const AVSubtitle *sub);
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 9861ead073..8086362eb2 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -221,8 +221,10 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket 
*pkt)
 if (ret < 0)
 goto finish;
 
+#if FF_API_OLD_ENCDEC
 if (avctx->codec->receive_frame)
 avci->compat_decode_consumed += pkt->size;
+#endif
 
 return 0;
 finish:
@@ -469,7 +471,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 
+#if FF_API_OLD_ENCDEC
 avci->compat_decode_consumed += ret;
+#endif
 
 if (ret >= pkt->size || ret < 0) {
 av_packet_unref(pkt);
@@ -693,6 +697,8 @@ int attribute_align_arg 
avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
 return 0;
 }
 
+#if FF_API_OLD_ENCDEC
+FF_DISABLE_DEPRECATION_WARNINGS
 static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
 {
 int ret;
@@ -834,6 +840,8 @@ int attribute_align_arg 
avcodec_decode_audio4(AVCodecContext *avctx,
 {
 return compat_decode(avctx, frame, got_frame_ptr, avpkt);
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 static void get_subtitle_defaults(AVSubtitle *sub)
 {
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 2e540baf37..29f41c3f92 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -356,6 +356,7 @@ int attribute_align_arg 
avcodec_receive_packet(AVCodecContext *avctx, AVPacket *
 return 0;
 }
 
+#if FF_API_OLD_ENCDEC
 static int compat_encode(AVCodecContext *avctx, AVPacket *avpkt,
  int *got_packet, const AVFrame *frame)
 {
@@ -456,3 +457,4 @@ int attribute_align_arg 
avcodec_encode_video2(AVCodecContext *avctx,
 
 return ret;
 }
+#endif
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 141f3fb88e..65760368d6 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -131,7 +131,9 @@ typedef struct AVCodecInternal {
  */
 int last_audio_frame;
 
+#if FF_API_OLD_ENCDEC
 AVFrame *to_free;
+#endif
 
 AVBufferRef *pool;
 
@@ -179,6 +181,8 @@ typedef struct AVCodecInternal {
 AVPacket *buffer_pkt;
 AVFrame *buffer_frame;
 int draining_done;
+
+#if FF_API_OLD_ENCDEC
 int compat_decode_warned;
 /* this variable is set by the decoder internals to signal to the old
  * API compat wrappers the amount of data consumed from the last packet */
@@ -188,6 +192,7 @@ typedef struct AVCodecInternal {
 size_t compat_decode_partial_size;
 AVFrame *compat_decode_frame;
 AVPacket *compat_encode_packet;
+#endif
 
 int showed_multi_packet_warning;
 
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 1b9d39a3a7..53fa065fc1 100644

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread Paul B Mahol
Will apply soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avcodec/dolby_e: Split decoder/parser files

2021-01-25 Thread Nicolas Gaullier
---
 libavcodec/Makefile  |   1 +
 libavcodec/dolby_e.c | 149 +--
 libavcodec/dolby_e.h | 598 +-
 libavcodec/dolby_e_parser.c  | 227 ++
 libavcodec/dolby_e_parser.h  |  41 ++
 libavcodec/dolby_e_parser_internal.h |  46 ++
 libavcodec/dolby_edec.h  | 607 +++
 7 files changed, 932 insertions(+), 737 deletions(-)
 create mode 100644 libavcodec/dolby_e_parser.c
 create mode 100644 libavcodec/dolby_e_parser.h
 create mode 100644 libavcodec/dolby_e_parser_internal.h
 create mode 100644 libavcodec/dolby_edec.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d48fecc5fc..633ebc37f8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -40,6 +40,7 @@ OBJS = ac3_parser.o   
  \
d3d11va.o\
decode.o \
dirac.o  \
+   dolby_e_parser.o \
dv_profile.o \
encode.o \
imgconvert.o \
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index 6bb817ec5c..74388f43d1 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -28,13 +28,14 @@
 #include "put_bits.h"
 #include "parser.h"
 #include "dolby_e.h"
+#include "dolby_edec.h"
+#include "dolby_e_parser_internal.h"
 #include "fft.h"
 
 static int skip_input(DBEContext *s, int nb_words)
 {
 if (nb_words > s->input_size) {
-if (s->avctx)
-av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
+av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
 return AVERROR_INVALIDDATA;
 }
 
@@ -65,8 +66,7 @@ static int convert_input(DBEContext *s, int nb_words, int key)
 av_assert0(nb_words <= 1024u);
 
 if (nb_words > s->input_size) {
-if (s->avctx)
-av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
+av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
 return AVERROR_INVALIDDATA;
 }
 
@@ -92,69 +92,6 @@ static int convert_input(DBEContext *s, int nb_words, int 
key)
 return init_get_bits(>gb, s->buffer, nb_words * s->word_bits);
 }
 
-static int parse_metadata(DBEContext *s, DolbyEHeaderInfo *hdr)
-{
-int i, ret, key, mtd_size;
-
-if ((key = parse_key(s)) < 0)
-return key;
-if ((ret = convert_input(s, 1, key)) < 0)
-return ret;
-
-skip_bits(>gb, 4);
-mtd_size = get_bits(>gb, 10);
-if (!mtd_size) {
-if (s->avctx)
-av_log(s->avctx, AV_LOG_ERROR, "Invalid metadata size\n");
-return AVERROR_INVALIDDATA;
-}
-
-if ((ret = convert_input(s, mtd_size, key)) < 0)
-return ret;
-
-skip_bits(>gb, 14);
-hdr->prog_conf = get_bits(>gb, 6);
-if (hdr->prog_conf > MAX_PROG_CONF) {
-if (s->avctx)
-av_log(s->avctx, AV_LOG_ERROR, "Invalid program configuration\n");
-return AVERROR_INVALIDDATA;
-}
-
-hdr->nb_channels = nb_channels_tab[hdr->prog_conf];
-hdr->nb_programs = nb_programs_tab[hdr->prog_conf];
-
-hdr->fr_code  = get_bits(>gb, 4);
-hdr->fr_code_orig = get_bits(>gb, 4);
-if (!sample_rate_tab[hdr->fr_code] ||
-!sample_rate_tab[hdr->fr_code_orig]) {
-if (s->avctx)
-av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n");
-return AVERROR_INVALIDDATA;
-}
-
-skip_bits_long(>gb, 88);
-for (i = 0; i < hdr->nb_channels; i++)
-hdr->ch_size[i] = get_bits(>gb, 10);
-hdr->mtd_ext_size = get_bits(>gb, 8);
-hdr->meter_size   = get_bits(>gb, 8);
-
-skip_bits_long(>gb, 10 * hdr->nb_programs);
-for (i = 0; i < hdr->nb_channels; i++) {
-hdr->rev_id[i] = get_bits(>gb,  4);
-skip_bits1(>gb);
-hdr->begin_gain[i] = get_bits(>gb, 10);
-hdr->end_gain[i]   = get_bits(>gb, 10);
-}
-
-if (get_bits_left(>gb) < 0) {
-if (s->avctx)
-av_log(s->avctx, AV_LOG_ERROR, "Read past end of metadata\n");
-return AVERROR_INVALIDDATA;
-}
-
-return skip_input(s, mtd_size + 1);
-}
-
 static int parse_metadata_ext(DBEDecodeContext *s1)
 {
 DBEContext *s = >dectx;
@@ -603,73 +540,6 @@ static int filter_frame(DBEDecodeContext *s, AVFrame 
*frame)
 return 0;
 }
 
-static int dolby_e_sync(DBEContext *s, const uint8_t *buf, int buf_size)
-{
-int hdr;
-
-if (buf_size < 3)
-return AVERROR_INVALIDDATA;
-
-hdr = AV_RB24(buf);
-if ((hdr & 0xfe) == 0x7888e) {
-s->word_bits = 24;
-} else if ((hdr & 0xe0) == 0x788e0) {
-s->word_bits = 20;
-} else if ((hdr & 

[FFmpeg-devel] [PATCH 1/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread Nicolas Gaullier
---
 Changelog|   1 +
 libavcodec/dolby_e.c | 254 +++
 libavcodec/dolby_e.h |  38 ++-
 libavcodec/parsers.c |   1 +
 libavcodec/version.h |   4 +-
 5 files changed, 199 insertions(+), 99 deletions(-)

diff --git a/Changelog b/Changelog
index 797b44d4f3..20f6b79ab4 100644
--- a/Changelog
+++ b/Changelog
@@ -57,6 +57,7 @@ version :
 - tmidequalizer filter
 - estdif filter
 - epx filter
+- Dolby E parser
 
 
 version 4.3:
diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c
index 2b2f0a1640..6bb817ec5c 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -26,13 +26,15 @@
 #include "internal.h"
 #include "get_bits.h"
 #include "put_bits.h"
+#include "parser.h"
 #include "dolby_e.h"
 #include "fft.h"
 
 static int skip_input(DBEContext *s, int nb_words)
 {
 if (nb_words > s->input_size) {
-av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
+if (s->avctx)
+av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
 return AVERROR_INVALIDDATA;
 }
 
@@ -44,7 +46,7 @@ static int skip_input(DBEContext *s, int nb_words)
 static int parse_key(DBEContext *s)
 {
 if (s->key_present) {
-uint8_t *key = s->input;
+const uint8_t *key = s->input;
 int  ret = skip_input(s, 1);
 if (ret < 0)
 return ret;
@@ -55,7 +57,7 @@ static int parse_key(DBEContext *s)
 
 static int convert_input(DBEContext *s, int nb_words, int key)
 {
-uint8_t *src = s->input;
+const uint8_t *src = s->input;
 uint8_t *dst = s->buffer;
 PutBitContext pb;
 int i;
@@ -63,7 +65,8 @@ static int convert_input(DBEContext *s, int nb_words, int key)
 av_assert0(nb_words <= 1024u);
 
 if (nb_words > s->input_size) {
-av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
+if (s->avctx)
+av_log(s->avctx, AV_LOG_ERROR, "Packet too short\n");
 return AVERROR_INVALIDDATA;
 }
 
@@ -89,7 +92,7 @@ static int convert_input(DBEContext *s, int nb_words, int key)
 return init_get_bits(>gb, s->buffer, nb_words * s->word_bits);
 }
 
-static int parse_metadata(DBEContext *s)
+static int parse_metadata(DBEContext *s, DolbyEHeaderInfo *hdr)
 {
 int i, ret, key, mtd_size;
 
@@ -101,7 +104,8 @@ static int parse_metadata(DBEContext *s)
 skip_bits(>gb, 4);
 mtd_size = get_bits(>gb, 10);
 if (!mtd_size) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid metadata size\n");
+if (s->avctx)
+av_log(s->avctx, AV_LOG_ERROR, "Invalid metadata size\n");
 return AVERROR_INVALIDDATA;
 }
 
@@ -109,49 +113,53 @@ static int parse_metadata(DBEContext *s)
 return ret;
 
 skip_bits(>gb, 14);
-s->prog_conf = get_bits(>gb, 6);
-if (s->prog_conf > MAX_PROG_CONF) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid program configuration\n");
+hdr->prog_conf = get_bits(>gb, 6);
+if (hdr->prog_conf > MAX_PROG_CONF) {
+if (s->avctx)
+av_log(s->avctx, AV_LOG_ERROR, "Invalid program configuration\n");
 return AVERROR_INVALIDDATA;
 }
 
-s->nb_channels = nb_channels_tab[s->prog_conf];
-s->nb_programs = nb_programs_tab[s->prog_conf];
+hdr->nb_channels = nb_channels_tab[hdr->prog_conf];
+hdr->nb_programs = nb_programs_tab[hdr->prog_conf];
 
-s->fr_code  = get_bits(>gb, 4);
-s->fr_code_orig = get_bits(>gb, 4);
-if (!sample_rate_tab[s->fr_code] ||
-!sample_rate_tab[s->fr_code_orig]) {
-av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n");
+hdr->fr_code  = get_bits(>gb, 4);
+hdr->fr_code_orig = get_bits(>gb, 4);
+if (!sample_rate_tab[hdr->fr_code] ||
+!sample_rate_tab[hdr->fr_code_orig]) {
+if (s->avctx)
+av_log(s->avctx, AV_LOG_ERROR, "Invalid frame rate code\n");
 return AVERROR_INVALIDDATA;
 }
 
 skip_bits_long(>gb, 88);
-for (i = 0; i < s->nb_channels; i++)
-s->ch_size[i] = get_bits(>gb, 10);
-s->mtd_ext_size = get_bits(>gb, 8);
-s->meter_size   = get_bits(>gb, 8);
-
-skip_bits_long(>gb, 10 * s->nb_programs);
-for (i = 0; i < s->nb_channels; i++) {
-s->rev_id[i] = get_bits(>gb,  4);
+for (i = 0; i < hdr->nb_channels; i++)
+hdr->ch_size[i] = get_bits(>gb, 10);
+hdr->mtd_ext_size = get_bits(>gb, 8);
+hdr->meter_size   = get_bits(>gb, 8);
+
+skip_bits_long(>gb, 10 * hdr->nb_programs);
+for (i = 0; i < hdr->nb_channels; i++) {
+hdr->rev_id[i] = get_bits(>gb,  4);
 skip_bits1(>gb);
-s->begin_gain[i] = get_bits(>gb, 10);
-s->end_gain[i]   = get_bits(>gb, 10);
+hdr->begin_gain[i] = get_bits(>gb, 10);
+hdr->end_gain[i]   = get_bits(>gb, 10);
 }
 
 if (get_bits_left(>gb) < 0) {
-av_log(s->avctx, AV_LOG_ERROR, "Read past end of metadata\n");
+if (s->avctx)
+av_log(s->avctx, AV_LOG_ERROR, "Read past end of metadata\n");

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-01-25 Thread Jan Ekström
On Mon, Jan 25, 2021 at 11:58 AM Nicolas George  wrote:
>
> Jan Ekström (12021-01-22):
> > From: Stefano Sabatini 
> >
> > ---
> >  libavutil/avstring.h |  7 ---
> >  libavutil/bprint.c   | 15 +++
> >  tools/ffescape.c |  7 ---
> >  3 files changed, 23 insertions(+), 6 deletions(-)
>
> Thanks for this new version.
>
> I think this patch and the next would be better merged.

For now I kept them separate since one is just moving Stefano's code,
and another adds new functionality that you requested.

> >
> > diff --git a/libavutil/avstring.h b/libavutil/avstring.h
> > index ee225585b3..189b4726a5 100644
> > --- a/libavutil/avstring.h
> > +++ b/libavutil/avstring.h
> > @@ -321,9 +321,10 @@ int av_match_name(const char *name, const char *names);
> >  char *av_append_path_component(const char *path, const char *component);
> >
> >  enum AVEscapeMode {
> > -AV_ESCAPE_MODE_AUTO,  ///< Use auto-selected escaping mode.
> > -AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
> > -AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
> > +AV_ESCAPE_MODE_AUTO,  ///< Use auto-selected escaping mode.
> > +AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
> > +AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
>
> > +AV_ESCAPE_MODE_XML_CHAR_DATA, ///< Use XML non-markup character data 
> > escaping.
>
> It could be shorter: XML_TEXT, XML_ATTR_QUOT and XML_ATTR_APOS are clear
> enough IMHO, and more convenient.
>

I really have no bigger bone with either naming, I just utilized:
1. How the XML spec calls the thing ("AttValue" thus becoming
ATT_VALUE, "CharData" becoming CHAR_DATA). I slightly would prefer to
keep this due to this making it easy to point towards what is actually
meant in the XML spec.
2. Single and double quotes are the wording that I am more acquainted
with, but I have no hard opinion so if you want _QUOT/_APOS, sure.

> >  };
> >
> >  /**
> > diff --git a/libavutil/bprint.c b/libavutil/bprint.c
> > index 2f059c5ba6..7cdbb75095 100644
> > --- a/libavutil/bprint.c
> > +++ b/libavutil/bprint.c
> > @@ -283,6 +283,21 @@ void av_bprint_escape(AVBPrint *dstbuf, const char 
> > *src, const char *special_cha
> >  av_bprint_chars(dstbuf, '\'', 1);
> >  break;
> >
> > +case AV_ESCAPE_MODE_XML_CHAR_DATA:
> > +/* escape XML non-markup character data as per 2.4 */
> > +/*  [^<&]* - ([^<&]* ']]>' [^<&]*) */
> > +for (; *src; src++) {
> > +switch (*src) {
> > +case '&' : av_bprintf(dstbuf, "%s", "");  break;
> > +case '<' : av_bprintf(dstbuf, "%s", "");   break;
> > +case '>' : av_bprintf(dstbuf, "%s", "");   break;
>
> > +case '"' : av_bprintf(dstbuf, "%s", ""); break;
> > +case '\'': av_bprintf(dstbuf, "%s", ""); break;
>
> Outside attributes, " and ' do not need to be quoted.
>

I think this is where I'm slightly going out of my comfort zone. This
is already existing code, and I just moved it out of ffprobe (where it
was already successfully merged and existed for a while). Additionally
the expression for char_data does at least reference single quotes. I
do see the paragraph at the end of 2.4 that notes

> To allow attribute values to contain both single and double quotes, the 
> apostrophe or single-quote character (') may be represented as "", and 
> the double-quote character (") as ""."

Of course, which seems specific to attribute values.

But at this point I'm 50/50 if it makes even sense for me to continue
this struggle or if this is an unclear message from you to me that I
should just utilize libxml2, which is already utilized in the DASH
demuxer. Mostly because there I at least can relatively surely know
that (probably) not only escaping, but also removal of invalid UTF-8
might be handled by it (which we currently do not do either with JSON
or XML output from ffprobe as far as I know). That way also I don't
have to attempt to be a nice person and attempt to re-utilize existing
code from ffprobe, nor do I have to touch ffprobe.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/concatdec: add support for setting input options

2021-01-25 Thread Jan Ekström
On Mon, Jan 25, 2021 at 11:52 AM Nicolas George  wrote:
>
> Jan Ekström (12021-01-22):
> > This way protocol or format related options can be set for all
> > of the files opened during concatenation.
> > ---
> >  libavformat/concatdec.c | 26 +-
> >  1 file changed, 25 insertions(+), 1 deletion(-)
>
> I know it is a little more work, but options need to be set segment per
> segment, in the script file.

I knew that would be useful, but opted out of it since:
1. For now I didn't yet need it.
2. I wanted to keep out of the actual playlist parsing code.
3. Possible security ramifications (since we already have "safe" /
"unsafe" playlist entries).

It is a relatively simple extension yes, if you ignore the points 2/3.
You have an AVDictionary per file and after initializing the
AVDictionary in the opening function and applying global input options
- copy the contents of the per-file options there, too.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread Paul B Mahol
On Mon, Jan 25, 2021 at 12:04 PM Nicolas Gaullier
 wrote:

> >De : ffmpeg-devel  De la part de Paul B
> Mahol
> >Envoyé : jeudi 21 janvier 2021 13:36
> >À : FFmpeg development discussions and patches 
> >Objet : Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser
> >
> >Changes looks trivial enough.
>
> If no one object, the two patches may be applied now ? I can rebase to
> make it straightforward.
>

Please do.


> Thank you,
> Nicolas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser

2021-01-25 Thread Nicolas Gaullier
>De : ffmpeg-devel  De la part de Paul B Mahol
>Envoyé : jeudi 21 janvier 2021 13:36
>À : FFmpeg development discussions and patches 
>Objet : Re: [FFmpeg-devel] [PATCH 0/2] avcodec/dolby_e: Add a parser
>
>Changes looks trivial enough.

If no one object, the two patches may be applied now ? I can rebase to make it 
straightforward.
Thank you,
Nicolas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avdevice/avdevice: Deprecate AVDevice Capabilities API

2021-01-25 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2021-01-24 21:42:10)
> James Almer:
> > On 1/24/2021 5:16 PM, Andreas Rheinhardt wrote:
> >> It has been added in 6db42a2b6b22e6f1928fafcf3faa67ed78201004,
> >> yet since then none of the necessary create/free_device_capabilities
> >> functions has been implemented, making this API completely useless.
> >>
> >> Because of this one can already simplify
> >> avdevice_capabilities_free/create and can already remove the function
> >> pointers at the next major bump.
> > 
> > Not against it if nobody will bother to implement this on existing
> > devices, but since the long term idea is to merge lavd into lavf, I
> > assume the entirety of the library's API will be eventually deprecated
> > and replaced.
> 
> I know that Anton is currently working on merging them, but I thought
> that this would only involve compiling lavd into libavformat.so; not
> that the API would be changed or the libavdevice/ source folder merged
> into libavformat.

My plan is currently to move the sources into a subdirectory of
libavformat/. The question of the API is for the most part separte.

I like this patch BTW.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH]lavfi/vflip: Support Bayer vertical flip

2021-01-25 Thread Paul B Mahol
On Mon, Jan 25, 2021 at 4:07 AM Carl Eugen Hoyos  wrote:

> Am Sa., 5. Sept. 2020 um 21:15 Uhr schrieb Carl Eugen Hoyos
> :
>
> > Attached patch fixes ticket #8819.
>
> Paul, I believe you had an objection but I forgot what it was...
>

Have you benched with alternative solutions this memcpy version?


>
> Please comment, Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

2021-01-25 Thread Nicolas George
Jan Ekström (12021-01-22):
> From: Stefano Sabatini 
> 
> ---
>  libavutil/avstring.h |  7 ---
>  libavutil/bprint.c   | 15 +++
>  tools/ffescape.c |  7 ---
>  3 files changed, 23 insertions(+), 6 deletions(-)

Thanks for this new version.

I think this patch and the next would be better merged.

> 
> diff --git a/libavutil/avstring.h b/libavutil/avstring.h
> index ee225585b3..189b4726a5 100644
> --- a/libavutil/avstring.h
> +++ b/libavutil/avstring.h
> @@ -321,9 +321,10 @@ int av_match_name(const char *name, const char *names);
>  char *av_append_path_component(const char *path, const char *component);
>  
>  enum AVEscapeMode {
> -AV_ESCAPE_MODE_AUTO,  ///< Use auto-selected escaping mode.
> -AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
> -AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
> +AV_ESCAPE_MODE_AUTO,  ///< Use auto-selected escaping mode.
> +AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
> +AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.

> +AV_ESCAPE_MODE_XML_CHAR_DATA, ///< Use XML non-markup character data 
> escaping.

It could be shorter: XML_TEXT, XML_ATTR_QUOT and XML_ATTR_APOS are clear
enough IMHO, and more convenient.

>  };
>  
>  /**
> diff --git a/libavutil/bprint.c b/libavutil/bprint.c
> index 2f059c5ba6..7cdbb75095 100644
> --- a/libavutil/bprint.c
> +++ b/libavutil/bprint.c
> @@ -283,6 +283,21 @@ void av_bprint_escape(AVBPrint *dstbuf, const char *src, 
> const char *special_cha
>  av_bprint_chars(dstbuf, '\'', 1);
>  break;
>  
> +case AV_ESCAPE_MODE_XML_CHAR_DATA:
> +/* escape XML non-markup character data as per 2.4 */
> +/*  [^<&]* - ([^<&]* ']]>' [^<&]*) */
> +for (; *src; src++) {
> +switch (*src) {
> +case '&' : av_bprintf(dstbuf, "%s", "");  break;
> +case '<' : av_bprintf(dstbuf, "%s", "");   break;
> +case '>' : av_bprintf(dstbuf, "%s", "");   break;

> +case '"' : av_bprintf(dstbuf, "%s", ""); break;
> +case '\'': av_bprintf(dstbuf, "%s", ""); break;

Outside attributes, " and ' do not need to be quoted.

> +default: av_bprint_chars(dstbuf, *src, 1);
> +}
> +}
> +break;
> +
>  /* case AV_ESCAPE_MODE_BACKSLASH or unknown mode */
>  default:
>  /* \-escape characters */
> diff --git a/tools/ffescape.c b/tools/ffescape.c
> index 0530d28c6d..e18f1edaf9 100644
> --- a/tools/ffescape.c
> +++ b/tools/ffescape.c
> @@ -101,9 +101,10 @@ int main(int argc, char **argv)
>  break;
>  }
>  case 'm':
> -if  (!strcmp(optarg, "auto"))  escape_mode = 
> AV_ESCAPE_MODE_AUTO;
> -else if (!strcmp(optarg, "backslash")) escape_mode = 
> AV_ESCAPE_MODE_BACKSLASH;
> -else if (!strcmp(optarg, "quote")) escape_mode = 
> AV_ESCAPE_MODE_QUOTE;
> +if  (!strcmp(optarg, "auto"))  escape_mode = 
> AV_ESCAPE_MODE_AUTO;
> +else if (!strcmp(optarg, "backslash")) escape_mode = 
> AV_ESCAPE_MODE_BACKSLASH;
> +else if (!strcmp(optarg, "quote")) escape_mode = 
> AV_ESCAPE_MODE_QUOTE;

> +else if (!strcmp(optarg, "xml_char_data")) escape_mode = 
> AV_ESCAPE_MODE_XML_CHAR_DATA;
>  else {
>  av_log(NULL, AV_LOG_ERROR,
> "Invalid value '%s' for option -m, "

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/concatdec: add support for setting input options

2021-01-25 Thread Nicolas George
Jan Ekström (12021-01-22):
> This way protocol or format related options can be set for all
> of the files opened during concatenation.
> ---
>  libavformat/concatdec.c | 26 +-
>  1 file changed, 25 insertions(+), 1 deletion(-)

I know it is a little more work, but options need to be set segment per
segment, in the script file.

Thanks for working on this. It has been needed for a long time.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 01/10] avcodec/atrac3plus_data: Remove unused arrays

2021-01-25 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Forgotten in 58fc810d42fde26ed6c1f2996122e98ab7005849.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/atrac3plus_data.h | 19 ---
>  1 file changed, 19 deletions(-)
> 
> diff --git a/libavcodec/atrac3plus_data.h b/libavcodec/atrac3plus_data.h
> index b0b85c4368..05ae2b78a9 100644
> --- a/libavcodec/atrac3plus_data.h
> +++ b/libavcodec/atrac3plus_data.h
> @@ -104,25 +104,6 @@ static const uint8_t atrac3p_sf_xlats[] = {
>   0,  1,  2, 14, 15,  3, 13,  4, 12,  5, 11,  6,  7,  9, 10,
>  };
>  
> -static const uint8_t atrac3p_ct_huff1[4][2] = {
> -{ 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 3 },
> -};
> -
> -static const uint8_t atrac3p_ct_huff2[8][2] = {
> -{ 0, 2 }, { 1, 3 }, { 2, 3 }, { 3, 3 }, { 4, 3 }, { 5, 3 }, { 6, 4 },
> -{ 7, 4 },
> -};
> -
> -static const uint8_t atrac3p_ct_huff3[8][2] = {
> -{ 0, 2 }, { 1, 3 }, { 2, 3 }, { 3, 3 }, { 6, 3 }, { 7, 3 }, { 4, 4 },
> -{ 5, 4 },
> -};
> -
> -static const uint8_t atrac3p_ct_huff4[8][2] = {
> -{ 0, 1 }, { 1, 3 }, { 2, 4 }, { 3, 4 }, { 4, 4 }, { 5, 4 }, { 6, 4 },
> -{ 7, 4 },
> -};
> -
>  /* weights for quantized word lengths */
>  static const int8_t atrac3p_wl_weights[6][32] = {
>  { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0,
> 
Will apply 1-9 tomorrow unless there are objections.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/dnxhd: Make ff_dxnhd_get_cid_table return a pointer, not index

2021-01-25 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> All callers only use the index into ff_dnxhd_cid_table to get a pointer
> to the desired entry.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/dnxhddata.c | 46 +-
>  libavcodec/dnxhddata.h |  4 +---
>  libavcodec/dnxhddec.c  | 13 ++--
>  libavcodec/dnxhdenc.c  |  8 +++-
>  4 files changed, 34 insertions(+), 37 deletions(-)
> 
> diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
> index 154be89860..3a69a0f501 100644
> --- a/libavcodec/dnxhddata.c
> +++ b/libavcodec/dnxhddata.c
> @@ -932,7 +932,7 @@ static const uint8_t dnxhd_1250_run[62] = {
>  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
>  };
>  
> -const CIDEntry ff_dnxhd_cid_table[] = {
> +static const CIDEntry dnxhd_cid_table[] = {
>  { 1235, 1920, 1080, 917504, 917504,
>0, 6, 10, 4,
>dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight,
> @@ -1075,31 +1075,31 @@ const CIDEntry ff_dnxhd_cid_table[] = {
>{ 0 }, { 5888, 255} },
>  };
>  
> -int ff_dnxhd_get_cid_table(int cid)
> +const CIDEntry *ff_dnxhd_get_cid_table(int cid)
>  {
> -int i;
> -for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++)
> -if (ff_dnxhd_cid_table[i].cid == cid)
> -return i;
> -return -1;
> +for (int i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++)
> +if (dnxhd_cid_table[i].cid == cid)
> +return _cid_table[i];
> +return NULL;
>  }
>  
>  int avpriv_dnxhd_get_frame_size(int cid)
>  {
> -int i = ff_dnxhd_get_cid_table(cid);
> -if (i<0)
> -return i;
> -return ff_dnxhd_cid_table[i].frame_size;
> +const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
> +if (!entry)
> +return -1;
> +return entry->frame_size;
>  }
>  
>  int avpriv_dnxhd_get_hr_frame_size(int cid, int w, int h)
>  {
> -int result, i = ff_dnxhd_get_cid_table(cid);
> +const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
> +int result;
>  
> -if (i < 0)
> -return i;
> +if (!entry)
> +return -1;
>  
> -result = ((h + 15) / 16) * ((w + 15) / 16) * 
> (int64_t)ff_dnxhd_cid_table[i].packet_scale.num / 
> ff_dnxhd_cid_table[i].packet_scale.den;
> +result = ((h + 15) / 16) * ((w + 15) / 16) * 
> (int64_t)entry->packet_scale.num / entry->packet_scale.den;
>  result = (result + 2048) / 4096 * 4096;
>  
>  return FFMAX(result, 8192);
> @@ -1107,10 +1107,10 @@ int avpriv_dnxhd_get_hr_frame_size(int cid, int w, 
> int h)
>  
>  int avpriv_dnxhd_get_interlaced(int cid)
>  {
> -int i = ff_dnxhd_get_cid_table(cid);
> -if (i < 0)
> -return i;
> -return ff_dnxhd_cid_table[i].flags & DNXHD_INTERLACED ? 1 : 0;
> +const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
> +if (!entry)
> +return -1;
> +return entry->flags & DNXHD_INTERLACED ? 1 : 0;
>  }
>  
>  static int dnxhd_find_hr_cid(AVCodecContext *avctx)
> @@ -1140,8 +1140,8 @@ int ff_dnxhd_find_cid(AVCodecContext *avctx, int 
> bit_depth)
>  
>  if (!mbs)
>  return 0;
> -for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
> -const CIDEntry *cid = _dnxhd_cid_table[i];
> +for (i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++) {
> +const CIDEntry *cid = _cid_table[i];
>  int interlaced = cid->flags & DNXHD_INTERLACED ? 1 : 0;
>  if (cid->width == avctx->width && cid->height == avctx->height &&
>  interlaced == !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) &&
> @@ -1163,8 +1163,8 @@ int ff_dnxhd_find_cid(AVCodecContext *avctx, int 
> bit_depth)
>  void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel)
>  {
>  int i, j;
> -for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
> -const CIDEntry *cid = _dnxhd_cid_table[i];
> +for (i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++) {
> +const CIDEntry *cid = _cid_table[i];
>  for (j = 0; j < FF_ARRAY_ELEMS(cid->bit_rates); j++) {
>  if (!cid->bit_rates[j])
>  break;
> diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h
> index cfa6b0c99d..898079cffc 100644
> --- a/libavcodec/dnxhddata.h
> +++ b/libavcodec/dnxhddata.h
> @@ -58,9 +58,7 @@ typedef struct CIDEntry {
>  AVRational packet_scale;
>  } CIDEntry;
>  
> -extern const CIDEntry ff_dnxhd_cid_table[];
> -
> -int ff_dnxhd_get_cid_table(int cid);
> +const CIDEntry *ff_dnxhd_get_cid_table(int cid);
>  int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth);
>  void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel);
>  
> diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
> index 09bc6f9b59..c78d55aee5 100644
> --- a/libavcodec/dnxhddec.c
> +++ b/libavcodec/dnxhddec.c
> @@ -113,18 +113,19 @@ static av_cold int dnxhd_decode_init(AVCodecContext 
> *avctx)
>  static int dnxhd_init_vlc(DNXHDContext *ctx, uint32_t cid, int bitdepth)
>  {
>  if (cid != ctx->cid) {
> -int index;
> +   

Re: [FFmpeg-devel] Patch for FFmpeg

2021-01-25 Thread Josh Dekker

On 2021-01-13 17:06, Robin Cooksey wrote:

I’ve attached a patch which makes avformat handle the 308 Permanent Redirect 
HTTP status code – which is more recently defined in 
https://tools.ietf.org/html/rfc7538

The change just treats 308 in the same way as the other 30x status codes.


Thanks. Applied with a slightly edited commit message to conform to our 
conventions & a small reference to the spec.


--
Josh
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/4] checkasm: add hevc_pel tests

2021-01-25 Thread Josh Dekker

On 2021-01-07 13:10, Josh Dekker wrote:

Co-authored-by: Niklas Haas 
Signed-off-by: Josh Dekker 
---
  tests/checkasm/Makefile   |   2 +-
  tests/checkasm/checkasm.c |  10 +
  tests/checkasm/checkasm.h |  10 +
  tests/checkasm/hevc_pel.c | 523 ++
  4 files changed, 544 insertions(+), 1 deletion(-)
  create mode 100644 tests/checkasm/hevc_pel.c

[...]


Pushed (only this patch).

--
Josh
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] configure: add fallback to $arch in msvc assembler check.

2021-01-25 Thread Josh Dekker

On 2021-01-23 14:14, Martin Storsjö wrote:

On Sat, 23 Jan 2021, Reimar Döffinger wrote:


Setting the defaults for $arch happens only later, so
the current code would not set AS correctly if --arch
was not specified on the command-line.
Fix it by adding an explicit fallback to $arch_default.
---
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 54fbbd6b5f..df298b4b9b 100755
--- a/configure
+++ b/configure
@@ -4268,7 +4268,7 @@ case "$toolchain" in
    ld_default="$source_path/compat/windows/mslink"
    nm_default="dumpbin.exe -symbols"
    ar_default="lib.exe"
-    case "$arch" in
+    case "${arch:-$arch_default}" in
    aarch64|arm64)
    as_default="armasm64.exe"
    ;;
--
2.30.0


LGTM, thanks!

// Martin


Thanks, pushed.

--
Josh
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/concatdec: add support for setting input options

2021-01-25 Thread Jan Ekström
On Fri, Jan 22, 2021 at 1:00 AM Jan Ekström  wrote:
>
> This way protocol or format related options can be set for all
> of the files opened during concatenation.

Ping for reviews.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/5] FIFO meta muxer related improvements

2021-01-25 Thread Jan Ekström
On Mon, Jan 11, 2021 at 4:46 PM Jan Ekström  wrote:
>
> On Mon, Dec 7, 2020 at 12:08 PM Jan Ekström  wrote:
> >
> > The primary parts of this are patches 1,4,5. 2 and 3 were just noticed when
> > poking at the recovery timestamp logic, where the stream-time comparison 
> > logic
> > seemed somewhat weird (such as comparing the pts to last_recovery_ts only if
> > last_recovery_ts == AV_NOPTS_VALUE). If they seem incorrectly understood,
> > they can be left out.
> >
> > As for the rest of the patches, they address the following issues:
> > 1. Even if the header and the first packet get written out, the muxer might
> >still fail at writing to a server when it actually decides to do I/O.
> >Currently (for example with the MP4 muxer) this leads to a constant retry
> >loop as each recovery is actually "successful". This patch makes sure 
> > that
> >even if a recovery is "successful", the following recovery will only 
> > happen
> >after the configured time, easing the load on any receiving server.
> > 4. In case of avformat_write_header failing, the fifo muxer until now would 
> > not
> >close the avformat context and its underlying I/O. This is now added, so
> >that file sockets do not keep creeping up.
> > 5. Unset a configured codec_tag if it is not supported by the underlying 
> > muxer,
> >as the API client has no visibility regarding whether a codec tag is
> >acceptable in cases of meta-muxers such as fifo.
> >
> > Jan
> >
> > Bernard Boulay (1):
> >   avformat/fifo: always wait recovery_wait_time between recoveries
> >
> > Jan Ekström (4):
> >   avformat/fifo: fix handling of stream-time non-NOPTS recovery
> >   avformat/fifo: cause immediate stream-time recovery if time went
> > backwards
> >   avformat/fifo: close IO in case header writing fails
> >   avformat/fifo: unset codec tag if unsupported by underlying muxer
> >
> >  libavformat/fifo.c | 77 ++
> >  1 file changed, 51 insertions(+), 26 deletions(-)
> >
>
> Ping for this patch set.

Ping for this patch set.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".