Re: [FFmpeg-devel] [PATCH] lavfi/vf_vpp_qsv: fix the infinite loop while framerate lower than input
> -Original Message- > From: Zhong Li > Sent: Saturday, February 29, 2020 13:14 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Cc: Fu, Linjie > Subject: Re: [FFmpeg-devel] [PATCH] lavfi/vf_vpp_qsv: fix the infinite loop > while framerate lower than input > > Linjie Fu 于2020年2月28日周五 下午11:34写道: > > > > There are frame droppings in frc while converting into a lower framerate, > > and MSDK returns ERROR_MORE_DATA which should be ignored. > > Should be fixed in MSDK instead of working around in FFmpeg? MSDK made decision regarding frame rate conversion. If it's the framerate down case, FRC would skip frame without producing an output [1], and request a new input frame. This seems to match the description in mediasdk-man.md [2]: MFX_ERR_MORE_DATA: Need more input frames before VPP can produce an output [1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp#L324 [2] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxvideovpp_runframevppasync ___ 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/2] avformat: Add AMQP version 0-9-1 protocol support
I think this was already rejected? On 2/28/20, Andriy Gelman wrote: > From: Andriy Gelman > > Supports connecting to a RabbitMQ broker via AMQP version 0-9-1. > > Signed-off-by: Andriy Gelman > --- > > Changes in v2: > - Addressed comments from Marton > - Updated documentation > > Compilation notes: > - Requires librabbitmq-dev package (on ubuntu). > - The pkg-config libprabbitmq.pc has a corrupt entry. > **update: fixed on the github master branch** > The line "Libs.private: rt; -lpthread" should be changed to > "Libs.private: -lrt -pthread". > - Compile FFmpeg with --enable-librabbitmq > > To run an example: > # > # Start the RabbitMQ broker (I use docker) > # The following starts the broker on localhost:5672. A webui is available on > # localhost:15672 (User/password is "guest" by default) > # > $ docker run -it --rm --name rabbitmq -p 127.0.0.1:5672:5672 -p > 127.0.0.1:15672:15672 rabbitmq:3-management > > # > # Stream to the RabbitMQ broker: > # > $ ./ffmpeg -re -f lavfi -i yuvtestsrc -codec:v libx264 -f mpegts > -routing_key "amqp" -exchange "amq.direct" amqp://localhost > > # > # Connect any number of clients to fetch data from the broker: > # The clients are filtered by the routing_key and exchange. > # > $ ./ffplay -routing_key "amqp" -exchange "amq.direct" amqp://localhost > > Changelog | 1 + > configure | 5 + > doc/general.texi| 1 + > doc/protocols.texi | 60 + > libavformat/Makefile| 1 + > libavformat/libamqp.c | 286 > libavformat/protocols.c | 1 + > libavformat/version.h | 4 +- > 8 files changed, 357 insertions(+), 2 deletions(-) > create mode 100644 libavformat/libamqp.c > > diff --git a/Changelog b/Changelog > index cb310a3abc2..ab30d670a15 100644 > --- a/Changelog > +++ b/Changelog > @@ -43,6 +43,7 @@ version : > - Rayman 2 ADPCM decoder > - Rayman 2 APM demuxer > - cas video filter > +- AMQP 0-9-1 protocol (RabbitMQ) > > > version 4.2: > diff --git a/configure b/configure > index 06e3a7b2a88..8b171349440 100755 > --- a/configure > +++ b/configure > @@ -255,6 +255,7 @@ External library support: >--enable-libopenmpt enable decoding tracked files via libopenmpt > [no] >--enable-libopus enable Opus de/encoding via libopus [no] >--enable-libpulseenable Pulseaudio input via libpulse [no] > + --enable-librabbitmq enable RabbitMQ library [no] >--enable-librav1eenable AV1 encoding via rav1e [no] >--enable-librsvg enable SVG rasterization via librsvg [no] >--enable-librubberband enable rubberband needed for rubberband filter > [no] > @@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST=" > libopenmpt > libopus > libpulse > +librabbitmq > librav1e > librsvg > librtmp > @@ -3434,6 +3436,8 @@ unix_protocol_deps="sys_un_h" > unix_protocol_select="network" > > # external library protocols > +libamqp_protocol_deps="librabbitmq" > +libamqp_protocol_select="network" > librtmp_protocol_deps="librtmp" > librtmpe_protocol_deps="librtmp" > librtmps_protocol_deps="librtmp" > @@ -6317,6 +6321,7 @@ enabled libopus && { > } > } > enabled libpulse && require_pkg_config libpulse libpulse > pulse/pulseaudio.h pa_context_new > +enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= > 0.7.1" amqp.h amqp_new_connection > enabled librav1e && require_pkg_config librav1e "rav1e >= 0.1.0" > rav1e.h rav1e_context_new > enabled librsvg && require_pkg_config librsvg librsvg-2.0 > librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo > enabled librtmp && require_pkg_config librtmp librtmp > librtmp/rtmp.h RTMP_Socket > diff --git a/doc/general.texi b/doc/general.texi > index dbdc3485982..623566dabea 100644 > --- a/doc/general.texi > +++ b/doc/general.texi > @@ -1330,6 +1330,7 @@ performance on systems without hardware floating point > support). > > @multitable @columnfractions .4 .1 > @item Name @tab Support > +@item AMQP @tab X > @item file @tab X > @item FTP @tab X > @item Gopher @tab X > diff --git a/doc/protocols.texi b/doc/protocols.texi > index 54a287f488b..dc5f49ba8cc 100644 > --- a/doc/protocols.texi > +++ b/doc/protocols.texi > @@ -51,6 +51,66 @@ in microseconds. > > A description of the currently available protocols follows. > > +@section amqp > + > +Advanced Message Queueing Protocol (AMQP) version 0-9-1 is a broker based > +publish-subscribe communication protocol. > + > +FFmpeg must be compiled with --enable-librabbitmq to support AMQP. A > separate > +AMQP broker must also be run. An example open-source AMQP broker is > RabbitMQ. > + > +After starting the broker, an FFmpeg client may stream data to the broker > using > +the command: > + > +@example > +ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port] > +@end exam
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support
Am Fr., 28. Feb. 2020 um 21:57 Uhr schrieb Andriy Gelman : > @@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST=" > libopenmpt > libopus > libpulse > +librabbitmq > librav1e > librsvg > librtmp If the patch is acceptable, I believe this belongs in EXTERNAL_LIBRARY_GPL_LIST Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] GSoC: Regarding Parsing and FLIF16 Frame Encoding
Oh, sorry about that. ___ 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/1] Patch for adding Documentation of ff_http_match_no_proxy
Patch for adding Documentation of ff_http_match_no_proxy Function ff_http_match_no_proxy check for host of proxy address matches with hostname or not. --- libavformat/network.h | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/network.h b/libavformat/network.h index 71347e815b..cd533a7cbc 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -302,7 +302,13 @@ int ff_accept(int fd, int timeout, URLContext *h); int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next); - +/** + * It Check for host of proxy address matches with hostname or not. + * + * @param no_proxy URL of proxy address + * @param hostname URL of hostname + * @return 0 if don't match, 1 for exactly match +*/ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname); int ff_socket(int domain, int type, int protocol); -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC] 2 Alternative approaches for AVFrame QP Tables
[PATCH 1/4] Remove all uses of AVFrame QP tables and related fields [PATCH 2/4] avutil/frame: Rename QP related fields so unintentional These 2 are common in both options, they break API but not ABI so should not be applied before the next release [PATCH 3/4] avutil: frame Update the existing QP API This is a rough sketch of how the existing API can cope with a much wider range of codecs. I did not check if this is enough to handle every codec that has QP values but a variant if this should be able to work with all. [PATCH 4/4] libavutil: AVEncodeInfo data structures This is the alternative to 3/4, which is Juan De Leóns patch which was previously posted and discussed. IIUC there where no objections to this previously but it was not applied by anyone. So Maybe we can just use this. The disadvantage here that i can see is primarely that every codec has to convert its internal format to the one specified in the API. In effect this would need a switch to only export such data when needed. Because otherwise it would waste time. ___ 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] Remove all uses of AVFrame QP tables and related fields in AVFrame
Signed-off-by: Michael Niedermayer --- libavutil/frame.c | 62 +-- 1 file changed, 12 insertions(+), 50 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index e4038096c2..89089c6cc0 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -57,15 +57,6 @@ int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type) AVFrameSideData *sd; AVBufferRef *ref; -FF_DISABLE_DEPRECATION_WARNINGS -av_buffer_unref(&f->qp_table_buf); - -f->qp_table_buf = buf; -f->qscale_table = buf->data; -f->qstride = stride; -f->qscale_type = qp_type; -FF_ENABLE_DEPRECATION_WARNINGS - av_frame_remove_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); av_frame_remove_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); @@ -90,30 +81,22 @@ FF_ENABLE_DEPRECATION_WARNINGS int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type) { AVBufferRef *buf = NULL; +AVFrameSideData *sd; +struct qp_properties *p; *stride = 0; *type = 0; -FF_DISABLE_DEPRECATION_WARNINGS -if (f->qp_table_buf) { -*stride = f->qstride; -*type = f->qscale_type; -buf = f->qp_table_buf; -FF_ENABLE_DEPRECATION_WARNINGS -} else { -AVFrameSideData *sd; -struct qp_properties *p; -sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); -if (!sd) -return NULL; -p = (struct qp_properties *)sd->data; -sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); -if (!sd) -return NULL; -*stride = p->stride; -*type = p->type; -buf = sd->buf; -} +sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); +if (!sd) +return NULL; +p = (struct qp_properties *)sd->data; +sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); +if (!sd) +return NULL; +*stride = p->stride; +*type = p->type; +buf = sd->buf; return buf ? buf->data : NULL; } @@ -408,22 +391,6 @@ FF_ENABLE_DEPRECATION_WARNINGS av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); } -#if FF_API_FRAME_QP -FF_DISABLE_DEPRECATION_WARNINGS -dst->qscale_table = NULL; -dst->qstride = 0; -dst->qscale_type = 0; -av_buffer_unref(&dst->qp_table_buf); -if (src->qp_table_buf) { -dst->qp_table_buf = av_buffer_ref(src->qp_table_buf); -if (dst->qp_table_buf) { -dst->qscale_table = dst->qp_table_buf->data; -dst->qstride = src->qstride; -dst->qscale_type = src->qscale_type; -} -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif av_buffer_unref(&dst->opaque_ref); av_buffer_unref(&dst->private_ref); @@ -565,11 +532,6 @@ void av_frame_unref(AVFrame *frame) av_buffer_unref(&frame->extended_buf[i]); av_freep(&frame->extended_buf); av_dict_free(&frame->metadata); -#if FF_API_FRAME_QP -FF_DISABLE_DEPRECATION_WARNINGS -av_buffer_unref(&frame->qp_table_buf); -FF_ENABLE_DEPRECATION_WARNINGS -#endif av_buffer_unref(&frame->hw_frames_ctx); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avutil: frame Update the existing QP API
This should extend the API to allow exporting internal tables for codecs with block sizes different from 16x16 and different values per plane or multiple values per block. This is unfinished and only to demonstrate how such API (which maintains API/ABI compatibility) would look This API may allow some codecs to export their tables with 0 copy Signed-off-by: Michael Niedermayer --- libavutil/frame.c | 21 libavutil/frame.h | 49 +-- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 89089c6cc0..2cd680c886 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -100,6 +100,27 @@ int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type) return buf ? buf->data : NULL; } + +int av_get_qp_table_type_details(int type, int *block_size, int *independant_qps_per_block, int *dependant_qps_per_block, + int *independant_chroma_planes, int *dependant_chroma_planes, int *independant_alpha_planes, int *dependant_alpha_planes) +{ +*block_size = 16; +*independant_qps_per_block = 0; +* dependant_qps_per_block = 0; +*independant_chroma_planes = 0; +* dependant_chroma_planes = 0; +*independant_alpha_planes = 0; +* dependant_alpha_planes = 0; +switch (type) { +case 0: +case 1: +case 2: +case 3: +return 0; +default: +return AVERROR(EINVAL); +} +} #endif const char *av_get_colorspace_name(enum AVColorSpace val) diff --git a/libavutil/frame.h b/libavutil/frame.h index b966f37fe0..84ee94c7bb 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -715,12 +715,6 @@ attribute_deprecated int av_frame_get_pkt_size(const AVFrame *frame); attribute_deprecated voidav_frame_set_pkt_size(AVFrame *frame, int val); -#if FF_API_FRAME_QP -attribute_deprecated -int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type); -attribute_deprecated -int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type); -#endif attribute_deprecated enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame); attribute_deprecated @@ -731,6 +725,49 @@ attribute_deprecated voidav_frame_set_color_range(AVFrame *frame, enum AVColorRange val); #endif +/** + * Get Quantization parameter table. + * This returns a 2D array of values representing the QP of the specified AVFrame. + * the array is organized in planes then rows then columns then QP per block. + * + * @param stridebytes per row in the returned array + * @returns a 2D array of QP values, the pixels per block depend on the type. + * the array is valid as long as the frame is not destroyed or a new + * qp table set. + * @see av_frame_set_qp_table() + */ +int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type); + +/** + * Set Quantization parameter table. + * This returns a 2D array of values representing the QP of the specified AVFrame. + * + * @param stridebytes per row in the set array + * @returns a 2D array of QP values, the pixels per block depend on the type. + * @see av_frame_set_qp_table() + */ +int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type); + +/** + * Returns the details, each QP represents. + * + * @param block_sizespatial size of the square, each QP represents. + * @param independant_qps_per_block number of independant QP parameters per block (stored for each block) + * @param dependant_qps_per_block number of dependant QP parameters per block (stored for each plane) + * @param independant_chroma_planes number of independant planes for chroma, this can be 0, 1 or 2 + * with 0, the luma plane is used for chroma, with 1 there is + * one QP plane for both chroma components, or 2 for seperate QP + * per Chroma channel. + * @param dependant_chroma_planes number of dependant planes for chroma, for each + * dependant chroma plane a single offset parameter if stored relative to + * the previous plane + * @param independant_alpha_planes number of independant alpha planes of QP components + * @param dependant_alpha_planes number of dependant alpha planes of QP components + */ +int av_get_qp_table_type_details(int type, int *block_size, int *independant_qps_per_block, int *dependant_qps_per_block, + int *independant_chroma_planes, int *dependant_chroma_planes, int *independant_alpha_planes, int *dependant_alpha_planes); + + /** * Get the name of a colorspace. * @return a static string identifying the colorspace; can be NULL. -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubs
[FFmpeg-devel] [PATCH 4/4] libavutil: AVEncodeInfo data structures
From: Juan De León AVEncodeInfoFrame data structure to store as AVFrameSideData of type AV_FRAME_DATA_ENCODE_INFO. The structure stores quantization index for each plane, DC/AC deltas for luma and chroma planes, and an array of AVEncodeInfoBlock type denoting position, size, and delta quantizer for each block in the frame. Can be extended to support extraction of other block information. Signed-off-by: Juan De León Signed-off-by: Michael Niedermayer --- libavutil/Makefile | 2 + libavutil/encode_info.c | 72 ++ libavutil/encode_info.h | 110 libavutil/frame.c | 1 + libavutil/frame.h | 7 +++ 5 files changed, 192 insertions(+) create mode 100644 libavutil/encode_info.c create mode 100644 libavutil/encode_info.h diff --git a/libavutil/Makefile b/libavutil/Makefile index a2dae8e89a..df01424c31 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -24,6 +24,7 @@ HEADERS = adler32.h \ dict.h\ display.h \ downmix_info.h\ + encode_info.h \ encryption_info.h \ error.h \ eval.h\ @@ -112,6 +113,7 @@ OBJS = adler32.o \ dict.o \ display.o\ downmix_info.o \ + encode_info.o\ encryption_info.o\ error.o \ eval.o \ diff --git a/libavutil/encode_info.c b/libavutil/encode_info.c new file mode 100644 index 00..1048173e7f --- /dev/null +++ b/libavutil/encode_info.c @@ -0,0 +1,72 @@ +/* + * 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 + +#include "libavutil/encode_info.h" +#include "libavutil/mem.h" + +/** + * Get the size to allocate of AVEncodeInfoFrame and the array of AVEncodeInfoBlock. + * AVEncodeInfoFrame already allocates size for one element of AVEncodeInfoBlock. + */ +#define AV_ENCODE_INFO_GET_SIZE(SIZE, N) \ +if (N > (SIZE_MAX - sizeof(AVEncodeInfoFrame)) / sizeof(AVEncodeInfoBlock) + 1) \ +return NULL; \ +SIZE = sizeof(AVEncodeInfoFrame) - sizeof(AVEncodeInfoBlock) \ ++ FFMAX(1, N) * sizeof(AVEncodeInfoBlock) + +static int init_encode_info_data(AVEncodeInfoFrame *info, unsigned nb_blocks) +{ +info->nb_blocks = nb_blocks; +info->block_size = sizeof(AVEncodeInfoBlock); +info->blocks_offset = offsetof(AVEncodeInfoFrame, blocks); + +for(int i = 0; i < AV_NUM_DATA_POINTERS; i++) +info->plane_q[i] = -1; + +return 0; +} + +AVEncodeInfoFrame *av_encode_info_alloc(unsigned nb_blocks) +{ +size_t size; +AV_ENCODE_INFO_GET_SIZE(size, nb_blocks); +AVEncodeInfoFrame *ptr = av_mallocz(size); +if (!ptr) +return NULL; + +init_encode_info_data(ptr, nb_blocks); + +return ptr; +} + +AVEncodeInfoFrame *av_encode_info_create_side_data(AVFrame *frame, unsigned nb_blocks) +{ +size_t size; +AV_ENCODE_INFO_GET_SIZE(size, nb_blocks); +AVFrameSideData *sd = av_frame_new_side_data(frame, + AV_FRAME_DATA_ENCODE_INFO, + size); +if (!sd) +return NULL; + +memset(sd->data, 0, size); +init_encode_info_data((AVEncodeInfoFrame*)sd->data, nb_blocks); + +return (AVEncodeInfoFrame*)sd->data; +} diff --git a/libavutil/encode_info.h b/libavutil/encode_info.h new file mode 100644 index 00..8afe0c9c9e --- /dev/null +++ b/libavutil/encode_in
[FFmpeg-devel] [PATCH 2/4] avutil/frame: Rename QP related fields so unintentional use is impossible
Signed-off-by: Michael Niedermayer --- libavutil/frame.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavutil/frame.h b/libavutil/frame.h index b5afb58634..b966f37fe0 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -614,18 +614,18 @@ typedef struct AVFrame { * QP table */ attribute_deprecated -int8_t *qscale_table; +int8_t *qscale_table_deprecated; /** * QP store stride */ attribute_deprecated -int qstride; +int qstride_deprecated; attribute_deprecated -int qscale_type; +int qscale_type_deprecated; attribute_deprecated -AVBufferRef *qp_table_buf; +AVBufferRef *qp_table_deprecated; #endif /** * For hwaccel-format frames, this should be a reference to the -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support
On Sat, 29 Feb 2020, Paul B Mahol wrote: I think this was already rejected? jb questioned if this belongs to libavformat, and timo asked how well the message brokers handle high bitrates/big message sizes, no hard rejects were made as far as I remember. Andriy provided numbers for scaling, I have not answered the concerns regarding libavformat integration, because I am not sure I understand the concern. AMQP is a general purpose protocol for message transfer, it even has an official URL scheme, so when we integrate it into libavformat as a *protocol* I don't really see why it would not fit into the framework or what can be gained if it is implemented separately. If people still have hard feelings against merging this, please speak up, but I honestly don't see a problem with it. Thanks, Marton On 2/28/20, Andriy Gelman wrote: From: Andriy Gelman Supports connecting to a RabbitMQ broker via AMQP version 0-9-1. Signed-off-by: Andriy Gelman --- Changes in v2: - Addressed comments from Marton - Updated documentation Compilation notes: - Requires librabbitmq-dev package (on ubuntu). - The pkg-config libprabbitmq.pc has a corrupt entry. **update: fixed on the github master branch** The line "Libs.private: rt; -lpthread" should be changed to "Libs.private: -lrt -pthread". - Compile FFmpeg with --enable-librabbitmq To run an example: # # Start the RabbitMQ broker (I use docker) # The following starts the broker on localhost:5672. A webui is available on # localhost:15672 (User/password is "guest" by default) # $ docker run -it --rm --name rabbitmq -p 127.0.0.1:5672:5672 -p 127.0.0.1:15672:15672 rabbitmq:3-management # # Stream to the RabbitMQ broker: # $ ./ffmpeg -re -f lavfi -i yuvtestsrc -codec:v libx264 -f mpegts -routing_key "amqp" -exchange "amq.direct" amqp://localhost # # Connect any number of clients to fetch data from the broker: # The clients are filtered by the routing_key and exchange. # $ ./ffplay -routing_key "amqp" -exchange "amq.direct" amqp://localhost Changelog | 1 + configure | 5 + doc/general.texi| 1 + doc/protocols.texi | 60 + libavformat/Makefile| 1 + libavformat/libamqp.c | 286 libavformat/protocols.c | 1 + libavformat/version.h | 4 +- 8 files changed, 357 insertions(+), 2 deletions(-) create mode 100644 libavformat/libamqp.c diff --git a/Changelog b/Changelog index cb310a3abc2..ab30d670a15 100644 --- a/Changelog +++ b/Changelog @@ -43,6 +43,7 @@ version : - Rayman 2 ADPCM decoder - Rayman 2 APM demuxer - cas video filter +- AMQP 0-9-1 protocol (RabbitMQ) version 4.2: diff --git a/configure b/configure index 06e3a7b2a88..8b171349440 100755 --- a/configure +++ b/configure @@ -255,6 +255,7 @@ External library support: --enable-libopenmpt enable decoding tracked files via libopenmpt [no] --enable-libopus enable Opus de/encoding via libopus [no] --enable-libpulseenable Pulseaudio input via libpulse [no] + --enable-librabbitmq enable RabbitMQ library [no] --enable-librav1eenable AV1 encoding via rav1e [no] --enable-librsvg enable SVG rasterization via librsvg [no] --enable-librubberband enable rubberband needed for rubberband filter [no] @@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST=" libopenmpt libopus libpulse +librabbitmq librav1e librsvg librtmp @@ -3434,6 +3436,8 @@ unix_protocol_deps="sys_un_h" unix_protocol_select="network" # external library protocols +libamqp_protocol_deps="librabbitmq" +libamqp_protocol_select="network" librtmp_protocol_deps="librtmp" librtmpe_protocol_deps="librtmp" librtmps_protocol_deps="librtmp" @@ -6317,6 +6321,7 @@ enabled libopus && { } } enabled libpulse && require_pkg_config libpulse libpulse pulse/pulseaudio.h pa_context_new +enabled librabbitmq && require_pkg_config librabbitmq "librabbitmq >= 0.7.1" amqp.h amqp_new_connection enabled librav1e && require_pkg_config librav1e "rav1e >= 0.1.0" rav1e.h rav1e_context_new enabled librsvg && require_pkg_config librsvg librsvg-2.0 librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo enabled librtmp && require_pkg_config librtmp librtmp librtmp/rtmp.h RTMP_Socket diff --git a/doc/general.texi b/doc/general.texi index dbdc3485982..623566dabea 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1330,6 +1330,7 @@ performance on systems without hardware floating point support). @multitable @columnfractions .4 .1 @item Name @tab Support +@item AMQP @tab X @item file @tab X @item FTP @tab X @item Gopher @tab X diff --git a/doc/protocols.texi b/doc/protocols.texi index 54a287f488b..dc5f49ba8cc 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -51,6 +51,66 @@ in microseconds. A description of the currently a
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support
On Sat, 29 Feb 2020, Carl Eugen Hoyos wrote: Am Fr., 28. Feb. 2020 um 21:57 Uhr schrieb Andriy Gelman : @@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST=" libopenmpt libopus libpulse +librabbitmq librav1e librsvg librtmp If the patch is acceptable, I believe this belongs in EXTERNAL_LIBRARY_GPL_LIST librabbitmq license is MIT, so are you sure about this? https://github.com/alanxz/rabbitmq-c/blob/master/LICENSE-MIT Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: Add AMQP version 0-9-1 protocol support
On 2/29/20, Andriy Gelman wrote: > On Sat, 29. Feb 11:21, Paul B Mahol wrote: >> I think this was already rejected? > > Thilo had a question on broker performance, which I believe addressed: > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257483.html > > j-b had concerns about how it fits into libavformat: > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/256977.html > As I see it, this is just another general purpose protocol. Well, i still do not care, but care if others are against it. > > -- > Andriy > ___ 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/2] avformat: Add AMQP version 0-9-1 protocol support
On Sat, 29. Feb 11:21, Paul B Mahol wrote: > I think this was already rejected? Thilo had a question on broker performance, which I believe addressed: http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257483.html j-b had concerns about how it fits into libavformat: http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/256977.html As I see it, this is just another general purpose protocol. -- Andriy ___ 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] GSoC: Regarding Parsing and FLIF16 Frame Encoding
It is just to remind that I am already working on Transformations involved in FLIF and the functions which these transformations use like Symbol Encoding @Anamitra. It would be helpful if someone could help me clear what does RAC refer to in FLIF spec. It is mentioned under Symbol Encoding and is being used repetitively. Thanks On Sat, Feb 29, 2020 at 4:52 PM Anamitra Ghorui wrote: > Oh, sorry about that. > > ___ > 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] GSoC: Regarding Parsing and FLIF16 Frame Encoding
Hi Anamitra, On Sat, Feb 29, 2020 at 04:50:23AM +, Anamitra Ghorui wrote: Hello, I have been reading through the parsing API and other things and here's what I've managed to gather (I will be ignoring overruns in these functions for now). Please tell me if I am right or wrong: 1. As long as the parse function determines next == END_NOT_FOUND, ff_combine_frame will keep increasing the AVParseContext index by buf_size. Once next is no longer END_NOT_FOUND, buf_size will be set to index + next. The bytes from the input chunks are copied into the buffer of AVParseContext during this process. while next == END_NOT_FOUND, and the thing being decoded is a video, we cannot really determine the end of frame, and hence poutbuf and poutbuf_size are set to zero by the function. However, this doesn't really matter for still images since they have a single frame. 2. av_parser_parse2 will look for whether poutbuf_size is greater than zero. If it is, the next frame start offset will be advanced, and the frame offset pointer will be set to the previous value of the next frame offset in AVCodecParserContext. 3. In https://ffmpeg.org/doxygen/trunk/decode_video_8c-example.html pkt->size will be set to zero as long as a frame has not been returned. Hence decode will not be triggered as long as a frame has not been found. Yes this is all correct. Good work of looking at different parsers to understand this. Now, Regarding FLIF16: 1. The pixels of the image are stored in this format (non interlaced): (see https://flif.info/spec.html#_part_4_pixel_data) ___ | _ | || ___ || all ||| _ ||| |||| ||| f1 | x1 x2 x3 . xw |||| || y1 ||_ | c1 ||...||| ||| _ ||| |||| ||| fn | x1 x2 x3 . xw |||| ||||_ ||| ||| |||___||| || ... || || ___ || ||| _ ||| |||| ||| f1 | x1 x2 x3 . xw |||| || yh ||_ ||| ... ||| ||| _ ||| |||| ||| fn | x1 x2 x3 . xw |||| ||||_ ||| ||| |||___||| ||_|| | | | ... | | cn| |___| where: ci: color channel yi: pixel row fi: frame number xi: individual pixel Ah FLIF is a bit wacky. I can see why this might be helpful for decoding partial images on-the-fly, but I don't think it will be easy or even possible to do with the current AVFrame API. The frames are not stored in a contiguous manner as observable. How should I be getting the frame over here? It dosen't seem possible without either putting the whole pixel data chunk in memory, or allocating space for all the frames at once and then putting data in them. I guess what the parser has to do in that case is that it will have to either return the whole file length as the buffer to the decoder function, or make the parser manage frames by itself through its own data structures and component functions. What should I be doing here? For now go with the approach of reading all the data into a single AVPacket. This does mean that parser isn't splitting frames. We can figure out how to do progressive decoding like intended by FLIF later. 2. The FLIF format spec refers to a thing known as the 24 bit RAC. Is it an abbreviation for 24 bit RAnge Coding? (https://en.wikipedia.org/wiki/Range_encoding) What does the "24 bit" mean? Is it the size of each symbol that is processed by the range coder? Yes RAC refers to Range Coding [1]. You can try to match what the reference codec does in [2] with the explanation in [1]. "24 b
[FFmpeg-devel] [PATCH] avformat/mxfenc: use a zero based continuity counter
The standard does not seem to require the counter to be zero based, but some checker tools (MyriadBits MXFInspect, Interra Baton) have validations against 0 start... Fixes ticket #6781. Signed-off-by: Marton Balint --- libavformat/mxfenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 1d8ad57415..a3cc1ea97b 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2671,7 +2671,7 @@ static void mxf_write_system_item(AVFormatContext *s) avio_w8(pb, mxf->content_package_rate); // content package rate avio_w8(pb, 0x00); // content package type avio_wb16(pb, 0x00); // channel handle -avio_wb16(pb, (mxf->tc.start + frame) & 0x); // continuity count, supposed to overflow +avio_wb16(pb, frame & 0x); // continuity count, supposed to overflow if (mxf->essence_container_count > 1) avio_write(pb, multiple_desc_ul, 16); else { -- 2.16.4 ___ 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/2] avformat: Add AMQP version 0-9-1 protocol support
> Am 29.02.2020 um 17:19 schrieb Marton Balint : > > > >> On Sat, 29 Feb 2020, Carl Eugen Hoyos wrote: >> >> Am Fr., 28. Feb. 2020 um 21:57 Uhr schrieb Andriy Gelman >> : >> >>> @@ -1789,6 +1790,7 @@ EXTERNAL_LIBRARY_LIST=" >>> libopenmpt >>> libopus >>> libpulse >>> +librabbitmq >>> librav1e >>> librsvg >>> librtmp >> >> If the patch is acceptable, I believe this belongs in >> EXTERNAL_LIBRARY_GPL_LIST > > librabbitmq license is MIT, so are you sure about this? > > https://github.com/alanxz/rabbitmq-c/blob/master/LICENSE-MIT Yes, definitely. Sorry for the noise, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4 v2] avcodec/librav1e: adapt to the new internal encode API
Signed-off-by: James Almer --- Fixed retrying to feed librav1e a frame after it returned RA_ENCODER_STATUS_ENOUGH_DATA the previous time (Can't be reproduced right now as librav1e hasn't yet introduced a queue limit). Also, no reindenting stuff this time to show the needed changes are trivial. Must still be squashed into PATCH 2/2 libavcodec/librav1e.c | 51 --- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index b8b1b4f8f1..ba8c2a56f9 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -30,12 +30,15 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" typedef struct librav1eContext { const AVClass *class; RaContext *ctx; +AVFrame *frame; +RaFrame *rframe; AVBSFContext *bsf; uint8_t *pass_data; @@ -165,7 +168,12 @@ static av_cold int librav1e_encode_close(AVCodecContext *avctx) rav1e_context_unref(ctx->ctx); ctx->ctx = NULL; } +if (ctx->rframe) { +rav1e_frame_unref(ctx->rframe); +ctx->rframe = NULL; +} +av_frame_free(&ctx->frame); av_bsf_free(&ctx->bsf); av_freep(&ctx->pass_data); @@ -180,6 +188,10 @@ static av_cold int librav1e_encode_init(AVCodecContext *avctx) int rret; int ret = 0; +ctx->frame = av_frame_alloc(); +if (!ctx->frame) +return AVERROR(ENOMEM); + cfg = rav1e_config_default(); if (!cfg) { av_log(avctx, AV_LOG_ERROR, "Could not allocate rav1e config.\n"); @@ -399,18 +411,27 @@ end: return ret; } -static int librav1e_send_frame(AVCodecContext *avctx, const AVFrame *frame) +static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) { librav1eContext *ctx = avctx->priv_data; -RaFrame *rframe = NULL; +RaFrame *rframe = ctx->rframe; +RaPacket *rpkt = NULL; int ret; -if (frame) { +if (!rframe) { +AVFrame *frame = ctx->frame; + +ret = ff_encode_get_frame(avctx, frame); +if (ret < 0 && ret != AVERROR_EOF) +return ret; + +if (frame->buf[0]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); rframe = rav1e_frame_new(ctx->ctx); if (!rframe) { av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e frame.\n"); +av_frame_unref(frame); return AVERROR(ENOMEM); } @@ -421,17 +442,23 @@ static int librav1e_send_frame(AVCodecContext *avctx, const AVFrame *frame) (frame->height >> shift) * frame->linesize[i], frame->linesize[i], bytes); } +av_frame_unref(frame); +} } ret = rav1e_send_frame(ctx->ctx, rframe); if (rframe) +if (ret == RA_ENCODER_STATUS_ENOUGH_DATA) { +ctx->rframe = rframe; /* Queue is full. Store the RaFrame to retry next call */ +} else { rav1e_frame_unref(rframe); /* No need to unref if flushing. */ +ctx->rframe = NULL; +} switch (ret) { case RA_ENCODER_STATUS_SUCCESS: -break; case RA_ENCODER_STATUS_ENOUGH_DATA: -return AVERROR(EAGAIN); +break; case RA_ENCODER_STATUS_FAILURE: av_log(avctx, AV_LOG_ERROR, "Could not send frame: %s\n", rav1e_status_to_str(ret)); return AVERROR_EXTERNAL; @@ -440,15 +467,6 @@ static int librav1e_send_frame(AVCodecContext *avctx, const AVFrame *frame) return AVERROR_UNKNOWN; } -return 0; -} - -static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt) -{ -librav1eContext *ctx = avctx->priv_data; -RaPacket *rpkt = NULL; -int ret; - retry: if (avctx->flags & AV_CODEC_FLAG_PASS1) { @@ -473,9 +491,7 @@ retry: } return AVERROR_EOF; case RA_ENCODER_STATUS_ENCODED: -if (avctx->internal->draining) -goto retry; -return AVERROR(EAGAIN); +goto retry; case RA_ENCODER_STATUS_NEED_MORE_DATA: if (avctx->internal->draining) { av_log(avctx, AV_LOG_ERROR, "Unexpected error when receiving packet after EOF.\n"); @@ -575,7 +591,6 @@ AVCodec ff_librav1e_encoder = { .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AV1, .init = librav1e_encode_init, -.send_frame = librav1e_send_frame, .receive_packet = librav1e_receive_packet, .close = librav1e_encode_close, .priv_data_size = sizeof(librav1eContext), -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/mxfenc: use a zero based continuity counter
The standard does not seem to require the counter to be zero based, but some checker tools (MyriadBits MXFInspect, Interra Baton) have validations against 0 start... Fixes ticket #6781. Signed-off-by: Marton Balint --- libavformat/mxfenc.c | 2 +- tests/ref/fate/mxf-user-comments | 2 +- tests/ref/lavf/mxf | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 7ea47d7311..5e0dc0e889 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -2686,7 +2686,7 @@ static void mxf_write_system_item(AVFormatContext *s) avio_w8(pb, mxf->content_package_rate); // content package rate avio_w8(pb, 0x00); // content package type avio_wb16(pb, 0x00); // channel handle -avio_wb16(pb, (mxf->tc.start + frame) & 0x); // continuity count, supposed to overflow +avio_wb16(pb, frame & 0x); // continuity count, supposed to overflow if (mxf->essence_container_count > 1) avio_write(pb, multiple_desc_ul, 16); else { diff --git a/tests/ref/fate/mxf-user-comments b/tests/ref/fate/mxf-user-comments index 4b734a0f85..e91b23baa5 100644 --- a/tests/ref/fate/mxf-user-comments +++ b/tests/ref/fate/mxf-user-comments @@ -1 +1 @@ -683bacb0105e5bc5bbf46aa430c644d1 +c6469c0ae2aaee602eacbc009080ae8e diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf index 471fc5518e..5b16496f06 100644 --- a/tests/ref/lavf/mxf +++ b/tests/ref/lavf/mxf @@ -1,7 +1,7 @@ -649009e3d3d62eb3b6c56334d057cc4d *tests/data/lavf/lavf.mxf +27b98795036b334e100c15c7e06d948f *tests/data/lavf/lavf.mxf 526393 tests/data/lavf/lavf.mxf tests/data/lavf/lavf.mxf CRC=0x8dddfaab -9076b7015cffe8aa72883e900a2041a5 *tests/data/lavf/lavf.mxf +783b475a818602f54e947094d57e2981 *tests/data/lavf/lavf.mxf 561721 tests/data/lavf/lavf.mxf tests/data/lavf/lavf.mxf CRC=0x96ff1b48 02bf8f0cd8951a49e277306691cb1538 *tests/data/lavf/lavf.mxf -- 2.16.4 ___ 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] [avfomat/rtp: source ips lost when specified as URL options] Patch for ffmpeg using rtp protocol where sources option is not retained
Ping... > On 26 Feb 2020, at 08:57, Ross Nicholson wrote: > > > Thanks, just thought you might have another idea, as it works just was not > sure if I was accomplishing it in the right way. > > Ya, I submitted the patch formally. Let’s see what’s a review comes back like. > > Thanks > >>> On 26 Feb 2020, at 05:10, Jun Li wrote: >>> >> >> >> >>> On Tue, Feb 25, 2020 at 5:01 AM Ross Nicholson wrote: >>> Hey Jun Li, >>> >>> I noticed you have submitted some patches which work around the same code >>> area's that I submitted for. Your patches look quite tidy and well thought >>> out so I was wondering if you could look at this patch and see if I'm going >>> about it in the right way. >>> >>> I'm not sure this area of ffmpeg currently has a maintainer currently so >>> the patches may be difficult to progress. >>> >>> Ross >>> On Tue, 11 Feb 2020 at 22:42, Ross Nicholson wrote: The patch was created as a workaround to an issue from in kodi (apologies, it's a rather long thread): https://forum.kodi.tv/showthread.php?tid=350901&pid=2923550#pid2923550 As an example, here is a URL: rtp://87.141.215.251@232.0.10.234:1 Taking this URL we should be able to either reformat it to: rtp://232.0.10.234:1?sources=87.141.215.251 or pass the sources as an av_dict to avfomat_open_input. Neither option works however. Instead the above workaround was created but it's not really the right way to fix this. Would be great to get some guidance on the right place to fix this in the right way. Thanks in advance. > On Tue, 11 Feb 2020 at 22:30, phunkyfish wrote: > --- > libavformat/rtsp.c | 26 -- > 1 file changed, 24 insertions(+), 2 deletions(-) > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > index 859defa592..f922055134 100644 > --- a/libavformat/rtsp.c > +++ b/libavformat/rtsp.c > @@ -2334,7 +2334,9 @@ static int sdp_read_header(AVFormatContext *s) > RTSPStream *rtsp_st; > int size, i, err; > char *content; > +const char *p, *sp="", *sources="", *sp2, *sources2; > char url[1024]; > +char sources_buf[1024]; > > if (!ff_network_init()) > return AVERROR(EIO); > @@ -2360,6 +2362,16 @@ static int sdp_read_header(AVFormatContext *s) > av_freep(&content); > if (err) goto fail; > > +/* Search for sources= tag in original URL for rtp protocol only */ > +if (strncmp(s->url, "rtp://", 6) == 0) { > +p = strchr(s->url, '?'); > +if (p && av_find_info_tag(sources_buf, sizeof(sources_buf), > "sources", p)) { > +/* av_log(s, AV_LOG_VERBOSE, "sdp_read_header found sources > %s\n", sources_buf); */ > +sp = sources_buf; > +sources = "&sources="; > +} > +} > + > /* open each RTP stream */ > for (i = 0; i < rt->nb_rtsp_streams; i++) { > char namebuf[50]; > @@ -2377,12 +2389,22 @@ static int sdp_read_header(AVFormatContext *s) > av_dict_free(&opts); > goto fail; > } > + > +/* Prepare to add sources to the url to be opened. > + Otherwise the join to the source specific muliticast will > be missing */ > +sources2 = sources; > +sp2 = sp; > +/* ignore sources from original URL, when sources are > already set in rtsp_st */ > +if (rtsp_st->nb_include_source_addrs > 0) > +sources2 = sp2 = ""; > + > ff_url_join(url, sizeof(url), "rtp", NULL, > namebuf, rtsp_st->sdp_port, > - > "?localport=%d&ttl=%d&connect=%d&write_to_source=%d", > + > "?localport=%d&ttl=%d&connect=%d&write_to_source=%d%s%s", > rtsp_st->sdp_port, rtsp_st->sdp_ttl, > rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0, > -rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : > 0); > +rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : > 0, > +sources2, sp2); > > append_source_addrs(url, sizeof(url), "sources", > rtsp_st->nb_include_source_addrs, > -- > 2.20.1 (Apple Git-117) > >> >> Hi Ross, >> I am not sure I understand your requirement clearly, an alternative way is >> to save the url in sdp(maybe in rtp_read_header?) and read it out in >> sdp_read_header. But I am not sure which field can carry this info (maybe >> uri attribute ?). >> >> Since you already have the code change, why now send it as a formal patch so >> that
Re: [FFmpeg-devel] [PATCH 1/1] Patch for adding Documentation of ff_http_match_no_proxy
On Sat, Feb 29, 2020 at 05:07:30PM +0530, Sourabh Sharma wrote: > Patch for adding Documentation of ff_http_match_no_proxy > > Function ff_http_match_no_proxy check for host of proxy address > matches with hostname or not. > --- > libavformat/network.h | 8 +++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/libavformat/network.h b/libavformat/network.h > index 71347e815b..cd533a7cbc 100644 > --- a/libavformat/network.h > +++ b/libavformat/network.h > @@ -302,7 +302,13 @@ int ff_accept(int fd, int timeout, URLContext *h); > int ff_listen_connect(int fd, const struct sockaddr *addr, >socklen_t addrlen, int timeout, >URLContext *h, int will_try_next); > - > +/** > + * It Check for host of proxy address matches with hostname or not. This has some english grammer issues. Also look at how other similar function doxy is worded > + * > + * @param no_proxy URL of proxy address > + * @param hostname URL of hostname I dont think the function would be understood from just this thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Does the universe only have a finite lifespan? No, its going to go on forever, its just that you wont like living in it. -- Hiranya Peiri 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 1/2] fftools/ffmpeg_opt: Fix leak of options when parsing options fails
On Fri, Feb 28, 2020 at 11:30:28PM +0100, Paul B Mahol wrote: > lgtm will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato 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 2/2] avfilter/vf_cas: Remove superfluous ;
On Fri, Feb 28, 2020 at 11:30:43PM +0100, Paul B Mahol wrote: > lgtm will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg_opt: warn about overwritten parsed options
Signed-off-by: Marton Balint --- fftools/ffmpeg_opt.c | 70 +--- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 12d44886ee..3d6fafe073 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -44,16 +44,80 @@ #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" +#define SPECIFIER_OPT_FMT_str "%s" +#define SPECIFIER_OPT_FMT_i"%i" +#define SPECIFIER_OPT_FMT_i64 "%"PRId64"d" +#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64"d" +#define SPECIFIER_OPT_FMT_f"%f" +#define SPECIFIER_OPT_FMT_dbl "%lf" + +static const char *opt_name_codec_names[] = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL}; +static const char *opt_name_audio_channels[]= {"ac", NULL}; +static const char *opt_name_audio_sample_rate[] = {"ar", NULL}; +static const char *opt_name_frame_rates[] = {"r", NULL}; +static const char *opt_name_frame_sizes[] = {"s", NULL}; +static const char *opt_name_frame_pix_fmts[]= {"pix_fmt", NULL}; +static const char *opt_name_ts_scale[] = {"itsscale", NULL}; +static const char *opt_name_hwaccels[] = {"hwaccel", NULL}; +static const char *opt_name_hwaccel_devices[] = {"hwaccel_device", NULL}; +static const char *opt_name_hwaccel_output_formats[]= {"hwaccel_output_format", NULL}; +static const char *opt_name_autorotate[]= {"autorotate", NULL}; +static const char *opt_name_max_frames[]= {"frames", "aframes", "vframes", "dframes", NULL}; +static const char *opt_name_bitstream_filters[] = {"bsf", "absf", "vbsf", NULL}; +static const char *opt_name_codec_tags[]= {"tag", "atag", "vtag", "stag", NULL}; +static const char *opt_name_sample_fmts[] = {"sample_fmt", NULL}; +static const char *opt_name_qscale[]= {"q", "qscale", NULL}; +static const char *opt_name_forced_key_frames[] = {"forced_key_frames", NULL}; +static const char *opt_name_force_fps[] = {"force_fps", NULL}; +static const char *opt_name_frame_aspect_ratios[] = {"aspect", NULL}; +static const char *opt_name_rc_overrides[] = {"rc_override", NULL}; +static const char *opt_name_intra_matrices[]= {"intra_matrix", NULL}; +static const char *opt_name_inter_matrices[]= {"inter_matrix", NULL}; +static const char *opt_name_chroma_intra_matrices[] = {"chroma_intra_matrix", NULL}; +static const char *opt_name_top_field_first[] = {"top", NULL}; +static const char *opt_name_presets[] = {"pre", "apre", "vpre", "spre", NULL}; +static const char *opt_name_copy_initial_nonkeyframes[] = {"copyinkfr", NULL}; +static const char *opt_name_copy_prior_start[] = {"copypriorss", NULL}; +static const char *opt_name_filters[] = {"filter", "af", "vf", NULL}; +static const char *opt_name_filter_scripts[]= {"filter_script", NULL}; +static const char *opt_name_reinit_filters[]= {"reinit_filter", NULL}; +static const char *opt_name_fix_sub_duration[] = {"fix_sub_duration", NULL}; +static const char *opt_name_canvas_sizes[] = {"canvas_size", NULL}; +static const char *opt_name_pass[] = {"pass", NULL}; +static const char *opt_name_passlogfiles[] = {"passlogfile", NULL}; +static const char *opt_name_max_muxing_queue_size[] = {"max_muxing_queue_size", NULL}; +static const char *opt_name_guess_layout_max[] = {"guess_layout_max", NULL}; +static const char *opt_name_apad[] = {"apad", NULL}; +static const char *opt_name_discard[] = {"discard", NULL}; +static const char *opt_name_disposition[] = {"disposition", NULL}; +static const char *opt_name_time_bases[]= {"time_base", NULL}; +static const char *opt_name_enc_time_bases[]= {"enc_time_base", NULL}; + +#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\ +{\ +char namestr[128] = "";\ +const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\ +for (i = 0; opt_name_##name[i]; i++)\ +av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\ +av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\ + namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\ +} + #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ {\ -int i, ret;\ +int i, ret, matches = 0;\ +SpecifierOpt *so;\ for (i = 0; i < o->nb_ ## name; i++) {\ char *spec = o->name[i].specifier;\ -if ((ret = check_stream_specifier(fmtctx, st
[FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg_opt: remove bogus warning of multiple -af and -vf usage
This is redundant after the last patch and also fixes ticket #7712. Signed-off-by: Marton Balint --- fftools/ffmpeg_opt.c | 4 1 file changed, 4 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 3d6fafe073..df6928ee10 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1746,8 +1746,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); MATCH_PER_STREAM_OPT(filters,str, ost->filters,oc, st); -if (o->nb_filters > 1) -av_log(NULL, AV_LOG_ERROR, "Only '-vf %s' read, ignoring remaining -vf options: Use ',' to separate filters\n", ost->filters); if (!ost->stream_copy) { const char *p = NULL; @@ -1929,8 +1927,6 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st); MATCH_PER_STREAM_OPT(filters,str, ost->filters,oc, st); -if (o->nb_filters > 1) -av_log(NULL, AV_LOG_ERROR, "Only '-af %s' read, ignoring remaining -af options: Use ',' to separate filters\n", ost->filters); if (!ost->stream_copy) { char *sample_fmt = NULL; -- 2.16.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/siren: Check several indexes
Fixes: Multiple out of array accesses Fixes: 20817/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SIREN_fuzzer-5754041227542528.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/siren.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavcodec/siren.c b/libavcodec/siren.c index 2577ff52dd..76dfe62843 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -428,6 +428,7 @@ static int decode_envelope(SirenContext *s, GetBitContext *gb, int *absolute_region_power_index, int esf_adjustment) { absolute_region_power_index[0] = (int)get_bits(gb, 5) - esf_adjustment; +absolute_region_power_index[0] = av_clip(absolute_region_power_index[0], -24, 39); decoder_standard_deviation[0] = s->standard_deviation[absolute_region_power_index[0] + 24]; for (int i = 1; i < number_of_regions; i++) { @@ -437,7 +438,7 @@ static int decode_envelope(SirenContext *s, GetBitContext *gb, index = differential_decoder_tree[i - 1][index][get_bits1(gb)]; } while (index > 0); -absolute_region_power_index[i] = absolute_region_power_index[i - 1] - index - 12; +absolute_region_power_index[i] = av_clip(absolute_region_power_index[i - 1] - index - 12, -24, 39); decoder_standard_deviation[i] = s->standard_deviation[absolute_region_power_index[i] + 24]; } @@ -500,6 +501,8 @@ static int categorize_regions(int number_of_regions, int number_of_available_bit } } } +if (raw_value == -99) +return AVERROR_INVALIDDATA; *min_rate_ptr++ = raw_min_idx; min += expected_bits_table[min_rate_categories[raw_min_idx] + 1] - @@ -518,6 +521,8 @@ static int categorize_regions(int number_of_regions, int number_of_available_bit } } } +if (raw_value == 99) +return AVERROR_INVALIDDATA; *--max_rate_ptr = raw_max_idx; max += expected_bits_table[max_rate_categories[raw_max_idx] - 1] - @@ -684,9 +689,11 @@ static int siren_decode(AVCodecContext *avctx, void *data, rate_control = get_bits(gb, 4); -categorize_regions(s->number_of_regions, get_bits_left(gb), - s->absolute_region_power_index, s->power_categories, - s->category_balance); +ret = categorize_regions(s->number_of_regions, get_bits_left(gb), + s->absolute_region_power_index, s->power_categories, + s->category_balance); +if (ret < 0) +return ret; for (int i = 0; i < rate_control; i++) s->power_categories[s->category_balance[i]]++; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/cuviddec: use AVCodec.bsfs to filter packets
Simplifies code considerably. Signed-off-by: James Almer --- libavcodec/cuviddec.c | 78 +-- 1 file changed, 16 insertions(+), 62 deletions(-) diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index acee78cf2c..69c64055fe 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -70,8 +70,6 @@ typedef struct CuvidContext AVBufferRef *hwdevice; AVBufferRef *hwframe; -AVBSFContext *bsf; - AVFifoBuffer *frame_queue; int deint_mode; @@ -387,8 +385,6 @@ static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) AVCUDADeviceContext *device_hwctx = device_ctx->hwctx; CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx; CUVIDSOURCEDATAPACKET cupkt; -AVPacket filter_packet = { 0 }; -AVPacket filtered_packet = { 0 }; int ret = 0, eret = 0, is_flush = ctx->decoder_flushing; av_log(avctx, AV_LOG_TRACE, "cuvid_decode_packet\n"); @@ -399,29 +395,8 @@ static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) if (cuvid_is_buffer_full(avctx) && avpkt && avpkt->size) return AVERROR(EAGAIN); -if (ctx->bsf && avpkt && avpkt->size) { -if ((ret = av_packet_ref(&filter_packet, avpkt)) < 0) { -av_log(avctx, AV_LOG_ERROR, "av_packet_ref failed\n"); -return ret; -} - -if ((ret = av_bsf_send_packet(ctx->bsf, &filter_packet)) < 0) { -av_log(avctx, AV_LOG_ERROR, "av_bsf_send_packet failed\n"); -av_packet_unref(&filter_packet); -return ret; -} - -if ((ret = av_bsf_receive_packet(ctx->bsf, &filtered_packet)) < 0) { -av_log(avctx, AV_LOG_ERROR, "av_bsf_receive_packet failed\n"); -return ret; -} - -avpkt = &filtered_packet; -} - ret = CHECK_CU(ctx->cudl->cuCtxPushCurrent(cuda_ctx)); if (ret < 0) { -av_packet_unref(&filtered_packet); return ret; } @@ -445,8 +420,6 @@ static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, &cupkt)); -av_packet_unref(&filtered_packet); - if (ret < 0) goto error; @@ -699,9 +672,6 @@ static av_cold int cuvid_decode_end(AVCodecContext *avctx) av_fifo_freep(&ctx->frame_queue); -if (ctx->bsf) -av_bsf_free(&ctx->bsf); - if (ctx->cuparser) ctx->cvdl->cuvidDestroyVideoParser(ctx->cuparser); @@ -823,7 +793,6 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) CUVIDSOURCEDATAPACKET seq_pkt; CUcontext cuda_ctx = NULL; CUcontext dummy; -const AVBitStreamFilter *bsf; int ret = 0; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_CUDA, @@ -976,28 +945,12 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) return AVERROR_BUG; } -if (avctx->codec->id == AV_CODEC_ID_H264 || avctx->codec->id == AV_CODEC_ID_HEVC) { -if (avctx->codec->id == AV_CODEC_ID_H264) -bsf = av_bsf_get_by_name("h264_mp4toannexb"); -else -bsf = av_bsf_get_by_name("hevc_mp4toannexb"); - -if (!bsf) { -ret = AVERROR_BSF_NOT_FOUND; -goto error; -} -if (ret = av_bsf_alloc(bsf, &ctx->bsf)) { -goto error; -} -if (((ret = avcodec_parameters_from_context(ctx->bsf->par_in, avctx)) < 0) || ((ret = av_bsf_init(ctx->bsf)) < 0)) { -av_bsf_free(&ctx->bsf); -goto error; -} - -ctx->cuparse_ext.format.seqhdr_data_length = ctx->bsf->par_out->extradata_size; +if (avctx->codec->bsfs) { +const AVBSFContext *bsf = avctx->internal->filter.bsfs[avctx->internal->filter.nb_bsfs - 1]; +ctx->cuparse_ext.format.seqhdr_data_length = bsf->par_out->extradata_size; memcpy(ctx->cuparse_ext.raw_seqhdr_data, - ctx->bsf->par_out->extradata, - FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), ctx->bsf->par_out->extradata_size)); + bsf->par_out->extradata, + FFMIN(sizeof(ctx->cuparse_ext.raw_seqhdr_data), bsf->par_out->extradata_size)); } else if (avctx->extradata_size > 0) { ctx->cuparse_ext.format.seqhdr_data_length = avctx->extradata_size; memcpy(ctx->cuparse_ext.raw_seqhdr_data, @@ -1142,7 +1095,7 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] = { NULL }; -#define DEFINE_CUVID_CODEC(x, X) \ +#define DEFINE_CUVID_CODEC(x, X, bsf_name) \ static const AVClass x##_cuvid_class = { \ .class_name = #x "_cuvid", \ .item_name = av_default_item_name, \ @@ -1161,6 +1114,7 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] = { .decode = cuvid_decode_frame, \ .receive_frame = cuvid_output_frame, \ .flush = cuvid_flush, \ +.bsfs = bsf_name, \ .capa
Re: [FFmpeg-devel] [PATCH 2/4] avcodec/encode: restructure the core encoding code
On Thu, 27. Feb 15:02, James Almer wrote: > This commit follows the same logic as 061a0c14bb, but for the encode API: The > new public encoding API will no longer be a wrapper around the old deprecated > one, and the internal API used by the encoders now consists of a single > receive_packet() callback that pulls frames as required. > > Signed-off-by: James Almer > --- > libavcodec/avcodec.h | 12 +- > libavcodec/encode.c | 268 -- > libavcodec/encode.h | 39 ++ > libavcodec/internal.h | 7 +- > libavcodec/utils.c| 12 +- > 5 files changed, 268 insertions(+), 70 deletions(-) > create mode 100644 libavcodec/encode.h > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 894a9e5565..9d22390dd3 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -3641,14 +3641,10 @@ typedef struct AVCodec { > int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, > AVPacket *avpkt); > int (*close)(AVCodecContext *); > /** > - * Encode API with decoupled packet/frame dataflow. The API is the > - * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except > - * that: > - * - never called if the codec is closed or the wrong type, > - * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent, > - * - only one drain frame is ever passed down, > - */ > -int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame); > + * Encode API with decoupled frame/packet dataflow. This function is > called > + * to get one output packet. It should call ff_encode_get_packet() to > obtain should it be ff_encode_get_frame() ? > + * input data. > + */ > int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt); > > /** > diff --git a/libavcodec/encode.c b/libavcodec/encode.c > index 9ed2cf0f59..a887a0ab55 100644 > --- a/libavcodec/encode.c > +++ b/libavcodec/encode.c > @@ -26,6 +26,7 @@ > #include "libavutil/samplefmt.h" > > #include "avcodec.h" > +#include "encode.h" > #include "frame_thread_encoder.h" > #include "internal.h" > > @@ -359,101 +360,250 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, > uint8_t *buf, int buf_size, > return ret; > } > > -static int do_encode(AVCodecContext *avctx, const AVFrame *frame, int > *got_packet) > +int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame) > { > +AVCodecInternal *avci = avctx->internal; > + > +if (avci->draining) > +return AVERROR_EOF; > + > +if (!avci->buffer_frame->buf[0]) > +return AVERROR(EAGAIN); > + > +av_frame_move_ref(frame, avci->buffer_frame); > + > +return 0; > +} > + > +static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) > +{ > +AVCodecInternal *avci = avctx->internal; > +EncodeSimpleContext *es = &avci->es; > +AVFrame *frame = es->in_frame; > +AVFrame *padded_frame = NULL; > +int got_packet; > int ret; > -*got_packet = 0; > > -av_packet_unref(avctx->internal->buffer_pkt); > -avctx->internal->buffer_pkt_valid = 0; > +if (!frame->buf[0] && !avci->draining) { > +av_frame_unref(frame); > +ret = ff_encode_get_frame(avctx, frame); > +if (ret < 0 && ret != AVERROR_EOF) > +return ret; > +} > > -if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { > -ret = avcodec_encode_video2(avctx, avctx->internal->buffer_pkt, > -frame, got_packet); > -} else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { > -ret = avcodec_encode_audio2(avctx, avctx->internal->buffer_pkt, > -frame, got_packet); > -} else { > -ret = AVERROR(EINVAL); > +if (avci->draining_done) > +return AVERROR_EOF; > + > +if (!frame->buf[0]) { > +if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY || > + avctx->active_thread_type & FF_THREAD_FRAME)) > +return AVERROR_EOF; > + > +// Flushing is signaled with a NULL frame > +frame = NULL; > +} > + > +got_packet = 0; > + > +if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) { > +if ((avctx->flags & AV_CODEC_FLAG_PASS1) && avctx->stats_out) > +avctx->stats_out[0] = '\0'; > + > +if (av_image_check_size2(avctx->width, avctx->height, > avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) { > +ret = AVERROR(EINVAL); > +goto end; > +} > +if (frame) { > +if (frame->format == AV_PIX_FMT_NONE) > +av_log(avctx, AV_LOG_WARNING, "AVFrame.format is not set\n"); > +if (frame->width == 0 || frame->height == 0) > +av_log(avctx, AV_LOG_WARNING, "AVFrame.width or height is > not set\n"); > +} > +} else if (frame && avctx->codec->type == AVMEDIA_TYPE_AUDIO) { > +/* extract audio service type metadata */ > +