[FFmpeg-devel] [PATCH] doc/examples/qsv_transcode: Fix a bug when use more than one parameter set
From: Wenbin Chen Signed-off-by: Wenbin Chen --- doc/examples/qsv_transcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/qsv_transcode.c b/doc/examples/qsv_transcode.c index 7ea3ef5674..48128b200c 100644 --- a/doc/examples/qsv_transcode.c +++ b/doc/examples/qsv_transcode.c @@ -88,7 +88,7 @@ static int dynamic_set_parameter(AVCodecContext *avctx) if (current_setting_number < setting_number && frame_number == dynamic_setting[current_setting_number].frame_number) { AVDictionaryEntry *e = NULL; -ret = str_to_dict(dynamic_setting[current_setting_number].optstr, ); +ret = str_to_dict(dynamic_setting[current_setting_number++].optstr, ); if (ret < 0) { fprintf(stderr, "The dynamic parameter is wrong\n"); goto fail; -- 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] libavcodec/qsvenc: Add dynamic setting support of low_delay_brc to av1_qsv
From: Wenbin Chen Signed-off-by: Wenbin Chen --- doc/encoders.texi | 2 +- libavcodec/qsvenc.c | 5 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index b02737b9df..e9b34010ed 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3344,7 +3344,7 @@ Supported in h264_qsv. Change these value to reset qsv codec's max/min qp configuration. @item @var{low_delay_brc} -Supported in h264_qsv and hevc_qsv. +Supported in h264_qsv, hevc_qsv and av1_qsv. Change this value to reset qsv codec's low_delay_brc configuration. @item @var{framerate} diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 3607859cb8..c975302b4f 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1127,6 +1127,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } else if (avctx->codec_id == AV_CODEC_ID_AV1) { if (q->low_delay_brc >= 0) q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; +q->old_low_delay_brc = q->low_delay_brc; } if (avctx->codec_id == AV_CODEC_ID_HEVC) { @@ -2213,7 +2214,9 @@ static int update_low_delay_brc(AVCodecContext *avctx, QSVEncContext *q) { int updated = 0; -if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) +if (avctx->codec_id != AV_CODEC_ID_H264 && +avctx->codec_id != AV_CODEC_ID_HEVC && +avctx->codec_id != AV_CODEC_ID_AV1) return 0; UPDATE_PARAM(q->old_low_delay_brc, q->low_delay_brc); -- 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] Use https for repository links
On Tue, Feb 28, 2023 at 11:44:45PM +0100, Stefano Sabatini wrote: > On date Tuesday 2023-02-28 20:27:12 +0100, Michael Niedermayer wrote: > > Signed-off-by: Michael Niedermayer > > --- > > CREDITS| 4 ++-- > > doc/authors.texi | 4 ++-- > > doc/git-howto.texi | 2 +- > > 3 files changed, 5 insertions(+), 5 deletions(-) > > LGTM. Will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong. 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] libavcodec/h264dec: avoid arithmetic on null pointers
On Wed, Mar 1, 2023 at 3:22 PM Jeremy Dorfman wrote: > > On Wed, Mar 1, 2023 at 2:07 PM James Almer wrote: > > > > On 3/1/2023 3:50 PM, Jeremy Dorfman wrote: > > > null pointer arithmetic is undefined behavior in C. > > > --- > > > libavcodec/h264dec.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c > > > index 2d691731c5..ef698f2630 100644 > > > --- a/libavcodec/h264dec.c > > > +++ b/libavcodec/h264dec.c > > > @@ -912,8 +912,8 @@ static int finalize_frame(H264Context *h, AVFrame > > > *dst, H264Picture *out, int *g > > > av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to > > > fill missing\n", field); > > > > > > for (p = 0; p<4; p++) { > > > -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; > > > -src_data[p] = f->data[p] + field *f->linesize[p]; > > > +dst_data[p] = f->data[p] ? f->data[p] + > > > (field^1)*f->linesize[p] : NULL; > > > +src_data[p] = f->data[p] ? f->data[p] + field > > > *f->linesize[p] : NULL; > > > linesizes[p] = 2*f->linesize[p]; > > > } > > > > Probably cleaner and clearer to do it like this: > > > > dst_data[p] = FF_PTR_ADD(f->data[p], (field^1)*f->linesize[p]); > > src_data[p] = FF_PTR_ADD(f->data[p], field *f->linesize[p]); > > Thank you for the feedback. That seems reasonable to me; I wasn't aware of > FF_PTR_ADD. > > --- > libavcodec/h264dec.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c > index 2d691731c5..0ac04baa4d 100644 > --- a/libavcodec/h264dec.c > +++ b/libavcodec/h264dec.c > @@ -31,6 +31,7 @@ > > #include "libavutil/avassert.h" > #include "libavutil/imgutils.h" > +#include "libavutil/internal.h" > #include "libavutil/opt.h" > #include "libavutil/thread.h" > #include "libavutil/video_enc_params.h" > @@ -912,8 +913,8 @@ static int finalize_frame(H264Context *h, AVFrame *dst, > H264Picture *out, int *g > av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill > missing\n", field); > > for (p = 0; p<4; p++) { > -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; > -src_data[p] = f->data[p] + field *f->linesize[p]; > +dst_data[p] = FF_PTR_ADD(f->data[p], > (field^1)*f->linesize[p]); > +src_data[p] = FF_PTR_ADD(f->data[p], field > *f->linesize[p]); > linesizes[p] = 2*f->linesize[p]; > } > I apologize for the mangled patch and spam. Hopefully this comes through as text/plain without the corrupted patch: --- libavcodec/h264dec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 2d691731c5..0ac04baa4d 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -31,6 +31,7 @@ #include "libavutil/avassert.h" #include "libavutil/imgutils.h" +#include "libavutil/internal.h" #include "libavutil/opt.h" #include "libavutil/thread.h" #include "libavutil/video_enc_params.h" @@ -912,8 +913,8 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field); for (p = 0; p<4; p++) { -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; -src_data[p] = f->data[p] + field *f->linesize[p]; +dst_data[p] = FF_PTR_ADD(f->data[p], (field^1)*f->linesize[p]); +src_data[p] = FF_PTR_ADD(f->data[p], field *f->linesize[p]); ___ 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] libavcodec/h264dec: avoid arithmetic on null pointers
On Wed, Mar 1, 2023 at 2:07 PM James Almer wrote: > > On 3/1/2023 3:50 PM, Jeremy Dorfman wrote: > > null pointer arithmetic is undefined behavior in C. > > --- > > libavcodec/h264dec.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c > > index 2d691731c5..ef698f2630 100644 > > --- a/libavcodec/h264dec.c > > +++ b/libavcodec/h264dec.c > > @@ -912,8 +912,8 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g > > av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field); > > > > for (p = 0; p<4; p++) { > > -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; > > -src_data[p] = f->data[p] + field *f->linesize[p]; > > +dst_data[p] = f->data[p] ? f->data[p] + (field^1)*f->linesize[p] : NULL; > > +src_data[p] = f->data[p] ? f->data[p] + field *f->linesize[p] : NULL; > > linesizes[p] = 2*f->linesize[p]; > > } > > Probably cleaner and clearer to do it like this: > > dst_data[p] = FF_PTR_ADD(f->data[p], (field^1)*f->linesize[p]); > src_data[p] = FF_PTR_ADD(f->data[p], field *f->linesize[p]); Thank you for the feedback. That seems reasonable to me; I wasn't aware of FF_PTR_ADD. --- libavcodec/h264dec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 2d691731c5..0ac04baa4d 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -31,6 +31,7 @@ #include "libavutil/avassert.h" #include "libavutil/imgutils.h" +#include "libavutil/internal.h" #include "libavutil/opt.h" #include "libavutil/thread.h" #include "libavutil/video_enc_params.h" @@ -912,8 +913,8 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field); for (p = 0; p<4; p++) { -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; -src_data[p] = f->data[p] + field *f->linesize[p]; +dst_data[p] = FF_PTR_ADD(f->data[p], (field^1)*f->linesize[p]); +src_data[p] = FF_PTR_ADD(f->data[p], field *f->linesize[p]); linesizes[p] = 2*f->linesize[p]; } ___ 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] libavcodec/h264dec: avoid arithmetic on null pointers
On 3/1/2023 3:50 PM, Jeremy Dorfman wrote: null pointer arithmetic is undefined behavior in C. --- libavcodec/h264dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 2d691731c5..ef698f2630 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -912,8 +912,8 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field); for (p = 0; p<4; p++) { -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; -src_data[p] = f->data[p] + field *f->linesize[p]; +dst_data[p] = f->data[p] ? f->data[p] + (field^1)*f->linesize[p] : NULL; +src_data[p] = f->data[p] ? f->data[p] + field *f->linesize[p] : NULL; linesizes[p] = 2*f->linesize[p]; } Probably cleaner and clearer to do it like this: dst_data[p] = FF_PTR_ADD(f->data[p], (field^1)*f->linesize[p]); src_data[p] = FF_PTR_ADD(f->data[p], field *f->linesize[p]); ___ 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/h264dec: avoid arithmetic on null pointers
null pointer arithmetic is undefined behavior in C. --- libavcodec/h264dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 2d691731c5..ef698f2630 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -912,8 +912,8 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field); for (p = 0; p<4; p++) { -dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; -src_data[p] = f->data[p] + field *f->linesize[p]; +dst_data[p] = f->data[p] ? f->data[p] + (field^1)*f->linesize[p] : NULL; +src_data[p] = f->data[p] ? f->data[p] + field *f->linesize[p] : NULL; linesizes[p] = 2*f->linesize[p]; } -- 2.40.0.rc0.216.gc4246ad0f0-goog ___ 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/pthread_frame: remove forgotten deprecation warning wrappers
Quoting James Almer (2023-02-28 13:07:45) > Missed in e0786a8e. > > Signed-off-by: James Almer > --- > libavcodec/pthread_frame.c | 2 -- > 1 file changed, 2 deletions(-) Looks obviously ok. -- 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 v2] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding
On Fri, Dec 23, 2022 at 7:01 PM Wu Jianhua wrote: > > [PATCH v2] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 > decoding > > Patches attached. > The naming scheme on this seems to be rather inconsistent. Both "d3d12dec" and "d3d12va" seem to be used in different places - please standardize it all on "d3d12va", it matches d3d11va and remains consistent with itself. Additionally, why are you not supporting all codecs that D3D11 supports? Are there any limitations on what it supports, for some reason? - Hendrik ___ 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 v2] avcodec: add D3D12VA hardware accelerated H264, HEVC, VP9, and AV1 decoding
Quoting Wu Jianhua (2022-12-23 19:01:01) > diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h > index 7ff08c8608..691c49087c 100644 > --- a/libavutil/hwcontext.h > +++ b/libavutil/hwcontext.h > @@ -33,6 +33,7 @@ enum AVHWDeviceType { > AV_HWDEVICE_TYPE_QSV, > AV_HWDEVICE_TYPE_VIDEOTOOLBOX, > AV_HWDEVICE_TYPE_D3D11VA, > +AV_HWDEVICE_TYPE_D3D12VA, You cannot add this in the middle of an enum - it will shift the value of the following identifiers and thus break ABI. Add it at the end. > AV_HWDEVICE_TYPE_DRM, > AV_HWDEVICE_TYPE_OPENCL, > AV_HWDEVICE_TYPE_MEDIACODEC, > diff --git a/libavutil/hwcontext_d3d12va.c b/libavutil/hwcontext_d3d12va.c > new file mode 100644 > index 00..94fb172b4b > --- /dev/null > +++ b/libavutil/hwcontext_d3d12va.c > @@ -0,0 +1,696 @@ > +/* > + * Direct3D 12 HW acceleration. > + * > + * copyright (c) 2022 Wu Jianhua > + * > + * 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 "config.h" > +#include "common.h" > +#include "hwcontext.h" > +#include "hwcontext_d3d12va.h" > +#include "hwcontext_internal.h" > +#include "imgutils.h" > +#include "pixdesc.h" > +#include "pixfmt.h" > +#include "thread.h" > +#include "compat/w32dlfcn.h" > +#include > + > +typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY2)(UINT Flags, REFIID riid, > void **ppFactory); > + > +static AVOnce functions_loaded = AV_ONCE_INIT; > + > +static PFN_CREATE_DXGI_FACTORY2 d3d12va_create_dxgi_factory2; > +static PFN_D3D12_CREATE_DEVICE d3d12va_create_device; > +static PFN_D3D12_GET_DEBUG_INTERFACE d3d12va_get_debug_interface; > + > +static av_cold void load_functions(void) > +{ > +HANDLE d3dlib, dxgilib; > + > +d3dlib = dlopen("d3d12.dll", 0); > +dxgilib = dlopen("dxgi.dll", 0); > +if (!d3dlib || !dxgilib) > +return; > + > +d3d12va_create_device = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(d3dlib, > "D3D12CreateDevice"); > +d3d12va_create_dxgi_factory2 = > (PFN_CREATE_DXGI_FACTORY2)GetProcAddress(dxgilib, "CreateDXGIFactory2"); > +d3d12va_get_debug_interface = > (PFN_D3D12_GET_DEBUG_INTERFACE)GetProcAddress(d3dlib, > "D3D12GetDebugInterface"); > +} > + > +typedef struct D3D12VAFramesContext { > +ID3D12Resource*staging_buffer; > +ID3D12CommandQueue*command_queue; > +ID3D12CommandAllocator*command_allocator; > +ID3D12GraphicsCommandList *command_list; > +AVD3D12VASyncContext *sync_ctx; > +intnb_surfaces; > +intnb_surfaces_used; > +DXGI_FORMATformat; > +UINT luma_component_size; > +} D3D12VAFramesContext; > + > +static const struct { > +DXGI_FORMAT d3d_format; > +enum AVPixelFormat pix_fmt; > +} supported_formats[] = { > +{ DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 }, > +{ DXGI_FORMAT_P010, AV_PIX_FMT_P010 }, > +}; > + > +DXGI_FORMAT av_d3d12va_map_sw_to_hw_format(enum AVPixelFormat pix_fmt) > +{ > +switch (pix_fmt) { > +case AV_PIX_FMT_NV12:return DXGI_FORMAT_NV12; > +case AV_PIX_FMT_P010:return DXGI_FORMAT_P010; > +default: return DXGI_FORMAT_UNKNOWN; > +} > +} > + > +int av_d3d12va_create_sync_context(AVD3D12VADeviceContext *ctx, > AVD3D12VASyncContext **sync_ctx) > +{ > +AVD3D12VASyncContext *sync; > + > +*sync_ctx = av_mallocz(sizeof(AVD3D12VASyncContext)); Memory allocations need to be checked. > +sync = *sync_ctx; > +DX_CHECK(ID3D12Device_CreateFence(ctx->device, sync->fence_value, > D3D12_FENCE_FLAG_NONE, _ID3D12Fence, >fence)); > + > +sync->event = CreateEvent(NULL, FALSE, FALSE, NULL); > +if (!sync->event) > +goto fail; > + > +return 0; > + > +fail: You should actually free the objects you created here. > diff --git a/libavutil/hwcontext_d3d12va.h b/libavutil/hwcontext_d3d12va.h > new file mode 100644 > index 00..6e1c9750b7 > --- /dev/null > +++ b/libavutil/hwcontext_d3d12va.h > @@ -0,0 +1,229 @@ > +/* > + * Direct3D 12 HW acceleration. > + * > + * copyright (c) 2022 Wu Jianhua > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it
[FFmpeg-devel] [PATCH] libavformat/tcp: add local_addr/local_port for network option
Signed-off-by: jackarain --- doc/protocols.texi| 6 + libavformat/network.c | 14 libavformat/network.h | 2 +- libavformat/tcp.c | 53 ++- 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 21ae6181a0..b3fad55591 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1882,6 +1882,12 @@ The list of supported options follows. Listen for an incoming connection. 0 disables listen, 1 enables listen in single client mode, 2 enables listen in multi-client mode. Default value is 0. +@item local_addr=@var{addr} +Local IP address of a network interface used for tcp socket connect. + +@item local_port=@var{port} +Local port used for tcp socket connect. + @item timeout=@var{microseconds} Set raise error timeout, expressed in microseconds. diff --git a/libavformat/network.c b/libavformat/network.c index 21e20b3e9a..de8b14be82 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -356,7 +356,7 @@ struct ConnectionAttempt { static int start_connect_attempt(struct ConnectionAttempt *attempt, struct addrinfo **ptr, int timeout_ms, URLContext *h, - void (*customize_fd)(void *, int), void *customize_ctx) + int (*customize_fd)(void *, int), void *customize_ctx) { struct addrinfo *ai = *ptr; int ret; @@ -371,8 +371,14 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, ff_socket_nonblock(attempt->fd, 1); -if (customize_fd) -customize_fd(customize_ctx, attempt->fd); +if (customize_fd) { +ret = customize_fd(customize_ctx, attempt->fd); +if (ret) { +closesocket(attempt->fd); +attempt->fd = -1; +return ret; +} +} while ((ret = connect(attempt->fd, ai->ai_addr, ai->ai_addrlen))) { ret = ff_neterrno(); @@ -402,7 +408,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, int parallel, URLContext *h, int *fd, -void (*customize_fd)(void *, int), void *customize_ctx) +int (*customize_fd)(void *, int), void *customize_ctx) { struct ConnectionAttempt attempts[3]; struct pollfd pfd[3]; diff --git a/libavformat/network.h b/libavformat/network.h index 71c49a73fb..8a8cbe672e 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -336,6 +336,6 @@ void ff_log_net_error(void *ctx, int level, const char* prefix); */ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, int parallel, URLContext *h, int *fd, -void (*customize_fd)(void *, int), void *customize_ctx); +int (*customize_fd)(void *, int), void *customize_ctx); #endif /* AVFORMAT_NETWORK_H */ diff --git a/libavformat/tcp.c b/libavformat/tcp.c index a11ccbb913..a897174f6c 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -36,6 +36,8 @@ typedef struct TCPContext { const AVClass *class; int fd; int listen; +char *local_port; +char *local_addr; int open_timeout; int rw_timeout; int listen_timeout; @@ -52,6 +54,8 @@ typedef struct TCPContext { #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, .flags = D|E }, +{ "local_port", "Local port", OFFSET(local_port), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, .flags = D|E }, +{ "local_addr", "Local address", OFFSET(local_addr), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, .flags = D|E }, { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "send_buffer_size", "Socket send buffer size (in bytes)", OFFSET(send_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, @@ -70,9 +74,42 @@ static const AVClass tcp_class = { .version= LIBAVUTIL_VERSION_INT, }; -static void customize_fd(void *ctx, int fd) +static int customize_fd(void *ctx, int fd) { TCPContext *s = ctx; + +if (s->local_addr || s->local_port) { +struct addrinfo hints = { 0 }, *ai, *cur_ai; +int ret; + +hints.ai_family = AF_UNSPEC; +hints.ai_socktype =
Re: [FFmpeg-devel] [PATCH 3/3] ffmpeg: respect AV_CODEC_CAP_SINGLE_SUB_RECT
On 2023/02/21 9:25, rcombs wrote: Fixes ASS output when multiple rects are present. --- fftools/ffmpeg.c | 28 ++-- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9884e0c6c6..23eac52438 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1021,6 +1021,7 @@ static void do_subtitle_out(OutputFile *of, AVCodecContext *enc; AVPacket *pkt = ost->pkt; int64_t pts; +int single_rect; if (sub->pts == AV_NOPTS_VALUE) { av_log(ost, AV_LOG_ERROR, "Subtitle packets must have a pts\n"); @@ -1031,11 +1032,15 @@ static void do_subtitle_out(OutputFile *of, enc = ost->enc_ctx; +single_rect = !!(enc->codec->capabilities & AV_CODEC_CAP_SINGLE_SUB_RECT); + /* Note: DVB subtitle need one packet to draw them and one other packet to clear them */ /* XXX: signal it in the codec context ? */ if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) nb = 2; +else if (single_rect) If the problem exists on assenc only, how about using codec id to be hard-coded? else if (enc->codec_id == AV_CODEC_ID_ASS) It meets your goal without changing framework (but may be dirty solution). The current code already hard-codes AV_CODEC_ID_DVB_SUBTITLE as a special case. +nb = FFMAX(sub->num_rects, 1); else nb = 1; @@ -1044,7 +1049,7 @@ static void do_subtitle_out(OutputFile *of, if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE) pts -= output_files[ost->file_index]->start_time; for (i = 0; i < nb; i++) { -unsigned save_num_rects = sub->num_rects; +AVSubtitle local_sub = *sub; It is better to put it out from "for" loop. It takes costs to copy entire structure on each loop. if (!check_recording_time(ost, pts, AV_TIME_BASE_Q)) return; @@ -1053,19 +1058,22 @@ static void do_subtitle_out(OutputFile *of, if (ret < 0) report_and_exit(AVERROR(ENOMEM)); -sub->pts = pts; +local_sub.pts = pts; // start_display_time is required to be 0 -sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q); -sub->end_display_time -= sub->start_display_time; -sub->start_display_time = 0; -if (i == 1) -sub->num_rects = 0; +local_sub.pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q); +local_sub.end_display_time -= sub->start_display_time; +local_sub.start_display_time = 0; + +if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE && i == 1) +local_sub.num_rects = 0; +else if (single_rect && sub->num_rects > 0) { +local_sub.num_rects = 1; +local_sub.rects += i; +} ost->frames_encoded++; -subtitle_out_size = avcodec_encode_subtitle(enc, pkt->data, pkt->size, sub); -if (i == 1) -sub->num_rects = save_num_rects; +subtitle_out_size = avcodec_encode_subtitle(enc, pkt->data, pkt->size, _sub); if (subtitle_out_size < 0) { av_log(ost, AV_LOG_FATAL, "Subtitle encoding failed\n"); exit_program(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] libavformat/tcp: add local_addr/local_port for network option
Signed-off-by: jackarain --- doc/protocols.texi| 6 + libavformat/network.c | 14 libavformat/network.h | 2 +- libavformat/tcp.c | 53 ++- 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 21ae6181a0..b3fad55591 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1882,6 +1882,12 @@ The list of supported options follows. Listen for an incoming connection. 0 disables listen, 1 enables listen in single client mode, 2 enables listen in multi-client mode. Default value is 0. +@item local_addr=@var{addr} +Local IP address of a network interface used for tcp socket connect. + +@item local_port=@var{port} +Local port used for tcp socket connect. + @item timeout=@var{microseconds} Set raise error timeout, expressed in microseconds. diff --git a/libavformat/network.c b/libavformat/network.c index 21e20b3e9a..de8b14be82 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -356,7 +356,7 @@ struct ConnectionAttempt { static int start_connect_attempt(struct ConnectionAttempt *attempt, struct addrinfo **ptr, int timeout_ms, URLContext *h, - void (*customize_fd)(void *, int), void *customize_ctx) + int (*customize_fd)(void *, int), void *customize_ctx) { struct addrinfo *ai = *ptr; int ret; @@ -371,8 +371,14 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, ff_socket_nonblock(attempt->fd, 1); -if (customize_fd) -customize_fd(customize_ctx, attempt->fd); +if (customize_fd) { +ret = customize_fd(customize_ctx, attempt->fd); +if (ret) { +closesocket(attempt->fd); +attempt->fd = -1; +return ret; +} +} while ((ret = connect(attempt->fd, ai->ai_addr, ai->ai_addrlen))) { ret = ff_neterrno(); @@ -402,7 +408,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, int parallel, URLContext *h, int *fd, -void (*customize_fd)(void *, int), void *customize_ctx) +int (*customize_fd)(void *, int), void *customize_ctx) { struct ConnectionAttempt attempts[3]; struct pollfd pfd[3]; diff --git a/libavformat/network.h b/libavformat/network.h index 71c49a73fb..8a8cbe672e 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -336,6 +336,6 @@ void ff_log_net_error(void *ctx, int level, const char* prefix); */ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, int parallel, URLContext *h, int *fd, -void (*customize_fd)(void *, int), void *customize_ctx); +int (*customize_fd)(void *, int), void *customize_ctx); #endif /* AVFORMAT_NETWORK_H */ diff --git a/libavformat/tcp.c b/libavformat/tcp.c index a11ccbb913..1987861353 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -36,6 +36,8 @@ typedef struct TCPContext { const AVClass *class; int fd; int listen; +char *local_port; +char *local_addr; int open_timeout; int rw_timeout; int listen_timeout; @@ -52,6 +54,8 @@ typedef struct TCPContext { #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { { "listen", "Listen for incoming connections", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, .flags = D|E }, +{ "local_port", "Local port", OFFSET(local_port), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, .flags = D|E }, +{ "local_addr", "Local address", OFFSET(local_addr), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, .flags = D|E }, { "timeout", "set timeout (in microseconds) of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "listen_timeout", "Connection awaiting timeout (in milliseconds)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "send_buffer_size", "Socket send buffer size (in bytes)", OFFSET(send_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, @@ -70,9 +74,42 @@ static const AVClass tcp_class = { .version= LIBAVUTIL_VERSION_INT, }; -static void customize_fd(void *ctx, int fd) +static int customize_fd(void *ctx, int fd) { TCPContext *s = ctx; + +if (s->local_addr || s->local_port) { +struct addrinfo hints = { 0 }, *ai; +int ret; + +hints.ai_family = AF_UNSPEC; +hints.ai_socktype = SOCK_STREAM; + +
Re: [FFmpeg-devel] [PATCH] libavformat/tcp: add local_addr/local_port for network option
Ok, thanks. Anton Khirnov 于2023年3月1日周三 22:44写道: > Quoting jackarain (2023-02-28 16:44:20) > > -static void customize_fd(void *ctx, int fd) > > +static int customize_fd(void *ctx, int fd) > > { > > TCPContext *s = ctx; > > + > > +if (s->local_addr || s->local_port) { > > +struct addrinfo hints = { 0 }, *ai; > > +int ret; > > + > > +hints.ai_family = AF_UNSPEC; > > +hints.ai_socktype = SOCK_STREAM; > > + > > +ret = getaddrinfo(s->local_addr, s->local_port, , ); > > +if (ret) { > > +av_log(ctx, AV_LOG_ERROR, > > + "Failed to getaddrinfo local addr: %s port: %s err: > %s\n", > > +s->local_addr, s->local_port, gai_strerror(ret)); > > +return ret; > > +} else { > > nit: the else clause pointlessly adds an indentation level and serves no > useful purpose > > > +struct addrinfo *cur_ai = ai; > > +while (cur_ai) { > > +ret = bind(fd, (struct sockaddr *)cur_ai->ai_addr, > (int)cur_ai->ai_addrlen); > > +if (ret) > > +cur_ai = cur_ai->ai_next; > > +else > > +break; > > +} > > +freeaddrinfo(ai); > > + > > +if (ret) { > > +av_log(ctx, AV_LOG_ERROR, > > +"Failed to bind local addr: %s port: %s err: %s\n", > > +s->local_addr, s->local_port, gai_strerror(ret)); > > +return ret; > > +} > > +} > > +} > > /* Set the socket's send or receive buffer sizes, if specified. > > If unspecified or setting fails, system default is used. */ > > if (s->recv_buffer_size > 0) { > > @@ -97,6 +134,8 @@ static void customize_fd(void *ctx, int fd) > > } > > } > > #endif /* !HAVE_WINSOCK2_H */ > > + > > +return 0; > > } > > > > /* return non zero if error */ > > @@ -129,6 +168,14 @@ static int tcp_open(URLContext *h, const char *uri, > int flags) > > if (buf == endptr) > > s->listen = 1; > > } > > +if (av_find_info_tag(buf, sizeof(buf), "local_port", p)) { > > +av_freep(>local_port); > > +s->local_port = av_strndup(buf, strlen(buf)); > > This does memory allocation, so the result should be checked. Also, it > av_str_n_dup() gives you no advantages since you call strlen anyway. > Just use av_strdup(). Same below. > > -- > 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] libavformat/tcp: add local_addr/local_port for network option
Quoting jackarain (2023-02-28 16:44:20) > -static void customize_fd(void *ctx, int fd) > +static int customize_fd(void *ctx, int fd) > { > TCPContext *s = ctx; > + > +if (s->local_addr || s->local_port) { > +struct addrinfo hints = { 0 }, *ai; > +int ret; > + > +hints.ai_family = AF_UNSPEC; > +hints.ai_socktype = SOCK_STREAM; > + > +ret = getaddrinfo(s->local_addr, s->local_port, , ); > +if (ret) { > +av_log(ctx, AV_LOG_ERROR, > + "Failed to getaddrinfo local addr: %s port: %s err: %s\n", > +s->local_addr, s->local_port, gai_strerror(ret)); > +return ret; > +} else { nit: the else clause pointlessly adds an indentation level and serves no useful purpose > +struct addrinfo *cur_ai = ai; > +while (cur_ai) { > +ret = bind(fd, (struct sockaddr *)cur_ai->ai_addr, > (int)cur_ai->ai_addrlen); > +if (ret) > +cur_ai = cur_ai->ai_next; > +else > +break; > +} > +freeaddrinfo(ai); > + > +if (ret) { > +av_log(ctx, AV_LOG_ERROR, > +"Failed to bind local addr: %s port: %s err: %s\n", > +s->local_addr, s->local_port, gai_strerror(ret)); > +return ret; > +} > +} > +} > /* Set the socket's send or receive buffer sizes, if specified. > If unspecified or setting fails, system default is used. */ > if (s->recv_buffer_size > 0) { > @@ -97,6 +134,8 @@ static void customize_fd(void *ctx, int fd) > } > } > #endif /* !HAVE_WINSOCK2_H */ > + > +return 0; > } > > /* return non zero if error */ > @@ -129,6 +168,14 @@ static int tcp_open(URLContext *h, const char *uri, int > flags) > if (buf == endptr) > s->listen = 1; > } > +if (av_find_info_tag(buf, sizeof(buf), "local_port", p)) { > +av_freep(>local_port); > +s->local_port = av_strndup(buf, strlen(buf)); This does memory allocation, so the result should be checked. Also, it av_str_n_dup() gives you no advantages since you call strlen anyway. Just use av_strdup(). Same below. -- 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] avcodec/aacps_tablegen: fix build error after 21814a7
Quoting Zhao Zhili (2023-02-28 19:23:00) > From: Zhao Zhili > > Fix tickets #10225 > > DECLARE_ALIGNED has been moved to mem_internal.h. > > Signed-off-by: Zhao Zhili > --- > libavcodec/aacps_tablegen.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h > index 0ac4f68d68..5fdd7f0a9d 100644 > --- a/libavcodec/aacps_tablegen.h > +++ b/libavcodec/aacps_tablegen.h > @@ -34,7 +34,7 @@ > #include "libavutil/common.h" > #include "libavutil/libm.h" > #include "libavutil/mathematics.h" > -#include "libavutil/mem.h" > +#include "libavutil/mem_internal.h" > #define NR_ALLPASS_BANDS20 30 > #define NR_ALLPASS_BANDS34 50 > #define PS_AP_LINKS 3 > -- > 2.25.1 looks ok -- 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/buffersrc: issue more specific error in case of invalid parameters
Quoting Stefano Sabatini (2023-03-01 01:01:26) > --- > libavfilter/buffersrc.c | 13 ++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c > index ba17450b93..ea9556d691 100644 > --- a/libavfilter/buffersrc.c > +++ b/libavfilter/buffersrc.c > @@ -273,9 +273,16 @@ static av_cold int init_video(AVFilterContext *ctx) > { > BufferSourceContext *c = ctx->priv; > > -if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h || > -av_q2d(c->time_base) <= 0) { > -av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n"); > +if (c->pix_fmt == AV_PIX_FMT_NONE) { > +av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n"); > +return AVERROR(EINVAL); > +} > +if (!c->w || !c->h) { > +av_log(ctx, AV_LOG_ERROR, "Invalid null size %dx%d\n", c->w, c->h); I don't know what a null size is, just drop the word. Otherwise looks good. -- 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/buffersrc: issue more specific error in case of invalid parameters
Quoting Stefano Sabatini (2023-03-01 01:05:29) > On date Wednesday 2023-03-01 01:01:26 +0100, Stefano Sabatini wrote: > > --- > > libavfilter/buffersrc.c | 13 ++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c > > index ba17450b93..ea9556d691 100644 > > --- a/libavfilter/buffersrc.c > > +++ b/libavfilter/buffersrc.c > > @@ -273,9 +273,16 @@ static av_cold int init_video(AVFilterContext *ctx) > > { > > BufferSourceContext *c = ctx->priv; > > > > -if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h || > > -av_q2d(c->time_base) <= 0) { > > -av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n"); > > +if (c->pix_fmt == AV_PIX_FMT_NONE) { > > +av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n"); > > +return AVERROR(EINVAL); > > +} > > +if (!c->w || !c->h) { > > +av_log(ctx, AV_LOG_ERROR, "Invalid null size %dx%d\n", c->w, c->h); > > +return AVERROR(EINVAL); > > +} > > +if (av_q2d(c->time_base) <= 0) { > > +av_log(ctx, AV_LOG_ERROR, "Invalid time base %d/%d\n", > > c->time_base.num, c->time_base.den); > > return AVERROR(EINVAL); > > } > > BTW, I noticied this as part of debugging transcode.c (which looks > broken at the moment), since the timebase is read as 0/1 from the > decoder context, it would be a valid value when reading from the > AVStream (but this information is not copied by > avcodec_parameters_to_context). In decode_filter_video.c this is > indeed "fixed" by copying the timebase directly from the AVStream. > > Is this expected? Shouldn't the timebase be copied to the decoder > context? Historically, AVCodecContext.time_base for decoding was NOT (as one might expect) the timebase of input packets, set by the user. It was instead the inverse of the framerate stored in codec-level headers, which was called "codec timebase" by some documents. Since that was massively confusing for pretty much everyone, I added AVCodecContext.framerate for exporting the framerate from the decoder, and deprecated the use of AVCodecContext.time_base for decoding entirely. After the recent major bump, time_base should not be used at all in any way when decoding. The timebase of input packets should instead be stored in AVCodecContext.pkt_timebase. I suppose after some time has passed we might want to merge its functionality into time_base. -- 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 1/3] decklink: Don't take for granted that first frame to decklink output will be PTS 0
On Tue, Feb 28, 2023 at 3:46 PM Marton Balint wrote: > And what if first packet pts is 0? Then the second packet pts will be > assigned to first pts? Maybe you should use AV_NOPTS_VALUE for the default > first_pts value and check for that instead. That's a good point. I never noticed that, but noticing that the first frame got dropped is probably not something that would have been immediately obvious. In any case, I prefer your approach and will resubmit. Thanks for the feedback, Devin -- Devin Heitmueller, Senior Software Engineer LTN Global Communications o: +1 (301) 363-1001 w: https://ltnglobal.com e: devin.heitmuel...@ltnglobal.com ___ 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 8/8] lavc/libvpxenc: drop FrameListData.duration
Quoting James Zern (2023-02-28 22:16:39) > On Tue, Feb 28, 2023 at 4:02 AM Anton Khirnov wrote: > > > > It is write-only. > > --- > > libavcodec/libvpxenc.c | 3 --- > > 1 file changed, 3 deletions(-) > > > > libaomenc.c transfers this to AVPacket. You added this in: > 7cf161abe5 lavc/libaomenc: pass through frame durations to encoded packets > Should the same be done here? We could do that, but the duration types do not match (we use int64_t, libvpx has unsigned long), which adds corner cases that need to be handled. Since I need the machinery for opaque[_ref] anyway, might as well use it for duration. I'll do the same for aomenc when I get to implementing opaque passthrough for it. -- 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 5/8] lavc/libvpxenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
Quoting James Almer (2023-03-01 00:30:25) > On 2/28/2023 9:01 AM, Anton Khirnov wrote: > > +#if FF_API_REORDERED_OPAQUE > > +FF_DISABLE_DEPRECATION_WARNINGS > > +avctx->reordered_opaque = fd.reordered_opaque; > > +FF_ENABLE_DEPRECATION_WARNINGS > > +#endif > > If this was not being set before this patch, does it make sense at all > to set it considering it's a deprecated field? I remember for example we > would not fill avctx->coded_frame on new encoders after it was deprecated. AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE currently guarantees that the encoder will set reordered_opaque. The users might rely on it, so we should keep the behavior until reordered_opaque is gone. -- 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 5/8] lavc/libvpxenc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
Quoting James Zern (2023-02-28 22:11:29) > On Tue, Feb 28, 2023 at 4:01 AM Anton Khirnov wrote: > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > > index 77921badba..af16e53deb 100644 > > --- a/libavcodec/libvpxenc.c > > +++ b/libavcodec/libvpxenc.c > > @@ -68,6 +68,14 @@ struct FrameListData { > > > > typedef struct FrameData { > > int64_t pts; > > +int64_t duration; > > + > > +#if FF_API_REORDERED_OPAQUE > > +int64_t reordered_opaque; > > +#endif > > +void*frame_opaque; > > +AVBufferRef *frame_opaque_ref; > > + > > AVBufferRef *hdr10_plus; > > } FrameData; > > > > @@ -329,32 +337,101 @@ static av_cold void free_frame_list(struct > > FrameListData *list) > > } > > } > > > > +static void frame_data_uninit(FrameData *fd) > > +{ > > +av_buffer_unref(>frame_opaque_ref); > > +av_buffer_unref(>hdr10_plus); > > +} > > + > > static av_cold void fifo_free(AVFifo **fifo) > > { > > FrameData fd; > > while (av_fifo_read(*fifo, , 1) >= 0) > > -av_buffer_unref(_plus); > > +frame_data_uninit(); > > av_fifo_freep2(fifo); > > } > > > > -static int frame_data_apply(AVFifo *fifo, AVPacket *pkt) > > +static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo, > > + const AVFrame *frame) > > +{ > > +VPxContext *ctx = avctx->priv_data; > > +const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc; > > + > > +FrameDatafd = { .pts = frame->pts }; > > + > > The alignment of this declaration looks strange. Ah yes, it's a remnant from before I moved it to a separate function. Fixed locally. > > > +AVFrameSideData *av_uninit(sd); > > +int ret; > > + > > +#if CONFIG_LIBVPX_VP9_ENCODER > > +// Keep HDR10+ if it has bit depth higher than 8 and > > +// it has PQ trc (SMPTE2084). > > Out of curiosity are there any HDR10+ files in fate? Yes, there is hevc/hdr10_plus_h265_sample.hevc. I tested that the side data does appear on output packets. > > > [...] > > diff --git a/libavcodec/version.h b/libavcodec/version.h > > index 06631ffa8c..789d9047c2 100644 > > --- a/libavcodec/version.h > > +++ b/libavcodec/version.h > > @@ -30,7 +30,7 @@ > > #include "version_major.h" > > > > #define LIBAVCODEC_VERSION_MINOR 4 > > -#define LIBAVCODEC_VERSION_MICRO 100 > > +#define LIBAVCODEC_VERSION_MICRO 101 > > > > This needs a rebase to apply cleanly. Rebased locally. -- 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 v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile
On Sat, Feb 18, 2023 at 8:43 PM Marth64 wrote: > > Signed-off-by: Marth64 The entire set looks good to me now. If there are no further objections or comments, I'll apply it in a day or two. - Hendrik ___ 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] libavcodec/libfdk-aacnc: send encoder delay/padding in packet side data
On Tue, 28 Feb 2023, JonHGee wrote: Signed-off-by: JonHGee --- libavcodec/libfdk-aacenc.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index 54549de473..954ddab07f 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -21,6 +21,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/common.h" +#include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "avcodec.h" #include "audio_frame_queue.h" @@ -46,6 +47,7 @@ typedef struct AACContext { int latm; int header_period; int vbr; +int delay_sent; AudioFrameQueue afq; } AACContext; @@ -368,7 +370,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int out_buffer_identifier = OUT_BITSTREAM_DATA; int out_buffer_size, out_buffer_element_size; void *in_ptr, *out_ptr; -int ret; +int ret, discard_padding; uint8_t dummy_buf[1]; AACENC_ERROR err; @@ -428,6 +430,27 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(>afq, avctx->frame_size, >pts, >duration); +discard_padding = avctx->frame_size - avpkt->duration; +// Check if subtraction resulted in an overflow +if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) { +av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n"); +av_packet_unref(avpkt); +return AVERROR(EINVAL); +} +if ((!s->delay_sent && avctx->initial_padding > 0) || discard_padding > 0) { +uint8_t *side_data = +av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10); +if (!side_data) { +av_packet_unref(avpkt); +return AVERROR(ENOMEM); +} +if (!s->delay_sent) { +AV_WL32(side_data, avctx->initial_padding); +s->delay_sent = 1; +} +AV_WL32(side_data + 4, discard_padding); +} + avpkt->size = out_args.numOutBytes; *got_packet_ptr = 1; return 0; -- 2.39.2.722.g9855ee24e9-goog LGTM, 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".