Re: [FFmpeg-devel] [PATCH] cbs_av1: Fill tile width/height values when uniform_tile_spacing_flag is set
> -Original Message- > From: ffmpeg-devel On Behalf Of Mark > Thompson > Sent: Sunday, August 23, 2020 6:26 AM > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH] cbs_av1: Fill tile width/height values when > uniform_tile_spacing_flag is set > > They are not explicitly in the bitstream in this case, but it is helpful to > be able to > use these values without always needing to check the flag beforehand. > --- > On 22/08/2020 23:01, Mark Thompson wrote: > > On 21/08/2020 06:29, Fei Wang wrote: > >> ... > >> + > >> + if (s->raw_frame_header.uniform_tile_spacing_flag) { > >> + mi_cols = 2 * ((s->raw_seq.max_frame_width_minus_1 + 8) >> > >> +3); > >> + mi_rows = 2 * ((s->raw_seq.max_frame_height_minus_1 + 8) >> > >> +3); > >> + sb_cols = s->raw_seq.use_128x128_superblock ? ((mi_cols + > >> +31) >> 5) > >> + : ((mi_cols + > >> +15) >> 4); > >> + sb_rows = s->raw_seq.use_128x128_superblock ? ((mi_rows + > >> +31) >> 5) > >> + : ((mi_rows + > >> +15) >> 4); > >> + tile_width_sb = (sb_cols + (1 << > >> +s->raw_frame_header.tile_cols_log2) > >> + -1) >> s->raw_frame_header.tile_cols_log2; > >> + tile_height_sb = (sb_rows + (1 << > >> +s->raw_frame_header.tile_rows_log2) > >> + -1) >> s->raw_frame_header.tile_rows_log2; > > > > Maybe cbs read should always fill the width/height_in_sbs arrays so that all > the special casing for uniform_spacing_flag in this function isn't needed? It > would be trivial to add it there. > > Like this. > > libavcodec/cbs_av1_syntax_template.c | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/libavcodec/cbs_av1_syntax_template.c > b/libavcodec/cbs_av1_syntax_template.c > index a315e8868a..2c976a9574 100644 > --- a/libavcodec/cbs_av1_syntax_template.c > +++ b/libavcodec/cbs_av1_syntax_template.c > @@ -624,6 +624,15 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, > RWContext *rw, > current->tile_rows_log2; > current->tile_rows = (sb_rows + tile_height_sb - 1) / > tile_height_sb; > > +for (i = 0; i < current->tile_cols - 1; i++) > +infer(width_in_sbs_minus_1[i], tile_width_sb); > +infer(width_in_sbs_minus_1[i], > + sb_cols - (current->tile_cols - 1) * tile_width_sb); Should this by using "tile_width_sb -1" and "sb_cols - (current->tile_cols - 1) * tile_width_sb - 1" ? And same for height_in_sbs_minus_1. > +for (i = 0; i < current->tile_rows - 1; i++) > +infer(height_in_sbs_minus_1[i], tile_height_sb); > +infer(height_in_sbs_minus_1[i], > + sb_rows - (current->tile_rows - 1) * tile_height_sb); > + > } else { > int widest_tile_sb, start_sb, size_sb, max_width, max_height; > > -- > 2.28.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 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] [FFmpeg-user] ffplay.exe leaves fullscreen mode and iconifies when losing focus
Dear Developers, I would like to use ffplay.exe in may application to play video files and to show live video sources. Thank you for that great application that covers all these possibilities! However as soon as ffplay.exe loses the input focus the fullscreen window of ffplay is iconified. I aloready reviewed the source code (event loop) but was notz abel to identify the handling that causes that behaviour. Is it possible to change the behaviour so that ffplay stays maximised even if the focus is lost or the ffplay windows is covered by an other window? Possibly by using a command line option? Best regards, Norbert Marouschek. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avcodec/cfhd: More strictly check tag order and multiplicity
On 8/31/20, Michael Niedermayer wrote: > This is based on the encoder and a small number of CFHD sample files > It should make the decoder more robust against crafted input. > Due to the lack of a proper specification it is possible that this > may be too strict and may need to be tuned as files not following this > ordering are found. > > Signed-off-by: Michael Niedermayer > --- I'm afraid this is not nice solution. Please consider sharing samples that causes crash to me. IMO I'm afraid that this patch is just band-aid and not proper solution. ___ 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] [FFmpeg-user] ffplay.exe leaves fullscreen mode and iconifies when losing focus
On 8/31/20, Norbert Marouschek wrote: > Dear Developers, > > I would like to use ffplay.exe in may application to play video files > and to show live video sources. Thank you for that great application > that covers all these possibilities! However as soon as ffplay.exe loses > the input focus the fullscreen window of ffplay is iconified. I aloready > reviewed the source code (event loop) but was notz abel to identify the > handling that causes that behaviour. > > Is it possible to change the behaviour so that ffplay stays maximised > even if the focus is lost or the ffplay windows is covered by an other > window? Possibly by using a command line option? I think that depends on underlying SDL library. > > Best regards, > Norbert Marouschek. > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavformat/dashenc: Reduce confusion in par error message
On 8/31/20, 9:47 AM, "Chris Miceli" wrote: > >In ticket #8754 there is discourse surrounding the error >message which is printed upon a mismatched aspect ratio in >derived encodings. This should make it clearer to the user >as to the issues which they are experiencing. >--- > libavformat/dashenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c >index dc3306a56a..2d757b3a87 100644 >--- a/libavformat/dashenc.c >+++ b/libavformat/dashenc.c >@@ -1686,7 +1686,7 @@ static int dash_init(AVFormatContext *s) > 1024 * 1024); > > if (as->par.num && av_cmp_q(par, as->par)) { >-av_log(s, AV_LOG_ERROR, "Conflicting stream par values in >Adaptation Set %d\n", os->as_idx); >+av_log(s, AV_LOG_ERROR, "Conflicting stream aspect ratios >values in Adaptation Set %d. Please ensure all adaptation sets have the same >aspect ratio\n", os->as_idx); > return AVERROR(EINVAL); > } > as->par = par; >-- >2.28.0 LGTM Thanks, Karthick > >___ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org > >To unsubscribe, visit link above, or email >ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/wavdec: add support for chapters
Support parsing 'cue ' and 'adtl' chunks. Signed-off-by: Paul B Mahol --- libavformat/wavdec.c | 50 1 file changed, 50 insertions(+) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 5b3c481421..545f04c742 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -500,6 +500,7 @@ static int wav_read_header(AVFormatContext *s) wav->smv_cur_pt = 0; goto break_loop; case MKTAG('L', 'I', 'S', 'T'): +case MKTAG('l', 'i', 's', 't'): if (size < 4) { av_log(s, AV_LOG_ERROR, "too short LIST tag\n"); return AVERROR_INVALIDDATA; @@ -507,6 +508,37 @@ static int wav_read_header(AVFormatContext *s) switch (avio_rl32(pb)) { case MKTAG('I', 'N', 'F', 'O'): ff_read_riff_info(s, size - 4); +break; +case MKTAG('a', 'd', 't', 'l'): +if (s->nb_chapters > 0) { +while (avio_tell(pb) < next_tag_ofs) { +AVChapter *chapter = NULL; +char cue_label[512]; +unsigned id, sub_size; + +if (avio_feof(pb)) +break; +if (avio_rl32(pb) != MKTAG('l', 'a', 'b', 'l')) +break; + +sub_size = avio_rl32(pb); +if (sub_size < 5) +break; +id = avio_rl32(pb); +avio_get_str(pb, sub_size - 4, cue_label, sizeof(cue_label)); +avio_skip(pb, avio_tell(pb) & 1); + +for (int i = 0; i < s->nb_chapters; i++) { +if (s->chapters[i]->id == id) { +chapter = s->chapters[i]; +break; +} +} +if (chapter) +av_dict_set(&chapter->metadata, "title", cue_label, 0); +} +} +break; } break; case MKTAG('I', 'D', '3', ' '): @@ -521,6 +553,24 @@ static int wav_read_header(AVFormatContext *s) ff_id3v2_free_extra_meta(&id3v2_extra_meta); } break; +case MKTAG('c', 'u', 'e', ' '): +if (size >= 4 && got_fmt && st->codecpar->sample_rate > 0) { +AVRational tb = {1, st->codecpar->sample_rate}; +unsigned nb_cues = avio_rl32(pb); + +if (size >= nb_cues * 24LL) { +for (int i = 0; i < nb_cues; i++) { +unsigned offset, id = avio_rl32(pb); + +avio_skip(pb, 16); +offset = avio_rl32(pb); + +if (!avpriv_new_chapter(s, id, tb, offset, AV_NOPTS_VALUE, NULL)) +return AVERROR(ENOMEM); +} +} +} +break; } /* seek to next tag unless we know that we'll run into EOF */ -- 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 1/5] avdevice/lavfi: Use av_packet_move_ref() for packet ownership transfer
On 8/30/20, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavdevice/lavfi.c | 5 + > 1 file changed, 1 insertion(+), 4 deletions(-) > LGTM if tested. I think this is covered by FATE. > diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c > index c949ff7e12..2a95cb013c 100644 > --- a/libavdevice/lavfi.c > +++ b/libavdevice/lavfi.c > @@ -392,10 +392,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, > AVPacket *pkt) > int size = 0; > > if (lavfi->subcc_packet.size) { > -*pkt = lavfi->subcc_packet; > -av_init_packet(&lavfi->subcc_packet); > -lavfi->subcc_packet.size = 0; > -lavfi->subcc_packet.data = NULL; > +av_packet_move_ref(pkt, &lavfi->subcc_packet); > return pkt->size; > } > > -- > 2.20.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] libopenjpeg decoder not correctly setting the pixel format for cinema JP2K wrapped MXF
sön 2020-08-30 klockan 18:22 +0100 skrev Rémi Achard: > Hi, > > As you are probably aware, the libopenjpeg decoder is not able to interpret > cinema jp2k mxf correctly, the pixel format being assigned as rgb48 instead > of xyz12 as it should. Note that ffmpeg native jp2k decoder parse the RSIZ > descriptor from the jp2k bitstream and is able to correctly assign the > pixel format, but libopenjpeg currently don't read the RSIZ marker so that > ffmpeg wrapper has no simple mean of doing this at the moment (a pull > request on libopenjpeg is still in progress to try to fix that). > > Someone recently pointed me to this commit from 2015 > https://github.com/FFmpeg/FFmpeg/commit/2af260e3a85ef2a9fadcac4f4fa652cee53e591e > . > According to my tests, it doesn't work because of a wrong RSIZ key and > missing JP2KEssenceSubDescriptor lookup group. I made a patch I made to fix > that, mxfdec is now able to correctly assign the descriptor->pix_fmt field. > Note that these keys can be found in SMPTE ST 429-4 or discovered through > asdcplib with asdcp-info command line tool parsing a cinema mxf video track. > > Then, even with that patch, the pixel format detected by the demuxer is not > communicated to the decoder, as far as I'm aware. Which makes me wonder, > what was the original goal of that commit and what I'm missing to > communicate this information to libopenjpeg decoder ? > Can't say much about the J2K part of this, so I'll comment on the MXF side of things. > -static const uint8_t mxf_jp2k_rsiz[] = { > 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 > }; > +static const uint8_t mxf_jp2k_rsiz[] = { > 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0a,0x04,0x01,0x06,0x03,0x01,0x00,0x00,0x00 > }; If you want the IS_KLV_KEY() check to be more lenient then you should make mxf_jp2k_rsiz[] shorter, not replace the end of it with NULs > +{ { > 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x5a,0x00 > }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* > JPEG2000PictureSubDescriptor */ Matches S422M, so should be OK. We need a sample here, as Carl says. /Tomas ___ 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 v9 2/5] lavc/avs3: add AVS3 related definitions
From: hwren Signed-off-by: hwren --- libavcodec/avs3.h | 118 ++ 1 file changed, 118 insertions(+) create mode 100644 libavcodec/avs3.h diff --git a/libavcodec/avs3.h b/libavcodec/avs3.h new file mode 100644 index 00..4189d9b583 --- /dev/null +++ b/libavcodec/avs3.h @@ -0,0 +1,118 @@ +/* + * AVS3 related definitions + * + * Copyright (C) 2020 Huiwen Ren, + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVS3_H +#define AVCODEC_AVS3_H + +#define AVS3_NAL_START_CODE 0x01 +#define AVS3_SEQ_START_CODE 0xB0 +#define AVS3_SEQ_END_CODE0xB1 +#define AVS3_USER_DATA_START_CODE0xB2 +#define AVS3_INTRA_PIC_START_CODE0xB3 +#define AVS3_UNDEF_START_CODE0xB4 +#define AVS3_EXTENSION_START_CODE0xB5 +#define AVS3_INTER_PIC_START_CODE0xB6 +#define AVS3_VIDEO_EDIT_CODE 0xB7 +#define AVS3_FIRST_SLICE_START_CODE 0x00 +#define AVS3_PROFILE_BASELINE_MAIN 0x20 +#define AVS3_PROFILE_BASELINE_MAIN10 0x22 + +#define AVS3_ISPIC(x) ((x) == AVS3_INTRA_PIC_START_CODE || (x) == AVS3_INTER_PIC_START_CODE) +#define AVS3_ISUNIT(x) ((x) == AVS3_SEQ_START_CODE || AVS3_ISPIC(x)) + +#include "libavutil/avutil.h" +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" + +static const AVRational ff_avs3_frame_rate_tab[16] = { +{ 0, 0 }, // forbid +{ 24000, 1001}, +{ 24 , 1 }, +{ 25 , 1 }, +{ 3, 1001}, +{ 30 , 1 }, +{ 50 , 1 }, +{ 6, 1001}, +{ 60 , 1 }, +{ 100 , 1 }, +{ 120 , 1 }, +{ 200 , 1 }, +{ 240 , 1 }, +{ 300 , 1 }, +{ 0, 0 }, // reserved +{ 0, 0 } // reserved +}; + +static const int ff_avs3_color_primaries_tab[10] = { +AVCOL_PRI_RESERVED0 ,// 0 +AVCOL_PRI_BT709 ,// 1 +AVCOL_PRI_UNSPECIFIED ,// 2 +AVCOL_PRI_RESERVED,// 3 +AVCOL_PRI_BT470M ,// 4 +AVCOL_PRI_BT470BG ,// 5 +AVCOL_PRI_SMPTE170M ,// 6 +AVCOL_PRI_SMPTE240M ,// 7 +AVCOL_PRI_FILM,// 8 +AVCOL_PRI_BT2020 // 9 +}; + +static const int ff_avs3_color_transfer_tab[15] = { +AVCOL_TRC_RESERVED0, // 0 +AVCOL_TRC_BT709, // 1 +AVCOL_TRC_UNSPECIFIED , // 2 +AVCOL_TRC_RESERVED , // 3 +AVCOL_TRC_GAMMA22 , // 4 +AVCOL_TRC_GAMMA28 , // 5 +AVCOL_TRC_SMPTE170M, // 6 +AVCOL_TRC_SMPTE240M, // 7 +AVCOL_TRC_LINEAR , // 8 +AVCOL_TRC_LOG , // 9 +AVCOL_TRC_LOG_SQRT , // 10 +AVCOL_TRC_BT2020_12, // 11 +AVCOL_TRC_SMPTE2084, // 12 +AVCOL_TRC_UNSPECIFIED , // 13 +AVCOL_TRC_ARIB_STD_B67 // 14 +}; + +static const int ff_avs3_color_matrix_tab[12] = { +AVCOL_SPC_RESERVED , // 0 +AVCOL_SPC_BT709, // 1 +AVCOL_SPC_UNSPECIFIED , // 2 +AVCOL_SPC_RESERVED , // 3 +AVCOL_SPC_FCC , // 4 +AVCOL_SPC_BT470BG , // 5 +AVCOL_SPC_SMPTE170M, // 6 +AVCOL_SPC_SMPTE240M, // 7 +AVCOL_SPC_BT2020_NCL , // 8 +AVCOL_SPC_BT2020_CL, // 9 +AVCOL_SPC_UNSPECIFIED , // 10 +AVCOL_SPC_UNSPECIFIED// 11 +}; + +static const enum AVPictureType ff_avs3_image_type[4] = { +AV_PICTURE_TYPE_NONE, +AV_PICTURE_TYPE_I, +AV_PICTURE_TYPE_P, +AV_PICTURE_TYPE_B +}; + +#endif /* AVCODEC_AVS3_H */ -- 2.23.0.windows.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 v9 0/5] Supplement AVS3-P2/IEEE1857.10 video decoding via libuavs3d
From: hwren *** Latest changes *** Put AVS3 related definitions in sigle avs3.h file. *** Historical changes *** === Version1 === These patches are to supplement the third generation of Audio Video Coding Standard, part 2: video (AVS3-P2), aka IEEE1857.10, decoding support via libuavs3d wrapper. The uAVS3d decoder could be found in https://github.com/uavs3/uavs3d AVS3 sample streams could be found in https://github.com/uavs3/avs3stream === Version 2 === Fix conflict with CAVS streams. Considering that there is no direct version flag in AVS. AVS3 demuxer only supports raw streams in format <*.avs3>. Fix API function conflict. === Version 3 === Rename parameter names that may be confused with AVS2 Reorder header files. === Version 4 === Add avs3_parser.h for some reusable definitions in AVS3 Refine avs3_parser.c and libuavs3d.c Fix some vague definitions and potential risks === Version 5 === Fix the wrong codec order in lavc/codec_desc.c Use additional lavc/avs3.h and lavc/avs3.c for common definitions Remove redundant description in the long name of libuavs3d. Update iteration information in lavf/version.h and lavc/version.h. === Version 6 === Fix incorrect code style problems. Remove confused comments. Add missing demuxer entry in Changelog. Add value check in lavc/libuavs3d.c === Version 7 === Supplement information in dec_frame, including pkt_pos, pkt_size, coded_picture_number and display_picture_number. === Version 8 === Pickup missing changes from previous version. Thanks. hwren (5): lavc: add AVS3 codec id and desc lavc/avs3: add AVS3 related definitions lavc/avs3_parser: add avs3 parser lavf/avs3dec: add raw avs3 demuxer lavc,doc: add libuavs3d video decoder wrapper Changelog| 2 + configure| 4 + doc/decoders.texi| 21 doc/general.texi | 8 ++ libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 1 + libavcodec/avs3.h| 118 ++ libavcodec/avs3_parser.c | 179 ++ libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h| 1 + libavcodec/libuavs3d.c | 262 +++ libavcodec/parsers.c | 1 + libavcodec/version.h | 4 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/avs3dec.c| 68 ++ libavformat/version.h| 2 +- 17 files changed, 679 insertions(+), 3 deletions(-) create mode 100644 libavcodec/avs3.h create mode 100644 libavcodec/avs3_parser.c create mode 100644 libavcodec/libuavs3d.c create mode 100644 libavformat/avs3dec.c -- 2.23.0.windows.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 v9 3/5] lavc/avs3_parser: add avs3 parser
From: hwren Signed-off-by: hbj Signed-off-by: hwren --- libavcodec/Makefile | 1 + libavcodec/avs3_parser.c | 179 +++ libavcodec/parsers.c | 1 + 3 files changed, 181 insertions(+) create mode 100644 libavcodec/avs3_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ca2e8a2530..5a2ddf8560 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1060,6 +1060,7 @@ OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o av1_parse.o OBJS-$(CONFIG_AVS2_PARSER) += avs2_parser.o +OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o diff --git a/libavcodec/avs3_parser.c b/libavcodec/avs3_parser.c new file mode 100644 index 00..bf97f75db6 --- /dev/null +++ b/libavcodec/avs3_parser.c @@ -0,0 +1,179 @@ +/* + * AVS3-P2/IEEE1857.10 video parser. + * Copyright (c) 2020 Zhenyu Wang + *Bingjie Han + *Huiwen Ren + * + * 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 "avs3.h" +#include "get_bits.h" +#include "parser.h" + +static int avs3_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) +{ +int pic_found = pc->frame_start_found; +uint32_t state = pc->state; +int cur = 0; + +if (!pic_found) { +for (; cur < buf_size; ++cur) { +state = (state << 8) | buf[cur]; +if (AVS3_ISPIC(buf[cur])){ +cur++; +pic_found = 1; +break; +} +} +} + +if (pic_found) { +if (!buf_size) +return END_NOT_FOUND; +for (; cur < buf_size; ++cur) { +state = (state << 8) | buf[cur]; +if ((state & 0xFF00) == 0x100 && AVS3_ISUNIT(state & 0xFF)) { +pc->frame_start_found = 0; +pc->state = -1; +return cur - 3; +} +} +} + +pc->frame_start_found = pic_found; +pc->state = state; + +return END_NOT_FOUND; +} + +static void parse_avs3_nal_units(AVCodecParserContext *s, const uint8_t *buf, + int buf_size, AVCodecContext *avctx) +{ +if (buf_size < 5) { +return; +} + +if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) { +if (buf[3] == AVS3_SEQ_START_CODE) { +GetBitContext gb; +int profile, ratecode; + +init_get_bits(&gb, buf + 4, buf_size - 4); + +s->key_frame = 1; +s->pict_type = AV_PICTURE_TYPE_I; + +profile = get_bits(&gb, 8); +// Skip bits: level(8) +//progressive(1) +//field(1) +//library(2) +//resv(1) +//width(14) +//resv(1) +//height(14) +//chroma(2) +//sampe_precision(3) +skip_bits(&gb, 47); + +if (profile == AVS3_PROFILE_BASELINE_MAIN10) { +int sample_precision = get_bits(&gb, 3); +if (sample_precision == 1) { +avctx->pix_fmt = AV_PIX_FMT_YUV420P; +} else if (sample_precision == 2) { +avctx->pix_fmt = AV_PIX_FMT_YUV420P10LE; +} else { +avctx->pix_fmt = AV_PIX_FMT_NONE; +} +} + +// Skip bits: resv(1) +//aspect(4) +skip_bits(&gb, 5); + +ratecode = get_bits(&gb, 4); + +// Skip bits: resv(1) +//bitrate_low(18) +//resv(1) +//bitrate_high(12) +skip_bits(&gb, 32); + +avctx->has_b_frames = !get_bits(&gb, 1); + +avctx->framerate.num = avctx->time_base.den = ff_avs3_frame_rate_tab[ratecode].num; +avctx->framerate.den =
[FFmpeg-devel] [PATCH v9 1/5] lavc: add AVS3 codec id and desc
From: hwren Signed-off-by: hbj Signed-off-by: hwren --- libavcodec/codec_desc.c | 7 +++ libavcodec/codec_id.h | 1 + 2 files changed, 8 insertions(+) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 0ae6aee63b..61473178fc 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1412,6 +1412,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, +{ +.id= AV_CODEC_ID_AVS3, +.type = AVMEDIA_TYPE_VIDEO, +.name = "avs3", +.long_name = NULL_IF_CONFIG_SMALL("AVS3-P2/IEEE1857.10"), +.props = AV_CODEC_PROP_LOSSY, +}, { .id= AV_CODEC_ID_Y41P, .type = AVMEDIA_TYPE_VIDEO, diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 896ecb0ce0..47aa0787b6 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -242,6 +242,7 @@ enum AVCodecID { AV_CODEC_ID_RSCC, AV_CODEC_ID_AVS2, AV_CODEC_ID_PGX, +AV_CODEC_ID_AVS3, AV_CODEC_ID_Y41P = 0x8000, AV_CODEC_ID_AVRP, -- 2.23.0.windows.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 v9 5/5] lavc, doc: add libuavs3d video decoder wrapper
From: hwren Signed-off-by: hbj Signed-off-by: hwren --- Changelog | 1 + configure | 4 + doc/decoders.texi | 21 doc/general.texi | 8 ++ libavcodec/Makefile| 1 + libavcodec/allcodecs.c | 1 + libavcodec/libuavs3d.c | 262 + libavcodec/version.h | 4 +- 8 files changed, 300 insertions(+), 2 deletions(-) create mode 100644 libavcodec/libuavs3d.c diff --git a/Changelog b/Changelog index e68461e85c..40300d6756 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,7 @@ version : - AV1 Low overhead bitstream format demuxer - RPZA video encoder - AVS3 bitstream format demuxer +- AVS3 video decoder via libuavs3d version 4.3: diff --git a/configure b/configure index 564072053b..c84c857d45 100755 --- a/configure +++ b/configure @@ -277,6 +277,7 @@ External library support: --enable-libtls enable LibreSSL (via libtls), needed for https support if openssl, gnutls or mbedtls is not used [no] --enable-libtwolame enable MP2 encoding via libtwolame [no] + --enable-libuavs3d enable AVS3 decoding via libuavs3d [no] --enable-libv4l2 enable libv4l2/v4l-utils [no] --enable-libvidstab enable video stabilization using vid.stab [no] --enable-libvmaf enable vmaf filter via libvmaf [no] @@ -1811,6 +1812,7 @@ EXTERNAL_LIBRARY_LIST=" libtesseract libtheora libtwolame +libuavs3d libv4l2 libvmaf libvorbis @@ -3253,6 +3255,7 @@ libspeex_encoder_select="audio_frame_queue" libsvtav1_encoder_deps="libsvtav1" libtheora_encoder_deps="libtheora" libtwolame_encoder_deps="libtwolame" +libuavs3d_decoder_deps="libuavs3d" libvo_amrwbenc_encoder_deps="libvo_amrwbenc" libvorbis_decoder_deps="libvorbis" libvorbis_encoder_deps="libvorbis libvorbisenc" @@ -6416,6 +6419,7 @@ enabled libtls&& require_pkg_config libtls libtls tls.h tls_configur enabled libtwolame&& require libtwolame twolame.h twolame_init -ltwolame && { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame || die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; } +enabled libuavs3d && require_pkg_config libuavs3d "uavs3d >= 1.1.41" uavs3d.h uavs3d_decode enabled libv4l2 && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl enabled libvidstab&& require_pkg_config libvidstab "vidstab >= 0.98" vid.stab/libvidstab.h vsMotionDetectInit enabled libvmaf && require_pkg_config libvmaf "libvmaf >= 1.5.2" libvmaf.h compute_vmaf diff --git a/doc/decoders.texi b/doc/decoders.texi index 9005714e3c..42b46fe153 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -88,6 +88,27 @@ This decoder allows libavcodec to decode AVS2 streams with davs2 library. @c man end VIDEO DECODERS +@section libuavs3d + +AVS3-P2/IEEE1857.10 video decoder. + +libuavs3d allows libavcodec to decode AVS3 streams. +Requires the presence of the libuavs3d headers and library during configuration. +You need to explicitly configure the build with @code{--enable-libuavs3d}. + +@subsection Options + +The following option is supported by the libuavs3d wrapper. + +@table @option + +@item frame_threads +Set amount of frame threads to use during decoding. The default value is 0 (autodetect). + +@end table + +@c man end VIDEO DECODERS + @chapter Audio Decoders @c man begin AUDIO DECODERS diff --git a/doc/general.texi b/doc/general.texi index d618565347..d68b9c69b7 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -125,6 +125,14 @@ Go to @url{https://github.com/pkuvcl/davs2} and follow the instructions for installing the library. Then pass @code{--enable-libdavs2} to configure to enable it. +@section uavs3d + +FFmpeg can make use of the uavs3d library for AVS3-P2/IEEE1857.10 video decoding. + +Go to @url{https://github.com/uavs3/uavs3d} and follow the instructions for +installing the library. Then pass @code{--enable-libuavs3d} to configure to +enable it. + @float NOTE libdavs2 is under the GNU Public License Version 2 or later (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 5a2ddf8560..d391e1401f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1033,6 +1033,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o OBJS-$(CONFIG_LIBSVTAV1_ENCODER) += libsvtav1.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o +OBJS-$(CONFIG_LIBUAVS3D_DECODER) += libuavs3d.o OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o OBJS-$(CONFIG_LIBVORBIS_DECODER) += libvorbisdec.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbisenc.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c i
[FFmpeg-devel] [PATCH v9 4/5] lavf/avs3dec: add raw avs3 demuxer
From: hwren Signed-off-by: hbj Signed-off-by: hwren --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/avs3dec.c| 68 libavformat/version.h| 2 +- 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 libavformat/avs3dec.c diff --git a/Changelog b/Changelog index 7467e73306..e68461e85c 100644 --- a/Changelog +++ b/Changelog @@ -15,6 +15,7 @@ version : - Argonaut Games ASF muxer - AV1 Low overhead bitstream format demuxer - RPZA video encoder +- AVS3 bitstream format demuxer version 4.3: diff --git a/libavformat/Makefile b/libavformat/Makefile index cbb33fe37c..8ddab3aee5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -122,6 +122,7 @@ OBJS-$(CONFIG_AVR_DEMUXER) += avr.o pcm.o OBJS-$(CONFIG_AVS_DEMUXER) += avs.o voc_packet.o vocdec.o voc.o OBJS-$(CONFIG_AVS2_DEMUXER) += davs2.o rawdec.o OBJS-$(CONFIG_AVS2_MUXER)+= rawenc.o +OBJS-$(CONFIG_AVS3_DEMUXER) += avs3dec.o rawdec.o OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o OBJS-$(CONFIG_BFI_DEMUXER) += bfi.o OBJS-$(CONFIG_BINK_DEMUXER) += bink.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 0aa9dd7198..7f41c12d7c 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -84,6 +84,7 @@ extern AVInputFormat ff_avr_demuxer; extern AVInputFormat ff_avs_demuxer; extern AVInputFormat ff_avs2_demuxer; extern AVOutputFormat ff_avs2_muxer; +extern AVInputFormat ff_avs3_demuxer; extern AVInputFormat ff_bethsoftvid_demuxer; extern AVInputFormat ff_bfi_demuxer; extern AVInputFormat ff_bintext_demuxer; diff --git a/libavformat/avs3dec.c b/libavformat/avs3dec.c new file mode 100644 index 00..a85f6f6c0b --- /dev/null +++ b/libavformat/avs3dec.c @@ -0,0 +1,68 @@ +/* + * RAW AVS3-P2/IEEE1857.10 video demuxer + * Copyright (c) 2020 Zhenyu Wang + *Bingjie Han + *Huiwen Ren + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/avs3.h" +#include "libavcodec/internal.h" +#include "avformat.h" +#include "rawdec.h" + +static int avs3video_probe(const AVProbeData *p) +{ +const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size; +uint32_t code = -1; +uint8_t state = 0; +int pic = 0, seq = 0, slice_pos = 0; +int ret = 0; + +while (ptr < end) { +ptr = avpriv_find_start_code(ptr, end, &code); +state = code & 0xFF; +if ((code & 0xFF00) == 0x100) { +if (state < AVS3_SEQ_START_CODE) { +if (code < slice_pos) +return 0; +slice_pos = code; +} else { +slice_pos = 0; +} +if (state == AVS3_SEQ_START_CODE) { +seq++; +if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != AVS3_PROFILE_BASELINE_MAIN10) +return 0; +} else if (AVS3_ISPIC(state)) { +pic++; +} else if ((state == AVS3_UNDEF_START_CODE) || + (state > AVS3_VIDEO_EDIT_CODE)) { +return 0; +} +} +} + +if (seq && pic && av_match_ext(p->filename, "avs3")) { +ret = AVPROBE_SCORE_MAX; +} + +return ret; +} + +FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, "avs3", AV_CODEC_ID_AVS3) \ No newline at end of file diff --git a/libavformat/version.h b/libavformat/version.h index 88876aec79..09444893eb 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 51 +#define LIBAVFORMAT_VERSION_MINOR 52 #define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 2.23.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https:
Re: [FFmpeg-devel] [PATCH] avformat/wavdec: add support for demuxing Broadcast Wave 64Bit
On 8/28/20, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- Will apply. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/wavdec: allow to change max size of single demuxed packet
On 8/28/20, Paul B Mahol wrote: > On 8/28/20, Paul B Mahol wrote: >> On 8/28/20, Andreas Rheinhardt wrote: >>> Paul B Mahol: On 8/28/20, Andreas Rheinhardt wrote: > Paul B Mahol: >> Can make demuxing much faster, expecially for files with >> huge number of channels. >> >> Signed-off-by: Paul B Mahol >> --- >> libavformat/wavdec.c | 21 ++--- >> 1 file changed, 18 insertions(+), 3 deletions(-) >> >> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c >> index e1b2115434..5b3c481421 100644 >> --- a/libavformat/wavdec.c >> +++ b/libavformat/wavdec.c >> @@ -56,6 +56,7 @@ typedef struct WAVDemuxContext { >> int smv_eof; >> int audio_eof; >> int ignore_length; >> +int max_size; >> int spdif; >> int smv_cur_pt; >> int smv_given_first; >> @@ -628,8 +629,6 @@ static int64_t find_guid(AVIOContext *pb, const >> uint8_t guid1[16]) >> return AVERROR_EOF; >> } >> >> -#define MAX_SIZE 4096 >> - >> static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) >> { >> int ret, size; >> @@ -706,7 +705,7 @@ smv_out: >> wav->data_end = avio_tell(s->pb) + left; >> } >> >> -size = MAX_SIZE; >> +size = wav->max_size; >> if (st->codecpar->block_align > 1) { >> if (size < st->codecpar->block_align) >> size = st->codecpar->block_align; >> @@ -759,6 +758,7 @@ static int wav_read_seek(AVFormatContext *s, >> #define DEC AV_OPT_FLAG_DECODING_PARAM >> static const AVOption demux_options[] = { >> { "ignore_length", "Ignore length", OFFSET(ignore_length), >> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC }, >> +{ "max_size", "max size of single packet", >> OFFSET(max_size), >> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC }, >> { NULL }, >> }; >> >> @@ -906,6 +906,20 @@ static int w64_read_header(AVFormatContext *s) >> return 0; >> } >> >> +#define OFFSET(x) offsetof(WAVDemuxContext, x) >> +#define DEC AV_OPT_FLAG_DECODING_PARAM >> +static const AVOption w64_demux_options[] = { >> +{ "max_size", "max size of single packet", OFFSET(max_size), >> AV_OPT_TYPE_INT, { .i64 = 4096 }, 1024, 1 << 22, DEC }, >> +{ NULL }, > > The ',' is unnecessary: Nothing will ever be added after the sentinel. > >> +}; > > You can use &demux_options[1] instead of w64_demux_options (but add a > comment for this). How the comment should look like? >>> >>> I thought of a comment for demux_options like "Hint: The options are >>> partially shared with the Wave64 demuxer." >> >> More like Warning instead of Hint. >> So some other developer does not add option that does not make sense for >> w64. > > Problem is demux_options are under ifdef so can not be shared as is. > What about using macro to define max_size option or just keep it as in > this patch. Gonna apply with removed comma after {NULL} in w64 options. > >> >>> > >> + >> +static const AVClass w64_demuxer_class = { >> +.class_name = "W64 demuxer", >> +.item_name = av_default_item_name, >> +.option = w64_demux_options, >> +.version= LIBAVUTIL_VERSION_INT, >> +}; >> + >> AVInputFormat ff_w64_demuxer = { >> .name = "w64", >> .long_name = NULL_IF_CONFIG_SMALL("Sony Wave64"), >> @@ -916,5 +930,6 @@ AVInputFormat ff_w64_demuxer = { >> .read_seek = wav_read_seek, >> .flags = AVFMT_GENERIC_INDEX, >> .codec_tag = (const AVCodecTag * const []) { >> ff_codec_wav_tags, >> 0 }, >> +.priv_class = &w64_demuxer_class, >> }; >> #endif /* CONFIG_W64_DEMUXER */ >> > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >>> >>> ___ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >>> To unsubscribe, visit link above, or email >>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >> > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or
Re: [FFmpeg-devel] [PATCH 1/5] avdevice/lavfi: Use av_packet_move_ref() for packet ownership transfer
Paul B Mahol: > On 8/30/20, Andreas Rheinhardt wrote: >> Signed-off-by: Andreas Rheinhardt >> --- >> libavdevice/lavfi.c | 5 + >> 1 file changed, 1 insertion(+), 4 deletions(-) >> > > LGTM if tested. > > I think this is covered by FATE. > It is, see [1]. All patches of this patchset except 4/5 are covered by it. - Andreas [1]: http://coverage.ffmpeg.org/index.src_libavdevice_lavfi.c.html >> diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c >> index c949ff7e12..2a95cb013c 100644 >> --- a/libavdevice/lavfi.c >> +++ b/libavdevice/lavfi.c >> @@ -392,10 +392,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, >> AVPacket *pkt) >> int size = 0; >> >> if (lavfi->subcc_packet.size) { >> -*pkt = lavfi->subcc_packet; >> -av_init_packet(&lavfi->subcc_packet); >> -lavfi->subcc_packet.size = 0; >> -lavfi->subcc_packet.data = NULL; >> +av_packet_move_ref(pkt, &lavfi->subcc_packet); >> return pkt->size; >> } >> >> -- >> 2.20.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 1/3][GSoC] Add mutithread function for dnn_backend_native_layer_conv2d.c
From: Xu Jun Use pthread to multithread dnn_execute_layer_conv2d. Can be tested with command "./ffmpeg_g -i input.png -vf \ format=yuvj420p,dnn_processing=dnn_backend=native:model= \ espcn.model:input=x:output=y -y sr_native.jpg -benchmark" before patch: utime=11.238s stime=0.005s rtime=11.248s after patch: utime=20.817s stime=0.047s rtime=1.051s Signed-off-by: Xu Jun --- .../dnn/dnn_backend_native_layer_conv2d.c | 95 --- 1 file changed, 84 insertions(+), 11 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index d079795bf8..570b974052 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -19,10 +19,23 @@ */ #include "libavutil/avassert.h" +#include "libavutil/thread.h" +#include "libavutil/cpu.h" #include "dnn_backend_native_layer_conv2d.h" #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x))) +//struct to pass parameters +typedef struct thread_data{ +DnnOperand *operands; +const int32_t *input_operand_indexes; +int32_t output_operand_index; +const void *parameters; +NativeContext *ctx; +int32_t thread_num; +int32_t thread_index; +} thread_data; + int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) { ConvolutionalParams *conv_params; @@ -88,17 +101,27 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int fil return dnn_size; } -int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes, - int32_t output_operand_index, const void *parameters, NativeContext *ctx) +static void * dnn_execute_layer_conv2d_thread(void *threadarg) { +static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; +//use mutexe to protect thread_index + +//pass parameters +struct thread_data *thread_data = (struct thread_data *)threadarg; +DnnOperand *operands = thread_data->operands; + +int thread_stride; +int thread_start; +int thread_end; + float *output; -int32_t input_operand_index = input_operand_indexes[0]; +int32_t input_operand_index = thread_data->input_operand_indexes[0]; int number = operands[input_operand_index].dims[0]; int height = operands[input_operand_index].dims[1]; int width = operands[input_operand_index].dims[2]; int channel = operands[input_operand_index].dims[3]; const float *input = operands[input_operand_index].data; -const ConvolutionalParams *conv_params = (const ConvolutionalParams *)parameters; +const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(thread_data->parameters); int radius = conv_params->kernel_size >> 1; int src_linesize = width * conv_params->input_num; @@ -106,7 +129,7 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ int filter_size = conv_params->kernel_size * filter_linesize; int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0; -DnnOperand *output_operand = &operands[output_operand_index]; +DnnOperand *output_operand = &operands[thread_data->output_operand_index]; output_operand->dims[0] = number; output_operand->dims[1] = height - pad_size * 2; output_operand->dims[2] = width - pad_size * 2; @@ -114,19 +137,30 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ output_operand->data_type = operands[input_operand_index].data_type; output_operand->length = calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { -av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); -return DNN_ERROR; +av_log(thread_data->ctx, AV_LOG_ERROR, "The output data length overflow\n"); +return (void *)DNN_ERROR; } output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) { -av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); -return DNN_ERROR; +av_log(thread_data->ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); +return (void *)DNN_ERROR; } + +//calculate area for this thread +thread_stride = (height - pad_size * 2) / thread_data->thread_num; +pthread_mutex_lock(&mtx); +thread_start = thread_stride * thread_data->thread_index + pad_size; +thread_end = (thread_data->thread_index == thread_data->thread_num - 1) ? (height - pad_size) : (thread_start + thread_stride); +thread_data->thread_index += 1; +pthread_mutex_unlock(&mtx); + output = output_operand->data; +//calculate output start pos for this thread +output += (conv_params->output_num) * (width - 2 * pad_size) * (thread_start - pad_size); a
[FFmpeg-devel] [PATCH 2/3][GSoC] Add x86-sse4 optimization for dnn_execute_layer_conv2d
From: Xu Jun Can be tested with command "./ffmpeg_g -i input.png -vf \ format=yuvj420p,dnn_processing=dnn_backend=native:model= \ espcn.model:input=x:output=y -y sr_native.jpg -benchmark"\ -cpuflags 0x100 before patch: utime=20.817s stime=0.047s rtime=1.051s after patch: utime=3.744s stime=0.037s rtime=0.252s Signed-off-by: Xu Jun ss Signed-off-by: Xu Jun --- libavfilter/dnn/Makefile | 1 + .../dnn/dnn_backend_native_layer_conv2d.c | 123 -- .../dnn_backend_native_layer_conv2d_x86.asm | 214 ++ 3 files changed, 314 insertions(+), 24 deletions(-) create mode 100644 libavfilter/dnn/dnn_backend_native_layer_conv2d_x86.asm diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile index e0957073ee..bdd334b192 100644 --- a/libavfilter/dnn/Makefile +++ b/libavfilter/dnn/Makefile @@ -8,6 +8,7 @@ OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_dep OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_maximum.o OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_mathbinary.o OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_mathunary.o +OBJS-$(CONFIG_DNN) += dnn/dnn_backend_native_layer_conv2d_x86.o DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o DNN-OBJS-$(CONFIG_LIBOPENVINO) += dnn/dnn_backend_openvino.o diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 570b974052..92cc5313dc 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -21,6 +21,7 @@ #include "libavutil/avassert.h" #include "libavutil/thread.h" #include "libavutil/cpu.h" +#include "libavutil/x86/cpu.h" #include "dnn_backend_native_layer_conv2d.h" #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x))) @@ -34,8 +35,20 @@ typedef struct thread_data{ NativeContext *ctx; int32_t thread_num; int32_t thread_index; +int step; } thread_data; +typedef struct execute_data{ +int thread_start, thread_end, input_num, output_num, kernel_size, padding_method, dilation; +int pad_size, width, height, radius, src_linesize, filter_size, filter_linesize; +float *input; +float *output; +float *kernel; +} execute_data; + +void ff_dnn_execute_layer_conv2d_sse4(execute_data *execute_data); +void ff_dnn_execute_layer_conv2d_c(execute_data *execute_data); + int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) { ConvolutionalParams *conv_params; @@ -101,6 +114,56 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int fil return dnn_size; } +void ff_dnn_execute_layer_conv2d_c(execute_data *execute_data){ +int thread_start = execute_data->thread_start; +int thread_end = execute_data->thread_end; +float *input = execute_data->input; +float *output = execute_data->output; +float *kernel = execute_data->kernel; +int input_num = execute_data->input_num; +int output_num = execute_data->output_num; +int kernel_size = execute_data->kernel_size; +int padding_method = execute_data->padding_method; +int dilation = execute_data->dilation; +int pad_size = execute_data->pad_size; +int width = execute_data->width; +int height = execute_data->height; +int radius = execute_data->radius; +int src_linesize = execute_data->src_linesize; +int filter_size = execute_data->filter_size; +int filter_linesize = execute_data->filter_linesize; + +for (int y = thread_start; y < thread_end; ++y) { +for (int x = pad_size; x < width - pad_size; ++x) { +for (int n_filter = 0; n_filter < output_num; ++n_filter) { +output[n_filter] = 0.0f; +for (int ch = 0; ch < input_num; ++ch) { +for (int kernel_y = 0; kernel_y < kernel_size; ++kernel_y) { +for (int kernel_x = 0; kernel_x < kernel_size; ++kernel_x) { +float input_pel; +if (padding_method == SAME_CLAMP_TO_EDGE) { +int y_pos = CLAMP_TO_EDGE(y + (kernel_y - radius) * dilation, height); +int x_pos = CLAMP_TO_EDGE(x + (kernel_x - radius) * dilation, width); +input_pel = input[y_pos * src_linesize + x_pos * input_num + ch]; +} else { +int y_pos = y + (kernel_y - radius) * dilation; +int x_pos = x + (kernel_x - radius) * dilation; +input_pel = (x_pos < 0 || x_pos >= width || y_pos < 0 || y_pos >= height) ? 0.0 : +input[y_pos * src_linesize +
[FFmpeg-devel] [PATCH 3/3][GSoC] Add x86-avx2 optimization for dnn_execute_layer_conv2d
From: Xu Jun Can be tested with command "./ffmpeg_g -i test_1s.mp4 -vf \ format=yuvj420p,dnn_processing=dnn_backend=native:model= \ espcn.model:input=x:output=y -y sr_native.mp4 -benchmark" before patch: utime=826.044s stime=0.550s rtime=39.680s after patch: utime=545.137s stime=0.467s rtime=27.113s Signed-off-by: Xu Jun --- .../dnn/dnn_backend_native_layer_conv2d.c | 10 +- .../dnn_backend_native_layer_conv2d_x86.asm | 121 ++ 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 92cc5313dc..089f724156 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -46,6 +46,7 @@ typedef struct execute_data{ float *kernel; } execute_data; +void ff_dnn_execute_layer_conv2d_avx2(execute_data *execute_data); void ff_dnn_execute_layer_conv2d_sse4(execute_data *execute_data); void ff_dnn_execute_layer_conv2d_c(execute_data *execute_data); @@ -243,7 +244,12 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg) execute_data->filter_size = filter_size; execute_data->filter_linesize = filter_linesize; if ((thread_data->step >= 4) && (conv_params->input_num >= 4)) { -ff_dnn_execute_layer_conv2d_sse4(execute_data); +if ((thread_data->step == 8) && (conv_params->input_num >= 8)) { +ff_dnn_execute_layer_conv2d_avx2(execute_data); +} +else { +ff_dnn_execute_layer_conv2d_sse4(execute_data); +} } else { ff_dnn_execute_layer_conv2d_c(execute_data); @@ -305,6 +311,8 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_SSE4(cpu_flags)) thread_data->step = 4; +if (EXTERNAL_AVX2(cpu_flags)) +thread_data->step = 8; #endif //create threads diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d_x86.asm b/libavfilter/dnn/dnn_backend_native_layer_conv2d_x86.asm index dc781d42e5..7c7285c4c5 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d_x86.asm +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d_x86.asm @@ -210,5 +210,126 @@ cglobal dnn_execute_layer_conv2d, 8, 15, 3, execute_data,\ cmp yd, tmp1d jl .loop_y +RET + +; void ff_dnn_execute_layer_conv2d_avx4(execute_data *execute_data); + +INIT_YMM avx2 +cglobal dnn_execute_layer_conv2d, 8, 15, 3, execute_data,\ +x, y, n_filter, cha, kernel_x, kernel_y, x_pos, y_pos, kernel_pos,\ +input, output, kernel, tmp1, tmp2 + +%define thread_start [execute_dataq] +%define thread_end [execute_dataq + 1 * 4] +%define input_num [execute_dataq + 2 * 4] +%define output_num [execute_dataq + 3 * 4] +%define kernel_size [execute_dataq + 4 * 4] +%define padding_method [execute_dataq + 5 * 4] +%define dilation [execute_dataq + 6 * 4] +%define pad_size [execute_dataq + 7 * 4] +%define width [execute_dataq + 8 * 4] +%define height [execute_dataq + 9 * 4] +%define radius [execute_dataq + 10 * 4] +%define src_linesize [execute_dataq + 11 * 4] +%define filter_size [execute_dataq + 12 * 4] +%define filter_linesize [execute_dataq + 13 * 4] +%define SAME_CLAMP_TO_EDGE 2 + +mov inputq, [execute_dataq + 14 * 4] +mov outputq, [execute_dataq + 14 * 4 + 8] +mov kernelq, [execute_dataq + 14 * 4 + 2 * 8] + +mov yd, thread_start +.loop_y: +mov xd, pad_size +.loop_x: +xor n_filterd, n_filterd +xor kernel_posq, kernel_posq +.loop_filter: +xorps m2, m2 +xor kernel_yd, kernel_yd + +mov tmp1d, kernel_yd +sub tmp1d, radius +mov y_posd, dilation +imul y_posd, tmp1d +add y_posd, yd + +.loop_kery: +xor kernel_xd, kernel_xd + +mov tmp1d, kernel_xd +sub tmp1d, radius +mov x_posd, dilation +imul x_posd, tmp1d +add x_posd, xd + +.loop_kerx: +COUNT_INPUT +xor chad, chad +.loop_ch: +cmp tmp1d, -1 +je .out + +movsxdifnidn tmp1q, tmp1d +movups m0, [inputq + tmp1q * 4] +add tmp1d, 8 +jmp .load_end + +.out: +xorps m0, m0 + +.load_end: + +movups m1, [kernelq + kernel_posq * 4] +add kernel_posq, 8 + +mulps m0, m1 +addps m2, m0 + +add chad, 8 +mov tmp2d, input_num +cmp chad, tmp2d +jl .loop_ch + +add x
Re: [FFmpeg-devel] [PATCH 2/3] lavfi/sine: switch to activate.
On 6/2/20, Nicolas George wrote: > Allow to set the EOF timestamp. > > Signed-off-by: Nicolas George > --- > libavfilter/asrc_sine.c | 16 +++- > 1 file changed, 11 insertions(+), 5 deletions(-) > LGTM ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avfilter/src_movie: switch to activate
Allow to set the EOF timestamp. Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 32 ++-- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index eeb8609855..2920ec06c1 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -44,6 +44,7 @@ #include "audio.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -97,7 +98,6 @@ static const AVOption movie_options[]= { }; static int movie_config_output_props(AVFilterLink *outlink); -static int movie_request_frame(AVFilterLink *outlink); static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) { @@ -309,7 +309,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); pad.config_props = movie_config_output_props; -pad.request_frame = movie_request_frame; if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) { av_freep(&pad.name); return ret; @@ -595,17 +594,28 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) return pkt_out_id == out_id; } -static int movie_request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { -AVFilterContext *ctx = outlink->src; -unsigned out_id = FF_OUTLINK_IDX(outlink); -int ret; +MovieContext *movie = ctx->priv; +int i; + +for (i = 0; i < ctx->nb_outputs; i++) { +AVFilterLink *outlink = ctx->outputs[i]; + +if (ff_outlink_frame_wanted(outlink)) { +int ret = movie_push_frame(ctx, i); -while (1) { -ret = movie_push_frame(ctx, out_id); -if (ret) -return FFMIN(ret, 0); +if (ret) { +if (ret < 0) +ff_outlink_set_status(outlink, AVERROR_EOF, movie->st[i].last_pts); +return 0; +} +} } + +ff_filter_set_ready(ctx, 100); + +return 0; } static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, @@ -666,6 +676,7 @@ AVFilter ff_avsrc_movie = { .inputs= NULL, .outputs = NULL, +.activate = activate, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, .process_command = process_command }; @@ -687,6 +698,7 @@ AVFilter ff_avsrc_amovie = { .inputs = NULL, .outputs= NULL, +.activate = activate, .priv_class = &amovie_class, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, .process_command = process_command, -- 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 v4] avcodec/cfhd: More strictly check tag order and multiplicity
On Mon, Aug 31, 2020 at 11:14:07AM +0200, Paul B Mahol wrote: > On 8/31/20, Michael Niedermayer wrote: > > This is based on the encoder and a small number of CFHD sample files > > It should make the decoder more robust against crafted input. > > Due to the lack of a proper specification it is possible that this > > may be too strict and may need to be tuned as files not following this > > ordering are found. > > > > Signed-off-by: Michael Niedermayer > > --- > > I'm afraid this is not nice solution. > Please consider sharing samples that causes crash to me. > IMO I'm afraid that this patch is just band-aid and not proper solution. As this ended up discussed on IRC too, heres the relevant log as reference for the archieve as otherwise noone will find it an interleaved discussion about AAC with JEEB is removed durandal_1707, kierank, i dont have any crashing samples which are fixed by the cfhd table patch. That patch was intended to restrict what/where elements can occur so that for example the one specifying the subband number is in the subband "header" and not the plane "header" and also not twice and also not missing. Iam happy to implement this differently if you have a suggestion ah, this is patch to "fix" timeouts durandal_1707, why do you write such flaimbait replies? The patch has nothing to do with timeouts. Its rather that i see multiple fixes for out of array writes in the history of the CFHD decoder and its header parser allowing basically anything in any order no matter if it has any sense. And the patch tries to restrict this. if you are against the patch just say so and ill work on something else if work on this fron continues, the next logic step would be to ensure each band, plane and so on is coded exactly once because IIRC ATM the decoder doesnt check this either not just that any band related field could be in the plane or main header part and so on I agree with michaelni here. The tone is flamebait-y for no reason. michaelni: restricting that with ugly patch is not nice to continue this on the ML which is where patch review belongs which other way do you prefer ? It could be implemented in many differnt ways, i cannot read your mind ... Each method has some advanatges and disadvanatges from ease of supporting unexpected order in odd files to code complexity to ease of backporting the patch ... The whole loop could be redesigned and split up into 1 function for each header type (main / plane / band / ...) each such function would then have a similar loop with the subset of tags that can occur. if you prefer that ? but that would probably not be backported far, leaving some releases without this or as already said, i can just work on something else if people dont like this. Or maybe you want to implement this ? I can ofer to review your patch if you want to implement this instead. Thanks -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is 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 v4] avcodec/cfhd: More strictly check tag order and multiplicity
On 8/31/20, Michael Niedermayer wrote: > On Mon, Aug 31, 2020 at 11:14:07AM +0200, Paul B Mahol wrote: >> On 8/31/20, Michael Niedermayer wrote: >> > This is based on the encoder and a small number of CFHD sample files >> > It should make the decoder more robust against crafted input. >> > Due to the lack of a proper specification it is possible that this >> > may be too strict and may need to be tuned as files not following this >> > ordering are found. >> > >> > Signed-off-by: Michael Niedermayer >> > --- >> >> I'm afraid this is not nice solution. >> Please consider sharing samples that causes crash to me. >> IMO I'm afraid that this patch is just band-aid and not proper solution. > > As this ended up discussed on IRC too, heres the relevant log as reference > for the archieve as otherwise noone will find it > an interleaved discussion about AAC with JEEB is removed > > durandal_1707, kierank, i dont have any crashing samples which > are fixed by the cfhd table patch. That patch was intended to restrict > what/where elements can occur so that for example the one specifying the > subband number is in the subband "header" and not the plane "header" and > also not twice and also not missing. > Iam happy to implement this differently if you have a > suggestion > ah, this is patch to "fix" timeouts > durandal_1707, why do you write such flaimbait replies? The > patch has nothing to do with timeouts. Its rather that i see multiple fixes > for out of array writes in the history of the CFHD decoder and its header > parser allowing basically anything in any order no matter if it has any > sense. And the patch tries to restrict this. > if you are against the patch just say so and ill work on > something else > if work on this fron continues, the next logic step would be to > ensure each band, plane and so on is coded exactly once > because IIRC ATM the decoder doesnt check this either not just > that any band related field could be in the plane or main header part and so > on > I agree with michaelni here. > The tone is flamebait-y for no reason. > michaelni: restricting that with ugly patch is not nice > > to continue this on the ML which is where patch review belongs > which other way do you prefer ? > It could be implemented in many differnt ways, i cannot read your mind ... > Each method has some advanatges and disadvanatges from ease of > supporting unexpected order in odd files to code complexity to ease of > backporting the patch ... > > The whole loop could be redesigned and split up into 1 function for > each header type (main / plane / band / ...) each such function would > then have a similar loop with the subset of tags that can occur. > if you prefer that ? > but that would probably not be backported far, leaving some releases > without this > or as already said, i can just work on something else if people dont like > this. > Or maybe you want to implement this ? I can ofer to review your patch if > you want to implement this instead. There are only some restrictions that can be tracked by reading SDK code. I prefer minimal intrusion in code - the minimal restrictions possible. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avformat/mxfenc: Write Mastering Display Colour Volume to MXF
Described in Annex B SMPTE ST 2067-21:2020 Signed-off-by: Harry Mallon --- libavformat/mxfenc.c | 56 1 file changed, 56 insertions(+) diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index e495b5ba0e..fe1ecb6705 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -44,6 +44,7 @@ #include "libavutil/random_seed.h" #include "libavutil/timecode.h" #include "libavutil/avassert.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/pixdesc.h" #include "libavutil/time_internal.h" #include "libavcodec/bytestream.h" @@ -421,6 +422,13 @@ static const MXFLocalTagPair mxf_user_comments_local_tag[] = { { 0x5003, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x03,0x02,0x01,0x02,0x0A,0x01,0x00,0x00}}, /* Value */ }; +static const MXFLocalTagPair mxf_mastering_display_local_tags[] = { +{ 0x8201, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00}}, /* Mastering Display Primaries */ +{ 0x8202, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00}}, /* Mastering Display White Point Chromaticity */ +{ 0x8203, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00}}, /* Mastering Display Maximum Luminance */ +{ 0x8204, {0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00}}, /* Mastering Display Minimum Luminance */ +}; + static void mxf_write_uuid(AVIOContext *pb, enum MXFMetadataSetType type, int value) { avio_write(pb, uuid_base, 12); @@ -510,6 +518,7 @@ static void mxf_write_primer_pack(AVFormatContext *s) AVIOContext *pb = s->pb; int local_tag_number, i = 0; int avc_tags_count = 0; +int mastering_tags_count = 0; local_tag_number = FF_ARRAY_ELEMS(mxf_local_tag_batch); local_tag_number += mxf->store_user_comments * FF_ARRAY_ELEMS(mxf_user_comments_local_tag); @@ -522,6 +531,15 @@ static void mxf_write_primer_pack(AVFormatContext *s) } } +for (i = 0; i < s->nb_streams; i++) { +uint8_t *side_data = av_stream_get_side_data(s->streams[i], AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); +if (side_data) { +mastering_tags_count = FF_ARRAY_ELEMS(mxf_mastering_display_local_tags); +local_tag_number += mastering_tags_count; +break; +} +} + avio_write(pb, primer_pack_key, 16); klv_encode_ber_length(pb, local_tag_number * 18 + 8); @@ -539,6 +557,8 @@ static void mxf_write_primer_pack(AVFormatContext *s) } if (avc_tags_count > 0) mxf_write_local_tags(pb, mxf_avc_subdescriptor_local_tags, avc_tags_count); +if (mastering_tags_count > 0) +mxf_write_local_tags(pb, mxf_mastering_display_local_tags, mastering_tags_count); } static void mxf_write_local_tag(AVIOContext *pb, int size, int tag) @@ -1048,6 +1068,11 @@ static const UID mxf_generic_sound_descriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0 static const UID mxf_avc_subdescriptor_key = { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x6E,0x00 }; +static inline int64_t rescale_mastering(AVRational q, int b) +{ +return av_rescale(q.num, b, q.den); +} + static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID key) { MXFStreamContext *sc = st->priv_data; @@ -1060,6 +1085,7 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID const MXFCodecUL *color_trc_ul; const MXFCodecUL *color_space_ul; int64_t pos = mxf_write_generic_desc(s, st, key); +uint8_t *side_data; color_primaries_ul = mxf_get_codec_ul_by_id(ff_mxf_color_primaries_uls, st->codecpar->color_primaries); color_trc_ul = mxf_get_codec_ul_by_id(ff_mxf_color_trc_uls, st->codecpar->color_trc); @@ -1228,6 +1254,36 @@ static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, const UID mxf_write_local_tag(pb, 16, 0x3201); avio_write(pb, *sc->codec_ul, 16); +// Mastering Display metadata +side_data = av_stream_get_side_data(st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, NULL); +if (side_data) { +const AVMasteringDisplayMetadata *metadata = (const AVMasteringDisplayMetadata*)side_data; +const int chroma_den = 5; +const int luma_den = 1; +if (metadata->has_primaries) { +mxf_write_local_tag(pb, 12, 0x8201); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[0][0], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[0][1], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[1][0], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[1][1], chroma_den)); +avio_wb16(pb, rescale_mastering(metadata->display_primaries[2][0], chroma_den)); +avio_wb16(pb, rescale_mastering(me
[FFmpeg-devel] [PATCH 3/3] avformat/mxfdec: Read Apple private Content Light Level from MXF
* As embedded by Apple Compressor Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 29 + 1 file changed, 29 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index a7a1e74a0a..58a11384b4 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -216,6 +216,8 @@ typedef struct MXFDescriptor { UID color_trc_ul; UID color_space_ul; AVMasteringDisplayMetadata *mastering; +AVContentLightMetadata *coll; +size_t coll_size; } MXFDescriptor; typedef struct MXFIndexTableSegment { @@ -335,6 +337,8 @@ static const uint8_t mxf_mastering_display_primaries[] = { 0x06,0 static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }; static const uint8_t mxf_mastering_display_maximum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }; static const uint8_t mxf_mastering_display_minimum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }; +static const uint8_t mxf_coll_apple_max_cll[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x01 }; +static const uint8_t mxf_coll_apple_max_fall[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x0e,0x20,0x04,0x01,0x05,0x03,0x01,0x02 }; #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) @@ -345,6 +349,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) case Descriptor: av_freep(&((MXFDescriptor *)*ctx)->extradata); av_freep(&((MXFDescriptor *)*ctx)->mastering); +av_freep(&((MXFDescriptor *)*ctx)->coll); break; case MultipleDescriptor: av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs); @@ -1334,6 +1339,22 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int if (descriptor->mastering->max_luminance.den != 0) descriptor->mastering->has_luminance = 1; } +if (IS_KLV_KEY(uid, mxf_coll_apple_max_cll)) { +if (!descriptor->coll) { +descriptor->coll = av_content_light_metadata_alloc(&descriptor->coll_size); +if (!descriptor->coll) +return AVERROR(ENOMEM); +} +descriptor->coll->MaxCLL = avio_rb16(pb); +} +if (IS_KLV_KEY(uid, mxf_coll_apple_max_fall)) { +if (!descriptor->coll) { +descriptor->coll = av_content_light_metadata_alloc(&descriptor->coll_size); +if (!descriptor->coll) +return AVERROR(ENOMEM); +} +descriptor->coll->MaxFALL = avio_rb16(pb); +} break; } return 0; @@ -2602,6 +2623,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) goto fail_and_free; descriptor->mastering = NULL; } +if (descriptor->coll) { +ret = av_stream_add_side_data(st, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + (uint8_t *)descriptor->coll, + descriptor->coll_size); +if (ret < 0) +goto fail_and_free; +descriptor->coll = NULL; +} } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul); /* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */ -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: Read Mastering Display Colour Volume from MXF
Described in Annex B SMPTE ST 2067-21:2020 Signed-off-by: Harry Mallon --- libavformat/mxfdec.c | 70 1 file changed, 70 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 6f6e8d586c..a7a1e74a0a 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -28,6 +28,7 @@ * SMPTE 381M Mapping MPEG Streams into the MXF Generic Container * SMPTE 382M Mapping AES3 and Broadcast Wave Audio into the MXF Generic Container * SMPTE 383M Mapping DV-DIF Data to the MXF Generic Container + * SMPTE 2067-21 Interoperable Master Format — Application #2E * * Principle * Search for Track numbers which will identify essence element KLV packets. @@ -47,6 +48,7 @@ #include "libavutil/aes.h" #include "libavutil/avassert.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "libavutil/intreadwrite.h" @@ -213,6 +215,7 @@ typedef struct MXFDescriptor { UID color_primaries_ul; UID color_trc_ul; UID color_space_ul; +AVMasteringDisplayMetadata *mastering; } MXFDescriptor; typedef struct MXFIndexTableSegment { @@ -328,6 +331,10 @@ static const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x static const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }; static const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; static const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }; +static const uint8_t mxf_mastering_display_primaries[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x01,0x00,0x00 }; +static const uint8_t mxf_mastering_display_white_point_chromaticity[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x02,0x00,0x00 }; +static const uint8_t mxf_mastering_display_maximum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x03,0x00,0x00 }; +static const uint8_t mxf_mastering_display_minimum_luminance[]= { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x20,0x04,0x01,0x01,0x04,0x00,0x00 }; #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) @@ -337,6 +344,7 @@ static void mxf_free_metadataset(MXFMetadataSet **ctx, int freectx) switch ((*ctx)->type) { case Descriptor: av_freep(&((MXFDescriptor *)*ctx)->extradata); +av_freep(&((MXFDescriptor *)*ctx)->mastering); break; case MultipleDescriptor: av_freep(&((MXFDescriptor *)*ctx)->sub_descriptors_refs); @@ -1272,6 +1280,60 @@ static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int rsiz == FF_PROFILE_JPEG2000_DCINEMA_4K) descriptor->pix_fmt = AV_PIX_FMT_XYZ12; } +if (IS_KLV_KEY(uid, mxf_mastering_display_primaries)) { +const int chroma_den = 5; +int i; +if (!descriptor->mastering) { +descriptor->mastering = av_mastering_display_metadata_alloc(); +if (!descriptor->mastering) +return AVERROR(ENOMEM); +} +for (i = 0; i < 3; i++) { +/* Order: large x, large y, other (i.e. RGB) */ +descriptor->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), chroma_den); +descriptor->mastering->display_primaries[i][1] = av_make_q(avio_rb16(pb), chroma_den); +} +/* Check we have seen mxf_mastering_display_white_point_chromaticity */ +if (descriptor->mastering->white_point[0].den != 0) +descriptor->mastering->has_primaries = 1; +} +if (IS_KLV_KEY(uid, mxf_mastering_display_white_point_chromaticity)) { +const int chroma_den = 5; +if (!descriptor->mastering) { +descriptor->mastering = av_mastering_display_metadata_alloc(); +if (!descriptor->mastering) +return AVERROR(ENOMEM); +} +descriptor->mastering->white_point[0] = av_make_q(avio_rb16(pb), chroma_den); +descriptor->mastering->white_point[1] = av_make_q(avio_rb16(pb), chroma_den); +/* Check we have seen mxf_mastering_display_primaries */ +if (descriptor->mastering->display_primaries[0][0].den != 0) +descriptor->mastering->has_primaries = 1; +} +if (IS_KLV_KEY(uid, mxf_mastering_display_maximum_luminance)) { +const int luma_den = 1; +if (!descriptor->mastering) { +descriptor->mastering = av_mastering_display_metadata_alloc(); +if (!descriptor->mastering) +
Re: [FFmpeg-devel] [PATCH 1/3][GSoC] Add mutithread function for dnn_backend_native_layer_conv2d.c
On 31/08/2020 18:03, xuju...@sjtu.edu.cn wrote: From: Xu Jun Use pthread to multithread dnn_execute_layer_conv2d. Can be tested with command "./ffmpeg_g -i input.png -vf \ format=yuvj420p,dnn_processing=dnn_backend=native:model= \ espcn.model:input=x:output=y -y sr_native.jpg -benchmark" before patch: utime=11.238s stime=0.005s rtime=11.248s after patch: utime=20.817s stime=0.047s rtime=1.051s Can you explain why it uses almost twice as much total CPU time after the patch? That seems rather more than can be explained away as scheduling overhead. If it's actually doing significantly more then maybe you want to document somewhere that enabling threading will improve latency at the cost of throughput. - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] hwcontext_vaapi: Don't require a render node when deriving from DRM
On 28/08/2020 23:15, Mark Thompson wrote: The V4L2 driver does not actually have an associated DRM device at all, so users work around the requirement by giving libva an unrelated display-only device instead (which is fine, because it doesn't actually do anything with that device). This was broken by bc9b6358fb7315c0173de322472641766f6289da forcing a render node, because the display-only device did not have an associated render node to use. Fix that by just passing through the original non-render DRM fd if we can't find a render node. Reported-by: Paul Kocialkowski --- Also tested by the reporter. I'll apply this in a few days if there are no comments. Applied. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] cbs_av1: Fill tile width/height values when uniform_tile_spacing_flag is set
They are not explicitly in the bitstream in this case, but it is helpful to be able to use these values without always needing to check the flag beforehand. --- On 31/08/2020 08:31, Wang, Fei W wrote:>> -Original Message- From: ffmpeg-devel On Behalf Of Mark Thompson Sent: Sunday, August 23, 2020 6:26 AM To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] cbs_av1: Fill tile width/height values when uniform_tile_spacing_flag is set They are not explicitly in the bitstream in this case, but it is helpful to be able to use these values without always needing to check the flag beforehand. --- libavcodec/cbs_av1_syntax_template.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index a315e8868a..2c976a9574 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -624,6 +624,15 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw, current->tile_rows_log2; current->tile_rows = (sb_rows + tile_height_sb - 1) / tile_height_sb; +for (i = 0; i < current->tile_cols - 1; i++) +infer(width_in_sbs_minus_1[i], tile_width_sb); +infer(width_in_sbs_minus_1[i], + sb_cols - (current->tile_cols - 1) * tile_width_sb); Should this by using "tile_width_sb -1" and "sb_cols - (current->tile_cols - 1) * tile_width_sb - 1" ? And same for height_in_sbs_minus_1. Oops, yeah (just looking at the numbers to check means you don't notice the minus_1). +for (i = 0; i < current->tile_rows - 1; i++) +infer(height_in_sbs_minus_1[i], tile_height_sb); +infer(height_in_sbs_minus_1[i], + sb_rows - (current->tile_rows - 1) * tile_height_sb); + } else { int widest_tile_sb, start_sb, size_sb, max_width, max_height; New version enclosing. Thanks, - Mark libavcodec/cbs_av1_syntax_template.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 19b82bc3f8..2d2e240e3e 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -636,6 +636,15 @@ static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw, current->tile_rows_log2; current->tile_rows = (sb_rows + tile_height_sb - 1) / tile_height_sb; +for (i = 0; i < current->tile_cols - 1; i++) +infer(width_in_sbs_minus_1[i], tile_width_sb - 1); +infer(width_in_sbs_minus_1[i], + sb_cols - (current->tile_cols - 1) * tile_width_sb - 1); +for (i = 0; i < current->tile_rows - 1; i++) +infer(height_in_sbs_minus_1[i], tile_height_sb - 1); +infer(height_in_sbs_minus_1[i], + sb_rows - (current->tile_rows - 1) * tile_height_sb - 1); + } else { int widest_tile_sb, start_sb, size_sb, max_width, max_height; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/8] avcodec/magicyuv: Don't invert Huffman table symbols twice
When the MagicYUV decoder builds Huffman tables from an array of code lengths, it proceeds as follows: First it copies the entries of the array of lengths into an array of HuffEntries (a struct which contains a length and a symbol field); it also sets the symbol field in descending order from nb_elem - 1 to 0, where nb_elem is the common number of elements of the length and HuffEntry arrays. Then the HuffEntry array is sorted lexicographically: a > b iff a.len > b.len or a.len == b.len and a.sym > b.sym. Afterwards the symbols of the so sorted array are inverted again (i.e. each symbol sym is replaced by nb_elem - sym). Yet inverting can easily be avoided altogether: Just modify the order so that smaller symbols correspond to bigger HuffEntries. This leads to the same permutation as the current code does and given that the two inversions just cancel each other out, the result is the same. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index a255f82d9c..32d744add2 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -79,19 +79,19 @@ typedef struct MagicYUVContext { static int huff_cmp_len(const void *a, const void *b) { const HuffEntry *aa = a, *bb = b; -return (aa->len - bb->len) * 256 + aa->sym - bb->sym; +return (aa->len - bb->len) * 256 + bb->sym - aa->sym; } static int huff_cmp_len10(const void *a, const void *b) { const HuffEntry *aa = a, *bb = b; -return (aa->len - bb->len) * 1024 + aa->sym - bb->sym; +return (aa->len - bb->len) * 1024 + bb->sym - aa->sym; } static int huff_cmp_len12(const void *a, const void *b) { const HuffEntry *aa = a, *bb = b; -return (aa->len - bb->len) * 4096 + aa->sym - bb->sym; +return (aa->len - bb->len) * 4096 + bb->sym - aa->sym; } static int huff_build10(VLC *vlc, uint8_t *len) @@ -104,7 +104,7 @@ static int huff_build10(VLC *vlc, uint8_t *len) int i; for (i = 0; i < 1024; i++) { -he[i].sym = 1023 - i; +he[i].sym = i; he[i].len = len[i]; if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; @@ -115,7 +115,7 @@ static int huff_build10(VLC *vlc, uint8_t *len) for (i = 1023; i >= 0; i--) { codes[i] = code >> (32 - he[i].len); bits[i] = he[i].len; -syms[i] = 1023 - he[i].sym; +syms[i] = he[i].sym; code += 0x8000u >> (he[i].len - 1); } @@ -136,7 +136,7 @@ static int huff_build12(VLC *vlc, uint8_t *len) int i; for (i = 0; i < 4096; i++) { -he[i].sym = 4095 - i; +he[i].sym = i; he[i].len = len[i]; if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; @@ -147,7 +147,7 @@ static int huff_build12(VLC *vlc, uint8_t *len) for (i = 4095; i >= 0; i--) { codes[i] = code >> (32 - he[i].len); bits[i] = he[i].len; -syms[i] = 4095 - he[i].sym; +syms[i] = he[i].sym; code += 0x8000u >> (he[i].len - 1); } @@ -168,7 +168,7 @@ static int huff_build(VLC *vlc, uint8_t *len) int i; for (i = 0; i < 256; i++) { -he[i].sym = 255 - i; +he[i].sym = i; he[i].len = len[i]; if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; @@ -179,7 +179,7 @@ static int huff_build(VLC *vlc, uint8_t *len) for (i = 255; i >= 0; i--) { codes[i] = code >> (32 - he[i].len); bits[i] = he[i].len; -syms[i] = 255 - he[i].sym; +syms[i] = he[i].sym; code += 0x8000u >> (he[i].len - 1); } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/8] avcodec/magicyuv: Avoid copying values around pointlessly
When parsing Huffman tables, an array of HuffEntries (a struct containing a code's bitlength, its bits and its symbol) is used as intermediate tables in order to sort the entries (the order depends on both the length of the entries as well on their symbols). After ordering them, the symbol and len components are copied into other arrays (the HuffEntries' code has never been set or used, despite using quite a lot of stack space) and the codes are generated. Afterwards, the VLC is created. Yet ff_init_vlc_sparse() can handle non-continuous arrays as input; there is no need to copy the entries at all. This commit implements this. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 39 --- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 32d744add2..f630464162 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -97,9 +97,6 @@ static int huff_cmp_len12(const void *a, const void *b) static int huff_build10(VLC *vlc, uint8_t *len) { HuffEntry he[1024]; -uint32_t codes[1024]; -uint8_t bits[1024]; -uint16_t syms[1024]; uint32_t code; int i; @@ -113,25 +110,20 @@ static int huff_build10(VLC *vlc, uint8_t *len) code = 1; for (i = 1023; i >= 0; i--) { -codes[i] = code >> (32 - he[i].len); -bits[i] = he[i].len; -syms[i] = he[i].sym; +he[i].code = code >> (32 - he[i].len); code += 0x8000u >> (he[i].len - 1); } ff_free_vlc(vlc); return ff_init_vlc_sparse(vlc, FFMIN(he[1023].len, 12), 1024, - bits, sizeof(*bits), sizeof(*bits), - codes, sizeof(*codes), sizeof(*codes), - syms, sizeof(*syms), sizeof(*syms), 0); + &he[0].len, sizeof(he[0]), sizeof(he[0].len), + &he[0].code, sizeof(he[0]), sizeof(he[0].code), + &he[0].sym, sizeof(he[0]), sizeof(he[0].sym), 0); } static int huff_build12(VLC *vlc, uint8_t *len) { HuffEntry he[4096]; -uint32_t codes[4096]; -uint8_t bits[4096]; -uint16_t syms[4096]; uint32_t code; int i; @@ -145,25 +137,20 @@ static int huff_build12(VLC *vlc, uint8_t *len) code = 1; for (i = 4095; i >= 0; i--) { -codes[i] = code >> (32 - he[i].len); -bits[i] = he[i].len; -syms[i] = he[i].sym; +he[i].code = code >> (32 - he[i].len); code += 0x8000u >> (he[i].len - 1); } ff_free_vlc(vlc); return ff_init_vlc_sparse(vlc, FFMIN(he[4095].len, 12), 4096, - bits, sizeof(*bits), sizeof(*bits), - codes, sizeof(*codes), sizeof(*codes), - syms, sizeof(*syms), sizeof(*syms), 0); + &he[0].len, sizeof(he[0]), sizeof(he[0].len), + &he[0].code, sizeof(he[0]), sizeof(he[0].code), + &he[0].sym, sizeof(he[0]), sizeof(he[0].sym), 0); } static int huff_build(VLC *vlc, uint8_t *len) { HuffEntry he[256]; -uint32_t codes[256]; -uint8_t bits[256]; -uint8_t syms[256]; uint32_t code; int i; @@ -177,17 +164,15 @@ static int huff_build(VLC *vlc, uint8_t *len) code = 1; for (i = 255; i >= 0; i--) { -codes[i] = code >> (32 - he[i].len); -bits[i] = he[i].len; -syms[i] = he[i].sym; +he[i].code = code >> (32 - he[i].len); code += 0x8000u >> (he[i].len - 1); } ff_free_vlc(vlc); return ff_init_vlc_sparse(vlc, FFMIN(he[255].len, 12), 256, - bits, sizeof(*bits), sizeof(*bits), - codes, sizeof(*codes), sizeof(*codes), - syms, sizeof(*syms), sizeof(*syms), 0); + &he[0].len, sizeof(he[0]), sizeof(he[0].len), + &he[0].code, sizeof(he[0]), sizeof(he[0].code), + &he[0].sym, sizeof(he[0]), sizeof(he[0].sym), 0); } static void magicyuv_median_pred16(uint16_t *dst, const uint16_t *src1, -- 2.20.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/8] avcodec/magicyuv: Unify qsort comparison functions
Up until now, there were three comparison functions depending upon bitness. But they all are actually the same, namely a lexical ordering: entry a > entry b iff a.len > b.len or a.len == b.len and a.sym < b.sym. So they can be easily unified. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index f630464162..5578374429 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -77,18 +77,6 @@ typedef struct MagicYUVContext { } MagicYUVContext; static int huff_cmp_len(const void *a, const void *b) -{ -const HuffEntry *aa = a, *bb = b; -return (aa->len - bb->len) * 256 + bb->sym - aa->sym; -} - -static int huff_cmp_len10(const void *a, const void *b) -{ -const HuffEntry *aa = a, *bb = b; -return (aa->len - bb->len) * 1024 + bb->sym - aa->sym; -} - -static int huff_cmp_len12(const void *a, const void *b) { const HuffEntry *aa = a, *bb = b; return (aa->len - bb->len) * 4096 + bb->sym - aa->sym; @@ -106,7 +94,7 @@ static int huff_build10(VLC *vlc, uint8_t *len) if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; } -AV_QSORT(he, 1024, HuffEntry, huff_cmp_len10); +AV_QSORT(he, 1024, HuffEntry, huff_cmp_len); code = 1; for (i = 1023; i >= 0; i--) { @@ -133,7 +121,7 @@ static int huff_build12(VLC *vlc, uint8_t *len) if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; } -AV_QSORT(he, 4096, HuffEntry, huff_cmp_len12); +AV_QSORT(he, 4096, HuffEntry, huff_cmp_len); code = 1; for (i = 4095; i >= 0; i--) { -- 2.20.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 8/8] avcodec/magicyuv: Avoid intermediate array when parsing Huffman tables
Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 21 - 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index d2656427b9..eed5ad1b40 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -68,7 +68,6 @@ typedef struct MagicYUVContext { int vshift[4]; Slice*slices[4]; // slice bitstream positions for each plane unsigned int slices_size[4]; // slice sizes for each plane -uint8_t len[4096]; // scratch table of code lengths VLC vlc[4]; // VLC for each plane int (*magy_decode_slice)(AVCodecContext *avctx, void *tdata, int j, int threadnr); @@ -81,18 +80,11 @@ static int huff_cmp_len(const void *a, const void *b) return (aa->len - bb->len) * 4096 + bb->sym - aa->sym; } -static int huff_build(VLC *vlc, uint8_t *len, int nb_elems) +static int huff_build(HuffEntry he[], VLC *vlc, int nb_elems) { -HuffEntry he[4096]; uint32_t code; int i; -for (i = 0; i < nb_elems; i++) { -he[i].sym = i; -he[i].len = len[i]; -if (len[i] == 0 || len[i] > 32) -return AVERROR_INVALIDDATA; -} AV_QSORT(he, nb_elems, HuffEntry, huff_cmp_len); code = 1; @@ -396,6 +388,7 @@ static int magy_decode_slice(AVCodecContext *avctx, void *tdata, static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) { MagicYUVContext *s = avctx->priv_data; +HuffEntry he[4096]; int i = 0, j = 0, k; while (get_bits_left(gbit) >= 8) { @@ -404,17 +397,19 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) int l = get_bitsz(gbit, b * 8) + 1; k = j + l; -if (k > max) { +if (k > max || x == 0 || x > 32) { av_log(avctx, AV_LOG_ERROR, "Invalid Huffman codes\n"); return AVERROR_INVALIDDATA; } -for (; j < k; j++) -s->len[j] = x; +for (; j < k; j++) { +he[j].sym = j; +he[j].len = x; +} if (j == max) { j = 0; -if (huff_build(&s->vlc[i], s->len, max)) { +if (huff_build(he, &s->vlc[i], max)) { av_log(avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n"); return AVERROR_INVALIDDATA; } -- 2.20.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 4/8] avcodec/magicyuv: Simplify check for invalid Huffman codes
Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 5578374429..f2204f3401 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -459,11 +459,15 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) int x = get_bits(gbit, 7); int l = get_bitsz(gbit, b * 8) + 1; -for (k = 0; k < l; k++) -if (j + k < max) -s->len[i][j + k] = x; +k = j + l; +if (k > max) { +av_log(avctx, AV_LOG_ERROR, "Invalid Huffman codes\n"); +return AVERROR_INVALIDDATA; +} + +for (; j < k; j++) +s->len[i][j] = x; -j += l; if (j == max) { j = 0; if (s->huff_build(&s->vlc[i], s->len[i])) { @@ -474,9 +478,6 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) if (i == s->planes) { break; } -} else if (j > max) { -av_log(avctx, AV_LOG_ERROR, "Invalid Huffman codes\n"); -return AVERROR_INVALIDDATA; } } -- 2.20.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 5/8] avcodec/magicyuv: Don't zero unnecessarily
The code already checks that exactly the expected amount of entries are read and set. Ergo it is unnecessary to zero them at the beginning. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index f2204f3401..9282b39723 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -453,7 +453,6 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) MagicYUVContext *s = avctx->priv_data; int i = 0, j = 0, k; -memset(s->len, 0, sizeof(s->len)); while (get_bits_left(gbit) >= 8) { int b = get_bits(gbit, 1); int x = get_bits(gbit, 7); -- 2.20.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 7/8] avcodec/magicyuv: Unify creating Huffman tables
Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 71 --- 1 file changed, 6 insertions(+), 65 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index a16135e683..d2656427b9 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -70,7 +70,6 @@ typedef struct MagicYUVContext { unsigned int slices_size[4]; // slice sizes for each plane uint8_t len[4096]; // scratch table of code lengths VLC vlc[4]; // VLC for each plane -int (*huff_build)(VLC *vlc, uint8_t *len); int (*magy_decode_slice)(AVCodecContext *avctx, void *tdata, int j, int threadnr); LLVidDSPContext llviddsp; @@ -82,82 +81,28 @@ static int huff_cmp_len(const void *a, const void *b) return (aa->len - bb->len) * 4096 + bb->sym - aa->sym; } -static int huff_build10(VLC *vlc, uint8_t *len) -{ -HuffEntry he[1024]; -uint32_t code; -int i; - -for (i = 0; i < 1024; i++) { -he[i].sym = i; -he[i].len = len[i]; -if (len[i] == 0 || len[i] > 32) -return AVERROR_INVALIDDATA; -} -AV_QSORT(he, 1024, HuffEntry, huff_cmp_len); - -code = 1; -for (i = 1023; i >= 0; i--) { -he[i].code = code >> (32 - he[i].len); -code += 0x8000u >> (he[i].len - 1); -} - -ff_free_vlc(vlc); -return ff_init_vlc_sparse(vlc, FFMIN(he[1023].len, 12), 1024, - &he[0].len, sizeof(he[0]), sizeof(he[0].len), - &he[0].code, sizeof(he[0]), sizeof(he[0].code), - &he[0].sym, sizeof(he[0]), sizeof(he[0].sym), 0); -} - -static int huff_build12(VLC *vlc, uint8_t *len) +static int huff_build(VLC *vlc, uint8_t *len, int nb_elems) { HuffEntry he[4096]; uint32_t code; int i; -for (i = 0; i < 4096; i++) { -he[i].sym = i; -he[i].len = len[i]; -if (len[i] == 0 || len[i] > 32) -return AVERROR_INVALIDDATA; -} -AV_QSORT(he, 4096, HuffEntry, huff_cmp_len); - -code = 1; -for (i = 4095; i >= 0; i--) { -he[i].code = code >> (32 - he[i].len); -code += 0x8000u >> (he[i].len - 1); -} - -ff_free_vlc(vlc); -return ff_init_vlc_sparse(vlc, FFMIN(he[4095].len, 12), 4096, - &he[0].len, sizeof(he[0]), sizeof(he[0].len), - &he[0].code, sizeof(he[0]), sizeof(he[0].code), - &he[0].sym, sizeof(he[0]), sizeof(he[0].sym), 0); -} - -static int huff_build(VLC *vlc, uint8_t *len) -{ -HuffEntry he[256]; -uint32_t code; -int i; - -for (i = 0; i < 256; i++) { +for (i = 0; i < nb_elems; i++) { he[i].sym = i; he[i].len = len[i]; if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; } -AV_QSORT(he, 256, HuffEntry, huff_cmp_len); +AV_QSORT(he, nb_elems, HuffEntry, huff_cmp_len); code = 1; -for (i = 255; i >= 0; i--) { +for (i = nb_elems - 1; i >= 0; i--) { he[i].code = code >> (32 - he[i].len); code += 0x8000u >> (he[i].len - 1); } ff_free_vlc(vlc); -return ff_init_vlc_sparse(vlc, FFMIN(he[255].len, 12), 256, +return ff_init_vlc_sparse(vlc, FFMIN(he[nb_elems - 1].len, 12), nb_elems, &he[0].len, sizeof(he[0]), sizeof(he[0].len), &he[0].code, sizeof(he[0]), sizeof(he[0].code), &he[0].sym, sizeof(he[0]), sizeof(he[0].sym), 0); @@ -469,7 +414,7 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) if (j == max) { j = 0; -if (s->huff_build(&s->vlc[i], s->len)) { +if (huff_build(&s->vlc[i], s->len, max)) { av_log(avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n"); return AVERROR_INVALIDDATA; } @@ -595,10 +540,6 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, } s->max = 1 << s->bps; s->magy_decode_slice = s->bps == 8 ? magy_decode_slice : magy_decode_slice10; -if ( s->bps == 8) -s->huff_build = huff_build; -else -s->huff_build = s->bps == 10 ? huff_build10 : huff_build12; s->planes = av_pix_fmt_count_planes(avctx->pix_fmt); bytestream2_skip(&gbyte, 1); -- 2.20.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 6/8] avcodec/magicyuv: Reuse array instead of using multiple arrays
The lengths of the VLC codes are implicitly contained in the VLC tables itself; apart from that they are not used lateron. So it is unnecessary to store them and the very same array can be reused to parse the Huffman table for the next plane. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 9282b39723..a16135e683 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -68,7 +68,7 @@ typedef struct MagicYUVContext { int vshift[4]; Slice*slices[4]; // slice bitstream positions for each plane unsigned int slices_size[4]; // slice sizes for each plane -uint8_t len[4][4096]; // table of code lengths for each plane +uint8_t len[4096]; // scratch table of code lengths VLC vlc[4]; // VLC for each plane int (*huff_build)(VLC *vlc, uint8_t *len); int (*magy_decode_slice)(AVCodecContext *avctx, void *tdata, @@ -465,11 +465,11 @@ static int build_huffman(AVCodecContext *avctx, GetBitContext *gbit, int max) } for (; j < k; j++) -s->len[i][j] = x; +s->len[j] = x; if (j == max) { j = 0; -if (s->huff_build(&s->vlc[i], s->len[i])) { +if (s->huff_build(&s->vlc[i], s->len)) { av_log(avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n"); return AVERROR_INVALIDDATA; } -- 2.20.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] avfilter/src_movie: switch to activate
On Mon, Aug 31, 2020 at 07:20:14PM +0200, Paul B Mahol wrote: > Allow to set the EOF timestamp. > > Signed-off-by: Paul B Mahol > --- > libavfilter/src_movie.c | 32 ++-- > 1 file changed, 22 insertions(+), 10 deletions(-) The following seems to end in an infinite loop after this patch ./ffmpeg -f lavfi -i 'amovie=fate-suite//wavpack/num_channels/eva_2.22_6.1_16bit-partial.wv,asplit=3[out1][a][b]; [a]showwaves=s=340x240,pad=iw:ih*2[waves]; [b]showspectrum=s=340x240[spectrum]; [waves][spectrum] overlay=0:h [out0]' -t 0.1 -qscale 2 -y w.avi [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship: All citizens are under surveillance, all their steps and actions recorded, for the politicians to enforce control. Democracy: All politicians are under surveillance, all their steps and actions recorded, for the citizens to enforce control. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/qpeg: speed-up copy of bytes
Signed-off-by: Paul B Mahol --- libavcodec/qpeg.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 40931e3bdc..8bc710acfd 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -101,8 +101,11 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst, } else { if (bytestream2_get_bytes_left(&qctx->buffer) < copy) copy = bytestream2_get_bytes_left(&qctx->buffer); -for(i = 0; i < copy; i++) { -dst[filled++] = bytestream2_get_byte(&qctx->buffer); +while (copy > 0) { +int step = FFMIN(copy, width - filled); +bytestream2_get_bufferu(&qctx->buffer, dst + filled, step); +filled += step; +copy -= step; if (filled >= width) { filled = 0; dst -= stride; -- 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] libavformat/dashenc: Reduce confusion in par error message
On Mon, Aug 31, 2020 at 09:57:17AM +, Jeyapal, Karthick wrote: > On 8/31/20, 9:47 AM, "Chris Miceli" wrote: > > > >In ticket #8754 there is discourse surrounding the error > >message which is printed upon a mismatched aspect ratio in > >derived encodings. This should make it clearer to the user > >as to the issues which they are experiencing. > >--- > > libavformat/dashenc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > >diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c > >index dc3306a56a..2d757b3a87 100644 > >--- a/libavformat/dashenc.c > >+++ b/libavformat/dashenc.c > >@@ -1686,7 +1686,7 @@ static int dash_init(AVFormatContext *s) > > 1024 * 1024); > > > > if (as->par.num && av_cmp_q(par, as->par)) { > >-av_log(s, AV_LOG_ERROR, "Conflicting stream par values in > >Adaptation Set %d\n", os->as_idx); > >+av_log(s, AV_LOG_ERROR, "Conflicting stream aspect ratios > >values in Adaptation Set %d. Please ensure all adaptation sets have the same > >aspect ratio\n", os->as_idx); > > return AVERROR(EINVAL); > > } > > as->par = par; > >-- > >2.28.0 > > LGTM will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin 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 v2] doc/decoders: Document default value of ac3's drc_scale option
On Sun, Aug 30, 2020 at 02:05:53PM -0400, Aman Verma wrote: > Signed-off-by: Aman Verma > --- > This is a revision of the previous patch taking Jim's comments into > consideration. Thanks to him and Gyan for the help. > > doc/decoders.texi | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "Nothing to hide" only works if the folks in power share the values of you and everyone you know entirely and always will -- Tom Scott 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/8] avcodec/magicyuv: Don't invert Huffman table symbols twice
On 8/31/20, Andreas Rheinhardt wrote: > When the MagicYUV decoder builds Huffman tables from an array of code > lengths, it proceeds as follows: First it copies the entries of the > array of lengths into an array of HuffEntries (a struct which contains > a length and a symbol field); it also sets the symbol field in > descending order from nb_elem - 1 to 0, where nb_elem is the common number > of elements of the length and HuffEntry arrays. Then the HuffEntry array > is sorted lexicographically: a > b iff a.len > b.len or a.len == b.len and > a.sym > b.sym. Afterwards the symbols of the so sorted array are > inverted again (i.e. each symbol sym is replaced by nb_elem - sym). > > Yet inverting can easily be avoided altogether: Just modify the order so > that smaller symbols correspond to bigger HuffEntries. This leads to the > same permutation as the current code does and given that the two > inversions just cancel each other out, the result is the same. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/magicyuv.c | 18 +- > 1 file changed, 9 insertions(+), 9 deletions(-) > LGTM whole patch set. ___ 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] avfilter/src_movie: switch to activate
Allow to set the EOF timestamp. Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 34 -- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index eeb8609855..b951b7e134 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -44,6 +44,7 @@ #include "audio.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -97,7 +98,6 @@ static const AVOption movie_options[]= { }; static int movie_config_output_props(AVFilterLink *outlink); -static int movie_request_frame(AVFilterLink *outlink); static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) { @@ -309,7 +309,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); pad.config_props = movie_config_output_props; -pad.request_frame = movie_request_frame; if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) { av_freep(&pad.name); return ret; @@ -595,17 +594,30 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) return pkt_out_id == out_id; } -static int movie_request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { -AVFilterContext *ctx = outlink->src; -unsigned out_id = FF_OUTLINK_IDX(outlink); -int ret; +MovieContext *movie = ctx->priv; +int nb_eofs = 0; + +for (int i = 0; i < ctx->nb_outputs; i++) { +AVFilterLink *outlink = ctx->outputs[i]; -while (1) { -ret = movie_push_frame(ctx, out_id); -if (ret) -return FFMIN(ret, 0); +nb_eofs += !!ff_outlink_get_status(outlink); +if (ff_outlink_frame_wanted(outlink)) { +int ret = movie_push_frame(ctx, i); + +if (ret) { +if (ret < 0) +ff_outlink_set_status(outlink, AVERROR_EOF, movie->st[i].last_pts); +return 0; +} +} } + +if (nb_eofs != ctx->nb_outputs) +ff_filter_set_ready(ctx, 100); + +return 0; } static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, @@ -666,6 +678,7 @@ AVFilter ff_avsrc_movie = { .inputs= NULL, .outputs = NULL, +.activate = activate, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, .process_command = process_command }; @@ -687,6 +700,7 @@ AVFilter ff_avsrc_amovie = { .inputs = NULL, .outputs= NULL, +.activate = activate, .priv_class = &amovie_class, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, .process_command = process_command, -- 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] avformat/http: ensure reply code in the range of 100..599
From: Zhao Zhili --- libavformat/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 6c39da1a8b..b77bdf1567 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -168,7 +168,7 @@ static const AVOption options[] = { { "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D }, { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E }, { "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, -{ "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, E}, +{ "reply_code", "The http status code to return to a client", OFFSET(reply_code), AV_OPT_TYPE_INT, { .i64 = 200}, 100, 599, E}, { 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 "unsubscribe".