[FFmpeg-devel] [PATCH v2 0/4] Initial region (styling) support for TTML
Now sets alignment, font size, font family and the region's position and size according to the ASS styles passed to the encoder. Regions are relatively important in TTML, since the spec-defined default region is in raster location (similar to the default with HTML) - it starts from the top left corner and covers the whole screen. Mapping of the ASS script resolution to the cell resolution and using cells as sizing metric is not perfect, but while TTML does have a pixel based reference sizing by means of setting an extent to the root tt element, it is specifically disallowed in the EBU-TT profile, as well as apparently generally frowned upon as opposed to defining the cell resolution. In general, mapping to cell resolution seems to give "close enough" results, though. FATE test output still passes https://github.com/skynav/ttt/ validation, and visually the result can be verified against such renderers as http://sandflow.com/imsc1_1/index.html . Changes from v1: * Removal of unnecessary intermediate AVBprints by printing elements in three steps instead of attempting to do a single one. A bit less pretty, but lets us write straight into the actual output buffer. * Removal of some local scopes. Seems like I'd been utilizing them as a convenient way of having variable definitions after initial sanity checks. * Merging of script play X/Y resolution being zero or smaller checks into just <= 0 checks. * Utilization of extradata buffers as-is after verifying that the buffer ends with a null. Removes the requirement to copy strings out of the extradata into the lavf context, and thus the deinit/free function was no longer necessary. The diff can be checked as follows on my git repository: https://github.com/jeeb/ffmpeg/compare/ttml_add_default_region_v1..ttml_add_default_region_v2 (more easily readable due to file limiting with the following command: git diff ttml_add_default_region_v1..ttml_add_default_region_v2 -- libavcodec/ttmlenc.* libavformat/ttmlenc.* ) Jan Jan Ekström (4): avcodec/ttmlenc: split header writing into its own function avformat/ttmlenc: enable writing out additional header values avcodec/ttmlenc: add initial support for regions and styles avcodec/ttmlenc: add support for region positioning and sizing libavcodec/ttmlenc.c | 267 ++--- libavcodec/ttmlenc.h | 6 + libavformat/ttmlenc.c | 70 +- tests/ref/fate/sub-ttmlenc | 88 +++- 4 files changed, 371 insertions(+), 60 deletions(-) -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/4] avformat/ttmlenc: enable writing out additional header values
From: Jan Ekström This way the encoder may pass on the following values to the muxer: 1) Additional root "tt" element attributes, such as the subtitle canvas reference size. 2) Anything before the body element of the document, such as regions in the head element, which can configure styles. Signed-off-by: Jan Ekström --- libavcodec/ttmlenc.h | 5 libavformat/ttmlenc.c | 70 +++ 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/libavcodec/ttmlenc.h b/libavcodec/ttmlenc.h index c1dd5ec990..c3bb11478d 100644 --- a/libavcodec/ttmlenc.h +++ b/libavcodec/ttmlenc.h @@ -25,4 +25,9 @@ #define TTMLENC_EXTRADATA_SIGNATURE "lavc-ttmlenc" #define TTMLENC_EXTRADATA_SIGNATURE_SIZE (sizeof(TTMLENC_EXTRADATA_SIGNATURE) - 1) +static const char ttml_default_namespacing[] = +" xmlns=\"http://www.w3.org/ns/ttml\"\n"; +" xmlns:ttm=\"http://www.w3.org/ns/ttml#metadata\"\n"; +" xmlns:tts=\"http://www.w3.org/ns/ttml#styling\"\n";; + #endif /* AVCODEC_TTMLENC_H */ diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c index 940f8bbd4e..34a0107a14 100644 --- a/libavformat/ttmlenc.c +++ b/libavformat/ttmlenc.c @@ -37,6 +37,11 @@ enum TTMLPacketType { PACKET_TYPE_DOCUMENT, }; +struct TTMLHeaderParameters { +const char *tt_element_params; +const char *pre_body_elements; +}; + typedef struct TTMLMuxContext { enum TTMLPacketType input_type; unsigned int document_written; @@ -45,10 +50,9 @@ typedef struct TTMLMuxContext { static const char ttml_header_text[] = "\n" "http://www.w3.org/ns/ttml\"\n"; -" xmlns:ttm=\"http://www.w3.org/ns/ttml#metadata\"\n"; -" xmlns:tts=\"http://www.w3.org/ns/ttml#styling\"\n"; +"%s" " xml:lang=\"%s\">\n" +"%s" " \n" "\n"; @@ -72,6 +76,48 @@ static void ttml_write_time(AVIOContext *pb, const char tag[], tag, hour, min, sec, millisec); } +static int ttml_set_header_values_from_extradata( +AVCodecParameters *par, struct TTMLHeaderParameters *header_params) +{ +size_t additional_data_size = +par->extradata_size - TTMLENC_EXTRADATA_SIGNATURE_SIZE; +char *value = +(char *)par->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE; +size_t value_size = av_strnlen(value, additional_data_size); +struct TTMLHeaderParameters local_params = { 0 }; + +if (!additional_data_size) { +// simple case, we don't have to go through local_params and just +// set default fall-back values (for old extradata format). +header_params->tt_element_params = ttml_default_namespacing; +header_params->pre_body_elements = ""; + +return 0; +} + +if (value_size == additional_data_size || +value[value_size] != '\0') +return AVERROR_INVALIDDATA; + +local_params.tt_element_params = value; + +additional_data_size -= value_size + 1; +value += value_size + 1; +if (!additional_data_size) +return AVERROR_INVALIDDATA; + +value_size = av_strnlen(value, additional_data_size); +if (value_size == additional_data_size || +value[value_size] != '\0') +return AVERROR_INVALIDDATA; + +local_params.pre_body_elements = value; + +*header_params = local_params; + +return 0; +} + static int ttml_write_header(AVFormatContext *ctx) { TTMLMuxContext *ttml_ctx = ctx->priv_data; @@ -103,8 +149,22 @@ static int ttml_write_header(AVFormatContext *ctx) avpriv_set_pts_info(st, 64, 1, 1000); -if (ttml_ctx->input_type == PACKET_TYPE_PARAGRAPH) -avio_printf(pb, ttml_header_text, printed_lang); +if (ttml_ctx->input_type == PACKET_TYPE_PARAGRAPH) { +struct TTMLHeaderParameters header_params; +int ret = ttml_set_header_values_from_extradata( +st->codecpar, &header_params); +if (ret < 0) { +av_log(ctx, AV_LOG_ERROR, + "Failed to parse TTML header values from extradata: " + "%s!\n", av_err2str(ret)); +return ret; +} + +avio_printf(pb, ttml_header_text, +header_params.tt_element_params, +printed_lang, +header_params.pre_body_elements); +} } return 0; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 4/4] avcodec/ttmlenc: add support for region positioning and sizing
From: Jan Ekström The ASS margins are utilized to generate percentual values, as the usage of cell-based sizing and offsetting seems to be not too well supported by renderers. Signed-off-by: Jan Ekström --- libavcodec/ttmlenc.c | 44 -- tests/ref/fate/sub-ttmlenc | 2 ++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index c190356683..eab6240a75 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -237,11 +237,35 @@ static const char *ttml_get_text_alignment(int alignment) } } +static void ttml_get_origin(ASSScriptInfo script_info, ASSStyle *style, + int *origin_left, int *origin_top) +{ +*origin_left = av_rescale(style->margin_l, 100, script_info.play_res_x); +*origin_top = +av_rescale((style->alignment >= 7) ? style->margin_v : 0, + 100, script_info.play_res_y); +} + +static void ttml_get_extent(ASSScriptInfo script_info, ASSStyle *style, + int *width, int *height) +{ +*width = av_rescale(script_info.play_res_x - style->margin_r, + 100, script_info.play_res_x); +*height = av_rescale((style->alignment <= 3) ? + script_info.play_res_y - style->margin_v : + script_info.play_res_y, + 100, script_info.play_res_y); +} + static int ttml_write_region(AVCodecContext *avctx, AVBPrint *buf, - ASSStyle *style) + ASSScriptInfo script_info, ASSStyle *style) { const char *display_alignment = NULL; const char *text_alignment = NULL; +int origin_left = 0; +int origin_top = 0; +int width = 0; +int height = 0; if (!style) return AVERROR_INVALIDDATA; @@ -257,6 +281,14 @@ static int ttml_write_region(AVCodecContext *avctx, AVBPrint *buf, return AVERROR_INVALIDDATA; } +if (style->margin_l < 0 || style->margin_r < 0 || style->margin_v < 0) { +av_log(avctx, AV_LOG_ERROR, + "One or more negative margin values in subtitle style: " + "left: %d, right: %d, vertical: %d!\n", + style->margin_l, style->margin_r, style->margin_v); +return AVERROR_INVALIDDATA; +} + display_alignment = ttml_get_display_alignment(style->alignment); text_alignment = ttml_get_text_alignment(style->alignment); if (!display_alignment || !text_alignment) { @@ -268,11 +300,19 @@ static int ttml_write_region(AVCodecContext *avctx, AVBPrint *buf, return AVERROR_INVALIDDATA; } +ttml_get_origin(script_info, style, &origin_left, &origin_top); +ttml_get_extent(script_info, style, &width, &height); + av_bprintf(buf, " name, NULL, AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); av_bprintf(buf, "\"\n"); +av_bprintf(buf, "tts:origin=\"%d%% %d%%\"\n", + origin_left, origin_top); +av_bprintf(buf, "tts:extent=\"%d%% %d%%\"\n", + width, height); + av_bprintf(buf, "tts:displayAlign=\""); av_bprint_escape(buf, display_alignment, NULL, AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); @@ -335,7 +375,7 @@ static int ttml_write_header_content(AVCodecContext *avctx) for (int i = 0; i < ass->styles_count; i++) { ASSStyle *style = &ass->styles[i]; -int ret = ttml_write_region(avctx, &s->buffer, style); +int ret = ttml_write_region(avctx, &s->buffer, script_info, style); if (ret < 0) return ret; } diff --git a/tests/ref/fate/sub-ttmlenc b/tests/ref/fate/sub-ttmlenc index 6d0a8067fc..4df8f8796f 100644 --- a/tests/ref/fate/sub-ttmlenc +++ b/tests/ref/fate/sub-ttmlenc @@ -9,6 +9,8 @@ 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 1/4] avcodec/ttmlenc: split header writing into its own function
From: Jan Ekström Signed-off-by: Jan Ekström --- libavcodec/ttmlenc.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index 3972b4368c..e3c155fdd1 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -173,16 +173,8 @@ static av_cold int ttml_encode_close(AVCodecContext *avctx) return 0; } -static av_cold int ttml_encode_init(AVCodecContext *avctx) +static int ttml_write_header_content(AVCodecContext *avctx) { -TTMLContext *s = avctx->priv_data; - -s->avctx = avctx; - -if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) { -return AVERROR_INVALIDDATA; -} - if (!(avctx->extradata = av_mallocz(TTMLENC_EXTRADATA_SIGNATURE_SIZE + 1 + AV_INPUT_BUFFER_PADDING_SIZE))) { return AVERROR(ENOMEM); @@ -192,8 +184,25 @@ static av_cold int ttml_encode_init(AVCodecContext *avctx) memcpy(avctx->extradata, TTMLENC_EXTRADATA_SIGNATURE, TTMLENC_EXTRADATA_SIGNATURE_SIZE); +return 0; +} + +static av_cold int ttml_encode_init(AVCodecContext *avctx) +{ +TTMLContext *s = avctx->priv_data; +int ret = AVERROR_BUG; +s->avctx = avctx; + av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED); +if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) { +return AVERROR_INVALIDDATA; +} + +if ((ret = ttml_write_header_content(avctx)) < 0) { +return ret; +} + return 0; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 3/4] avcodec/ttmlenc: add initial support for regions and styles
From: Jan Ekström Attempts to utilize the TTML cell resolution as a mapping to the reference resolution, and maps font size to cell size. Additionally sets the display and text alignment according to the ASS alignment number. Signed-off-by: Jan Ekström --- libavcodec/ttmlenc.c | 210 ++--- libavcodec/ttmlenc.h | 3 +- tests/ref/fate/sub-ttmlenc | 86 --- 3 files changed, 247 insertions(+), 52 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index e3c155fdd1..c190356683 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -100,20 +100,33 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, dialog = ff_ass_split_dialog(s->ass_ctx, ass, 0, &num); for (; dialog && num--; dialog++) { -int ret = ff_ass_split_override_codes(&ttml_callbacks, s, - dialog->text); -int log_level = (ret != AVERROR_INVALIDDATA || - avctx->err_recognition & AV_EF_EXPLODE) ? -AV_LOG_ERROR : AV_LOG_WARNING; +if (dialog->style) { +av_bprintf(&s->buffer, "buffer, dialog->style, NULL, + AV_ESCAPE_MODE_XML, + AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); +av_bprintf(&s->buffer, "\">"); +} -if (ret < 0) { -av_log(avctx, log_level, - "Splitting received ASS dialog failed: %s\n", - av_err2str(ret)); +{ +int ret = ff_ass_split_override_codes(&ttml_callbacks, s, + dialog->text); +int log_level = (ret != AVERROR_INVALIDDATA || + avctx->err_recognition & AV_EF_EXPLODE) ? +AV_LOG_ERROR : AV_LOG_WARNING; -if (log_level == AV_LOG_ERROR) -return ret; +if (ret < 0) { +av_log(avctx, log_level, + "Splitting received ASS dialog failed: %s\n", + av_err2str(ret)); + +if (log_level == AV_LOG_ERROR) +return ret; +} } + +if (dialog->style) +av_bprintf(&s->buffer, ""); } } else { #endif @@ -121,6 +134,14 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, if (!dialog) return AVERROR(ENOMEM); +if (dialog->style) { +av_bprintf(&s->buffer, "buffer, dialog->style, NULL, + AV_ESCAPE_MODE_XML, + AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES); +av_bprintf(&s->buffer, "\">"); +} + { int ret = ff_ass_split_override_codes(&ttml_callbacks, s, dialog->text); @@ -140,6 +161,9 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, } } +if (dialog->style) +av_bprintf(&s->buffer, ""); + ff_ass_free_dialog(&dialog); } #if FF_API_ASS_TIMING @@ -173,17 +197,175 @@ static av_cold int ttml_encode_close(AVCodecContext *avctx) return 0; } +static const char *ttml_get_display_alignment(int alignment) +{ +switch (alignment) { +case 1: +case 2: +case 3: +return "after"; +case 4: +case 5: +case 6: +return "center"; +case 7: +case 8: +case 9: +return "before"; +default: +return NULL; +} +} + +static const char *ttml_get_text_alignment(int alignment) +{ +switch (alignment) { +case 1: +case 4: +case 7: +return "left"; +case 2: +case 5: +case 8: +return "center"; +case 3: +case 6: +case 9: +return "right"; +default: +return NULL; +} +} + +static int ttml_write_region(AVCodecContext *avctx, AVBPrint *buf, + ASSStyle *style) +{ +const char *display_alignment = NULL; +const char *text_alignment = NULL; + +if (!style) +return AVERROR_INVALIDDATA; + +if (!style->name) { +av_log(avctx, AV_LOG_ERROR, "Subtitle style name not set!\n"); +return AVERROR_INVALIDDATA; +} + +if (style->font_size < 0) { +av_log(avctx, AV_LOG_ERROR, "Invalid font size for TTML: %d!\n", + style->font_size); +return AVERROR_INVALIDDATA; +} + +display_alignment = ttml_get_display_alignment(style->alignment); +te
Re: [FFmpeg-devel] [PATCH] avformat/dashdec: Also fetch final partial segment
> 2021年4月14日 上午3:42,Matt Robinson 写道: > > On Tue, 6 Apr 2021 at 02:36, Steven Liu wrote: >> >>> 2021年4月6日 上午1:45,Matt Robinson 写道: >>> >>> Currently, the DASH demuxer omits the final segment for a non-live >>> stream (using SegmentTemplate) if it is shorter than the other segments. >>> >>> Correct calc_max_seg_no to round up when calulating the number of >>> segments instead of rounding down to resolve this issue. >>> >>> Signed-off-by: Matt Robinson >>> --- >>> libavformat/dashdec.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c >>> index 6f3f28dcc7..73effd85db 100644 >>> --- a/libavformat/dashdec.c >>> +++ b/libavformat/dashdec.c >>> @@ -1445,7 +1445,7 @@ static int64_t calc_max_seg_no(struct representation >>> *pls, DASHContext *c) >>>} else if (c->is_live && pls->fragment_duration) { >>>num = pls->first_seq_no + (((get_current_time_in_sec() - >>> c->availability_start_time)) * pls->fragment_timescale) / >>> pls->fragment_duration; >>>} else if (pls->fragment_duration) { >>> -num = pls->first_seq_no + (c->media_presentation_duration * >>> pls->fragment_timescale) / pls->fragment_duration; >>> +num = pls->first_seq_no + av_rescale_rnd(1, >>> c->media_presentation_duration * pls->fragment_timescale, >>> pls->fragment_duration, AV_ROUND_UP); >>>} >>> >>>return num; >>> -- >>> 2.25.1 >> >> LGTM >> >> >> Thanks >> >> Steven Liu > > Perfect, thank you Steven. > > Does anyone else have any comments on the patch, or would somebody be > okay to commit it? Patch applied, Thanks for your contribution Matt. Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/aarch64: add pred16x16 10-bit functions
On Tue, 13 Apr 2021, Mikhail Nitenko wrote: Benchmarks: pred16x16_dc_10_c: 124.0 pred16x16_dc_10_neon: 97.2 pred16x16_horizontal_10_c: 71.7 pred16x16_horizontal_10_neon: 66.2 pred16x16_top_dc_10_c: 90.7 pred16x16_top_dc_10_neon: 71.5 pred16x16_vertical_10_c: 64.7 pred16x16_vertical_10_neon: 61.7 When posting benchmark numbers, it's nice if you'd mention what CPU it was benchmarked on, as the numbers sometimes differ quite a bit between various CPUs. Some functions work slower than C and are left commented out. --- libavcodec/aarch64/h264pred_init.c | 12 +++ libavcodec/aarch64/h264pred_neon.S | 117 + 2 files changed, 129 insertions(+) diff --git a/libavcodec/aarch64/h264pred_init.c b/libavcodec/aarch64/h264pred_init.c index fc8989ae0d..9a1f13910d 100644 --- a/libavcodec/aarch64/h264pred_init.c +++ b/libavcodec/aarch64/h264pred_init.c @@ -45,6 +45,11 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride); void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride); void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride); + static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) @@ -78,6 +83,12 @@ static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; } +if (bit_depth == 10) { +h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10; +h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon_10; +h->pred16x16[HOR_PRED8x8] = ff_pred16x16_hor_neon_10; +h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10; +} } av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, @@ -88,3 +99,4 @@ av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, if (have_neon(cpu_flags)) h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc); } + Stray newline added diff --git a/libavcodec/aarch64/h264pred_neon.S b/libavcodec/aarch64/h264pred_neon.S index 213b40b3e7..5ce50323f8 100644 --- a/libavcodec/aarch64/h264pred_neon.S +++ b/libavcodec/aarch64/h264pred_neon.S @@ -359,3 +359,120 @@ function ff_pred8x8_0l0_dc_neon, export=1 dup v1.8b, v1.b[0] b .L_pred8x8_dc_end endfunc + +.macro ldcol.16 rd, rs, rt, n=4, hi=0 +.if \n >= 4 || \hi == 0 +ld1 {\rd\().h}[0], [\rs], \rt +ld1 {\rd\().h}[1], [\rs], \rt +.endif +.if \n >= 4 || \hi == 1 +ld1 {\rd\().h}[2], [\rs], \rt +ld1 {\rd\().h}[3], [\rs], \rt +.endif +.if \n == 8 +ld1 {\rd\().h}[4], [\rs], \rt +ld1 {\rd\().h}[5], [\rs], \rt +ld1 {\rd\().h}[6], [\rs], \rt +ld1 {\rd\().h}[7], [\rs], \rt +.endif +.endm + +// slower than C +/* +function ff_pred16x16_128_dc_neon_10, export=1 +moviv0.8h, #2, lsl #8 // 512, 1 << (bit_depth - 1) + +b .L_pred16x16_dc_10_end +endfunc +*/ + +function ff_pred16x16_top_dc_neon_10, export=1 +sub x2, x0, x1 + +ld1 {v0.8h, v1.8h}, [x2] + +addvh0, v0.8h +addvh1, v1.8h + +add v0.4h, v0.4h, v1.4h + +rshrn v0.4h, v0.4s, #4 +dup v0.8h, v0.h[0] +b .L_pred16x16_dc_10_end +endfunc + +// slower than C +/* +function ff_pred16x16_left_dc_neon_10, export=1 +sub x2, x0, #2 // access to the "left" column +ldcol.16v0, x2, x1, 8 +ldcol.16v1, x2, x1, 8 // load "left" column + +addvh0, v0.8h +addvh1, v1.8h + +add v0.4h, v0.4h, v1.4h + +rshrn v0.4h, v0.4s, #4 +dup v0.8h, v0.h[0] +b .L_pred16x16_dc_10_end +endfunc +*/ + +function ff_pred16x16_dc_neon_10, export=1 +sub x2, x0, x1 // access to the "top" row +sub x3, x0, #2 // access to the "left" column + +ld1 {v0.8h, v1.8h}, [x2] +ldcol.16v2, x3, x1, 8 +ldcol.16v3, x3, x1, 8 // load pixels in "top" row and "left" col + +addvh0, v0.8h +addvh1, v1.8h +addvh2, v2.8h // sum all pixels in the "top" row and "left" col +addvh3, v3.8h // (su
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/aarch64: add pred16x16 10-bit functions
Inlined a few comments for ff_pred16x16_top_dc_neon_10, other are similar. At 2021-04-14 20:35:44, "Martin Storsjö" wrote: >On Tue, 13 Apr 2021, Mikhail Nitenko wrote: > >> Benchmarks: >> pred16x16_dc_10_c: 124.0 >> pred16x16_dc_10_neon: 97.2 >> pred16x16_horizontal_10_c: 71.7 >> pred16x16_horizontal_10_neon: 66.2 >> pred16x16_top_dc_10_c: 90.7 >> pred16x16_top_dc_10_neon: 71.5 >> pred16x16_vertical_10_c: 64.7 >> pred16x16_vertical_10_neon: 61.7 > >When posting benchmark numbers, it's nice if you'd mention what CPU it was >benchmarked on, as the numbers sometimes differ quite a bit between >various CPUs. > >> >> Some functions work slower than C and are left commented out. >> --- >> libavcodec/aarch64/h264pred_init.c | 12 +++ >> libavcodec/aarch64/h264pred_neon.S | 117 + >> 2 files changed, 129 insertions(+) >> >> diff --git a/libavcodec/aarch64/h264pred_init.c >> b/libavcodec/aarch64/h264pred_init.c >> index fc8989ae0d..9a1f13910d 100644 >> --- a/libavcodec/aarch64/h264pred_init.c >> +++ b/libavcodec/aarch64/h264pred_init.c >> @@ -45,6 +45,11 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t >> stride); >> void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride); >> void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride); >> >> +void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride); >> +void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride); >> +void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride); >> +void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride); >> + >> static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, >> const int bit_depth, >> const int chroma_format_idc) >> @@ -78,6 +83,12 @@ static av_cold void h264_pred_init_neon(H264PredContext >> *h, int codec_id, >> codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) >> h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; >> } >> +if (bit_depth == 10) { >> +h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10; >> +h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon_10; >> +h->pred16x16[HOR_PRED8x8] = ff_pred16x16_hor_neon_10; >> +h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10; >> +} >> } >> >> av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, >> @@ -88,3 +99,4 @@ av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, >> int codec_id, >> if (have_neon(cpu_flags)) >> h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc); >> } >> + > >Stray newline added > >> diff --git a/libavcodec/aarch64/h264pred_neon.S >> b/libavcodec/aarch64/h264pred_neon.S >> index 213b40b3e7..5ce50323f8 100644 >> --- a/libavcodec/aarch64/h264pred_neon.S >> +++ b/libavcodec/aarch64/h264pred_neon.S >> @@ -359,3 +359,120 @@ function ff_pred8x8_0l0_dc_neon, export=1 >> dup v1.8b, v1.b[0] >> b .L_pred8x8_dc_end >> endfunc >> + >> +.macro ldcol.16 rd, rs, rt, n=4, hi=0 >> +.if \n >= 4 || \hi == 0 >> +ld1 {\rd\().h}[0], [\rs], \rt >> +ld1 {\rd\().h}[1], [\rs], \rt >> +.endif >> +.if \n >= 4 || \hi == 1 >> +ld1 {\rd\().h}[2], [\rs], \rt >> +ld1 {\rd\().h}[3], [\rs], \rt >> +.endif >> +.if \n == 8 >> +ld1 {\rd\().h}[4], [\rs], \rt >> +ld1 {\rd\().h}[5], [\rs], \rt >> +ld1 {\rd\().h}[6], [\rs], \rt >> +ld1 {\rd\().h}[7], [\rs], \rt >> +.endif >> +.endm >> + >> +// slower than C >> +/* >> +function ff_pred16x16_128_dc_neon_10, export=1 >> +moviv0.8h, #2, lsl #8 // 512, 1 << (bit_depth - 1) >> + >> +b .L_pred16x16_dc_10_end >> +endfunc >> +*/ >> + >> +function ff_pred16x16_top_dc_neon_10, export=1 >> +sub x2, x0, x1 >> + >> +ld1 {v0.8h, v1.8h}, [x2] >> + >> +addvh0, v0.8h >> +addvh1, v1.8h >> + >> +add v0.4h, v0.4h, v1.4h ld1+addv+addv+add ==> latency 5+5+5+2=17, throughput 1+1+1+1/2=3.5 Dynamic range analyze: sum 16 of 10-bits is up to 14-bits New instructions may: ld1+add+addp+addp+addp ==> latency 5+2+2+2+2=13, throughput 1+1/2+1/2+1/2+1/2=3 or ld1+add+addv ==> latency 5+2+5=12, throughput 1+1/2+1=2.5 btw: we may replace LD1 by LDP to get more bandwidth. >> + >> +rshrn v0.4h, v0.4s, #4 >> +dup v0.8h, v0.h[0] >> +b .L_pred16x16_dc_10_end >> +endfunc >> + >> +// slower than C >> +/* >> +function ff_pred16x16_left_dc_neon_10, export=1 >> +sub x2, x0, #2 // access to the "left" column >> +ldcol.16v0, x2, x1, 8 >> +ldcol.16v1, x2, x1, 8 // load "left" column >> + >> +
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/aarch64: add pred16x16 10-bit functions
thank you, i've tried your suggestions and here is what I got (the left column is A53 and the right is A72) current code: pred16x16_top_dc_10_c: 106.093.2 pred16x16_top_dc_10_neon:87.777.5 ld1, add, addv variant: pred16x16_top_dc_10_c: 106.095.5 pred16x16_top_dc_10_neon:87.777.2 ld1, add, addp, addp, addp variant: pred16x16_top_dc_10_c: 106.093.7 pred16x16_top_dc_10_neon:93.781.2 ldp variant: pred16x16_top_dc_10_c: 106.093.7 pred16x16_top_dc_10_neon:87.777.5 so I will change code to use one addv instruction ср, 14 апр. 2021 г. в 16:18, chen : > > Inlined a few comments for ff_pred16x16_top_dc_neon_10, other are similar. > > At 2021-04-14 20:35:44, "Martin Storsjö" wrote: > >On Tue, 13 Apr 2021, Mikhail Nitenko wrote: > > > >> Benchmarks: > >> pred16x16_dc_10_c: 124.0 > >> pred16x16_dc_10_neon: 97.2 > >> pred16x16_horizontal_10_c: 71.7 > >> pred16x16_horizontal_10_neon: 66.2 > >> pred16x16_top_dc_10_c: 90.7 > >> pred16x16_top_dc_10_neon: 71.5 > >> pred16x16_vertical_10_c: 64.7 > >> pred16x16_vertical_10_neon: 61.7 > > > >When posting benchmark numbers, it's nice if you'd mention what CPU it was > >benchmarked on, as the numbers sometimes differ quite a bit between > >various CPUs. > > > >> > >> Some functions work slower than C and are left commented out. > >> --- > >> libavcodec/aarch64/h264pred_init.c | 12 +++ > >> libavcodec/aarch64/h264pred_neon.S | 117 + > >> 2 files changed, 129 insertions(+) > >> > >> diff --git a/libavcodec/aarch64/h264pred_init.c > >> b/libavcodec/aarch64/h264pred_init.c > >> index fc8989ae0d..9a1f13910d 100644 > >> --- a/libavcodec/aarch64/h264pred_init.c > >> +++ b/libavcodec/aarch64/h264pred_init.c > >> @@ -45,6 +45,11 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t > >> stride); > >> void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride); > >> void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride); > >> > >> +void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride); > >> +void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride); > >> +void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride); > >> +void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride); > >> + > >> static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, > >> const int bit_depth, > >> const int chroma_format_idc) > >> @@ -78,6 +83,12 @@ static av_cold void h264_pred_init_neon(H264PredContext > >> *h, int codec_id, > >> codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) > >> h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; > >> } > >> +if (bit_depth == 10) { > >> +h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10; > >> +h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon_10; > >> +h->pred16x16[HOR_PRED8x8] = ff_pred16x16_hor_neon_10; > >> +h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10; > >> +} > >> } > >> > >> av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, > >> @@ -88,3 +99,4 @@ av_cold void ff_h264_pred_init_aarch64(H264PredContext > >> *h, int codec_id, > >> if (have_neon(cpu_flags)) > >> h264_pred_init_neon(h, codec_id, bit_depth, chroma_format_idc); > >> } > >> + > > > >Stray newline added > > > >> diff --git a/libavcodec/aarch64/h264pred_neon.S > >> b/libavcodec/aarch64/h264pred_neon.S > >> index 213b40b3e7..5ce50323f8 100644 > >> --- a/libavcodec/aarch64/h264pred_neon.S > >> +++ b/libavcodec/aarch64/h264pred_neon.S > >> @@ -359,3 +359,120 @@ function ff_pred8x8_0l0_dc_neon, export=1 > >> dup v1.8b, v1.b[0] > >> b .L_pred8x8_dc_end > >> endfunc > >> + > >> +.macro ldcol.16 rd, rs, rt, n=4, hi=0 > >> +.if \n >= 4 || \hi == 0 > >> +ld1 {\rd\().h}[0], [\rs], \rt > >> +ld1 {\rd\().h}[1], [\rs], \rt > >> +.endif > >> +.if \n >= 4 || \hi == 1 > >> +ld1 {\rd\().h}[2], [\rs], \rt > >> +ld1 {\rd\().h}[3], [\rs], \rt > >> +.endif > >> +.if \n == 8 > >> +ld1 {\rd\().h}[4], [\rs], \rt > >> +ld1 {\rd\().h}[5], [\rs], \rt > >> +ld1 {\rd\().h}[6], [\rs], \rt > >> +ld1 {\rd\().h}[7], [\rs], \rt > >> +.endif > >> +.endm > >> + > >> +// slower than C > >> +/* > >> +function ff_pred16x16_128_dc_neon_10, export=1 > >> +moviv0.8h, #2, lsl #8 // 512, 1 << (bit_depth - 1) > >> + > >> +b .L_pred16x16_dc_10_end > >> +endfunc > >> +*/ > >> + > >> +function ff_pred16x16_top_dc_neon_10, export=1 > >> +sub x2, x0, x1 > >> + > >> +ld1 {v0.8h, v1.8h}, [x2] > >> + > >> +addvh0, v0.8h >
[FFmpeg-devel] [PATCH 1/2] Include attributes.h directly
Some files currently rely on libavutil/cpu.h to include it for them; yet said file won't use include it any more after the currently deprecated functions are removed, so include attributes.h directly. Signed-off-by: Andreas Rheinhardt --- libavcodec/aarch64/aacpsdsp_init_aarch64.c | 1 + libavcodec/aarch64/opusdsp_init.c | 1 + libavcodec/arm/flacdsp_init_arm.c | 1 + libavcodec/arm/mpegvideo_arm.c | 1 + libavcodec/arm/mpegvideoencdsp_init_arm.c | 1 + libavcodec/arm/sbcdsp_init_arm.c| 1 + libavcodec/mips/aacdec_mips.c | 1 + libavcodec/mips/cabac.h | 1 + libavcodec/mips/fft_mips.c | 1 + libavcodec/mips/fmtconvert_mips.c | 1 + libavcodec/mips/h263dsp_init_mips.c | 1 + libavcodec/mips/h264chroma_init_mips.c | 1 + libavcodec/mips/h264dsp_init_mips.c | 1 + libavcodec/mips/h264pred_init_mips.c| 1 + libavcodec/mips/h264qpel_init_mips.c| 1 + libavcodec/mips/idctdsp_init_mips.c | 1 + libavcodec/mips/lsp_mips.h | 1 + libavcodec/mips/me_cmp_init_mips.c | 1 + libavcodec/mips/mpegvideo_init_mips.c | 1 + libavcodec/mips/mpegvideoencdsp_init_mips.c | 1 + libavcodec/mips/vc1dsp_mmi.c| 2 +- libavcodec/mips/vp8dsp_mmi.c| 1 + libavcodec/mips/vp9dsp_init_mips.c | 1 + libavcodec/mips/xvididct_init_mips.c| 1 + libavcodec/neon/mpegvideo.c | 1 + libavcodec/ppc/fft_init.c | 1 + libavcodec/ppc/mpegvideodsp.c | 1 + libavcodec/ppc/vp8dsp_altivec.c | 1 + libavcodec/x86/aacencdsp_init.c | 1 + libavcodec/x86/celt_pvq_init.c | 1 + libavcodec/x86/fdct.c | 1 + libavcodec/x86/flacdsp_init.c | 1 + libavcodec/x86/mdct15_init.c| 1 + libavcodec/x86/opusdsp_init.c | 1 + libavcodec/x86/sbcdsp_init.c| 1 + libavcodec/x86/snowdsp.c| 1 + libavcodec/x86/takdsp_init.c| 1 + libavcodec/x86/ttadsp_init.c| 1 + libavcodec/x86/ttaencdsp_init.c | 1 + libavcodec/x86/v210-init.c | 1 + libavcodec/x86/v210enc_init.c | 1 + libavcodec/x86/vc1dsp_mmx.c | 1 + libavcodec/x86/vp56_arith.h | 2 ++ libavcodec/x86/vp9dsp_init.h| 1 + libavfilter/aarch64/vf_nlmeans_init.c | 1 + libavutil/mips/libm_mips.h | 2 ++ libavutil/x86/lls_init.c| 1 + libswresample/aarch64/resample_init.c | 1 + libswresample/arm/resample_init.c | 1 + libswresample/x86/audio_convert_init.c | 1 + libswresample/x86/rematrix_init.c | 1 + libswresample/x86/resample_init.c | 1 + libswscale/aarch64/swscale.c| 1 + libswscale/arm/swscale.c| 1 + libswscale/ppc/swscale_ppc_template.c | 1 + libswscale/x86/hscale_fast_bilinear_simd.c | 1 + 56 files changed, 58 insertions(+), 1 deletion(-) diff --git a/libavcodec/aarch64/aacpsdsp_init_aarch64.c b/libavcodec/aarch64/aacpsdsp_init_aarch64.c index 5e7e19bba4..cc9e4d79bd 100644 --- a/libavcodec/aarch64/aacpsdsp_init_aarch64.c +++ b/libavcodec/aarch64/aacpsdsp_init_aarch64.c @@ -18,6 +18,7 @@ #include "config.h" +#include "libavutil/attributes.h" #include "libavutil/aarch64/cpu.h" #include "libavcodec/aacpsdsp.h" diff --git a/libavcodec/aarch64/opusdsp_init.c b/libavcodec/aarch64/opusdsp_init.c index cc6a1b672d..bb6d71b66b 100644 --- a/libavcodec/aarch64/opusdsp_init.c +++ b/libavcodec/aarch64/opusdsp_init.c @@ -18,6 +18,7 @@ #include "config.h" +#include "libavutil/attributes.h" #include "libavutil/aarch64/cpu.h" #include "libavcodec/opusdsp.h" diff --git a/libavcodec/arm/flacdsp_init_arm.c b/libavcodec/arm/flacdsp_init_arm.c index 564e3dc79b..c4a6e3a535 100644 --- a/libavcodec/arm/flacdsp_init_arm.c +++ b/libavcodec/arm/flacdsp_init_arm.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavcodec/flacdsp.h" #include "config.h" diff --git a/libavcodec/arm/mpegvideo_arm.c b/libavcodec/arm/mpegvideo_arm.c index 918be16d03..008ef18eea 100644 --- a/libavcodec/arm/mpegvideo_arm.c +++ b/libavcodec/arm/mpegvideo_arm.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/internal.h" #include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" diff --git a/libavcodec/arm/mpegvideoencdsp_init_arm.c b/libavcodec/arm/mpegvideoencdsp_init_arm.c index 4bfe835684..31d1474416 100644 --- a/libavcodec/arm/mpegvideoencdsp_init_arm.c +++ b/libavcodec/arm/mpegvideoencdsp_init_arm.c @@ -18,6 +18,7 @@ #include +#include "libavutil/att
[FFmpeg-devel] [PATCH 2/2] avutil/cpu: Schedule deprecated functions for removal
av_set_cpu_flags_mask() has been deprecated in the commit which merged it: 6df42f98746be06c883ce683563e07c9a2af983f; av_parse_cpu_flags() has been deprecated in 4b529edff8934c258af95e5acc51f84deea66262. Signed-off-by: Andreas Rheinhardt --- libavutil/cpu.c | 3 ++- libavutil/cpu.h | 3 +++ libavutil/version.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 8e3576a1f3..bdac454421 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -102,6 +102,7 @@ int av_get_cpu_flags(void) return flags; } +#if FF_API_CPU_FLAGS void av_set_cpu_flags_mask(int mask) { atomic_store_explicit(&cpu_flags, get_cpu_flags() & mask, @@ -192,7 +193,7 @@ int av_parse_cpu_flags(const char *s) return flags & INT_MAX; } - +#endif int av_parse_cpu_caps(unsigned *flags, const char *s) { static const AVOption cpuflags_opts[] = { diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 83099dd969..18dfa492ef 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -24,6 +24,7 @@ #include #include "attributes.h" +#include "version.h" #define AV_CPU_FLAG_FORCE0x8000 /* force usage of selected flags (OR) */ @@ -88,6 +89,7 @@ int av_get_cpu_flags(void); */ void av_force_cpu_flags(int flags); +#if FF_API_CPU_FLAGS /** * Set a mask on flags returned by av_get_cpu_flags(). * This function is mainly useful for testing. @@ -106,6 +108,7 @@ attribute_deprecated void av_set_cpu_flags_mask(int mask); */ attribute_deprecated int av_parse_cpu_flags(const char *s); +#endif /** * Parse CPU caps from a string and update the given AV_CPU_* flags based on that. diff --git a/libavutil/version.h b/libavutil/version.h index e88e1ad08d..4e5bf45cf8 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -135,6 +135,9 @@ #ifndef FF_API_BUFFER_SIZE_T #define FF_API_BUFFER_SIZE_T(LIBAVUTIL_VERSION_MAJOR < 57) #endif +#ifndef FF_API_CPU_FLAGS +#define FF_API_CPU_FLAGS(LIBAVUTIL_VERSION_MAJOR < 57) +#endif #ifndef FF_API_D2STR #define FF_API_D2STR(LIBAVUTIL_VERSION_MAJOR < 58) #endif -- 2.27.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/5] avformat/aaxdec: Check avio_seek() in inner loop for failure
On Tue, Apr 13, 2021 at 01:09:52PM -0300, James Almer wrote: > On 4/13/2021 12:45 PM, Michael Niedermayer wrote: > > Fixes: Timeout > > Fixes: > > 32450/clusterfuzz-testcase-minimized-ffmpeg_dem_AAX_fuzzer-4875522262827008 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/aaxdec.c | 5 - > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/aaxdec.c b/libavformat/aaxdec.c > > index c6d2d1c8d1..ff9768efac 100644 > > --- a/libavformat/aaxdec.c > > +++ b/libavformat/aaxdec.c > > @@ -249,7 +249,10 @@ static int aax_read_header(AVFormatContext *s) > > goto fail; > > } > > -avio_seek(pb, data_offset, SEEK_SET); > > +ret = avio_seek(pb, data_offset, SEEK_SET); > > There's another unchecked seek, and for both you should use an int64_t > variable to store the return value, otherwise values > INT_MAX could be > misinterpreted as errors. There are 3 other unchecked seeks in the function, and 2 outside. do you want me to add checks to all ? we tend not to check avio_seek() unless its needed i chanegd the code locally to use 64bit Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates 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] libsvtav1: Add logical_processors option
On Sat, Apr 10, 2021 at 3:07 PM Christopher Degawa wrote: > ping on this patch again > pong again ___ 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/utils: Combine identical statements
This would only make a difference in case the first attempt to initialize the encoder failed and the second succeeded. The only reason I can think of for this to happen is that the options (in particular the codec whitelist) are not used for the second try and that obviously implies that we should not even try a second time to open the decoder. Signed-off-by: Andreas Rheinhardt --- libavformat/utils.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index d9971d7fd3..d4ec3d0190 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3747,16 +3747,10 @@ FF_ENABLE_DEPRECATION_WARNINGS if (ic->codec_whitelist) av_dict_set(options ? &options[i] : &thread_opt, "codec_whitelist", ic->codec_whitelist, 0); -/* Ensure that subtitle_header is properly set. */ -if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE -&& codec && !avctx->codec) { -if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0) -av_log(ic, AV_LOG_WARNING, - "Failed to open codec in %s\n",__FUNCTION__); -} - // Try to just open decoders, in case this is enough to get parameters. -if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0) { +// Also ensure that subtitle_header is properly set. +if (!has_codec_parameters(st, NULL) && st->internal->request_probe <= 0 || +st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (codec && !avctx->codec) if (avcodec_open2(avctx, codec, options ? &options[i] : &thread_opt) < 0) av_log(ic, AV_LOG_WARNING, -- 2.27.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] avcodec/jpeglsdec: Don't allocate+free JPEGLSState for every frame
Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsdec.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 69980eaa49..92df81600b 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -45,6 +45,11 @@ */ //#define JLS_BROKEN +typedef struct JpegLSDecodeContext { +MJpegDecodeContext mjpeg; +JLSState state; +} JpegLSDecodeContext; + /** * Decode LSE block with initialization parameters */ @@ -350,7 +355,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, { int i, t = 0; uint8_t *zero, *last, *cur; -JLSState *state; +JLSState *const state = &((JpegLSDecodeContext*)s)->state; int off = 0, stride = 1, width, shift, ret = 0; int decoded_height = 0; @@ -360,12 +365,8 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, last = zero; cur = s->picture_ptr->data[0]; -state = av_mallocz(sizeof(JLSState)); -if (!state) { -av_free(zero); -return AVERROR(ENOMEM); -} /* initialize JPEG-LS state from JPEG parameters */ +memset(state, 0, sizeof(*state)); state->near = near; state->bpp= (s->bits < 2) ? 2 : s->bits; state->maxval = s->maxval; @@ -537,7 +538,6 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, } end: -av_free(state); av_free(zero); return ret; @@ -548,7 +548,7 @@ AVCodec ff_jpegls_decoder = { .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_JPEGLS, -.priv_data_size = sizeof(MJpegDecodeContext), +.priv_data_size = sizeof(JpegLSDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, .receive_frame = ff_mjpeg_receive_frame, -- 2.27.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] avformat/matroskaenc: Remove unnecessary function calls
ffio_fill() is used when initially writing unknown length elements; yet it can happen that the amount of bytes written by it is zero in which case it is of course unnecessary to ever call it. Whether it is possible to know this during compiletime depends upon how aggressively the compiler inlines function calls (i.e. if it inlines calls to start_ebml_master() where the upper bound for the size of the element implies that the size will be written on one byte) and this depends upon optimization settings. It is not the aim of this patch to inline all calls where it is known that ffio_fill() will be unnecessary, but merely to make compilers that inline such calls aware of the fact that writing zero bytes with ffio_fill() is unnecessary. To this end av_builtin_constant_p() is used to check whether the size is a compiletime constant. For GCC 10 this made a difference at -O3 only: The size of .text decreased from 0x747F (with 29 calls to ffio_fill(), eight of which use size zero) to 0x7337 (with 21 calls to ffio_fill(), zero of which use size zero). For Clang 11 it made a difference at -O2 and -O3: At -O2, the size of .text decreased from 0x879C to 0x871C (with eight calls to ffio_fill() eliminated); at -O3 the size of .text decreased from 0xAF2F to 0xAEBF. Once again, eight calls to ffio_fill() with size zero have been eliminated. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 3649ac25a2..0141fb0b8d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -195,6 +195,8 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) { av_assert0(bytes <= 8); avio_w8(pb, 0x1ff >> bytes); +if (av_builtin_constant_p(bytes) && bytes == 1) +return; ffio_fill(pb, 0xff, bytes - 1); } -- 2.27.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/5] avcodec: Remove redundant freeing of extradata of encoders
AVCodecContext.extradata is freed generically by libavformat for encoders, so it is unnecessary for an encoder to do it on its own. Signed-off-by: Andreas Rheinhardt --- libavcodec/flacenc.c | 2 -- libavcodec/huffyuvenc.c| 1 - libavcodec/lclenc.c| 1 - libavcodec/libfdk-aacenc.c | 1 - libavcodec/libkvazaar.c| 3 --- libavcodec/libopusenc.c| 2 -- libavcodec/libspeexenc.c | 1 - libavcodec/libtheoraenc.c | 1 - libavcodec/libvorbisenc.c | 1 - libavcodec/libx264.c | 1 - libavcodec/libxavs.c | 1 - libavcodec/libxvid.c | 1 - libavcodec/mpegvideo_enc.c | 2 -- libavcodec/opusenc.c | 1 - libavcodec/vorbisenc.c | 2 -- 15 files changed, 21 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 05a85d830f..32b2465279 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1455,8 +1455,6 @@ static av_cold int flac_encode_close(AVCodecContext *avctx) av_freep(&s->md5_buffer); ff_lpc_end(&s->lpc_ctx); } -av_freep(&avctx->extradata); -avctx->extradata_size = 0; return 0; } diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 2882433db5..7e5c8f7fac 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1038,7 +1038,6 @@ static av_cold int encode_end(AVCodecContext *avctx) ff_huffyuv_common_end(s); -av_freep(&avctx->extradata); av_freep(&avctx->stats_out); return 0; diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c index 4fe52b40da..fbf65e5428 100644 --- a/libavcodec/lclenc.c +++ b/libavcodec/lclenc.c @@ -161,7 +161,6 @@ static av_cold int encode_end(AVCodecContext *avctx) { LclEncContext *c = avctx->priv_data; -av_freep(&avctx->extradata); deflateEnd(&c->zstream); return 0; diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index 6494c11ddc..692508eaa3 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -112,7 +112,6 @@ static int aac_encode_close(AVCodecContext *avctx) if (s->handle) aacEncClose(&s->handle); -av_freep(&avctx->extradata); ff_af_queue_close(&s->afq); return 0; diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index 4432649853..286d97a318 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -156,9 +156,6 @@ static av_cold int libkvazaar_close(AVCodecContext *avctx) ctx->api->config_destroy(ctx->config); } -if (avctx->extradata) -av_freep(&avctx->extradata); - return 0; } diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index 70d17f802b..6c7ec4db3c 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -432,7 +432,6 @@ static av_cold int libopus_encode_init(AVCodecContext *avctx) fail: opus_multistream_encoder_destroy(enc); -av_freep(&avctx->extradata); return ret; } @@ -538,7 +537,6 @@ static av_cold int libopus_encode_close(AVCodecContext *avctx) ff_af_queue_close(&opus->afq); av_freep(&opus->samples); -av_freep(&avctx->extradata); return 0; } diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 6a37dbc76c..9ea35a763f 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -318,7 +318,6 @@ static av_cold int encode_close(AVCodecContext *avctx) speex_encoder_destroy(s->enc_state); ff_af_queue_close(&s->afq); -av_freep(&avctx->extradata); return 0; } diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 16966ed433..8a7b80e174 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -365,7 +365,6 @@ static av_cold int encode_close(AVCodecContext* avc_context) th_encode_free(h->t_state); av_freep(&h->stats); av_freep(&avc_context->stats_out); -av_freep(&avc_context->extradata); avc_context->extradata_size = 0; return 0; diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index bf94764954..9d36457328 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -196,7 +196,6 @@ static av_cold int libvorbis_encode_close(AVCodecContext *avctx) av_fifo_freep(&s->pkt_fifo); ff_af_queue_close(&s->afq); -av_freep(&avctx->extradata); av_vorbis_parse_free(&s->vp); diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 4ddc4973a4..4535d23848 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -508,7 +508,6 @@ static av_cold int X264_close(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; -av_freep(&avctx->extradata); av_freep(&x4->sei); av_freep(&x4->reordered_opaque); diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index a83b93b836..62f7e9dfa7 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -228,7 +228,6 @@ static av_cold int XAVS_close(AVCodecContext *avctx) { XavsContext *x4 = avctx->priv_data; -av_freep(&avctx->extr
[FFmpeg-devel] [PATCH 2/5] avcodec/flacenc: Remove always-true check
Signed-off-by: Andreas Rheinhardt --- libavcodec/flacenc.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 32b2465279..f1e3e1989b 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1449,12 +1449,11 @@ FF_ENABLE_DEPRECATION_WARNINGS static av_cold int flac_encode_close(AVCodecContext *avctx) { -if (avctx->priv_data) { -FlacEncodeContext *s = avctx->priv_data; -av_freep(&s->md5ctx); -av_freep(&s->md5_buffer); -ff_lpc_end(&s->lpc_ctx); -} +FlacEncodeContext *s = avctx->priv_data; + +av_freep(&s->md5ctx); +av_freep(&s->md5_buffer); +ff_lpc_end(&s->lpc_ctx); return 0; } -- 2.27.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 3/5] avcodec/libvorbisenc: Fix memleak upon error
The vorbis_comment struct used to during codec initialization would leak in case an error happened after its initialization (e.g. if the allocation of extradata failed). This has been fixed. Given that said struct is only used when writing the header, it has also been moved from the context. Signed-off-by: Andreas Rheinhardt --- libavcodec/libvorbisenc.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index 9d36457328..b556280a95 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -47,7 +47,6 @@ typedef struct LibvorbisEncContext { AVFifoBuffer *pkt_fifo; /**< output packet buffer */ int eof;/**< end-of-file flag */ int dsp_initialized;/**< vd has been initialized*/ -vorbis_comment vc; /**< VorbisComment info */ double iblock; /**< impulse block bias option */ AVVorbisParseContext *vp; /**< parse context to get durations */ AudioFrameQueue afq;/**< frame queue for timestamps */ @@ -206,6 +205,7 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) { LibvorbisEncContext *s = avctx->priv_data; ogg_packet header, header_comm, header_code; +vorbis_comment vc; uint8_t *p; unsigned int offset; int ret; @@ -227,12 +227,14 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) goto error; } -vorbis_comment_init(&s->vc); +vorbis_comment_init(&vc); if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) -vorbis_comment_add_tag(&s->vc, "encoder", LIBAVCODEC_IDENT); +vorbis_comment_add_tag(&vc, "encoder", LIBAVCODEC_IDENT); -if ((ret = vorbis_analysis_headerout(&s->vd, &s->vc, &header, &header_comm, - &header_code))) { +ret = vorbis_analysis_headerout(&s->vd, &vc, &header, &header_comm, +&header_code); +vorbis_comment_clear(&vc); +if (ret) { ret = vorbis_error_to_averror(ret); goto error; } @@ -264,8 +266,6 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) return ret; } -vorbis_comment_clear(&s->vc); - avctx->frame_size = LIBVORBIS_FRAME_SIZE; ff_af_queue_init(avctx, &s->afq); -- 2.27.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 4/5] avcodec/libvorbisenc: Actually set error upon goto error
Signed-off-by: Andreas Rheinhardt --- libavcodec/libvorbisenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index b556280a95..061a4e9da7 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -263,7 +263,8 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) s->vp = av_vorbis_parse_init(avctx->extradata, avctx->extradata_size); if (!s->vp) { av_log(avctx, AV_LOG_ERROR, "invalid extradata\n"); -return ret; +ret = AVERROR_UNKNOWN; +goto error; } avctx->frame_size = LIBVORBIS_FRAME_SIZE; -- 2.27.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 5/5] avcodec/vorbis_parser: Improve returned error codes
av_vorbis_parse_init() doesn't return an error code which is a slight problem in libvorbisenc.c. Fix this by making the internal initialization function behind av_vorbis_parse_init() available. This also avoids allocations and frees (for users inside of this inside libavcodec). Signed-off-by: Andreas Rheinhardt --- libavcodec/libvorbisenc.c | 12 +--- libavcodec/vorbis_parser.c | 29 + libavcodec/vorbis_parser_internal.h | 3 +++ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index 061a4e9da7..b111379e10 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -28,6 +28,7 @@ #include "internal.h" #include "vorbis.h" #include "vorbis_parser.h" +#include "vorbis_parser_internal.h" /* Number of samples the user should send in each call. @@ -48,7 +49,7 @@ typedef struct LibvorbisEncContext { int eof;/**< end-of-file flag */ int dsp_initialized;/**< vd has been initialized*/ double iblock; /**< impulse block bias option */ -AVVorbisParseContext *vp; /**< parse context to get durations */ +AVVorbisParseContext vp;/**< parse context to get durations */ AudioFrameQueue afq;/**< frame queue for timestamps */ } LibvorbisEncContext; @@ -196,8 +197,6 @@ static av_cold int libvorbis_encode_close(AVCodecContext *avctx) av_fifo_freep(&s->pkt_fifo); ff_af_queue_close(&s->afq); -av_vorbis_parse_free(&s->vp); - return 0; } @@ -260,10 +259,9 @@ static av_cold int libvorbis_encode_init(AVCodecContext *avctx) offset += header_code.bytes; av_assert0(offset == avctx->extradata_size); -s->vp = av_vorbis_parse_init(avctx->extradata, avctx->extradata_size); -if (!s->vp) { +ret = ff_vorbis_parse_init(&s->vp, avctx->extradata, avctx->extradata_size); +if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "invalid extradata\n"); -ret = AVERROR_UNKNOWN; goto error; } @@ -355,7 +353,7 @@ static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, avpkt->pts = ff_samples_to_time_base(avctx, op.granulepos); -duration = av_vorbis_parse_frame(s->vp, avpkt->data, avpkt->size); +duration = av_vorbis_parse_frame(&s->vp, avpkt->data, avpkt->size); if (duration > 0) { /* we do not know encoder delay until we get the first packet from * libvorbis, so we have to update the AudioFrameQueue counts */ diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c index 0b2c97cde5..0d87102adc 100644 --- a/libavcodec/vorbis_parser.c +++ b/libavcodec/vorbis_parser.c @@ -181,8 +181,8 @@ bad_header: return ret; } -static int vorbis_parse_init(AVVorbisParseContext *s, - const uint8_t *extradata, int extradata_size) +int ff_vorbis_parse_init(AVVorbisParseContext *s, + const uint8_t *extradata, int extradata_size) { const uint8_t *header_start[3]; int header_len[3]; @@ -287,7 +287,7 @@ AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, if (!s) return NULL; -ret = vorbis_parse_init(s, extradata, extradata_size); +ret = ff_vorbis_parse_init(s, extradata, extradata_size); if (ret < 0) { av_vorbis_parse_free(&s); return NULL; @@ -298,24 +298,20 @@ AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, #if CONFIG_VORBIS_PARSER -typedef struct VorbisParseContext { -AVVorbisParseContext *vp; -} VorbisParseContext; - static int vorbis_parse(AVCodecParserContext *s1, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { -VorbisParseContext *s = s1->priv_data; +AVVorbisParseContext *s = s1->priv_data; int duration; -if (!s->vp && avctx->extradata && avctx->extradata_size) { -s->vp = av_vorbis_parse_init(avctx->extradata, avctx->extradata_size); +if (!s->valid_extradata && avctx->extradata && avctx->extradata_size) { +ff_vorbis_parse_init(s, avctx->extradata, avctx->extradata_size); } -if (!s->vp) +if (!s->valid_extradata) goto end; -if ((duration = av_vorbis_parse_frame(s->vp, buf, buf_size)) >= 0) +if ((duration = av_vorbis_parse_frame(s, buf, buf_size)) >= 0) s1->duration = duration; end: @@ -326,16 +322,9 @@ end: return buf_size; } -static void vorbis_parser_close(AVCodecParserContext *ctx) -{ -VorbisParseContext *s = ctx->priv_data; -av_vorbis_parse_free(&s->vp); -} - AVCodecParser ff_vorbis_parser = { .codec_ids = { AV_CODEC_ID_VORBIS }, -.priv_data_size = sizeof(VorbisParseContext), +.priv_data_size = sizeof(AVVorbisParseContext), .p
[FFmpeg-devel] [PATCH] avformat/mpegts: set correct extradata size for Opus streams
map_type 0 is always 19 bytes, whereas map_type 1 and 255 are 21 + channel count bytes. Should fix ticket #9190. Signed-off-by: James Almer --- libavformat/mpegts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 6e0d9d7496..5343a14e38 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2030,6 +2030,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type st->codecpar->extradata[19] = opus_stream_cnt[channel_config_code]; st->codecpar->extradata[20] = opus_coupled_stream_cnt[channel_config_code]; memcpy(&st->codecpar->extradata[21], opus_channel_map[channels - 1], channels); +st->codecpar->extradata_size = 19 + (st->codecpar->extradata[18] ? 2 + channels : 0); } else { avpriv_request_sample(fc, "Opus in MPEG-TS - channel_config_code > 0x8"); } -- 2.31.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] avformat/rawenc: remove singlejpeg muxer
On 2021-04-12 21:27, Gyan Doshi wrote: Ping. Plan to push in 24h. On 2021-04-10 20:00, Gyan Doshi wrote: It was added in 51ac1f616f due to ticket #4218, in order to show a single image via ffserver. With ffserver long gone, it serves no purpose. --- libavformat/Makefile | 1 - libavformat/allformats.c | 1 - libavformat/rawenc.c | 13 - 3 files changed, 15 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 0f340f74a0..bc1ddfa81c 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -506,7 +506,6 @@ OBJS-$(CONFIG_SGA_DEMUXER) += sga.o OBJS-$(CONFIG_SHORTEN_DEMUXER) += shortendec.o rawdec.o OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o OBJS-$(CONFIG_SIMBIOSIS_IMX_DEMUXER) += imx.o -OBJS-$(CONFIG_SINGLEJPEG_MUXER) += rawenc.o OBJS-$(CONFIG_SLN_DEMUXER) += pcmdec.o pcm.o OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o OBJS-$(CONFIG_SMJPEG_DEMUXER) += smjpegdec.o smjpeg.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index a38fd1f583..fa093c7ac2 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -405,7 +405,6 @@ extern AVInputFormat ff_sga_demuxer; extern AVInputFormat ff_shorten_demuxer; extern AVInputFormat ff_siff_demuxer; extern AVInputFormat ff_simbiosis_imx_demuxer; -extern AVOutputFormat ff_singlejpeg_muxer; extern AVInputFormat ff_sln_demuxer; extern AVInputFormat ff_smacker_demuxer; extern AVInputFormat ff_smjpeg_demuxer; diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index caec297f4a..a43a7a6278 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -399,19 +399,6 @@ AVOutputFormat ff_mjpeg_muxer = { }; #endif -#if CONFIG_SINGLEJPEG_MUXER -AVOutputFormat ff_singlejpeg_muxer = { - .name = "singlejpeg", - .long_name = NULL_IF_CONFIG_SMALL("JPEG single image"), - .mime_type = "image/jpeg", - .audio_codec = AV_CODEC_ID_NONE, - .video_codec = AV_CODEC_ID_MJPEG, - .init = force_one_stream, - .write_packet = ff_raw_write_packet, - .flags = AVFMT_NOTIMESTAMPS, -}; -#endif - #if CONFIG_MLP_MUXER AVOutputFormat ff_mlp_muxer = { .name = "mlp", ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/movenc: fix writing dOps atoms
Don't blindly copy all bytes in extradata past ChannelMappingFamily. Instead check if ChannelMappingFamily is not 0 and then only write the correct amount of bytes from ChannelMappingTable, as defined in the spec[1]. Should fix ticket #9190. [1] https://opus-codec.org/docs/opus_in_isobmff.html#4.3.2 Signed-off-by: James Almer --- Compared to "avformat/mpegts: set correct extradata size for Opus streams", which only ensured the mpets demuxer would output something the mov muxer would not mishandle, this is a proper fix for the ticket, making the muxer spec compliant. libavformat/movenc.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0b620a802d..8e6ed817d8 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -797,6 +797,7 @@ static int mov_write_dfla_tag(AVIOContext *pb, MOVTrack *track) static int mov_write_dops_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); +int channels, channel_map; avio_wb32(pb, 0); ffio_wfourcc(pb, "dOps"); avio_w8(pb, 0); /* Version */ @@ -807,12 +808,22 @@ static int mov_write_dops_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra /* extradata contains an Ogg OpusHead, other than byte-ordering and OpusHead's preceeding magic/version, OpusSpecificBox is currently identical. */ -avio_w8(pb, AV_RB8(track->par->extradata + 9)); /* OuputChannelCount */ +channels = AV_RB8(track->par->extradata + 9); +channel_map = AV_RB8(track->par->extradata + 18); + +avio_w8(pb, channels); /* OuputChannelCount */ avio_wb16(pb, AV_RL16(track->par->extradata + 10)); /* PreSkip */ avio_wb32(pb, AV_RL32(track->par->extradata + 12)); /* InputSampleRate */ avio_wb16(pb, AV_RL16(track->par->extradata + 16)); /* OutputGain */ +avio_w8(pb, channel_map); /* ChannelMappingFamily */ /* Write the rest of the header out without byte-swapping. */ -avio_write(pb, track->par->extradata + 18, track->par->extradata_size - 18); +if (channel_map) { +if (track->par->extradata_size < 21 + channels) { +av_log(s, AV_LOG_ERROR, "invalid extradata size\n"); +return AVERROR_INVALIDDATA; +} +avio_write(pb, track->par->extradata + 19, 2 + channels); /* ChannelMappingTable */ +} return update_size(pb, pos); } -- 2.31.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".