Re: [FFmpeg-devel] [PATCH v3] vaapi_encode_h264: Only set pic_order_cnt_type to 0 with B-frames

2023-01-28 Thread Xiang, Haihao
On Di, 2023-01-17 at 12:17 +0100, David Rosca wrote:
> v3: pic_order_cnt steps by 2
> ---
>  libavcodec/vaapi_encode_h264.c | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index f15bcc6..de0951f 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -361,8 +361,10 @@ static int
> vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
>  sps->chroma_format_idc= 1;
>  
>  sps->log2_max_frame_num_minus4 = 4;
> -sps->pic_order_cnt_type= 0;
> -sps->log2_max_pic_order_cnt_lsb_minus4 = 4;
> +sps->pic_order_cnt_type= ctx->max_b_depth ? 0 : 2;
> +if (sps->pic_order_cnt_type == 0) {
> +sps->log2_max_pic_order_cnt_lsb_minus4 = 4;
> +}
>  
>  sps->max_num_ref_frames = priv->dpb_frames;
>  
> @@ -643,6 +645,10 @@ static int
> vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
>  }
>  }
>  hpic->pic_order_cnt = pic->display_order - hpic->last_idr_frame;
> +if (priv->raw_sps.pic_order_cnt_type == 2) {
> +hpic->pic_order_cnt *= 2;
> +}
> +
>  hpic->dpb_delay = pic->display_order - pic->encode_order + ctx-
> >max_b_depth;
>  hpic->cpb_delay = pic->encode_order - hpic->last_idr_frame;
>  

LGTM, will apply.

Thanks
Haihao

___
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 VA-API variants of the stack filters

2023-01-28 Thread Xiang, Haihao
On Do, 2023-01-19 at 16:30 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang 
> 
> Include hstack_vaapi, vstack_vaapi and xstack_vaapi. They may accept
> input streams with different sizes.  libva2 (VA-API 1.0+) is required.
> 
> Example:
> $ ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -i input.h265
> -filter_complex
> "[0:v][0:v]hstack_vaapi" -c:v h264_vaapi out.h264
> 
> $ ffmpeg \
> -hwaccel vaapi -hwaccel_output_format vaapi -i input.h264 \
> -hwaccel vaapi -hwaccel_output_format vaapi -i input.h264 \
> -hwaccel vaapi -hwaccel_output_format vaapi -i input.h264 \
> -hwaccel vaapi -hwaccel_output_format vaapi -i input.h264 \
> -filter_complex
> "[0:v][1:v][2:v][3:v]xstack_vaapi=inputs=4:fill=0x00:layout=0_0_1920x1080|
> w0_0_1920x1080|0_h0_1920x1080|w0_h0_1920x1080" \
> -c:v hevc_vaapi out.h265
> 
> Signed-off-by: Haihao Xiang 
> ---
>  Changelog|   1 +
>  configure|   3 +
>  doc/filters.texi |  81 +
>  libavfilter/Makefile |   3 +
>  libavfilter/allfilters.c |   3 +
>  libavfilter/version.h|   2 +-
>  libavfilter/vf_stack_vaapi.c | 574 +++
>  7 files changed, 666 insertions(+), 1 deletion(-)
>  create mode 100644 libavfilter/vf_stack_vaapi.c
> 
> diff --git a/Changelog b/Changelog
> index 5c01e8365e..a6c0a08433 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -29,6 +29,7 @@ version :
>  - corr video filter
>  - adrc audio filter
>  - afdelaysrc audio filter
> +- hstack_vaapi, vstack_vaapi and xstack_vaapi filters
>  
>  
>  version 5.1:
> diff --git a/configure b/configure
> index 6e88c32223..a4620b1005 100755
> --- a/configure
> +++ b/configure
> @@ -3765,6 +3765,9 @@ xfade_opencl_filter_deps="opencl"
>  yadif_cuda_filter_deps="ffnvcodec"
>  yadif_cuda_filter_deps_any="cuda_nvcc cuda_llvm"
>  yadif_videotoolbox_filter_deps="metal corevideo videotoolbox"
> +hstack_vaapi_filter_deps="vaapi_1"
> +vstack_vaapi_filter_deps="vaapi_1"
> +xstack_vaapi_filter_deps="vaapi_1"
>  
>  # examples
>  avio_list_dir_deps="avformat avutil"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index be70a2396b..89c8420f7f 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -14915,6 +14915,7 @@ Set the scaling dimension: @code{2} for @code{hq2x},
> @code{3} for
>  Default is @code{3}.
>  @end table
>  
> +@anchor{hstack}
>  @section hstack
>  Stack input videos horizontally.
>  
> @@ -24366,6 +24367,7 @@ Example:
>  ffmpeg -i ref.mpg -vf vmafmotion -f null -
>  @end example
>  
> +@anchor{vstack}
>  @section vstack
>  Stack input videos vertically.
>  
> @@ -24847,6 +24849,7 @@ minimum values, and @code{1} maximum values.
>  
>  This filter supports all above options as @ref{commands}, excluding option
> @code{inputs}.
>  
> +@anchor{xstack}
>  @section xstack
>  Stack video inputs into custom layout.
>  
> @@ -26663,6 +2,84 @@ tonemap_vaapi=format=p010:t=bt2020-10
>  @end example
>  @end itemize
>  
> +@section hstack_vaapi
> +Stack input videos horizontally.
> +
> +This is the VA-API variant of the @ref{hstack} filter, each input stream may
> +have different height, this filter will scale down/up each input stream while
> +keeping the orignal aspect.
> +
> +It accepts the following options:
> +
> +@table @option
> +@item inputs
> +See @ref{hstack}.
> +
> +@item shortest
> +See @ref{hstack}.
> +
> +@item height
> +Set height of output. If set to 0, this filter will set height of output to
> +height of the first input stream. Default value is 0.
> +@end table
> +
> +@section vstack_vaapi
> +Stack input videos vertically.
> +
> +This is the VA-API variant of the @ref{vstack} filter, each input stream may
> +have different width, this filter will scale down/up each input stream while
> +keeping the orignal aspect.
> +
> +It accepts the following options:
> +
> +@table @option
> +@item inputs
> +See @ref{vstack}.
> +
> +@item shortest
> +See @ref{vstack}.
> +
> +@item width
> +Set width of output. If set to 0, this filter will set width of output to
> +width of the first input stream. Default value is 0.
> +@end table
> +
> +@section xstack_vaapi
> +Stack video inputs into custom layout.
> +
> +This is the VA-API variant of the @ref{xstack} filter,  each input stream may
> +have different size, this filter will scale down/up each input stream to the
> +given output size, or the size of the first input stream.
> +
> +It accepts the following options:
> +
> +@table @option
> +@item inputs
> +See @ref{xstack}.
> +
> +@item shortest
> +See @ref{xstack}.
> +
> +@item layout
> +See @ref{xstack}.
> +Moreover, this permits the user to supply output size for each input stream.
> +@example
> +xstack_vaapi=inputs=4:layout=0_0_1920x1080|0_h0_1920x1080|w0_0_1920x1080|w0_h
> 0_1920x1080
> +@end example
> +
> +@item grid
> +See @ref{xstack}.
> +
> +@item grid_tile_size
> +Set output size for each input stream when @option{grid} is set. If this
> option
> +is not set, this filter will set output size by default t

[FFmpeg-devel] [PATCH 3/3] doc/ffmpeg: drop non-existent -dc option

2023-01-28 Thread Anton Khirnov
---
 doc/ffmpeg.texi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 67b3294256..6b93386b49 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1041,8 +1041,6 @@ version > 1:
 @code{out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= 
%8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s}
 @item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream})
 top=1/bottom=0/auto=-1 field first
-@item -dc @var{precision}
-Intra_dc_precision.
 @item -vtag @var{fourcc/tag} (@emph{output})
 Force video tag/fourcc. This is an alias for @code{-tag:v}.
 @item -qphist (@emph{global})
-- 
2.35.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] fftools/ffmpeg: add an AVClass to MuxStream/OutputStream

2023-01-28 Thread Anton Khirnov
Use it for logging. This makes log messages related to this output
stream more consistent.
---
 fftools/ffmpeg.c  |  95 
 fftools/ffmpeg.h  |   5 +-
 fftools/ffmpeg_demux.c|  10 +--
 fftools/ffmpeg_mux.c  |  13 ++--
 fftools/ffmpeg_mux.h  |   3 +
 fftools/ffmpeg_mux_init.c | 149 ++
 fftools/ffmpeg_opt.c  |   9 ++-
 7 files changed, 157 insertions(+), 127 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index f722ae7632..72206246a7 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -728,8 +728,8 @@ static int init_output_stream_wrapper(OutputStream *ost, 
AVFrame *frame,
 
 ret = init_output_stream(ost, frame, error, sizeof(error));
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- 
%s\n",
-   ost->file_index, ost->index, error);
+av_log(ost, AV_LOG_ERROR, "Error initializing output stream: %s\n",
+   error);
 
 if (fatal)
 exit_program(1);
@@ -811,7 +811,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 ost->samples_encoded += frame->nb_samples;
 
 if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "encoder <- type:%s "
+av_log(ost, AV_LOG_INFO, "encoder <- type:%s "
"frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
type_desc,
av_ts2str(frame->pts), av_ts2timestr(frame->pts, 
&enc->time_base),
@@ -823,7 +823,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 
 ret = avcodec_send_frame(enc, frame);
 if (ret < 0 && !(ret == AVERROR_EOF && !frame)) {
-av_log(NULL, AV_LOG_ERROR, "Error submitting %s frame to the 
encoder\n",
+av_log(ost, AV_LOG_ERROR, "Error submitting %s frame to the encoder\n",
type_desc);
 return ret;
 }
@@ -844,12 +844,12 @@ static int encode_frame(OutputFile *of, OutputStream 
*ost, AVFrame *frame)
 of_output_packet(of, pkt, ost, 1);
 return ret;
 } else if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
+av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc);
 return ret;
 }
 
 if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "encoder -> type:%s "
+av_log(ost, AV_LOG_INFO, "encoder -> type:%s "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
"duration:%s duration_time:%s\n",
type_desc,
@@ -861,7 +861,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, 
AVFrame *frame)
 av_packet_rescale_ts(pkt, enc->time_base, ost->mux_timebase);
 
 if (debug_ts) {
-av_log(NULL, AV_LOG_INFO, "encoder -> type:%s "
+av_log(ost, AV_LOG_INFO, "encoder -> type:%s "
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
"duration:%s duration_time:%s\n",
type_desc,
@@ -966,7 +966,7 @@ static void do_subtitle_out(OutputFile *of,
 int64_t pts;
 
 if (sub->pts == AV_NOPTS_VALUE) {
-av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
+av_log(ost, AV_LOG_ERROR, "Subtitle packets must have a pts\n");
 if (exit_on_error)
 exit_program(1);
 return;
@@ -1010,7 +1010,7 @@ static void do_subtitle_out(OutputFile *of,
 if (i == 1)
 sub->num_rects = save_num_rects;
 if (subtitle_out_size < 0) {
-av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n");
+av_log(ost, AV_LOG_FATAL, "Subtitle encoding failed\n");
 exit_program(1);
 }
 
@@ -1057,9 +1057,9 @@ static void video_sync_process(OutputFile *of, 
OutputStream *ost,
 ost->vsync_method != VSYNC_PASSTHROUGH &&
 ost->vsync_method != VSYNC_DROP) {
 if (delta0 < -0.6) {
-av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", 
-delta0);
+av_log(ost, AV_LOG_VERBOSE, "Past duration %f too large\n", 
-delta0);
 } else
-av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by 
%f\n", -delta0);
+av_log(ost, AV_LOG_DEBUG, "Clipping frame in rate conversion by 
%f\n", -delta0);
 sync_ipts = ost->next_pts;
 duration += delta0;
 delta0 = 0;
@@ -1068,7 +1068,7 @@ static void video_sync_process(OutputFile *of, 
OutputStream *ost,
 switch (ost->vsync_method) {
 case VSYNC_VSCFR:
 if (ost->vsync_frame_number == 0 && delta0 >= 0.5) {
-av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", 
(int)lrintf(delta0));
+av_log(ost, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", 
(int)lrintf(delta0));
 delta = duration;
 delta0 = 0;
   

[FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg: add an AVClass to Muxer/OutputFile

2023-01-28 Thread Anton Khirnov
Use it for logging. This makes log messages related to this output file
more consistent.
---
 fftools/ffmpeg.h  |   2 +
 fftools/ffmpeg_mux.c  |  26 +++-
 fftools/ffmpeg_mux.h  |   3 +
 fftools/ffmpeg_mux_init.c | 133 +++---
 4 files changed, 96 insertions(+), 68 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 5527dbe49b..b1876f7788 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -628,6 +628,8 @@ typedef struct OutputStream {
 } OutputStream;
 
 typedef struct OutputFile {
+const AVClass *class;
+
 int index;
 
 const AVOutputFormat *format;
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 20524e5a28..96d6747749 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -207,8 +207,7 @@ static void *muxer_thread(void *arg)
 
 ret = tq_receive(mux->tq, &stream_idx, pkt);
 if (stream_idx < 0) {
-av_log(NULL, AV_LOG_VERBOSE,
-   "All streams finished for output file #%d\n", of->index);
+av_log(mux, AV_LOG_VERBOSE, "All streams finished\n");
 ret = 0;
 break;
 }
@@ -219,8 +218,7 @@ static void *muxer_thread(void *arg)
 if (ret == AVERROR_EOF)
 tq_receive_finish(mux->tq, stream_idx);
 else if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR,
-   "Error muxing a packet for output file #%d\n", of->index);
+av_log(mux, AV_LOG_ERROR, "Error muxing a packet\n");
 break;
 }
 }
@@ -231,7 +229,7 @@ finish:
 for (unsigned int i = 0; i < mux->fc->nb_streams; i++)
 tq_receive_finish(mux->tq, i);
 
-av_log(NULL, AV_LOG_VERBOSE, "Terminating muxer thread %d\n", of->index);
+av_log(mux, AV_LOG_VERBOSE, "Terminating muxer thread\n");
 
 return (void*)(intptr_t)ret;
 }
@@ -511,10 +509,8 @@ int mux_check_init(Muxer *mux)
 
 ret = avformat_write_header(fc, &mux->opts);
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR,
-   "Could not write header for output file #%d "
-   "(incorrect codec parameters ?): %s\n",
-   of->index, av_err2str(ret));
+av_log(mux, AV_LOG_ERROR, "Could not write header (incorrect codec "
+   "parameters ?): %s\n", av_err2str(ret));
 return ret;
 }
 //assert_avoptions(of->opts);
@@ -604,10 +600,9 @@ int of_write_trailer(OutputFile *of)
 int ret;
 
 if (!mux->tq) {
-av_log(NULL, AV_LOG_ERROR,
-   "Nothing was written into output file %d (%s), because "
-   "at least one of its streams received no packets.\n",
-   of->index, fc->url);
+av_log(mux, AV_LOG_ERROR,
+   "Nothing was written into output file, because "
+   "at least one of its streams received no packets.\n");
 return AVERROR(EINVAL);
 }
 
@@ -617,7 +612,7 @@ int of_write_trailer(OutputFile *of)
 
 ret = av_write_trailer(fc);
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", 
fc->url, av_err2str(ret));
+av_log(mux, AV_LOG_ERROR, "Error writing trailer: %s\n", 
av_err2str(ret));
 return ret;
 }
 
@@ -626,8 +621,7 @@ int of_write_trailer(OutputFile *of)
 if (!(of->format->flags & AVFMT_NOFILE)) {
 ret = avio_closep(&fc->pb);
 if (ret < 0) {
-av_log(NULL, AV_LOG_ERROR, "Error closing file %s: %s\n",
-   fc->url, av_err2str(ret));
+av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", 
av_err2str(ret));
 return ret;
 }
 }
diff --git a/fftools/ffmpeg_mux.h b/fftools/ffmpeg_mux.h
index 6a72b9dc91..8a90cc56c6 100644
--- a/fftools/ffmpeg_mux.h
+++ b/fftools/ffmpeg_mux.h
@@ -63,6 +63,9 @@ typedef struct MuxStream {
 typedef struct Muxer {
 OutputFile of;
 
+// name used for logging
+char log_name[32];
+
 AVFormatContext *fc;
 
 pthread_tthread;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 9eea8639dc..f543438b18 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -818,7 +818,7 @@ static void init_output_filter(OutputFilter *ofilter, const 
OptionsContext *o,
 case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(mux, o, NULL); break;
 case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(mux, o, NULL); break;
 default:
-av_log(NULL, AV_LOG_FATAL, "Only video and audio filters are supported 
"
+av_log(mux, AV_LOG_FATAL, "Only video and audio filters are supported "
"currently.\n");
 exit_program(1);
 }
@@ -1023,7 +1023,7 @@ static void map_manual(Muxer *mux, const OptionsContext 
*o, const StreamMap *map
 }
 loop_end:
 if (!ofilter) {
-av_log(NULL, AV_LOG_FATAL, "Output with label '%s' does not exist "
+av_log(mux, AV_LOG_FATAL, "Output with label '%s' does not exist "
   

Re: [FFmpeg-devel] [PATCH 3/3] doc/ffmpeg: drop non-existent -dc option

2023-01-28 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/3] fftools/ffmpeg: add an AVClass to MuxStream/OutputStream

2023-01-28 Thread Paul B Mahol
Probably ok
___
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/3] fftools/ffmpeg: add an AVClass to Muxer/OutputFile

2023-01-28 Thread Paul B Mahol
Probably ok
___
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/19] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Anton Khirnov
Will push the set tomorrow if nobody has further comments.

-- 
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 01/19] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Marvin Scholz



On 25 Jan 2023, at 17:55, Anton Khirnov wrote:

> Change return value descriptions into proper lists.
> ---
>  libavcodec/avcodec.h | 81 +++-
>  1 file changed, 42 insertions(+), 39 deletions(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 0ac581d660..f3ca41f126 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2605,17 +2605,18 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
> AVSubtitle *sub,
>   *  still has frames buffered, it will return them after 
> sending
>   *  a flush packet.
>   *
> - * @return 0 on success, otherwise negative error code:
> - *  AVERROR(EAGAIN):   input is not accepted in the current state - user
> - * must read output with avcodec_receive_frame() 
> (once
> - * all output is read, the packet should be resent, 
> and
> - * the call will not fail with EAGAIN).
> - *  AVERROR_EOF:   the decoder has been flushed, and no new packets 
> can
> - * be sent to it (also returned if more than 1 flush
> - * packet is sent)
> - *  AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
> flush
> - *  AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
> - *  other errors: legitimate decoding errors
> + * @return
> + * - 0: success
> + * - AVERROR(EAGAIN):   input is not accepted in the current state - user 
> must
> + *  read output with avcodec_receive_frame() (once all
> + *  output is read, the packet should be resent, and the
> + *  call will not fail with EAGAIN).
> + * - AVERROR_EOF:   the decoder has been flushed, and no new packets can 
> be
> + *  sent to it (also returned if more than 1 flush 
> packet is
> + *  sent)
> + * - AVERROR(EINVAL):   codec not opened, it is an encoder, or requires flush
> + * - AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
> + * - other errors:  legitimate decoding errors
>   */

Wouldn't @retval work better for such return value documentation?

>  int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
>
> @@ -2630,17 +2631,17 @@ int avcodec_send_packet(AVCodecContext *avctx, const 
> AVPacket *avpkt);
>   *  av_frame_unref(frame) before doing anything else.
>   *
>   * @return
> - *  0: success, a frame was returned
> - *  AVERROR(EAGAIN):   output is not available in this state - user must 
> try
> - * to send new input
> - *  AVERROR_EOF:   the codec has been fully flushed, and there will 
> be
> - * no more output frames
> - *  AVERROR(EINVAL):   codec not opened, or it is an encoder without
> - * the AV_CODEC_FLAG_RECON_FRAME flag enabled
> - *  AVERROR_INPUT_CHANGED:   current decoded frame has changed parameters
> - *   with respect to first decoded frame. 
> Applicable
> - *   when flag AV_CODEC_FLAG_DROPCHANGED is set.
> - *  other negative values: legitimate decoding errors
> + * - 0: success, a frame was returned
> + * - AVERROR(EAGAIN):   output is not available in this state - user must
> + *  try to send new input
> + * - AVERROR_EOF:   the codec has been fully flushed, and there will 
> be
> + *  no more output frames
> + * - AVERROR(EINVAL):   codec not opened, or it is an encoder without the
> + *  AV_CODEC_FLAG_RECON_FRAME flag enabled
> + * - AVERROR_INPUT_CHANGED: current decoded frame has changed parameters with
> + *  respect to first decoded frame. Applicable when 
> flag
> + *  AV_CODEC_FLAG_DROPCHANGED is set.
> + * - other negative values: legitimate decoding errors
>   */
>  int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
>
> @@ -2667,16 +2668,17 @@ int avcodec_receive_frame(AVCodecContext *avctx, 
> AVFrame *frame);
>   *  If it is not set, frame->nb_samples must be equal to
>   *  avctx->frame_size for all frames except the last.
>   *  The final frame may be smaller than avctx->frame_size.
> - * @return 0 on success, otherwise negative error code:
> - *  AVERROR(EAGAIN):   input is not accepted in the current state - user
> - * must read output with avcodec_receive_packet() 
> (once
> - * all output is read, the packet should be resent, 
> and
> - * the call will not fail with EAGAIN).
> - *  AVERROR_EOF:   the encoder has been flushed, and no new frames 
> can
> - *

Re: [FFmpeg-devel] [PATCH 01/19] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Anton Khirnov
Quoting Marvin Scholz (2023-01-28 12:37:42)
> 
> 
> On 25 Jan 2023, at 17:55, Anton Khirnov wrote:
> 
> > Change return value descriptions into proper lists.
> > ---
> >  libavcodec/avcodec.h | 81 +++-
> >  1 file changed, 42 insertions(+), 39 deletions(-)
> >
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 0ac581d660..f3ca41f126 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -2605,17 +2605,18 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
> > AVSubtitle *sub,
> >   *  still has frames buffered, it will return them after 
> > sending
> >   *  a flush packet.
> >   *
> > - * @return 0 on success, otherwise negative error code:
> > - *  AVERROR(EAGAIN):   input is not accepted in the current state - 
> > user
> > - * must read output with avcodec_receive_frame() 
> > (once
> > - * all output is read, the packet should be 
> > resent, and
> > - * the call will not fail with EAGAIN).
> > - *  AVERROR_EOF:   the decoder has been flushed, and no new 
> > packets can
> > - * be sent to it (also returned if more than 1 
> > flush
> > - * packet is sent)
> > - *  AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
> > flush
> > - *  AVERROR(ENOMEM):   failed to add packet to internal queue, or 
> > similar
> > - *  other errors: legitimate decoding errors
> > + * @return
> > + * - 0: success
> > + * - AVERROR(EAGAIN):   input is not accepted in the current state - user 
> > must
> > + *  read output with avcodec_receive_frame() (once all
> > + *  output is read, the packet should be resent, and 
> > the
> > + *  call will not fail with EAGAIN).
> > + * - AVERROR_EOF:   the decoder has been flushed, and no new packets 
> > can be
> > + *  sent to it (also returned if more than 1 flush 
> > packet is
> > + *  sent)
> > + * - AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
> > flush
> > + * - AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
> > + * - other errors:  legitimate decoding errors
> >   */
> 
> Wouldn't @retval work better for such return value documentation?

I don't know, how is it better?

-- 
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".


[FFmpeg-devel] [PATCH] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Anton Khirnov
Change return value descriptions into proper lists.
---
 libavcodec/avcodec.h | 79 ++--
 1 file changed, 39 insertions(+), 40 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0ac581d660..ad6377e8d8 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2605,17 +2605,17 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
AVSubtitle *sub,
  *  still has frames buffered, it will return them after 
sending
  *  a flush packet.
  *
- * @return 0 on success, otherwise negative error code:
- *  AVERROR(EAGAIN):   input is not accepted in the current state - user
- * must read output with avcodec_receive_frame() (once
- * all output is read, the packet should be resent, and
- * the call will not fail with EAGAIN).
- *  AVERROR_EOF:   the decoder has been flushed, and no new packets can
- * be sent to it (also returned if more than 1 flush
- * packet is sent)
- *  AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
flush
- *  AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
- *  other errors: legitimate decoding errors
+ * @retval 0 success
+ * @retval AVERROR(EAGAIN)   input is not accepted in the current state - user
+ *   must read output with avcodec_receive_frame() 
(once
+ *   all output is read, the packet should be resent,
+ *   and the call will not fail with EAGAIN).
+ * @retval AVERROR_EOF   the decoder has been flushed, and no new packets 
can be
+ *   sent to it (also returned if more than 1 flush
+ *   packet is sent)
+ * @retval AVERROR(EINVAL)   codec not opened, it is an encoder, or requires 
flush
+ * @retval AVERROR(ENOMEM)   failed to add packet to internal queue, or similar
+ * @retval "another negative error code" legitimate decoding errors
  */
 int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
 
@@ -2629,18 +2629,17 @@ int avcodec_send_packet(AVCodecContext *avctx, const 
AVPacket *avpkt);
  *  codec. Note that the function will always call
  *  av_frame_unref(frame) before doing anything else.
  *
- * @return
- *  0: success, a frame was returned
- *  AVERROR(EAGAIN):   output is not available in this state - user must 
try
- * to send new input
- *  AVERROR_EOF:   the codec has been fully flushed, and there will be
- * no more output frames
- *  AVERROR(EINVAL):   codec not opened, or it is an encoder without
- * the AV_CODEC_FLAG_RECON_FRAME flag enabled
- *  AVERROR_INPUT_CHANGED:   current decoded frame has changed parameters
- *   with respect to first decoded frame. 
Applicable
- *   when flag AV_CODEC_FLAG_DROPCHANGED is set.
- *  other negative values: legitimate decoding errors
+ * @retval 0success, a frame was returned
+ * @retval AVERROR(EAGAIN)  output is not available in this state - user must
+ *  try to send new input
+ * @retval AVERROR_EOF  the codec has been fully flushed, and there will be
+ *  no more output frames
+ * @retval AVERROR(EINVAL)  codec not opened, or it is an encoder without the
+ *  AV_CODEC_FLAG_RECON_FRAME flag enabled
+ * @retval AVERROR_INPUT_CHANGED current decoded frame has changed parameters 
with
+ *  respect to first decoded frame. Applicable when 
flag
+ *  AV_CODEC_FLAG_DROPCHANGED is set.
+ * @retval "other negative error code" legitimate decoding errors
  */
 int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
 
@@ -2667,16 +2666,16 @@ int avcodec_receive_frame(AVCodecContext *avctx, 
AVFrame *frame);
  *  If it is not set, frame->nb_samples must be equal to
  *  avctx->frame_size for all frames except the last.
  *  The final frame may be smaller than avctx->frame_size.
- * @return 0 on success, otherwise negative error code:
- *  AVERROR(EAGAIN):   input is not accepted in the current state - user
- * must read output with avcodec_receive_packet() (once
- * all output is read, the packet should be resent, and
- * the call will not fail with EAGAIN).
- *  AVERROR_EOF:   the encoder has been flushed, and no new frames can
- * be sent to it
- *  AVERROR(EINVAL):   codec not opened, it is a decoder, or requires flush
- *  AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
- *

[FFmpeg-devel] [PATCH 32/32] avutil/{color_utils, csp}: merge color_utils into csp and expose API

2023-01-28 Thread Leo Izen
libavutil/color_utils contains some avpriv_ symbols that map
enum AVTransferCharacteristic values to gamma-curve approximations and
to the actual transfer functions to invert them (i.e. -> linear).

There's two issues with this:
(1) avpriv is evil and should be avoided whenever possible
(2) libavutil/csp.h exposes a public API for handling color that
already handles primaries and matricies

I don't see any reason this API has to be private, so this commit takes
the functionality from avutil/color_utils and merges it into avutil/csp
with an exposed av_ API rather than the previous avpriv_ API.

Every reference to the previous API has been updated to point to the
new one. color_utils.h has been deleted as well. This should not break
any applications as it only contained avpriv_ symbols in the first
place, so nothing in that header could be referenced by other
applications.

Signed-off-by: Leo Izen 
---
 libavcodec/exr.c  |   8 +-
 libavcodec/fflcms2.c  |   1 -
 libavcodec/pngenc.c   |   3 +-
 libavformat/movenc.c  |   7 +-
 libavutil/Makefile|   1 -
 libavutil/color_utils.c   | 234 --
 libavutil/color_utils.h   |  56 
 libavutil/csp.c   | 172 +
 libavutil/csp.h   |  39 ++
 libavutil/tests/color_utils.c |   4 +-
 10 files changed, 221 insertions(+), 304 deletions(-)
 delete mode 100644 libavutil/color_utils.c
 delete mode 100644 libavutil/color_utils.h

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 6a0af96ce4..2f1766c17b 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -36,11 +36,11 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
+#include "libavutil/csp.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/avstring.h"
 #include "libavutil/opt.h"
-#include "libavutil/color_utils.h"
 #include "libavutil/half2float.h"
 
 #include "avcodec.h"
@@ -1189,7 +1189,7 @@ static int decode_block(AVCodecContext *avctx, void 
*tdata,
 int i, x, buf_size = s->buf_size;
 int c, rgb_channel_count;
 float one_gamma = 1.0f / s->gamma;
-avpriv_trc_function trc_func = 
avpriv_get_trc_function_from_trc(s->apply_trc_type);
+av_csp_trc_function trc_func = av_csp_trc_func_from_id(s->apply_trc_type);
 int ret;
 
 line_offset = AV_RL64(s->gb.buffer + jobnr * 8);
@@ -2215,7 +2215,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 uint32_t i;
 union av_intfloat32 t;
 float one_gamma = 1.0f / s->gamma;
-avpriv_trc_function trc_func = NULL;
+av_csp_trc_function trc_func = NULL;
 
 ff_init_half2float_tables(&s->h2f_tables);
 
@@ -2227,7 +2227,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 ff_bswapdsp_init(&s->bbdsp);
 #endif
 
-trc_func = avpriv_get_trc_function_from_trc(s->apply_trc_type);
+trc_func = av_csp_trc_func_from_id(s->apply_trc_type);
 if (trc_func) {
 for (i = 0; i < 65536; ++i) {
 t.i = half2float(i, &s->h2f_tables);
diff --git a/libavcodec/fflcms2.c b/libavcodec/fflcms2.c
index fd370fb310..5443f178bc 100644
--- a/libavcodec/fflcms2.c
+++ b/libavcodec/fflcms2.c
@@ -17,7 +17,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/color_utils.h"
 #include "libavutil/csp.h"
 
 #include "fflcms2.h"
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 0ce684342e..e97150f55f 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -29,7 +29,6 @@
 #include "zlib_wrapper.h"
 
 #include "libavutil/avassert.h"
-#include "libavutil/color_utils.h"
 #include "libavutil/crc.h"
 #include "libavutil/csp.h"
 #include "libavutil/libm.h"
@@ -317,7 +316,7 @@ static int png_get_chrm(enum AVColorPrimaries prim,  
uint8_t *buf)
 
 static int png_get_gama(enum AVColorTransferCharacteristic trc, uint8_t *buf)
 {
-double gamma = avpriv_get_gamma_from_trc(trc);
+double gamma = av_csp_approximate_trc_gamma(trc);
 if (gamma <= 1e-6)
 return 0;
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8d31317838..6182dc7f58 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -47,6 +47,7 @@
 #include "internal.h"
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
+#include "libavutil/csp.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/libm.h"
@@ -56,7 +57,6 @@
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
 #include "libavutil/dovi_meta.h"
-#include "libavutil/color_utils.h"
 #include "libavutil/uuid.h"
 #include "hevc.h"
 #include "rtpenc.h"
@@ -2011,9 +2011,8 @@ static int mov_write_pasp_tag(AVIOContext *pb, MOVTrack 
*track)
 static int mov_write_gama_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack 
*track, double gamma)
 {
 uint32_t gama = 0;
-if (gamma <= 0.0) {
-gamma = avpriv_get_gamma_from_trc(track->par->color_

Re: [FFmpeg-devel] drawtext filter

2023-01-28 Thread Francesco Carusi

On 27/01/2023 18:31, Paul B Mahol wrote:

On 1/27/23, Francesco Carusi  wrote:

On 26/01/2023 17:37, Paul B Mahol wrote:

On 1/26/23, Francesco Carusi  wrote:

On 26/01/2023 14:21, Paul B Mahol wrote:

On 1/26/23, Francesco Carusi  wrote:

The drawtext reinit command is also used in the docs as an example for
the sendcmd filter, so I thought it was fine to use commands in that
way. In my opinion it is also a convenient way to modify multiple
options at the same time.
Should the command match the name of a filter option instead?


Please do not top post.

It is much better to use already existing options for commands that is
more intuitive to users. Also multiple options can be set at runtime,
there is no such limitation.

ok, I'm going to remove the "change" command and add commands that match
the options that it included.

Thanks, feel free to ask questions on #ffmpeg-devel irc channel.

I'm attaching the updated patch, I also updated the document at
https://github.com/yethie/FFmpeg/blob/master/drawtext/CHANGES.md
Thanks

Amazing, I like demos!

Could improve code style of newly added/changed lines?
For example opening { put on separate line. So code style is in sync
with rest of codebase.
Sure, I'll put opening { on a new line for functions, not for control 
statements, like in the rest of the code. Is it fine?

The commands stuff does not need to use strcmp to detect if option
value have been changed, you could avoid strcmp by just caching old
value prior to calling function the picks new values, and after that
just compare old with new and then if it differs call needed code.
I'll cache the numeric values. I think that caching string values is not 
the preferred solution because in addition to the strcmp needed to check 
the value, it would also need a strdup to cache the previous value, even 
when the command does not involve those options. Does it sound reasonable?

On 26/01/2023 11:50, Paul B Mahol wrote:

On 1/26/23, Francesco Carusi  wrote:

Hi, I'm new to contributing to ffmpeg!

I modified the drawtext filter to improve text rendering and add
some
features. You can find a high level description of the changes at
this
link:

https://github.com/yethie/FFmpeg/blob/master/drawtext/CHANGES.md

I'm also attaching the patch file.
I looked for the filter maintainer to discuss about the changes I
made
but it looks like there isn't any, am I correct?

Please let me know if this is the right way to submit my
contribution.

Why filter can not support normal commands for options? Like most/all
other filters that have support for changing options values at
runtime.

The reinit and yours added change option(s) are very
strange/inconvenient things to do.
___
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 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 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 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/19] lavc/avcodec: improve enc/dec API doxy

2023-01-28 Thread Marvin Scholz



On 28 Jan 2023, at 14:23, Anton Khirnov wrote:

> Quoting Marvin Scholz (2023-01-28 12:37:42)
>>
>>
>> On 25 Jan 2023, at 17:55, Anton Khirnov wrote:
>>
>>> Change return value descriptions into proper lists.
>>> ---
>>>  libavcodec/avcodec.h | 81 +++-
>>>  1 file changed, 42 insertions(+), 39 deletions(-)
>>>
>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>> index 0ac581d660..f3ca41f126 100644
>>> --- a/libavcodec/avcodec.h
>>> +++ b/libavcodec/avcodec.h
>>> @@ -2605,17 +2605,18 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, 
>>> AVSubtitle *sub,
>>>   *  still has frames buffered, it will return them after 
>>> sending
>>>   *  a flush packet.
>>>   *
>>> - * @return 0 on success, otherwise negative error code:
>>> - *  AVERROR(EAGAIN):   input is not accepted in the current state - 
>>> user
>>> - * must read output with avcodec_receive_frame() 
>>> (once
>>> - * all output is read, the packet should be 
>>> resent, and
>>> - * the call will not fail with EAGAIN).
>>> - *  AVERROR_EOF:   the decoder has been flushed, and no new 
>>> packets can
>>> - * be sent to it (also returned if more than 1 
>>> flush
>>> - * packet is sent)
>>> - *  AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
>>> flush
>>> - *  AVERROR(ENOMEM):   failed to add packet to internal queue, or 
>>> similar
>>> - *  other errors: legitimate decoding errors
>>> + * @return
>>> + * - 0: success
>>> + * - AVERROR(EAGAIN):   input is not accepted in the current state - user 
>>> must
>>> + *  read output with avcodec_receive_frame() (once all
>>> + *  output is read, the packet should be resent, and 
>>> the
>>> + *  call will not fail with EAGAIN).
>>> + * - AVERROR_EOF:   the decoder has been flushed, and no new packets 
>>> can be
>>> + *  sent to it (also returned if more than 1 flush 
>>> packet is
>>> + *  sent)
>>> + * - AVERROR(EINVAL):   codec not opened, it is an encoder, or requires 
>>> flush
>>> + * - AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
>>> + * - other errors:  legitimate decoding errors
>>>   */
>>
>> Wouldn't @retval work better for such return value documentation?
>
> I don't know, how is it better?
>

It should produce a more consistent output like in other places that use retval 
and is
semantically the more correct choice here.

Currently the documentation of possible return values is a bit all over the 
place with
some using lists, others just explain the values in a sentence, other places 
use retval.

IMO we should consistently try to use retval where it makes sense.

> -- 
> 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".
___
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] drawtext filter

2023-01-28 Thread Paul B Mahol
On 1/28/23, Francesco Carusi  wrote:
> On 27/01/2023 18:31, Paul B Mahol wrote:
>> On 1/27/23, Francesco Carusi  wrote:
>>> On 26/01/2023 17:37, Paul B Mahol wrote:
 On 1/26/23, Francesco Carusi  wrote:
> On 26/01/2023 14:21, Paul B Mahol wrote:
>> On 1/26/23, Francesco Carusi  wrote:
>>> The drawtext reinit command is also used in the docs as an example
>>> for
>>> the sendcmd filter, so I thought it was fine to use commands in that
>>> way. In my opinion it is also a convenient way to modify multiple
>>> options at the same time.
>>> Should the command match the name of a filter option instead?
>>>
>> Please do not top post.
>>
>> It is much better to use already existing options for commands that
>> is
>> more intuitive to users. Also multiple options can be set at runtime,
>> there is no such limitation.
> ok, I'm going to remove the "change" command and add commands that
> match
> the options that it included.
 Thanks, feel free to ask questions on #ffmpeg-devel irc channel.
>>> I'm attaching the updated patch, I also updated the document at
>>> https://github.com/yethie/FFmpeg/blob/master/drawtext/CHANGES.md
>>> Thanks
>> Amazing, I like demos!
>>
>> Could improve code style of newly added/changed lines?
>> For example opening { put on separate line. So code style is in sync
>> with rest of codebase.
> Sure, I'll put opening { on a new line for functions, not for control
> statements, like in the rest of the code. Is it fine?

Yes. Thanks.

>> The commands stuff does not need to use strcmp to detect if option
>> value have been changed, you could avoid strcmp by just caching old
>> value prior to calling function the picks new values, and after that
>> just compare old with new and then if it differs call needed code.
> I'll cache the numeric values. I think that caching string values is not
> the preferred solution because in addition to the strcmp needed to check
> the value, it would also need a strdup to cache the previous value, even
> when the command does not involve those options. Does it sound reasonable?

Yes.

>>> On 26/01/2023 11:50, Paul B Mahol wrote:
 On 1/26/23, Francesco Carusi  wrote:
> Hi, I'm new to contributing to ffmpeg!
>
> I modified the drawtext filter to improve text rendering and add
> some
> features. You can find a high level description of the changes at
> this
> link:
>
> https://github.com/yethie/FFmpeg/blob/master/drawtext/CHANGES.md
>
> I'm also attaching the patch file.
> I looked for the filter maintainer to discuss about the changes I
> made
> but it looks like there isn't any, am I correct?
>
> Please let me know if this is the right way to submit my
> contribution.
 Why filter can not support normal commands for options? Like
 most/all
 other filters that have support for changing options values at
 runtime.

 The reinit and yours added change option(s) are very
 strange/inconvenient things to do.
 ___
 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 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 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] lavfi/vf_ssim360: Fix compilation with MSVC

2023-01-28 Thread Martin Storsjö
Don't use "static const" for compile time float constants, but use
defines. This fixes the following error:

src/libavfilter/vf_ssim360.c(549): error C2099: initializer is not a constant

Signed-off-by: Martin Storsjö 
---
 libavfilter/vf_ssim360.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c
index 0990db0ed5..a0bf73da1e 100644
--- a/libavfilter/vf_ssim360.c
+++ b/libavfilter/vf_ssim360.c
@@ -72,11 +72,11 @@
 
 #define DEFAULT_EXPANSION_COEF 1.01f
 
-static const float BARREL_THETA_RANGE   = DEFAULT_EXPANSION_COEF *  2.0f * 
M_PI_F;
-static const float BARREL_PHI_RANGE = DEFAULT_EXPANSION_COEF *  M_PI_2_F;
+#define BARREL_THETA_RANGE (DEFAULT_EXPANSION_COEF *  2.0f * M_PI_F)
+#define BARREL_PHI_RANGE   (DEFAULT_EXPANSION_COEF *  M_PI_2_F)
 
 // Use fixed-point with 16 bit precision for fast bilinear math
-static const int   FIXED_POINT_PRECISION = 16;
+#define FIXED_POINT_PRECISION 16
 
 // Use 1MB per channel for the histogram to get 5-digit precise SSIM value
 #define SSIM360_HIST_SIZE 131072
-- 
2.34.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] lavfi/vf_ssim360: Fix compilation with MSVC

2023-01-28 Thread Martin Storsjö

On Sat, 28 Jan 2023, Martin Storsjö wrote:


Don't use "static const" for compile time float constants, but use
defines. This fixes the following error:

src/libavfilter/vf_ssim360.c(549): error C2099: initializer is not a constant

Signed-off-by: Martin Storsjö 
---
libavfilter/vf_ssim360.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c
index 0990db0ed5..a0bf73da1e 100644
--- a/libavfilter/vf_ssim360.c
+++ b/libavfilter/vf_ssim360.c
@@ -72,11 +72,11 @@

#define DEFAULT_EXPANSION_COEF 1.01f

-static const float BARREL_THETA_RANGE   = DEFAULT_EXPANSION_COEF *  2.0f * 
M_PI_F;
-static const float BARREL_PHI_RANGE = DEFAULT_EXPANSION_COEF *  M_PI_2_F;
+#define BARREL_THETA_RANGE (DEFAULT_EXPANSION_COEF *  2.0f * M_PI_F)
+#define BARREL_PHI_RANGE   (DEFAULT_EXPANSION_COEF *  M_PI_2_F)

// Use fixed-point with 16 bit precision for fast bilinear math
-static const int   FIXED_POINT_PRECISION = 16;
+#define FIXED_POINT_PRECISION 16

// Use 1MB per channel for the histogram to get 5-digit precise SSIM value
#define SSIM360_HIST_SIZE 131072
--
2.34.1


OK'd by Anton on irc, pushed.

// Martin
___
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/3] avfilter/vf_ssim360: Fix left-shift of negative value

2023-01-28 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_ssim360.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c
index a0bf73da1e..89f5100740 100644
--- a/libavfilter/vf_ssim360.c
+++ b/libavfilter/vf_ssim360.c
@@ -547,7 +547,7 @@ static double ssim360_db(double ssim360, double weight)
 static int get_bilinear_sample(const uint8_t *data, BilinearMap *m, int 
max_value)
 {
 static const int fixed_point_half = 1 << (FIXED_POINT_PRECISION - 1);
-static const int inv_byte_mask = (-1) << 8;
+static const int inv_byte_mask = UINT_MAX << 8;
 
 int tl, tr, bl, br, v;
 
-- 
2.34.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] avfilter/vf_ssim360: Don't initialize twice

2023-01-28 Thread Andreas Rheinhardt
The FILTER_INPUTS and FILTER_OUTPUTS macros already set
AVFilter.(inputs|outputs); Clang therefore emits a warning for
this: "initializer overrides prior initialization of this subobject
[-Winitializer-overrides]"

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_ssim360.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c
index 89f5100740..35b0819d5f 100644
--- a/libavfilter/vf_ssim360.c
+++ b/libavfilter/vf_ssim360.c
@@ -1760,8 +1760,6 @@ AVFilter ff_vf_ssim360 = {
 .activate  = activate,
 .priv_size = sizeof(SSIM360Context),
 .priv_class= &ssim360_class,
-.inputs= ssim360_inputs,
-.outputs   = ssim360_outputs,
 FILTER_INPUTS(ssim360_inputs),
 FILTER_OUTPUTS(ssim360_outputs),
 FILTER_PIXFMTS_ARRAY(ssim360_pixfmts),
-- 
2.34.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] avfilter/vf_ssim369: Constify AVFilter

2023-01-28 Thread Andreas Rheinhardt
This brings ff_vf_ssim360 in line with its declaration in allfilters.c;
this discrepancy is actually undefined behaviour.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_ssim360.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_ssim360.c b/libavfilter/vf_ssim360.c
index 35b0819d5f..3eb8e43bbc 100644
--- a/libavfilter/vf_ssim360.c
+++ b/libavfilter/vf_ssim360.c
@@ -1751,7 +1751,7 @@ static const AVFilterPad ssim360_outputs[] = {
 },
 };
 
-AVFilter ff_vf_ssim360 = {
+const AVFilter ff_vf_ssim360 = {
 .name  = "ssim360",
 .description   = NULL_IF_CONFIG_SMALL("Calculate the SSIM between two 360 
video streams."),
 .preinit   = ssim360_framesync_preinit,
-- 
2.34.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/3] avfilter/vf_ssim360: Fix left-shift of negative value

2023-01-28 Thread Anton Khirnov
set LGTM

thanks,
-- 
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] [BUMP PATCH 1/2] avcodec: change AVCodecContext.frame_number to int64_t

2023-01-28 Thread Marton Balint




On Fri, 27 Jan 2023, Marton Balint wrote:




On Fri, 27 Jan 2023, James Almer wrote:


 On 1/27/2023 3:04 PM, Anton Khirnov wrote:

  Quoting Marton Balint (2023-01-27 18:59:39)



  On Fri, 27 Jan 2023, Anton Khirnov wrote:


  I still think we should do a deprecation+replacement like we do for
  everything else.


  You mean you want to introduce a new 64 bit member and deprecate the
  old
  32 bit field?

  E.g.

  int64_t frame_num;

  attribute_deprcated
  int frame_number

  And during the transition you want to sync the value between the 64bit
  and
  the 32bit ?


  yes


 We did make changes like int -> size_t without adding new fields in places
 like AVBufferRef. See 14040a1d91.


Or AVFormatContext bit_rate sometime before.


 It does however probably need an FF_API_ dance, much like in that example.


If no new field is added, and no old field is deprecated, then if the type 
change is done directly before the bump, then the dance is not needed, 
beacuse you'd just remove the dance at the bump.


Anyhow, I will send and alternate patch series which is introducing a new 
field for the 64-bit variant. That series is not dependant of the API 
bump, can be applied before or after.


If people prefer that, fine with me.

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".


[FFmpeg-devel] [PATCH 1/4] avcodec: add AVCodecContext.frame_num as 64 bit variant to frame_number

2023-01-28 Thread Marton Balint
Frame counters can overflow relatively easily (INT_MAX number of frames is
slightly more than 1 year for 60 fps content), so make sure we use 64 bit
values for them.

Also deprecate the old 32 bit frame_number attribute.

Signed-off-by: Marton Balint 
---
 doc/APIchanges  |  4 
 doc/examples/decode_video.c |  4 ++--
 libavcodec/4xm.c|  8 
 libavcodec/8svx.c   |  2 +-
 libavcodec/aacenc.c |  4 ++--
 libavcodec/ansi.c   |  2 +-
 libavcodec/atrac3plus.c |  4 ++--
 libavcodec/avcodec.c|  7 ++-
 libavcodec/avcodec.h| 15 +++
 libavcodec/bfi.c|  2 +-
 libavcodec/cdgraphics.c |  2 +-
 libavcodec/cljrenc.c|  2 +-
 libavcodec/decode.c | 22 --
 libavcodec/dvenc.c  |  2 +-
 libavcodec/eac3enc.c|  2 +-
 libavcodec/encode.c | 14 --
 libavcodec/evrcdec.c|  4 ++--
 libavcodec/flashsv2enc.c| 16 
 libavcodec/flashsvenc.c |  8 
 libavcodec/g2meet.c |  4 ++--
 libavcodec/gif.c|  4 ++--
 libavcodec/h261dec.c|  2 +-
 libavcodec/h264_slice.c |  2 +-
 libavcodec/interplayvideo.c |  8 
 libavcodec/ituh263dec.c |  2 +-
 libavcodec/libwebpenc_animencoder.c |  2 +-
 libavcodec/mjpegdec.c   |  2 +-
 libavcodec/mlpenc.c |  6 +++---
 libavcodec/mpegutils.c  |  2 +-
 libavcodec/nuv.c|  2 +-
 libavcodec/options_table.h  |  2 +-
 libavcodec/opusenc.c|  2 +-
 libavcodec/pngenc.c |  8 
 libavcodec/pthread_frame.c  |  5 +
 libavcodec/qcelpdec.c   |  4 ++--
 libavcodec/qtrleenc.c   |  2 +-
 libavcodec/rv10.c   |  2 +-
 libavcodec/smcenc.c |  2 +-
 libavcodec/snowenc.c| 12 ++--
 libavcodec/svq1enc.c|  6 +++---
 libavcodec/svq3.c   |  4 ++--
 libavcodec/version.h|  2 +-
 libavcodec/version_major.h  |  1 +
 libavcodec/vp3.c|  6 +++---
 libavcodec/wcmv.c   |  2 +-
 libavcodec/wmaprodec.c  |  6 +++---
 libavcodec/yop.c|  2 +-
 tools/decode_simple.c   |  6 +++---
 tools/scale_slice_test.c|  4 ++--
 tools/venc_data_dump.c  |  2 +-
 50 files changed, 145 insertions(+), 95 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a11acadecd..2de7174556 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2023-xx-xx - xx - lavc 59.59.100 - avcodec.h
+  Add AVCodecContext.frame_num as a 64bit version of frame_number.
+  Deprecate AVCodecContext.frame_number.
+
 2023-01-13 - xx - lavu 57.44.100 - ambient_viewing_environment.h 
frame.h
   Adds a new structure for holding H.274 Ambient Viewing Environment metadata,
   AVAmbientViewingEnvironment.
diff --git a/doc/examples/decode_video.c b/doc/examples/decode_video.c
index 7238e38103..1a232ff877 100644
--- a/doc/examples/decode_video.c
+++ b/doc/examples/decode_video.c
@@ -69,12 +69,12 @@ static void decode(AVCodecContext *dec_ctx, AVFrame *frame, 
AVPacket *pkt,
 exit(1);
 }
 
-printf("saving frame %3d\n", dec_ctx->frame_number);
+printf("saving frame %3"PRId64"\n", dec_ctx->frame_num);
 fflush(stdout);
 
 /* the picture is allocated by the decoder. no need to
free it */
-snprintf(buf, sizeof(buf), "%s-%d", filename, dec_ctx->frame_number);
+snprintf(buf, sizeof(buf), "%s-%"PRId64, filename, dec_ctx->frame_num);
 pgm_save(frame->data[0], frame->linesize[0],
  frame->width, frame->height, buf);
 }
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 5636fdef2d..fab3fb5b77 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -875,7 +875,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*picture,
 }
 
 for (i = 0; i < CFRAME_BUFFER_COUNT; i++)
-if (f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
+if (f->cfrm[i].id && f->cfrm[i].id < avctx->frame_num)
 av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n",
f->cfrm[i].id);
 
@@ -910,9 +910,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame 
*picture,
 buf= cfrm->data;
 frame_size = cfrm->size;
 
-if (id != avctx->frame_number)
-av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n",
-   id, avctx->frame_number);
+if (id != avctx->frame_num)
+ 

[FFmpeg-devel] [PATCH 2/4] avcodec/diracdec: do not use AVFrame.display_picture_number for decoding

2023-01-28 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavcodec/diracdec.c | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index a5cad29597..22a2925188 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -77,6 +77,7 @@ typedef struct {
 uint8_t *hpel[3][4];
 uint8_t *hpel_base[3][4];
 int reference;
+unsigned picture_number;
 } DiracFrame;
 
 typedef struct {
@@ -252,13 +253,13 @@ static inline int divide3(int x)
 return (int)((x+1U)*21845 + 10922) >> 16;
 }
 
-static DiracFrame *remove_frame(DiracFrame *framelist[], int picnum)
+static DiracFrame *remove_frame(DiracFrame *framelist[], unsigned picnum)
 {
 DiracFrame *remove_pic = NULL;
 int i, remove_idx = -1;
 
 for (i = 0; framelist[i]; i++)
-if (framelist[i]->avframe->display_picture_number == picnum) {
+if (framelist[i]->picture_number == picnum) {
 remove_pic = framelist[i];
 remove_idx = i;
 }
@@ -2002,7 +2003,7 @@ static int dirac_decode_picture_header(DiracContext *s)
 GetBitContext *gb = &s->gb;
 
 /* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
-picnum = s->current_picture->avframe->display_picture_number = 
get_bits_long(gb, 32);
+picnum = s->current_picture->picture_number = get_bits_long(gb, 32);
 
 
 av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum);
@@ -2021,9 +2022,9 @@ static int dirac_decode_picture_header(DiracContext *s)
 /* Jordi: this is needed if the referenced picture hasn't yet arrived 
*/
 for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++)
 if (s->ref_frames[j]
-&& FFABS(s->ref_frames[j]->avframe->display_picture_number - 
refnum) < refdist) {
+&& FFABS(s->ref_frames[j]->picture_number - refnum) < refdist) 
{
 s->ref_pics[i] = s->ref_frames[j];
-refdist = 
FFABS(s->ref_frames[j]->avframe->display_picture_number - refnum);
+refdist = FFABS(s->ref_frames[j]->picture_number - refnum);
 }
 
 if (!s->ref_pics[i] || refdist)
@@ -2062,7 +2063,7 @@ static int dirac_decode_picture_header(DiracContext *s)
 /* if reference array is full, remove the oldest as per the spec */
 while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, 
s->current_picture)) {
 av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n");
-remove_frame(s->ref_frames, 
s->ref_frames[0]->avframe->display_picture_number)->reference &= 
DELAYED_PIC_REF;
+remove_frame(s->ref_frames, 
s->ref_frames[0]->picture_number)->reference &= DELAYED_PIC_REF;
 }
 }
 
@@ -2090,7 +2091,7 @@ static int get_delayed_pic(DiracContext *s, AVFrame 
*picture, int *got_frame)
 
 /* find frame with lowest picture number */
 for (i = 1; s->delay_frames[i]; i++)
-if (s->delay_frames[i]->avframe->display_picture_number < 
out->avframe->display_picture_number) {
+if (s->delay_frames[i]->picture_number < out->picture_number) {
 out = s->delay_frames[i];
 out_idx = i;
 }
@@ -2102,6 +2103,7 @@ static int get_delayed_pic(DiracContext *s, AVFrame 
*picture, int *got_frame)
 out->reference ^= DELAYED_PIC_REF;
 if((ret = av_frame_ref(picture, out->avframe)) < 0)
 return ret;
+picture->display_picture_number = out->picture_number;
 *got_frame = 1;
 }
 
@@ -2318,19 +2320,19 @@ static int dirac_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 if (!s->current_picture)
 return buf_size;
 
-if (s->current_picture->avframe->display_picture_number > s->frame_number) 
{
+if (s->current_picture->picture_number > s->frame_number) {
 DiracFrame *delayed_frame = remove_frame(s->delay_frames, 
s->frame_number);
 
 s->current_picture->reference |= DELAYED_PIC_REF;
 
 if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) {
-int min_num = s->delay_frames[0]->avframe->display_picture_number;
+unsigned min_num = s->delay_frames[0]->picture_number;
 /* Too many delayed frames, so we display the frame with the 
lowest pts */
 av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n");
 
 for (i = 1; s->delay_frames[i]; i++)
-if (s->delay_frames[i]->avframe->display_picture_number < 
min_num)
-min_num = 
s->delay_frames[i]->avframe->display_picture_number;
+if (s->delay_frames[i]->picture_number < min_num)
+min_num = s->delay_frames[i]->picture_number;
 
 delayed_frame = remove_frame(s->delay_frames, min_num);
 add_frame(s->delay_frames, MAX_DELAY, s->current_picture);
@@ -2340,18 +2342,19 @@ static int dirac_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 delayed_frame->referenc

[FFmpeg-devel] [PATCH 3/4] avcodec/mpegvideo_enc: do not use AVFrame.*_picture_number for encoding

2023-01-28 Thread Marton Balint
Move these fields to MPEGPicture instead and use that.

Signed-off-by: Marton Balint 
---
 libavcodec/mpeg12enc.c |  4 ++--
 libavcodec/mpegpicture.c   |  4 
 libavcodec/mpegpicture.h   |  3 +++
 libavcodec/mpegvideo_enc.c | 17 ++---
 libavcodec/ratecontrol.c   |  4 ++--
 libavcodec/snowenc.c   |  5 ++---
 6 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index a6663a158b..00a8085d12 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -420,10 +420,10 @@ static void mpeg1_encode_sequence_header(MpegEncContext 
*s)
 /* time code: we must convert from the real frame rate to a
  * fake MPEG frame rate in case of low frame rate */
 fps   = (framerate.num + framerate.den / 2) / framerate.den;
-time_code = s->current_picture_ptr->f->coded_picture_number +
+time_code = s->current_picture_ptr->coded_picture_number +
 mpeg12->timecode_frame_start;
 
-mpeg12->gop_picture_number = 
s->current_picture_ptr->f->coded_picture_number;
+mpeg12->gop_picture_number = s->current_picture_ptr->coded_picture_number;
 
 av_assert0(mpeg12->drop_frame_timecode == !!(mpeg12->tc.flags & 
AV_TIMECODE_FLAG_DROPFRAME));
 if (mpeg12->drop_frame_timecode)
diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 977bc65191..3204a70578 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -332,6 +332,8 @@ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture 
*pic)
 pic->needs_realloc = 0;
 pic->reference = 0;
 pic->shared= 0;
+pic->display_picture_number = 0;
+pic->coded_picture_number   = 0;
 }
 
 int ff_update_picture_tables(Picture *dst, const Picture *src)
@@ -397,6 +399,8 @@ int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture 
*dst, Picture *src)
 dst->needs_realloc   = src->needs_realloc;
 dst->reference   = src->reference;
 dst->shared  = src->shared;
+dst->display_picture_number  = src->display_picture_number;
+dst->coded_picture_number= src->coded_picture_number;
 
 return 0;
 fail:
diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h
index a1455ee13c..7919aa402c 100644
--- a/libavcodec/mpegpicture.h
+++ b/libavcodec/mpegpicture.h
@@ -76,6 +76,9 @@ typedef struct Picture {
 
 int reference;
 int shared;
+
+int display_picture_number;
+int coded_picture_number;
 } Picture;
 
 /**
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index bb101612e5..4e49a103e1 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1219,7 +1219,7 @@ static int load_input_picture(MpegEncContext *s, const 
AVFrame *pic_arg)
 if (ret < 0)
 return ret;
 
-pic->f->display_picture_number = display_picture_number;
+pic->display_picture_number = display_picture_number;
 pic->f->pts = pts; // we set this here to avoid modifying pic_arg
 } else {
 /* Flushing: When we have not received enough input frames,
@@ -1477,14 +1477,14 @@ static int select_input_picture(MpegEncContext *s)
 !s->next_picture_ptr || s->intra_only) {
 s->reordered_input_picture[0] = s->input_picture[0];
 s->reordered_input_picture[0]->f->pict_type = AV_PICTURE_TYPE_I;
-s->reordered_input_picture[0]->f->coded_picture_number =
+s->reordered_input_picture[0]->coded_picture_number =
 s->coded_picture_number++;
 } else {
 int b_frames = 0;
 
 if (s->avctx->flags & AV_CODEC_FLAG_PASS2) {
 for (i = 0; i < s->max_b_frames + 1; i++) {
-int pict_num = 
s->input_picture[0]->f->display_picture_number + i;
+int pict_num = s->input_picture[0]->display_picture_number 
+ i;
 
 if (pict_num >= s->rc_context.num_entries)
 break;
@@ -1563,13 +1563,13 @@ static int select_input_picture(MpegEncContext *s)
 s->reordered_input_picture[0] = s->input_picture[b_frames];
 if (s->reordered_input_picture[0]->f->pict_type != 
AV_PICTURE_TYPE_I)
 s->reordered_input_picture[0]->f->pict_type = 
AV_PICTURE_TYPE_P;
-s->reordered_input_picture[0]->f->coded_picture_number =
+s->reordered_input_picture[0]->coded_picture_number =
 s->coded_picture_number++;
 for (i = 0; i < b_frames; i++) {
 s->reordered_input_picture[i + 1] = s->input_picture[i];
 s->reordered_input_picture[i + 1]->f->pict_type =
 AV_PICTURE_TYPE_B;
-s->reordered_input_picture[i + 1]->f->coded_picture_number =
+s->reordered_input_picture[i + 1]->coded_picture_number =
 s->coded_picture_number++;
 }
 }
@@ -1604,6 +1604,8 @@ no_output_pic

[FFmpeg-devel] [PATCH 4/4] avutil/frame: deprecate AVFrame.coded_picture_number and display_picture_number

2023-01-28 Thread Marton Balint
Their usefulness are questionable, very few decoders set them, and their type
should have been int64_t. A replacement field can be added later if a valid use
case is found.

Signed-off-by: Marton Balint 
---
 doc/APIchanges   |  4 
 doc/examples/demuxing_decoding.c |  4 ++--
 fftools/ffprobe.c|  4 
 libavcodec/diracdec.c| 12 
 libavcodec/h264_slice.c  |  4 
 libavcodec/libuavs3d.c   |  4 
 libavcodec/mpegvideo_dec.c   |  4 
 libavutil/frame.c|  4 
 libavutil/frame.h|  4 
 libavutil/version.h  |  3 ++-
 10 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 2de7174556..191071b0ce 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2023-xx-xx - xx - lavu 57.45.100 - frame.h
+  Deprecated AVFrame.coded_picture_number and display_picture_number.
+  Their usefulness are questionable and very few decoders set them.
+
 2023-xx-xx - xx - lavc 59.59.100 - avcodec.h
   Add AVCodecContext.frame_num as a 64bit version of frame_number.
   Deprecate AVCodecContext.frame_number.
diff --git a/doc/examples/demuxing_decoding.c b/doc/examples/demuxing_decoding.c
index 999a78db0d..54a82751e5 100644
--- a/doc/examples/demuxing_decoding.c
+++ b/doc/examples/demuxing_decoding.c
@@ -73,8 +73,8 @@ static int output_video_frame(AVFrame *frame)
 return -1;
 }
 
-printf("video_frame n:%d coded_n:%d\n",
-   video_frame_count++, frame->coded_picture_number);
+printf("video_frame n:%d\n",
+   video_frame_count++);
 
 /* copy decoded frame to destination buffer:
  * this is required since rawvideo expects non aligned data */
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index dfa7ff1b24..d6740ae400 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2617,8 +2617,12 @@ static void show_frame(WriterContext *w, AVFrame *frame, 
AVStream *stream,
 print_str_opt("sample_aspect_ratio", "N/A");
 }
 print_fmt("pict_type",  "%c", 
av_get_picture_type_char(frame->pict_type));
+#if LIBAVUTIL_VERSION_MAJOR < 59
+AV_NOWARN_DEPRECATED(
 print_int("coded_picture_number",   frame->coded_picture_number);
 print_int("display_picture_number", frame->display_picture_number);
+)
+#endif
 print_int("interlaced_frame",   frame->interlaced_frame);
 print_int("top_field_first",frame->top_field_first);
 print_int("repeat_pict",frame->repeat_pict);
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 22a2925188..0ae582befe 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -2103,7 +2103,11 @@ static int get_delayed_pic(DiracContext *s, AVFrame 
*picture, int *got_frame)
 out->reference ^= DELAYED_PIC_REF;
 if((ret = av_frame_ref(picture, out->avframe)) < 0)
 return ret;
+#if FF_API_FRAME_PICTURE_NUMBER
+FF_DISABLE_DEPRECATION_WARNINGS
 picture->display_picture_number = out->picture_number;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 *got_frame = 1;
 }
 
@@ -2343,7 +2347,11 @@ static int dirac_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 if((ret = av_frame_ref(picture, delayed_frame->avframe)) < 0)
 return ret;
 s->frame_number = delayed_frame->picture_number + 1LL;
+#if FF_API_FRAME_PICTURE_NUMBER
+FF_DISABLE_DEPRECATION_WARNINGS
 picture->display_picture_number = delayed_frame->picture_number;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 *got_frame = 1;
 }
 } else if (s->current_picture->picture_number == s->frame_number) {
@@ -2351,7 +2359,11 @@ static int dirac_decode_frame(AVCodecContext *avctx, 
AVFrame *picture,
 if((ret = av_frame_ref(picture, s->current_picture->avframe)) < 0)
 return ret;
 s->frame_number = s->current_picture->picture_number + 1LL;
+#if FF_API_FRAME_PICTURE_NUMBER
+FF_DISABLE_DEPRECATION_WARNINGS
 picture->display_picture_number = s->current_picture->picture_number;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 *got_frame = 1;
 }
 
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 97e66a2907..7767e16cf1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -489,7 +489,11 @@ static int h264_frame_start(H264Context *h)
 pic = &h->DPB[i];
 
 pic->reference  = h->droppable ? 0 : h->picture_structure;
+#if FF_API_FRAME_PICTURE_NUMBER
+FF_DISABLE_DEPRECATION_WARNINGS
 pic->f->coded_picture_number = h->coded_picture_number++;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 pic->field_picture  = h->picture_structure != PICT_FRAME;
 pic->frame_num   = h->poc.frame_num;
 /*
diff --git a/libavcodec/libuavs3d.c b/libavcode

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/utils: use 32pixel alignment for bink

2023-01-28 Thread Michael Niedermayer
On Fri, Jan 27, 2023 at 10:59:38AM +1100, Peter Ross wrote:
> On Sun, Jan 22, 2023 at 01:02:21AM +0100, Michael Niedermayer wrote:
> > bink supports 16x16 blocks in chroma planes thus we need to allocate enough.
> > Fixes: out of array access
> > Fixes: 
> > 55026/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-6013915371012096
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/utils.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index 2b63a498b9..87634e3711 100644
> > --- a/libavcodec/utils.c
> > +++ b/libavcodec/utils.c
> > @@ -243,6 +243,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int 
> > *width, int *height,
> >  case AV_PIX_FMT_GBRAP16BE:
> >  w_align = 16; //FIXME assume 16 pixel per macroblock
> >  h_align = 16 * 2; // interlaced needs 2 macroblocks height
> > +if (s->codec_id == AV_CODEC_ID_BINKVIDEO)
> > +w_align = 16*2;
> >  break;
> >  case AV_PIX_FMT_YUV411P:
> >  case AV_PIX_FMT_YUVJ411P:
> 
> please apply.

will apply

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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".