From 7e697e932b633426c4a449ab41c3caf80aff1072 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Mon, 25 Jul 2022 23:06:22 +0200 Subject: [PATCH 001/590] Initial commit --- libavformat/imf.h | 2 + libavformat/imf_cpl.c | 102 ++++++++++++++++++++++++++++++++++++++++ libavformat/imfdec.c | 12 +++++ libavformat/tests/imf.c | 7 +++ 4 files changed, 123 insertions(+) diff --git a/libavformat/imf.h b/libavformat/imf.h index 4271cd9582..70ed007312 100644 --- a/libavformat/imf.h +++ b/libavformat/imf.h @@ -59,6 +59,7 @@ #include "libavformat/avio.h" #include "libavutil/rational.h" #include "libavutil/uuid.h" +#include "libavutil/timecode.h" #include /** @@ -130,6 +131,7 @@ typedef struct FFIMFCPL { AVUUID id_uuid; /**< CompositionPlaylist/Id element */ xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ + AVTimecode *tc; /**< CompositionPlaylist/CompositionTimecode element */ FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ uint32_t main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 4acc20feee..c30ab512b2 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -116,6 +116,25 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) return ret; } +static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value) +{ + xmlChar *element_text = NULL; + int ret = 0; + + element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + + if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") == 0) + *value = 1; + else if (xmlStrcmp(element_text, "false") == 0 || xmlStrcmp(element_text, "0") == 0) + *value = 0; + else + ret = 1; + + xmlFree(element_text); + + return ret; +} + static void imf_base_virtual_track_init(FFIMFBaseVirtualTrack *track) { memset(track->id_uuid, 0, sizeof(track->id_uuid)); @@ -179,6 +198,83 @@ static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl) return 0; } +static int digit_to_int(char digit) +{ + if (digit >= '0' && digit <= '9') + return digit - '0'; + return -1; +} + +static int parse_cpl_tc_type(const char *s, int *tc_comps) +{ + int i; + + if (av_strnlen(s, 11) != 11) + return AVERROR(EINVAL); + + for (i = 0; i < 4; i++) { + int hi; + int lo; + + hi = digit_to_int(s[i * 3]); + lo = digit_to_int(s[i * 3 + 1]); + + if (hi == -1 || lo == -1) + return AVERROR(EINVAL); + + tc_comps[i] = (hi << 4) + lo; + } + + return 0; +} + +static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl) +{ + xmlNodePtr tc_element = NULL; + xmlNodePtr element = NULL; + xmlChar *tc_str = NULL; + int df = 0; + int comps[4]; + int ret = 0; + + tc_element = ff_imf_xml_get_child_element_by_name(cpl_element, "CompositionTimecode"); + if (! tc_element) + return 0; + + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeDropFrame"); + if (! element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeDropFrame child element\n"); + return AVERROR_INVALIDDATA; + } + + if (ff_imf_xml_read_boolean(element, &df)) { + av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n"); + return AVERROR_INVALIDDATA; + } + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeStartAddress"); + if (! element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeStartAddress child element\n"); + return AVERROR_INVALIDDATA; + } + + tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + ret = parse_cpl_tc_type(tc_str, comps); + xmlFree(tc_str); + if (ret) + return ret; + cpl->tc = av_malloc(sizeof(AVTimecode)); + if (! cpl->tc) + return AVERROR(ENOMEM); + ret = av_timecode_init_from_components(cpl->tc, cpl->edit_rate, + df ? AV_TIMECODE_FLAG_DROPFRAME : 0, + comps[0], comps[1], comps[2], comps[3], + NULL); + + return ret; +} + static int fill_edit_rate(xmlNodePtr cpl_element, FFIMFCPL *cpl) { xmlNodePtr element = NULL; @@ -682,6 +778,8 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl) goto cleanup; if ((ret = fill_edit_rate(cpl_element, *cpl))) goto cleanup; + if ((ret = fill_timecode(cpl_element, *cpl))) + goto cleanup; if ((ret = fill_virtual_tracks(cpl_element, *cpl))) goto cleanup; @@ -731,6 +829,7 @@ static void imf_cpl_init(FFIMFCPL *cpl) av_uuid_nil(cpl->id_uuid); cpl->content_title_utf8 = NULL; cpl->edit_rate = av_make_q(0, 1); + cpl->tc = NULL; cpl->main_markers_track = NULL; cpl->main_image_2d_track = NULL; cpl->main_audio_track_count = 0; @@ -753,6 +852,9 @@ void ff_imf_cpl_free(FFIMFCPL *cpl) if (!cpl) return; + if (cpl->tc) + av_freep(&cpl->tc); + xmlFree(cpl->content_title_utf8); imf_marker_virtual_track_free(cpl->main_markers_track); diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 5bbe7a53f8..4a382a4f5b 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -622,6 +622,8 @@ static int imf_read_header(AVFormatContext *s) IMFContext *c = s->priv_data; char *asset_map_path; char *tmp_str; + AVDictionaryEntry* tcr; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret = 0; c->interrupt_callback = &s->interrupt_callback; @@ -641,6 +643,16 @@ static int imf_read_header(AVFormatContext *s) if ((ret = ff_imf_parse_cpl(s->pb, &c->cpl)) < 0) return ret; + tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + + if ((! tcr) && c->cpl->tc) { + ret = av_dict_set(&s->metadata, "timecode", + av_timecode_make_string(c->cpl->tc, tc_buf, 0), 0); + if (ret) + return ret; + av_log(s, AV_LOG_INFO, "Setting timecode to IMF CPL timecode %s\n", tc_buf); + } + av_log(s, AV_LOG_DEBUG, "parsed IMF CPL: " AV_PRI_URN_UUID "\n", diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index e65629ccbc..d42295dc29 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -70,6 +70,11 @@ const char *cpl_doc = " urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f" " " "" + "" + "false" + "24" + "02:10:01.23" + "" "24000 1001" "" "" @@ -288,6 +293,7 @@ static int test_cpl_parsing(void) { xmlDocPtr doc; FFIMFCPL *cpl; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret; doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0); @@ -306,6 +312,7 @@ static int test_cpl_parsing(void) printf("%s\n", cpl->content_title_utf8); printf(AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->id_uuid)); printf("%i %i\n", cpl->edit_rate.num, cpl->edit_rate.den); + printf("%s\n", av_timecode_make_string(cpl->tc, tc_buf, 0)); printf("Marker resource count: %" PRIu32 "\n", cpl->main_markers_track->resource_count); for (uint32_t i = 0; i < cpl->main_markers_track->resource_count; i++) { From 311b2acbd3dbf5f565f482b482688cd023c6adbf Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Wed, 27 Jul 2022 08:08:16 +0200 Subject: [PATCH 002/590] Fix TC parsing bug --- libavformat/imf_cpl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index c30ab512b2..939e9149be 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -205,6 +205,14 @@ static int digit_to_int(char digit) return -1; } +/** + * Parses a string that conform to the TimecodeType used in IMF CPL and defined + * in SMPTE ST 2067-3. + * @param[in] s string to parse + * @param[out] tc_comps pointer to an array of 4 integers where the parsed HH, + * MM, SS and FF fields of the timecode are returned. + * @return 0 on success, < 0 AVERROR code on error. + */ static int parse_cpl_tc_type(const char *s, int *tc_comps) { int i; @@ -222,7 +230,7 @@ static int parse_cpl_tc_type(const char *s, int *tc_comps) if (hi == -1 || lo == -1) return AVERROR(EINVAL); - tc_comps[i] = (hi << 4) + lo; + tc_comps[i] = 10 * hi + lo; } return 0; From 3f03816fc28116f39e50ef6f134d6e8fccde1c8a Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Mon, 22 Aug 2022 21:43:17 -0700 Subject: [PATCH 003/590] avformat/imfdec: use CPL start timecode if available --- libavformat/imf.h | 2 + libavformat/imf_cpl.c | 109 ++++++++++++++++++++++++++++++++++++++++++ libavformat/imfdec.c | 11 +++++ 3 files changed, 122 insertions(+) diff --git a/libavformat/imf.h b/libavformat/imf.h index 4271cd9582..70ed007312 100644 --- a/libavformat/imf.h +++ b/libavformat/imf.h @@ -59,6 +59,7 @@ #include "libavformat/avio.h" #include "libavutil/rational.h" #include "libavutil/uuid.h" +#include "libavutil/timecode.h" #include /** @@ -130,6 +131,7 @@ typedef struct FFIMFCPL { AVUUID id_uuid; /**< CompositionPlaylist/Id element */ xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ + AVTimecode *tc; /**< CompositionPlaylist/CompositionTimecode element */ FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ uint32_t main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 4acc20feee..1868d7db45 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -116,6 +116,25 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) return ret; } +static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value) +{ + xmlChar *element_text = NULL; + int ret = 0; + + element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + + if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") == 0) + *value = 1; + else if (xmlStrcmp(element_text, "false") == 0 || xmlStrcmp(element_text, "0") == 0) + *value = 0; + else + ret = 1; + + xmlFree(element_text); + + return ret; +} + static void imf_base_virtual_track_init(FFIMFBaseVirtualTrack *track) { memset(track->id_uuid, 0, sizeof(track->id_uuid)); @@ -179,6 +198,90 @@ static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl) return 0; } +static int digit_to_int(char digit) +{ + if (digit >= '0' && digit <= '9') + return digit - '0'; + return -1; +} + +/** + * Parses a string that conform to the TimecodeType used in IMF CPL and defined + * in SMPTE ST 2067-3. + * @param[in] s string to parse + * @param[out] tc_comps pointer to an array of 4 integers where the parsed HH, + * MM, SS and FF fields of the timecode are returned. + * @return 0 on success, < 0 AVERROR code on error. + */ +static int parse_cpl_tc_type(const char *s, int *tc_comps) +{ + if (av_strnlen(s, 11) != 11) + return AVERROR(EINVAL); + + for (int i = 0; i < 4; i++) { + int hi; + int lo; + + hi = digit_to_int(s[i * 3]); + lo = digit_to_int(s[i * 3 + 1]); + + if (hi == -1 || lo == -1) + return AVERROR(EINVAL); + + tc_comps[i] = 10 * hi + lo; + } + + return 0; +} + +static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl) +{ + xmlNodePtr tc_element = NULL; + xmlNodePtr element = NULL; + xmlChar *tc_str = NULL; + int df = 0; + int comps[4]; + int ret = 0; + + tc_element = ff_imf_xml_get_child_element_by_name(cpl_element, "CompositionTimecode"); + if (!tc_element) + return 0; + + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeDropFrame"); + if (!element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeDropFrame child element\n"); + return AVERROR_INVALIDDATA; + } + + if (ff_imf_xml_read_boolean(element, &df)) { + av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n"); + return AVERROR_INVALIDDATA; + } + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeStartAddress"); + if (!element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeStartAddress child element\n"); + return AVERROR_INVALIDDATA; + } + + tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + ret = parse_cpl_tc_type(tc_str, comps); + xmlFree(tc_str); + if (ret) + return ret; + + cpl->tc = av_malloc(sizeof(AVTimecode)); + if (!cpl->tc) + return AVERROR(ENOMEM); + ret = av_timecode_init_from_components(cpl->tc, cpl->edit_rate, + df ? AV_TIMECODE_FLAG_DROPFRAME : 0, + comps[0], comps[1], comps[2], comps[3], + NULL); + + return ret; +} + static int fill_edit_rate(xmlNodePtr cpl_element, FFIMFCPL *cpl) { xmlNodePtr element = NULL; @@ -682,6 +785,8 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl) goto cleanup; if ((ret = fill_edit_rate(cpl_element, *cpl))) goto cleanup; + if ((ret = fill_timecode(cpl_element, *cpl))) + goto cleanup; if ((ret = fill_virtual_tracks(cpl_element, *cpl))) goto cleanup; @@ -731,6 +836,7 @@ static void imf_cpl_init(FFIMFCPL *cpl) av_uuid_nil(cpl->id_uuid); cpl->content_title_utf8 = NULL; cpl->edit_rate = av_make_q(0, 1); + cpl->tc = NULL; cpl->main_markers_track = NULL; cpl->main_image_2d_track = NULL; cpl->main_audio_track_count = 0; @@ -753,6 +859,9 @@ void ff_imf_cpl_free(FFIMFCPL *cpl) if (!cpl) return; + if (cpl->tc) + av_freep(&cpl->tc); + xmlFree(cpl->content_title_utf8); imf_marker_virtual_track_free(cpl->main_markers_track); diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 5bbe7a53f8..fdf9a4e87c 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -622,6 +622,8 @@ static int imf_read_header(AVFormatContext *s) IMFContext *c = s->priv_data; char *asset_map_path; char *tmp_str; + AVDictionaryEntry* tcr; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret = 0; c->interrupt_callback = &s->interrupt_callback; @@ -641,6 +643,15 @@ static int imf_read_header(AVFormatContext *s) if ((ret = ff_imf_parse_cpl(s->pb, &c->cpl)) < 0) return ret; + tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + if (!tcr && c->cpl->tc) { + ret = av_dict_set(&s->metadata, "timecode", + av_timecode_make_string(c->cpl->tc, tc_buf, 0), 0); + if (ret) + return ret; + av_log(s, AV_LOG_INFO, "Setting timecode to IMF CPL timecode %s\n", tc_buf); + } + av_log(s, AV_LOG_DEBUG, "parsed IMF CPL: " AV_PRI_URN_UUID "\n", From 5cb1f9abbce09733a294db4ecc8708d3f687b395 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Mon, 22 Aug 2022 21:46:22 -0700 Subject: [PATCH 004/590] avformat/tests/imf: add CPL timecode test --- libavformat/tests/imf.c | 7 +++++++ tests/ref/fate/imf | 1 + 2 files changed, 8 insertions(+) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index e65629ccbc..d42295dc29 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -70,6 +70,11 @@ const char *cpl_doc = " urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f" " " "" + "" + "false" + "24" + "02:10:01.23" + "" "24000 1001" "" "" @@ -288,6 +293,7 @@ static int test_cpl_parsing(void) { xmlDocPtr doc; FFIMFCPL *cpl; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret; doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0); @@ -306,6 +312,7 @@ static int test_cpl_parsing(void) printf("%s\n", cpl->content_title_utf8); printf(AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->id_uuid)); printf("%i %i\n", cpl->edit_rate.num, cpl->edit_rate.den); + printf("%s\n", av_timecode_make_string(cpl->tc, tc_buf, 0)); printf("Marker resource count: %" PRIu32 "\n", cpl->main_markers_track->resource_count); for (uint32_t i = 0; i < cpl->main_markers_track->resource_count; i++) { diff --git a/tests/ref/fate/imf b/tests/ref/fate/imf index 90b461dc5d..5093167bc7 100644 --- a/tests/ref/fate/imf +++ b/tests/ref/fate/imf @@ -1,6 +1,7 @@ FFMPEG sample content urn:uuid:8713c020-2489-45f5-a9f7-87be539e20b5 24000 1001 +02:10:01:23 Marker resource count: 2 Marker resource 0 Marker 0 From 505eaf0e37fa3cddaee5e624695d1d2dbd510bd1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 21 Aug 2022 23:40:49 +0200 Subject: [PATCH 005/590] avcodec/wmalosslessdec: Remove unnecessary emms_c() Possible since 6feea076e98512d78c8d735509ab6b5e9a71ca1c. Signed-off-by: Andreas Rheinhardt --- libavcodec/wmalosslessdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 614b6135f5..6ba9f04d25 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -783,7 +783,6 @@ static void revert_cdlms ## bits (WmallDecodeCtx *s, int ch, \ s->channel_residues[ch][icoef] = input; \ } \ } \ - if (bits <= 16) emms_c(); \ } CD_LMS(16, WMALL_COEFF_PAD_SIZE) From da0e7c3b676867caf02a503cd74d9fe372e3c95d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 21 Aug 2022 23:54:35 +0200 Subject: [PATCH 006/590] avcodec/takdec: Remove unnecessary emms_c() Possible since 3d716d38abdae1982e84e30becb57458244656bd. Signed-off-by: Andreas Rheinhardt --- libavcodec/takdec.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 3e53401328..6f4cc92e88 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -502,8 +502,6 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded, memcpy(s->residues, &s->residues[y], 2 * filter_order); } - emms_c(); - return 0; } @@ -660,8 +658,6 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length) memmove(s->residues, &s->residues[tmp], 2 * filter_order); } - - emms_c(); break; } } From 73f024aa581ddbc49e6db9d39d944ce64b9d8a1c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 00:09:05 +0200 Subject: [PATCH 007/590] avcodec/jpeglsenc: Remove unnecessary emms_c() This encoder does not use any MMX anywhere. Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsenc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index ba9355225b..8f3197e687 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -413,8 +413,6 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, /* End of image */ put_marker_byteu(&pb, EOI); - emms_c(); - av_shrink_packet(pkt, bytestream2_tell_p(&pb)); *got_packet = 1; return 0; From 4a699858d56261b87afad98f03ca3f9de4b196be Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 12:33:50 +0200 Subject: [PATCH 008/590] avcodec/ffv1(dec|enc): Remove unnecessary emms_c() These codecs do not use MMX at all. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1dec.c | 2 -- libavcodec/ffv1enc.c | 1 - 2 files changed, 3 deletions(-) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 4fe1738dea..fd549c7913 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -360,8 +360,6 @@ static int decode_slice(AVCodecContext *c, void *arg) } } - emms_c(); - ff_thread_report_progress(&f->picture, si, 0); return 0; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 90593fbaf1..b939871664 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1076,7 +1076,6 @@ static int encode_slice(AVCodecContext *c, void *arg) } else { ret = encode_rgb_frame(fs, planes, width, height, p->linesize); } - emms_c(); if (ret < 0) { av_assert0(fs->slice_coding_mode == 0); From 145914524bb2208585c34a32352b85908c792b9a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 13:28:33 +0200 Subject: [PATCH 009/590] avcodec/apedec: Remove unnecessary emms_c() Possible since 6feea076e98512d78c8d735509ab6b5e9a71ca1c. Signed-off-by: Andreas Rheinhardt --- libavcodec/apedec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 26183067a8..e7baa2e77f 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1577,7 +1577,6 @@ static int ape_decode_frame(AVCodecContext *avctx, AVFrame *frame, ape_unpack_mono(s, blockstodecode); else ape_unpack_stereo(s, blockstodecode); - emms_c(); if (s->error) { s->samples=0; From 5bf71873276a4e264188a07e3c1624d94d7741d7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 13:31:40 +0200 Subject: [PATCH 010/590] avcodec/4xm: Remove unnecessary and redundant emms_c() It is unnecessary since ee551a21ddcbf81afe183d9489c534ee80f263a0; but it was redundant even before that, because decode_simple_internal() calls emms_c(). Signed-off-by: Andreas Rheinhardt --- libavcodec/4xm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index a7c9043b0a..94d1cbe98a 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -966,8 +966,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, *got_frame = 1; - emms_c(); - return buf_size; } From 85655bd9dab7d3fb2d644a0ab1fa20f570d4f57e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 14:37:20 +0200 Subject: [PATCH 011/590] avcodec/loongarch/cabac, vp9dsp_loongarch: Add missing headers Fixes checkheaders on loongarch. Signed-off-by: Andreas Rheinhardt --- libavcodec/loongarch/cabac.h | 1 + libavcodec/loongarch/vp9dsp_loongarch.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/libavcodec/loongarch/cabac.h b/libavcodec/loongarch/cabac.h index e1c946fe16..f896ccf138 100644 --- a/libavcodec/loongarch/cabac.h +++ b/libavcodec/loongarch/cabac.h @@ -25,6 +25,7 @@ #ifndef AVCODEC_LOONGARCH_CABAC_H #define AVCODEC_LOONGARCH_CABAC_H +#include "libavutil/attributes.h" #include "libavcodec/cabac.h" #include "config.h" diff --git a/libavcodec/loongarch/vp9dsp_loongarch.h b/libavcodec/loongarch/vp9dsp_loongarch.h index 3cc918a18c..9fe4294d50 100644 --- a/libavcodec/loongarch/vp9dsp_loongarch.h +++ b/libavcodec/loongarch/vp9dsp_loongarch.h @@ -22,6 +22,9 @@ #ifndef AVCODEC_LOONGARCH_VP9DSP_LOONGARCH_H #define AVCODEC_LOONGARCH_VP9DSP_LOONGARCH_H +#include +#include + #define VP9_8TAP_LOONGARCH_LSX_FUNC(SIZE, type, type_idx) \ void ff_put_8tap_##type##_##SIZE##h_lsx(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, \ From d09dacc197f99f2ea0b7b9285a5d63d2fd71e1c7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 15:55:46 +0200 Subject: [PATCH 012/590] avformat/os_support: Include stdint.h for int64_t Fixes checkheaders for Windows targets. Signed-off-by: Andreas Rheinhardt --- libavformat/os_support.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/os_support.h b/libavformat/os_support.h index b419efa408..f2ff38e23b 100644 --- a/libavformat/os_support.h +++ b/libavformat/os_support.h @@ -42,6 +42,7 @@ #ifdef _WIN32 # include +# include # ifdef lseek # undef lseek # endif From 0bb0c2679943098c5d39ce235c804c2694ad6bc6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 22 Aug 2022 16:41:09 +0200 Subject: [PATCH 013/590] avutil/mem_internal: Fix headers Including avassert.h is unnecessary since commit 786be70e28fe739b8e49893fa13ae4652a68d1ea. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/h264_qpel.c | 1 + libavutil/mem_internal.h | 3 ++- libavutil/tx.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/x86/h264_qpel.c b/libavcodec/x86/h264_qpel.c index b9b1edcd9e..2df4c11f82 100644 --- a/libavcodec/x86/h264_qpel.c +++ b/libavcodec/x86/h264_qpel.c @@ -20,6 +20,7 @@ */ #include "libavutil/attributes.h" +#include "libavutil/avassert.h" #include "libavutil/cpu.h" #include "libavutil/mem_internal.h" #include "libavutil/x86/asm.h" diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h index ed846aac52..955e31a698 100644 --- a/libavutil/mem_internal.h +++ b/libavutil/mem_internal.h @@ -25,7 +25,8 @@ #include -#include "avassert.h" +#include "attributes.h" +#include "macros.h" #include "mem.h" #include "version.h" diff --git a/libavutil/tx.c b/libavutil/tx.c index e6fcf9f451..c90ca509f5 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "avassert.h" #include "cpu.h" #include "qsort.h" #include "bprint.h" From 0b3f09689dd3dde90e44e6ada4dd3d77cb4d44ac Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 15:00:40 +0200 Subject: [PATCH 014/590] avcodec/gif: Remove unnecessary headers The gif encoder uses the bytestream API, not the PutBit-API. Signed-off-by: Andreas Rheinhardt --- libavcodec/gif.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 8e84b79b8c..a0406f5544 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -30,9 +30,7 @@ * @see http://www.w3.org/Graphics/GIF/spec-gif89a.txt */ -#define BITSTREAM_WRITER_LE #include "libavutil/opt.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" @@ -40,8 +38,6 @@ #include "lzw.h" #include "gif.h" -#include "put_bits.h" - #define DEFAULT_TRANSPARENCY_INDEX 0x1f typedef struct GIFContext { From 76cb899f8ad370bdbd02bb953d4a64af988f1665 Mon Sep 17 00:00:00 2001 From: "Wujian(Chin)" Date: Mon, 22 Aug 2022 13:59:45 +0000 Subject: [PATCH 015/590] avformat/wavdec: fix the ID3 metadata obtained in WAV format's missing Fixes ticket #9848. Signed-off-by: wujian_nanjing Signed-off-by: Steven Liu --- libavformat/wavdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index ca61b844b5..e3f790fcc9 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -555,7 +555,7 @@ static int wav_read_header(AVFormatContext *s) case MKTAG('I', 'D', '3', ' '): case MKTAG('i', 'd', '3', ' '): { ID3v2ExtraMeta *id3v2_extra_meta; - ff_id3v2_read_dict(pb, &ffformatcontext(s)->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta); + ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta, 0); if (id3v2_extra_meta) { ff_id3v2_parse_apic(s, id3v2_extra_meta); ff_id3v2_parse_chapters(s, id3v2_extra_meta); From 48cb2c7a8a2deca40dd2f143848dd5addc25465c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 24 Aug 2022 15:35:32 +0300 Subject: [PATCH 016/590] videotoolbox_vp9: Add a missing include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes compilation after 0bb0c2679943098c5d39ce235c804c2694ad6bc6. Signed-off-by: Martin Storsjö --- libavcodec/videotoolbox_vp9.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/videotoolbox_vp9.c b/libavcodec/videotoolbox_vp9.c index 1b6d08f00b..a998f36d1a 100644 --- a/libavcodec/videotoolbox_vp9.c +++ b/libavcodec/videotoolbox_vp9.c @@ -24,6 +24,7 @@ #include "videotoolbox.h" #include "libavutil/hwcontext_videotoolbox.h" #include "vt_internal.h" +#include "libavutil/avassert.h" #include "libavutil/avutil.h" #include "libavutil/frame.h" #include "libavutil/hwcontext.h" From 57041bb7b5d39b2de22da793b53cc7fbda556a41 Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 23 Aug 2022 20:20:10 -0300 Subject: [PATCH 017/590] avcodec/libvpxenc: use av_fast_realloc() to resize the stats buffer Reviewed-by: James Zern Signed-off-by: James Almer --- libavcodec/libvpxenc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index e08df5fb96..bbbe56c0dc 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -80,6 +80,7 @@ typedef struct VPxEncoderContext { struct vpx_image rawimg_alpha; uint8_t is_alpha; struct vpx_fixed_buf twopass_stats; + unsigned twopass_stats_size; int deadline; //i.e., RT/GOOD/BEST uint64_t sse[4]; int have_sse; /**< true if we have pending sse[] */ @@ -1356,16 +1357,20 @@ static int queue_frames(AVCodecContext *avctx, struct vpx_codec_ctx *encoder, break; case VPX_CODEC_STATS_PKT: { struct vpx_fixed_buf *stats = &ctx->twopass_stats; - int err; + uint8_t *tmp; if (!pkt_out) break; - if ((err = av_reallocp(&stats->buf, - stats->sz + - pkt->data.twopass_stats.sz)) < 0) { + tmp = av_fast_realloc(stats->buf, + &ctx->twopass_stats_size, + stats->sz + + pkt->data.twopass_stats.sz); + if (!tmp) { + av_freep(&stats->buf); stats->sz = 0; av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n"); - return err; + return AVERROR(ENOMEM); } + stats->buf = tmp; memcpy((uint8_t*)stats->buf + stats->sz, pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz); stats->sz += pkt->data.twopass_stats.sz; From 22514527d316f3ed184301d4694d4d028e2a362e Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 23 Aug 2022 20:32:33 -0300 Subject: [PATCH 018/590] avcodec/libaomenc: use av_fast_realloc() to resize the stats buffer Reviewed-by: James Zern Signed-off-by: James Almer --- libavcodec/libaomenc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 1fd69d59a7..485f554165 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -70,6 +70,7 @@ typedef struct AOMEncoderContext { struct aom_codec_ctx encoder; struct aom_image rawimg; struct aom_fixed_buf twopass_stats; + unsigned twopass_stats_size; struct FrameListData *coded_frame_list; int cpu_used; int auto_alt_ref; @@ -1200,14 +1201,17 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out) case AOM_CODEC_STATS_PKT: { struct aom_fixed_buf *stats = &ctx->twopass_stats; - int err; - if ((err = av_reallocp(&stats->buf, - stats->sz + - pkt->data.twopass_stats.sz)) < 0) { + uint8_t *tmp = av_fast_realloc(stats->buf, + &ctx->twopass_stats_size, + stats->sz + + pkt->data.twopass_stats.sz); + if (!tmp) { + av_freep(&stats->buf); stats->sz = 0; av_log(avctx, AV_LOG_ERROR, "Stat buffer realloc failed\n"); - return err; + return AVERROR(ENOMEM); } + stats->buf = tmp; memcpy((uint8_t *)stats->buf + stats->sz, pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz); stats->sz += pkt->data.twopass_stats.sz; From 9546b3a1cbcd94e9107f85c8f1d2175efc6cf083 Mon Sep 17 00:00:00 2001 From: rcombs Date: Fri, 5 Aug 2022 15:57:31 -0500 Subject: [PATCH 019/590] lswr: take const AVChannelLayout* in swr_alloc_set_opts2() This is fully backwards-compatible in both ABI and API, so it's only a minor bump. --- libswresample/swresample.c | 4 ++-- libswresample/swresample.h | 4 ++-- libswresample/version.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 601e691596..6f04d130d3 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -83,8 +83,8 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif int swr_alloc_set_opts2(struct SwrContext **ps, - AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, - AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, + const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, + const AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx) { struct SwrContext *s = *ps; int ret; diff --git a/libswresample/swresample.h b/libswresample/swresample.h index 26d42fab8d..980be65783 100644 --- a/libswresample/swresample.h +++ b/libswresample/swresample.h @@ -286,8 +286,8 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, * On error, the Swr context is freed and *ps set to NULL. */ int swr_alloc_set_opts2(struct SwrContext **ps, - AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, - AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, + const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, + const AVChannelLayout *in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx); /** * @} diff --git a/libswresample/version.h b/libswresample/version.h index 66bac2fa9b..4b9952d914 100644 --- a/libswresample/version.h +++ b/libswresample/version.h @@ -30,7 +30,7 @@ #include "version_major.h" -#define LIBSWRESAMPLE_VERSION_MINOR 8 +#define LIBSWRESAMPLE_VERSION_MINOR 9 #define LIBSWRESAMPLE_VERSION_MICRO 100 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ From b347a05f1fe4a8c7fe4f274eaea09decf012adf0 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 23 Aug 2022 10:11:55 +0200 Subject: [PATCH 020/590] avformat/riff: add support for ICMV files --- libavformat/riff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/riff.c b/libavformat/riff.c index 7a97cf1ccf..6c06ad2d60 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -579,6 +579,7 @@ const AVCodecTag ff_codec_wav_tags[] = { { AV_CODEC_ID_DTS, 0x2001 }, { AV_CODEC_ID_SONIC, 0x2048 }, { AV_CODEC_ID_SONIC_LS, 0x2048 }, + { AV_CODEC_ID_G729, 0x2222 }, { AV_CODEC_ID_PCM_MULAW, 0x6c75 }, { AV_CODEC_ID_AAC, 0x706d }, { AV_CODEC_ID_AAC, 0x4143 }, From 9bf9d42d013bb6ff17aca90d63e2e257a50a6dc3 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 23 Aug 2022 22:39:41 +0200 Subject: [PATCH 021/590] avcodec/wavpack: fix regression in decoding Regression introduced in c6831e2a70f734c71f483d69d46d0635963530. Fix it by using bitreader that reads 0-32 bits, instead of 0-25 bits and asserting on anything higher. --- libavcodec/wavpack.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index c12e1d6ec6..a09ce00fe2 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -119,7 +119,7 @@ typedef struct WavpackContext { #define LEVEL_DECAY(a) (((a) + 0x80) >> 8) -static av_always_inline unsigned get_tail(GetBitContext *gb, int k) +static av_always_inline unsigned get_tail(GetBitContext *gb, unsigned k) { int p, e, res; @@ -127,7 +127,7 @@ static av_always_inline unsigned get_tail(GetBitContext *gb, int k) return 0; p = av_log2(k); e = (1 << (p + 1)) - k - 1; - res = get_bitsz(gb, p); + res = get_bits_long(gb, p); if (res >= e) res = (res << 1) - e + get_bits1(gb); return res; @@ -266,10 +266,6 @@ static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, INC_MED(2); } if (!c->error_limit) { - if (add >= 0x2000000U) { - av_log(ctx->avctx, AV_LOG_ERROR, "k %d is too large\n", add); - goto error; - } ret = base + get_tail(gb, add); if (get_bits_left(gb) <= 0) goto error; From f932b89ea3ef0b8a31077c839371fe7fa2b2baa3 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 3 Feb 2022 11:27:03 +0000 Subject: [PATCH 022/590] lavu/tx: implement aarch64 NEON SIMD FFT The fastest fast Fourier transform in not just the west, but the world, now for the most popular toy ISA. On a high level, it follows the design of the AVX2 version closely, with the exception that the input is slightly less permuted as we don't have to do lane switching with the input on double 4pt and 8pt. On a low level, the lack of subadd/addsub instructions REALLY penalizes any attempt at writing an FFT. That single register matters a lot, and reloading it simply takes unacceptably long. In x86 land, vendors would've noticed developers need this. In ARM land, you get a badly designed complex multiplication instruction we cannot use, that's not present on 95% of devices. Because only compilers matter, right? Future optimization options are very few, perhaps better register management to use more ld1/st1s. All timings below are in cycles: A53: Length | C | New (lavu) | Old (lavc) | FFTW ------ |-------------|-------------|-------------|----- 4 | 842 | 420 | 1210 | 1460 8 | 1538 | 1020 | 1850 | 2520 16 | 3717 | 1900 | 3700 | 3990 32 | 9156 | 4070 | 8289 | 8860 64 | 21160 | 9931 | 18600 | 19625 128 | 49180 | 23278 | 41922 | 41922 256 | 112073 | 53876 | 93202 | 101092 512 | 252864 | 122884 | 205897 | 207868 1024 | 560512 | 278322 | 458071 | 453053 2048 | 1295402 | 775835 | 1038205 | 1020265 4096 | 3281263 | 2021221 | 2409718 | 2577554 8192 | 8577845 | 4780526 | 5673041 | 6802722 Apple M1 New - Total for len 512 reps 2097152 = 1.459141 s Old - Total for len 512 reps 2097152 = 2.251344 s FFTW - Total for len 512 reps 2097152 = 1.868429 s New - Total for len 1024 reps 4194304 = 6.490080 s Old - Total for len 1024 reps 4194304 = 9.604949 s FFTW - Total for len 1024 reps 4194304 = 7.889281 s New - Total for len 16384 reps 262144 = 10.374001 s Old - Total for len 16384 reps 262144 = 15.266713 s FFTW - Total for len 16384 reps 262144 = 12.341745 s New - Total for len 65536 reps 8192 = 1.769812 s Old - Total for len 65536 reps 8192 = 4.209413 s FFTW - Total for len 65536 reps 8192 = 3.012365 s New - Total for len 131072 reps 4096 = 1.942836 s Old - Segfaults FFTW - Total for len 131072 reps 4096 = 3.713713 s Thanks to wbs for some simplifications, assembler fixes and a review and to jannau for giving it a look. --- libavutil/aarch64/Makefile | 4 +- libavutil/aarch64/tx_float_init.c | 65 ++ libavutil/aarch64/tx_float_neon.S | 1294 +++++++++++++++++++++++++++++ libavutil/tx.c | 3 + libavutil/tx_priv.h | 1 + 5 files changed, 1366 insertions(+), 1 deletion(-) create mode 100644 libavutil/aarch64/tx_float_init.c create mode 100644 libavutil/aarch64/tx_float_neon.S diff --git a/libavutil/aarch64/Makefile b/libavutil/aarch64/Makefile index 5613813ba8..eba0151337 100644 --- a/libavutil/aarch64/Makefile +++ b/libavutil/aarch64/Makefile @@ -1,4 +1,6 @@ OBJS += aarch64/cpu.o \ aarch64/float_dsp_init.o \ + aarch64/tx_float_init.o \ -NEON-OBJS += aarch64/float_dsp_neon.o +NEON-OBJS += aarch64/float_dsp_neon.o \ + aarch64/tx_float_neon.o \ diff --git a/libavutil/aarch64/tx_float_init.c b/libavutil/aarch64/tx_float_init.c new file mode 100644 index 0000000000..2e8d61f688 --- /dev/null +++ b/libavutil/aarch64/tx_float_init.c @@ -0,0 +1,65 @@ +/* + * 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 + */ + +#define TX_FLOAT +#include "libavutil/tx_priv.h" +#include "libavutil/attributes.h" +#include "libavutil/aarch64/cpu.h" + +TX_DECL_FN(fft2, neon) +TX_DECL_FN(fft4_fwd, neon) +TX_DECL_FN(fft4_inv, neon) +TX_DECL_FN(fft8, neon) +TX_DECL_FN(fft8_ns, neon) +TX_DECL_FN(fft16, neon) +TX_DECL_FN(fft16_ns, neon) +TX_DECL_FN(fft32, neon) +TX_DECL_FN(fft32_ns, neon) +TX_DECL_FN(fft_sr, neon) +TX_DECL_FN(fft_sr_ns, neon) + +static av_cold int neon_init(AVTXContext *s, const FFTXCodelet *cd, + uint64_t flags, FFTXCodeletOptions *opts, + int len, int inv, const void *scale) +{ + const int inv_lookup = opts ? opts->invert_lookup : 1; + ff_tx_init_tabs_float(len); + if (cd->max_len == 2) + return ff_tx_gen_ptwo_revtab(s, inv_lookup); + else + return ff_tx_gen_split_radix_parity_revtab(s, inv_lookup, 8, 0); +} + +const FFTXCodelet * const ff_tx_codelet_list_float_aarch64[] = { + TX_DEF(fft2, FFT, 2, 2, 2, 0, 128, NULL, neon, NEON, AV_TX_INPLACE, 0), + TX_DEF(fft2, FFT, 2, 2, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), + TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 128, NULL, neon, NEON, AV_TX_INPLACE | FF_TX_FORWARD_ONLY, 0), + TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), + TX_DEF(fft4_inv, FFT, 4, 4, 2, 0, 128, NULL, neon, NEON, AV_TX_INPLACE | FF_TX_INVERSE_ONLY, 0), + TX_DEF(fft8, FFT, 8, 8, 2, 0, 128, neon_init, neon, NEON, AV_TX_INPLACE, 0), + TX_DEF(fft8_ns, FFT, 8, 8, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), + TX_DEF(fft16, FFT, 16, 16, 2, 0, 128, neon_init, neon, NEON, AV_TX_INPLACE, 0), + TX_DEF(fft16_ns, FFT, 16, 16, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), + TX_DEF(fft32, FFT, 32, 32, 2, 0, 128, neon_init, neon, NEON, AV_TX_INPLACE, 0), + TX_DEF(fft32_ns, FFT, 32, 32, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), + + TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 128, neon_init, neon, NEON, 0, 0), + TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 192, neon_init, neon, NEON, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), + + NULL, +}; diff --git a/libavutil/aarch64/tx_float_neon.S b/libavutil/aarch64/tx_float_neon.S new file mode 100644 index 0000000000..4126c3b812 --- /dev/null +++ b/libavutil/aarch64/tx_float_neon.S @@ -0,0 +1,1294 @@ +/* + * Copyright (c) Lynne + * + * 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 "libavutil/aarch64/asm.S" + +/* Open `doc/transforms.md` to see the code upon which the transforms here were + * based upon. + * + * File conventions: + * GPRs: x0-x3 - arguments, untouched + * x4 - Lookup table base pointer + * x5-x6 - macro ld1 temps/function scratch + * x7-x9 - FFT table state + * x10-x17 - lookup table/macro scratch + * w19-w20 - current/target length when needed + * x21-x22 - len*2, len*6 + * + * Vectors: v0-v7 - coefficients + * v8-v15 - coefficients when needed, otherwise untouched + * v16-v30 - used as needed + * v31 - -1.0, +1.0, -1.0, +1.0. Never touched after loading. + * + * Stack: backup for v8-v15 and x19-x22 when needed, and transform lengths + */ + +#define M_SQRT1_2 0.707106781186547524401 +#define COS16_1 0.92387950420379638671875 +#define COS16_3 0.3826834261417388916015625 + +/* We only ever load this once at the start, and then live with losing an + * entire register as we need to lug this all the time everywhere. + * Clearly should be integrated into an fsadd and fmlsa, but "muh RISC!". */ +const subadd, align=4 + .float -1.0, 1.0, -1.0, 1.0 +endconst + +.macro LOAD_SUBADD + movrel x5, subadd + ld1 { v31.4s }, [x5] +.endm + +.macro SETUP_LUT no_lut=0 +.if \no_lut == 0 + ldr x4, [x0, #8] +.endif +.endm + +.macro LOAD_INPUT dst1, dst2, dst3, dst4, src, no_lut=0, discont=0 +.if \no_lut == 1 +.if \discont == 1 + ldp q\dst1\(), q\dst2\(), [\src\()] + ldp q\dst3\(), q\dst4\(), [\src\(), #32] + add \src\(), \src\(), #64 +.else + ld1 { v\dst1\().4s, v\dst2\().4s, v\dst3\().4s, v\dst4\().4s }, [\src], #64 +.endif +.else + ldp w10, w11, [x4, #0 ] + ldp w12, w13, [x4, #8 ] + ldp w14, w15, [x4, #16] + ldp w16, w17, [x4, #24] + + add x4, x4, #32 + + ldr d\dst1, [\src, x10, lsl #3] + add x11, \src, x11, lsl #3 + ldr d\dst2, [\src, x12, lsl #3] + add x13, \src, x13, lsl #3 + ldr d\dst3, [\src, x14, lsl #3] + add x15, \src, x15, lsl #3 + ldr d\dst4, [\src, x16, lsl #3] + add x17, \src, x17, lsl #3 + + ld1 { v\dst1\().d }[1], [x11] + ld1 { v\dst2\().d }[1], [x13] + ld1 { v\dst3\().d }[1], [x15] + ld1 { v\dst4\().d }[1], [x17] +.endif +.endm + +.macro FFT4 e0, o0, standalone + fadd v16.4s, \e0\().4s, \o0\().4s // r1..4 + fsub \e0\().4s, \e0\().4s, \o0\().4s // t1..4 + + rev64 v18.4s, \e0\().4s + + zip2 \o0\().2d, v16.2d, \e0\().2d + zip1 v17.2d, v16.2d, \e0\().2d + + mov \o0\().d[1], v18.d[1] + + fadd \e0\().4s, v17.4s, \o0\().4s // a1,2 b1,4 + fsub v16.4s, v17.4s, \o0\().4s // a3,4 b3,2 + + mov \o0\().16b, v16.16b // Swap once again... + mov \o0\().s[3], \e0\().s[3] + mov \e0\().s[3], v16.s[3] + +.if \standalone == 0 + uzp2 \o0\().2d, \e0\().2d, \o0\().2d + uzp1 \e0\().2d, \e0\().2d, v16.2d +.endif +.endm + +const shuf_4pt_x2, align=4 + .byte 24, 25, 26, 27 // reg2, 3 + .byte 12, 13, 14, 15 // reg1, 4 + .byte 8, 9, 10, 11 // reg1, 3 + .byte 28, 29, 30, 31 // reg2, 4 +endconst + +// Identical to FFT4, but does 2 transforms in parallel, with no deinterleaving +.macro FFT4_X2 e0, o0, e1, o1, \ + t0=v16, t1=v17, t2=v18, t3=v19, t4=v20, t5=v21, t6=v22 + + fadd \t0\().4s, \e0\().4s, \o0\().4s // r1234 + fadd \t2\().4s, \e1\().4s, \o1\().4s // r1234 + fsub \e0\().4s, \e0\().4s, \o0\().4s // t1234 + fsub \e1\().4s, \e1\().4s, \o1\().4s // t1234 + + movrel x5, shuf_4pt_x2 + + rev64 \t4\().4s, \e0\().4s + rev64 \t5\().4s, \e1\().4s + + zip2 \o0\().2d, \t0\().2d, \e0\().2d // t3,4 r3,4 + zip2 \o1\().2d, \t2\().2d, \e1\().2d // t3,4 r3,4 + + ld1 { \t6\().16b }, [x5] + + mov \o0\().d[1], \t4\().d[1] + mov \o1\().d[1], \t5\().d[1] + + zip1 \t1\().2d, \t0\().2d, \e0\().2d // t1,2 r1,2 + zip1 \t3\().2d, \t2\().2d, \e1\().2d // t1,2 r1,2 + + fsub \t4\().4s, \t1\().4s, \o0\().4s // a34 b32 + fadd \t5\().4s, \t1\().4s, \o0\().4s // a12 b14 + fsub \t2\().4s, \t3\().4s, \o1\().4s // a34 b32 + fadd \t3\().4s, \t3\().4s, \o1\().4s // a12 b14 + + // TODO: experiment with movs instead of tables here + tbl \o0\().16b, { \t4\().16b, \t5\().16b }, \t6\().16b // b1234 + tbl \o1\().16b, { \t2\().16b, \t3\().16b }, \t6\().16b // b1234 + + zip1 \e0\().2d, \t5\().2d, \t4\().2d // a1234 +// zip2 \o0\().2d, \t5\().2d, \t4\().2d // b1432 + zip1 \e1\().2d, \t3\().2d, \t2\().2d // a1234 +// zip2 \o1\().2d, \t3\().2d, \t2\().2d // b1432 +// rev64 \o0\().4s, \o0\().4s // b4123 +// rev64 \o1\().4s, \o1\().4s // b4123 +// ext \o0\().16b, \o0\().16b, \o0\().16b, #4 // b1234 +// ext \o1\().16b, \o1\().16b, \o1\().16b, #4 // b1234 +.endm + +const tab_8pt, align=4 + .float M_SQRT1_2, -M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2 +endconst + +.macro FFT8 e0, e1, o0, o1, \ + t0=v16, t1=v17, t2=v18, t3=v19, t4=v20, t5=v21, t6=v22 + + movrel x5, tab_8pt + + fsub \t1\().4s, \e1\().4s, \o1\().4s // j1234 + fadd \o1\().4s, \e1\().4s, \o1\().4s // k1234 + fsub \t0\().4s, \e0\().4s, \o0\().4s // r1234 + fadd \o0\().4s, \e0\().4s, \o0\().4s // q1234 + + ld1 { \t5\().4s }, [x5] + + ext \t4\().16b, \o1\().16b, \o1\().16b, #12 + rev64 \t4\().4s, \t4\().4s + + ext \t2\().16b, \o0\().16b, \t4\().16b, #8 // o0[0,1], o1[3,2] + mov \o0\().d[1], \t4\().d[1] // o0[3, 4]; o1[1, 4] + + fsub \e1\().4s, \o0\().4s, \t2\().4s // s34, g43 + fadd \t2\().4s, \o0\().4s, \t2\().4s // s12, g12 + + rev64 \t6\().4s, v31.4s // 1, -1, 1, -1 + dup \o0\().2d, \t0\().d[0] // r1212 + dup \o1\().2d, \t0\().d[1] // r3434 + + rev64 \t4\().4s, \e1\().4s // xxg34 + rev64 \o1\().4s, \o1\().4s // r4343 + + ext \t6\().16b, v31.16b, \t6\().16b, #8 // -1, 1, 1, -1 + zip1 \t3\().2d, \t2\().2d, \e1\().2d // s1234 + zip2 \t2\().2d, \t2\().2d, \t4\().2d // g1234 + + fadd \e0\().4s, \t3\().4s, \t2\().4s // out_e1 + fsub \e1\().4s, \t3\().4s, \t2\().4s // out_e2 + + fmul \t1\().4s, \t1\().4s, \t5\().4s // j * +--+M_SQRT1_2 + fmls \o0\().4s, \o1\().4s, \t6\().4s // z1234 + + rev64 \t4\().4s, \t1\().4s // j2143 + fmla \t1\().4s, \t4\().4s, v31.4s // l2143 + + rev64 \t4\().4s, \t1\().4s // l1234 + ext \t4\().16b, \t4\().16b, \t4\().16b, #8 // l3412 + + fmla \t4\().4s, \t1\().4s, v31.4s // t1234 + + fadd \o1\().4s, \o0\().4s, \t4\().4s // out_o2 + fsub \o0\().4s, \o0\().4s, \t4\().4s // out_o1 +.endm + +// Identical as FFT8, but does 2 transforms in parallel +.macro FFT8_X2 e0, e1, o0, o1, e2, e3, o2, o3 + + movrel x5, tab_8pt + + fadd v19.4s, \e3\().4s, \o3\().4s // k1234 + fadd v17.4s, \e1\().4s, \o1\().4s // k1234 + fadd v18.4s, \e2\().4s, \o2\().4s // q1234 + fadd v16.4s, \e0\().4s, \o0\().4s // q1234 + + ld1 { v23.4s }, [x5] + + ext v22.16b, v19.16b, v19.16b, #12 + ext v21.16b, v17.16b, v17.16b, #12 + + rev64 v22.4s, v22.4s + rev64 v21.4s, v21.4s + + ext v19.16b, v18.16b, v22.16b, #8 + ext v17.16b, v16.16b, v21.16b, #8 + + mov v18.d[1], v22.d[1] + mov v21.d[0], v16.d[0] + + fadd v22.4s, v18.4s, v19.4s // s12, g12 + fsub v19.4s, v18.4s, v19.4s // s34, g43 + fsub v18.4s, v21.4s, v17.4s // s34, g43 + fadd v16.4s, v21.4s, v17.4s // s12, g12 + + fsub \e0\().4s, \e0\().4s, \o0\().4s // r1234 + fsub v20.4s, \e1\().4s, \o1\().4s // j1234 + fsub \e2\().4s, \e2\().4s, \o2\().4s // r1234 + fsub v21.4s, \e3\().4s, \o3\().4s // j1234 + + rev64 v24.4s, v31.4s // 1, -1, 1, -1 + zip1 v17.2d, v16.2d, v18.2d // s1234 + zip1 \e1\().2d, v22.2d, v19.2d // s1234 + + rev64 v18.4s, v18.4s // xxg34 + rev64 v19.4s, v19.4s // xxg34 + + zip2 v16.2d, v16.2d, v18.2d // g1234 + zip2 \e3\().2d, v22.2d, v19.2d // g1234 + + dup \o0\().2d, \e0\().d[0] // r1212 + dup \o1\().2d, \e0\().d[1] // r3434 + dup \o2\().2d, \e2\().d[0] // r1212 + dup \o3\().2d, \e2\().d[1] // r3434 + + fadd \e2\().4s, \e1\().4s, \e3\().4s // out_e1 + fsub \e3\().4s, \e1\().4s, \e3\().4s // out_e2 + fadd \e0\().4s, v17.4s, v16.4s // out_e1 + fsub \e1\().4s, v17.4s, v16.4s // out_e2 + + ext v24.16b, v31.16b, v24.16b, #8 // -1, 1, 1, -1 + rev64 \o1\().4s, \o1\().4s // r4343 + rev64 \o3\().4s, \o3\().4s // r4343 + + fmul v19.4s, v20.4s, v23.4s // j * +--+M_SQRT1_2 + fmul v21.4s, v21.4s, v23.4s // j * +--+M_SQRT1_2 + + rev64 v20.4s, v19.4s // j2143 + rev64 v18.4s, v21.4s // j2143 + + fmls \o0\().4s, \o1\().4s, v24.4s // z1234 + fmls \o2\().4s, \o3\().4s, v24.4s // z1234 + + fmla v19.4s, v20.4s, v31.4s // l2143 + fmla v21.4s, v18.4s, v31.4s // l2143 + + rev64 v20.4s, v19.4s // l1234 + rev64 v18.4s, v21.4s // l1234 + ext v20.16b, v20.16b, v20.16b, #8 // l3412 + ext v18.16b, v18.16b, v18.16b, #8 // l3412 + + fmla v20.4s, v19.4s, v31.4s // t1234 + fmla v18.4s, v21.4s, v31.4s // t1234 + + fadd \o1\().4s, \o0\().4s, v20.4s // out_o2 + fadd \o3\().4s, \o2\().4s, v18.4s // out_o2 + fsub \o0\().4s, \o0\().4s, v20.4s // out_o1 + fsub \o2\().4s, \o2\().4s, v18.4s // out_o1 +.endm + +const tab_16pt, align=4 + .float -COS16_1, COS16_1, -COS16_3, COS16_3 // Could be +-+- too + .float COS16_3, COS16_3, COS16_1, COS16_1 + .float 1.0, 1.0, M_SQRT1_2, M_SQRT1_2 +endconst + +// 16-point FFT +// t3, t4, t5, t6 must be sequential +.macro FFT16 e0, e1, e2, e3, o0, o1, o2, o3, \ + t0=v16, t1=v17, t2=v18, t3=v19, t4=v20, t5=v21, t6=v22 + + FFT8 \e0, \e1, \e2, \e3, \t0, \t1, \t2, \t3, \t4, \t5, \t6 + FFT4_X2 \o0, \o1, \o2, \o3, \t0, \t1, \t2, \t3, \t4, \t5, \t6 + + movrel x5, tab_16pt + + rev64 \t0\().4s, \o0\().4s // z[ 8, 9].imre + rev64 \t1\().4s, \o2\().4s // z[10,11].imre + + ins \t0\().d[0], xzr + ins \t1\().d[0], xzr + + ld1 { \t4\().4s, \t5\().4s, \t6\().4s }, [x5] + // TODO: We could derive \t4\() or \t5\() from either, but it seems cheaper to load + + fmla \o2\().4s, \t1\().4s, v31.4s // s[4567] + fmls \o0\().4s, \t0\().4s, v31.4s // s[0123] + + fmul \t2\().4s, \o1\().4s, \t4\().4s + fmul \t3\().4s, \o3\().4s, \t4\().4s + + rev64 \o3\().4s, \o3\().4s + rev64 \o1\().4s, \o1\().4s + + fmla \t3\().4s, \o3\().4s, \t5\().4s // s[12, 13, 14, 15] + fmls \t2\().4s, \o1\().4s, \t5\().4s // s[ 8, 9, 10, 11] + + fmul \t1\().4s, \o2\().4s, \t6\().4s // s[4567] * mult + fmul \t0\().4s, \o0\().4s, \t6\().4s // s[0123] * mult + + mov \o1\().16b, \t3\().16b + mov \o2\().16b, \t1\().16b + + fsub \t3\().4s, \t3\().4s, \t2\().4s // y34, u34 + fsub \t1\().4s, \t1\().4s, \t0\().4s // w34, x34 + + fadd \t2\().4s, \t2\().4s, \o1\().4s // y56, u56 + rev64 \t3\().4s, \t3\().4s + fadd \t0\().4s, \t0\().4s, \o2\().4s // w56, x56 + rev64 \t1\().4s, \t1\().4s + + fmul \t2\().4s, \t2\().4s, v31.4s + fmul \t1\().4s, \t1\().4s, v31.4s + + fadd \o3\().4s, \e3\().4s, \t3\().4s + fsub \o2\().4s, \e3\().4s, \t3\().4s + fsub \o1\().4s, \e2\().4s, \t2\().4s + fadd \o0\().4s, \e2\().4s, \t2\().4s + + fsub \e2\().4s, \e0\().4s, \t0\().4s + fadd \e0\().4s, \e0\().4s, \t0\().4s + fsub \e3\().4s, \e1\().4s, \t1\().4s + fadd \e1\().4s, \e1\().4s, \t1\().4s +.endm + +function ff_tx_fft2_float_neon, export=1 + ld2r { v0.2d, v1.2d }, [x2] + + fneg v2.2s, v1.2s + mov v2.d[1], v1.d[0] + + fsub v2.4s, v0.4s, v2.4s + + st1 { v2.4s }, [x1] + ret +endfunc + +.macro FFT4_FN name, inv +function ff_tx_fft4_\name\()_float_neon, export=1 + ld1 {v0.4s, v1.4s}, [x2] + +.if \inv == 1 + mov v2.d[0], v0.d[1] + mov v0.d[1], v1.d[1] + mov v1.d[1], v2.d[0] +.endif + + FFT4 v0, v1, 1 + + st1 { v0.4s, v1.4s }, [x1] + ret +endfunc +.endm + +FFT4_FN fwd, 0 +FFT4_FN inv, 1 + +.macro FFT8_FN name, no_perm +function ff_tx_fft8_\name\()_neon, export=1 + SETUP_LUT \no_perm + LOAD_INPUT 0, 1, 2, 3, x2, \no_perm + + LOAD_SUBADD + FFT8 v0, v1, v2, v3 + + zip1 v16.2d, v0.2d, v2.2d + zip2 v17.2d, v0.2d, v2.2d + zip1 v18.2d, v1.2d, v3.2d + zip2 v19.2d, v1.2d, v3.2d + st1 { v16.4s, v17.4s, v18.4s, v19.4s }, [x1] + + ret +endfunc +.endm + +FFT8_FN float, 0 +FFT8_FN ns_float, 1 + +.macro FFT16_FN name, no_perm +function ff_tx_fft16_\name\()_neon, export=1 + SETUP_LUT \no_perm + LOAD_INPUT 0, 1, 2, 3, x2, \no_perm + LOAD_INPUT 4, 5, 6, 7, x2, \no_perm + + LOAD_SUBADD + FFT16 v0, v1, v2, v3, v4, v5, v6, v7 + + zip1 v20.2d, v0.2d, v4.2d + zip2 v21.2d, v0.2d, v4.2d + zip1 v22.2d, v1.2d, v6.2d + zip2 v23.2d, v1.2d, v6.2d + st1 { v20.4s, v21.4s, v22.4s, v23.4s }, [x1], #64 + + zip1 v24.2d, v2.2d, v5.2d + zip2 v25.2d, v2.2d, v5.2d + zip1 v26.2d, v3.2d, v7.2d + zip2 v27.2d, v3.2d, v7.2d + st1 { v24.4s, v25.4s, v26.4s, v27.4s }, [x1] + + ret +endfunc +.endm + +FFT16_FN float, 0 +FFT16_FN ns_float, 1 + +.macro SETUP_SR_RECOMB len, re, im, dec + ldr w5, =(\len - 4*7) + movrel \re, X(ff_tx_tab_\len\()_float) + add \im, \re, x5 + mov \dec, #-32 + +.if \len > 32 + mov x21, #2*\len + add x22, x21, x21, lsl #1 +.endif +.endm + +.macro SR_COMBINE e0, e1, e2, e3, e4, e5, e6, e7, \ + o0, o1, o2, o3, o4, o5, o6, o7, \ + re, im, dec, swap_im, \ + t0=v16, t1=v17, t2=v18, t3=v19, t4=v20, t5=v21, \ + t6=v22, t7=v23, t8=v24, t9=v25, ta=v26, tb=v27 + + ld1 { \t8\().4s, \t9\().4s }, [\im], \dec + ld1 { \t0\().4s, \t1\().4s }, [\re], #32 + +.if \swap_im == 1 + ext \t2\().16b, \t9\().16b, \t9\().16b, #8 + ext \t3\().16b, \t8\().16b, \t8\().16b, #8 +.else + ext \t2\().16b, \t8\().16b, \t8\().16b, #8 + ext \t3\().16b, \t9\().16b, \t9\().16b, #8 +.endif + + trn1 \t4\().4s, \t0\().4s, \t0\().4s // cos0022 + trn2 \t0\().4s, \t0\().4s, \t0\().4s // cos4466 + trn1 \t5\().4s, \t1\().4s, \t1\().4s // cos1133 + trn2 \t1\().4s, \t1\().4s, \t1\().4s // cos5577 + + rev64 \t6\().4s, \o0\().4s // E m2[0,1].imre + rev64 \t7\().4s, \o2\().4s // O m2[0,1].imre + rev64 \t8\().4s, \o4\().4s // E m2[2,3].imre + rev64 \t9\().4s, \o6\().4s // O m2[2,3].imre + + fmul \t6\().4s, \t6\().4s, \t4\().4s // E m2[0,1].imre*t1[0,2] + fmul \t7\().4s, \t7\().4s, \t0\().4s // O m2[0,1].imre*t1[0,2] + fmul \t8\().4s, \t8\().4s, \t4\().4s // E m2[2,3].imre*t1[0,2] + fmul \t9\().4s, \t9\().4s, \t0\().4s // O m2[2,3].imre*t1[0,2] + + rev64 \ta\().4s, \o1\().4s // E m3[0,1].imre + rev64 \tb\().4s, \o3\().4s // O m3[0,1].imre + rev64 \t4\().4s, \o5\().4s // E m3[2,3].imre + rev64 \t0\().4s, \o7\().4s // O m3[2,3].imre + + fmul \ta\().4s, \ta\().4s, \t5\().4s // E m3[0,1].imre*t1[4,6] + fmul \tb\().4s, \tb\().4s, \t1\().4s // O m3[0,1].imre*t1[4,6] + fmul \t4\().4s, \t4\().4s, \t5\().4s // E m3[2,3].imre*t1[4,6] + fmul \t0\().4s, \t0\().4s, \t1\().4s // O m3[2,3].imre*t1[4,6] + + trn1 \t5\().4s, \t3\().4s, \t3\().4s // wim2200 + trn2 \t3\().4s, \t3\().4s, \t3\().4s // wim3311 + trn1 \t1\().4s, \t2\().4s, \t2\().4s // wim6644 + trn2 \t2\().4s, \t2\().4s, \t2\().4s // wim7755 + + fmul \t5\().4s, \t5\().4s, v31.4s + fmul \t3\().4s, \t3\().4s, v31.4s + fmul \t1\().4s, \t1\().4s, v31.4s + fmul \t2\().4s, \t2\().4s, v31.4s + + fmla \t7\().4s, \o2\().4s, \t5\().4s // O w0123 + fmls \t9\().4s, \o6\().4s, \t5\().4s // O j0123 + fmla \t6\().4s, \o0\().4s, \t3\().4s // E w0123 + fmls \t8\().4s, \o4\().4s, \t3\().4s // E j0123 + + fmla \ta\().4s, \o1\().4s, \t2\().4s // E w4567 + fmla \tb\().4s, \o3\().4s, \t1\().4s // O w4567 + fmls \t4\().4s, \o5\().4s, \t2\().4s // E j4567 + fmls \t0\().4s, \o7\().4s, \t1\().4s // O j4567 + + fsub \t2\().4s, \t7\().4s, \t9\().4s + fsub \t1\().4s, \t8\().4s, \t6\().4s + fsub \t3\().4s, \t4\().4s, \ta\().4s + fsub \t5\().4s, \t0\().4s, \tb\().4s + + fadd \t6\().4s, \t8\().4s, \t6\().4s + fadd \t7\().4s, \t9\().4s, \t7\().4s + fadd \t8\().4s, \t4\().4s, \ta\().4s + fadd \t9\().4s, \t0\().4s, \tb\().4s + + fmul \t1\().4s, \t1\().4s, v31.4s + fmul \t2\().4s, \t2\().4s, v31.4s + fmul \t3\().4s, \t3\().4s, v31.4s + fmul \t5\().4s, \t5\().4s, v31.4s + + rev64 \t6\().4s, \t6\().4s + rev64 \t8\().4s, \t8\().4s + rev64 \t7\().4s, \t7\().4s + rev64 \t9\().4s, \t9\().4s + + fsub \o0\().4s, \e0\().4s, \t6\().4s + fsub \o1\().4s, \e1\().4s, \t8\().4s + fsub \o2\().4s, \e2\().4s, \t1\().4s + fsub \o3\().4s, \e3\().4s, \t3\().4s + + fsub \o4\().4s, \e4\().4s, \t7\().4s + fsub \o5\().4s, \e6\().4s, \t9\().4s + fadd \o6\().4s, \e5\().4s, \t2\().4s + fsub \o7\().4s, \e7\().4s, \t5\().4s + + fadd \e0\().4s, \e0\().4s, \t6\().4s + fadd \e1\().4s, \e1\().4s, \t8\().4s + fadd \e2\().4s, \e2\().4s, \t1\().4s + fadd \e3\().4s, \e3\().4s, \t3\().4s + + fadd \e4\().4s, \e4\().4s, \t7\().4s + fsub \e5\().4s, \e5\().4s, \t2\().4s // swapped + fadd \e6\().4s, \e6\().4s, \t9\().4s // swapped + fadd \e7\().4s, \e7\().4s, \t5\().4s +.endm + +.macro SR_COMBINE_HALF e0, e1, e2, e3, \ + o0, o1, o2, o3, \ + c0, c1, c2, c3, \ + t0, t1, t2, t3, t4, t5, part + +.if \part == 0 + trn1 \t4\().4s, \c0\().4s, \c0\().4s // cos0022 + trn1 \c1\().4s, \c1\().4s, \c1\().4s // cos1133 +.else + trn2 \t4\().4s, \c0\().4s, \c0\().4s // cos0022 + trn2 \c1\().4s, \c1\().4s, \c1\().4s // cos1133 +.endif +.if \part == 0 + trn2 \t5\().4s, \c2\().4s, \c2\().4s // wim7755 + trn2 \c3\().4s, \c3\().4s, \c3\().4s // wim3311 +.else + trn1 \t5\().4s, \c2\().4s, \c2\().4s // wim7755 + trn1 \c3\().4s, \c3\().4s, \c3\().4s // wim3311 +.endif + + fmul \t5\().4s, \t5\().4s, v31.4s + fmul \c3\().4s, \c3\().4s, v31.4s + + rev64 \t0\().4s, \o0\().4s // E m2[0,1].imre + rev64 \t1\().4s, \o2\().4s // E m2[2,3].imre + rev64 \t2\().4s, \o1\().4s // E m3[0,1].imre + rev64 \t3\().4s, \o3\().4s // E m3[2,3].imre + + fmul \o0\().4s, \o0\().4s, \c3\().4s // E m2[0,1].imre*t1[0,2] + fmul \o1\().4s, \o1\().4s, \t5\().4s // E m3[0,1].imre*t1[4,6] + fmla \o0\().4s, \t0\().4s, \t4\().4s // E w0123 + fmla \o1\().4s, \t2\().4s, \c1\().4s // E w4567 + + fmul \t1\().4s, \t1\().4s, \t4\().4s // E m2[2,3].imre*t1[0,2] + fmul \t3\().4s, \t3\().4s, \c1\().4s // E m3[2,3].imre*t1[4,6] + fmls \t1\().4s, \o2\().4s, \c3\().4s // E j0123 + fmls \t3\().4s, \o3\().4s, \t5\().4s // E j4567 + + fsub \t0\().4s, \t1\().4s, \o0\().4s + fadd \t1\().4s, \t1\().4s, \o0\().4s + fadd \t2\().4s, \t3\().4s, \o1\().4s + fsub \t3\().4s, \t3\().4s, \o1\().4s + + fmul \t0\().4s, \t0\().4s, v31.4s + fmul \t3\().4s, \t3\().4s, v31.4s + + rev64 \t1\().4s, \t1\().4s + rev64 \t2\().4s, \t2\().4s + +.if \part == 0 + fsub \o0\().4s, \e0\().4s, \t1\().4s + fsub \o1\().4s, \e1\().4s, \t2\().4s + fsub \o2\().4s, \e2\().4s, \t0\().4s + fsub \o3\().4s, \e3\().4s, \t3\().4s +.else + fsub \o0\().4s, \e0\().4s, \t1\().4s + fadd \o2\().4s, \e1\().4s, \t2\().4s + fsub \o1\().4s, \e2\().4s, \t0\().4s + fadd \o3\().4s, \e3\().4s, \t3\().4s +.endif + +.if \part == 0 + fadd \e0\().4s, \e0\().4s, \t1\().4s + fadd \e1\().4s, \e1\().4s, \t2\().4s + fadd \e2\().4s, \e2\().4s, \t0\().4s + fadd \e3\().4s, \e3\().4s, \t3\().4s +.else + fadd \e0\().4s, \e0\().4s, \t1\().4s + fsub \e1\().4s, \e1\().4s, \t2\().4s // swapped + fadd \e2\().4s, \e2\().4s, \t0\().4s // swapped + fsub \e3\().4s, \e3\().4s, \t3\().4s +.endif +.endm + +/* Same as SR_COMBINE_HALF, but heroically tries to use 3 temporary registers + * without touching the tables. */ +.macro SR_COMBINE_LITE e0, e1, e2, e3, \ + o0, o1, o2, o3, \ + c0, c1, c2, c3, \ + t0, t1, t2, part + + rev64 \t0\().4s, \o0\().4s // E m2[0,1].imre + rev64 \t1\().4s, \o2\().4s // E m2[2,3].imre +.if \part == 0 + trn2 \t2\().4s, \c3\().4s, \c3\().4s // wim3311 +.else + trn1 \t2\().4s, \c3\().4s, \c3\().4s // wim3311 +.endif + fmul \t2\().4s, \t2\().4s, v31.4s + fmul \o2\().4s, \o2\().4s, \t2\().4s + fmul \o0\().4s, \o0\().4s, \t2\().4s // E m2[0,1].imre*t1[0,2] +.if \part == 0 + trn1 \t2\().4s, \c0\().4s, \c0\().4s // cos0022 +.else + trn2 \t2\().4s, \c0\().4s, \c0\().4s // cos0022 +.endif + fmul \t1\().4s, \t1\().4s, \t2\().4s // E m2[2,3].imre*t1[0,2] + fmla \o0\().4s, \t0\().4s, \t2\().4s // E w0123 + fsub \t1\().4s, \t1\().4s, \o2\().4s // E j0123 + + rev64 \t2\().4s, \o1\().4s // E m3[0,1].imre + rev64 \o2\().4s, \o3\().4s // E m3[2,3].imre + +.if \part == 0 + trn2 \t0\().4s, \c2\().4s, \c2\().4s // wim7755 +.else + trn1 \t0\().4s, \c2\().4s, \c2\().4s // wim7755 +.endif + fmul \t0\().4s, \t0\().4s, v31.4s + + fmul \o1\().4s, \o1\().4s, \t0\().4s // E m3[0,1].imre*t1[4,6] + fmul \o3\().4s, \o3\().4s, \t0\().4s + +.if \part == 0 + trn1 \t0\().4s, \c1\().4s, \c1\().4s // cos1133 +.else + trn2 \t0\().4s, \c1\().4s, \c1\().4s // cos1133 +.endif + fmul \o2\().4s, \o2\().4s, \t0\().4s // E m3[2,3].imre*t1[4,6] + fmla \o1\().4s, \t2\().4s, \t0\().4s // E w4567 + fsub \o2\().4s, \o2\().4s, \o3\().4s // E j4567 + + fsub \t0\().4s, \t1\().4s, \o0\().4s + fadd \o0\().4s, \t1\().4s, \o0\().4s + fadd \t2\().4s, \o2\().4s, \o1\().4s + fsub \t1\().4s, \o2\().4s, \o1\().4s + + fmul \t0\().4s, \t0\().4s, v31.4s + fmul \t1\().4s, \t1\().4s, v31.4s + + rev64 \t2\().4s, \t2\().4s + rev64 \o0\().4s, \o0\().4s + +.if \part == 0 + fsub \o1\().4s, \e1\().4s, \t2\().4s + fsub \o2\().4s, \e2\().4s, \t0\().4s + fsub \o3\().4s, \e3\().4s, \t1\().4s +.else + fadd \o2\().4s, \e1\().4s, \t0\().4s + fsub \o1\().4s, \e2\().4s, \t2\().4s + fadd \o3\().4s, \e3\().4s, \t1\().4s +.endif + +.if \part == 0 + fadd \e1\().4s, \e1\().4s, \t2\().4s + fadd \e2\().4s, \e2\().4s, \t0\().4s + fadd \e3\().4s, \e3\().4s, \t1\().4s +.else + fsub \e1\().4s, \e1\().4s, \t0\().4s // swapped + fadd \e2\().4s, \e2\().4s, \t2\().4s // swapped + fsub \e3\().4s, \e3\().4s, \t1\().4s +.endif + + mov \t1\().16b, \o0\().16b + + fsub \o0\().4s, \e0\().4s, \t1\().4s + fadd \e0\().4s, \e0\().4s, \t1\().4s +.endm + +.macro SR_COMBINE_4 len, part, off + add x10, x1, x21 + add x11, x1, x21, lsl #1 + add x12, x1, x22 + + ldp q0, q1, [x1, #((0 + \part)*32 + \off)] + ldp q4, q5, [x1, #((2 + \part)*32 + \off)] + ldp q2, q3, [x10, #((0 + \part)*32 + \off)] + ldp q6, q7, [x10, #((2 + \part)*32 + \off)] + + ldp q8, q9, [x11, #((0 + \part)*32 + \off)] + ldp q10, q11, [x11, #((2 + \part)*32 + \off)] + ldp q12, q13, [x12, #((0 + \part)*32 + \off)] + ldp q14, q15, [x12, #((2 + \part)*32 + \off)] + + SR_COMBINE v0, v1, v2, v3, v4, v6, v5, v7, \ + v8, v9, v10, v11, v12, v13, v14, v15, \ + x7, x8, x9, 0 + + stp q0, q1, [x1, #((0 + \part)*32 + \off)] + stp q4, q5, [x1, #((2 + \part)*32 + \off)] + stp q2, q3, [x10, #((0 + \part)*32 + \off)] + stp q6, q7, [x10, #((2 + \part)*32 + \off)] + + stp q8, q9, [x11, #((0 + \part)*32 + \off)] + stp q12, q13, [x11, #((2 + \part)*32 + \off)] + stp q10, q11, [x12, #((0 + \part)*32 + \off)] + stp q14, q15, [x12, #((2 + \part)*32 + \off)] +.endm + +.macro SR_COMBINE_FULL len, off=0 + add x10, x1, x21 + add x11, x1, x21, lsl #1 + add x12, x1, x22 + + SR_COMBINE_4 \len, 0, \off + SR_COMBINE_4 \len, 1, \off + SR_COMBINE_4 \len, 4, \off + SR_COMBINE_4 \len, 5, \off +.endm + +.macro SR_COMBINE_D2 part, off + add x10, x1, #((\part)*32 + \off) + add x11, x14, #((\part)*32 + \off) + add x12, x15, #((\part)*32 + \off) + add x13, x16, #((\part)*32 + \off) + + ldp q0, q1, [x10] + ldp q4, q5, [x10, #(2*32)] + ldp q2, q3, [x11] + ldp q6, q7, [x11, #(2*32)] + + ldp q8, q9, [x12] + ldp q10, q11, [x12, #(2*32)] + ldp q12, q13, [x13] + ldp q14, q15, [x13, #(2*32)] + + SR_COMBINE v0, v1, v2, v3, v4, v6, v5, v7, \ + v8, v9, v10, v11, v12, v13, v14, v15, \ + x7, x8, x9, 0, \ + v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27 + + zip1 v16.2d, v0.2d, v4.2d + zip2 v17.2d, v0.2d, v4.2d + zip1 v18.2d, v1.2d, v5.2d + zip2 v19.2d, v1.2d, v5.2d + + zip1 v20.2d, v2.2d, v6.2d + zip2 v21.2d, v2.2d, v6.2d + zip1 v22.2d, v3.2d, v7.2d + zip2 v23.2d, v3.2d, v7.2d + + ldp q0, q1, [x10, #(1*32)] + ldp q4, q5, [x10, #(3*32)] + ldp q2, q3, [x11, #(1*32)] + ldp q6, q7, [x11, #(3*32)] + + st1 { v16.4s, v17.4s, v18.4s, v19.4s }, [x10], #64 + st1 { v20.4s, v21.4s, v22.4s, v23.4s }, [x11], #64 + + zip1 v20.2d, v8.2d, v12.2d + zip2 v21.2d, v8.2d, v12.2d + zip1 v22.2d, v9.2d, v13.2d + zip2 v23.2d, v9.2d, v13.2d + zip1 v24.2d, v10.2d, v14.2d + zip2 v25.2d, v10.2d, v14.2d + zip1 v26.2d, v11.2d, v15.2d + zip2 v27.2d, v11.2d, v15.2d + + ldp q8, q9, [x12, #(1*32)] + ldp q10, q11, [x12, #(3*32)] + ldp q12, q13, [x13, #(1*32)] + ldp q14, q15, [x13, #(3*32)] + + st1 { v20.4s, v21.4s, v22.4s, v23.4s }, [x12], #64 + st1 { v24.4s, v25.4s, v26.4s, v27.4s }, [x13], #64 + + SR_COMBINE v0, v1, v2, v3, v4, v6, v5, v7, \ + v8, v9, v10, v11, v12, v13, v14, v15, \ + x7, x8, x9, 0, \ + v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27 + + zip1 v16.2d, v0.2d, v4.2d + zip2 v17.2d, v0.2d, v4.2d + zip1 v18.2d, v1.2d, v5.2d + zip2 v19.2d, v1.2d, v5.2d + st1 { v16.4s, v17.4s, v18.4s, v19.4s }, [x10] + + zip1 v16.2d, v2.2d, v6.2d + zip2 v17.2d, v2.2d, v6.2d + zip1 v18.2d, v3.2d, v7.2d + zip2 v19.2d, v3.2d, v7.2d + st1 { v16.4s, v17.4s, v18.4s, v19.4s }, [x11] + + zip1 v20.2d, v8.2d, v12.2d + zip2 v21.2d, v8.2d, v12.2d + zip1 v22.2d, v9.2d, v13.2d + zip2 v23.2d, v9.2d, v13.2d + st1 { v20.4s, v21.4s, v22.4s, v23.4s }, [x12] + + zip1 v24.2d, v10.2d, v14.2d + zip2 v25.2d, v10.2d, v14.2d + zip1 v26.2d, v11.2d, v15.2d + zip2 v27.2d, v11.2d, v15.2d + st1 { v24.4s, v25.4s, v26.4s, v27.4s }, [x13] +.endm + +.macro SR_COMBINE_DINT off=0 + add x14, x1, x21 + add x15, x1, x21, lsl #1 + add x16, x1, x22 + + SR_COMBINE_D2 0, \off + SR_COMBINE_D2 4, \off +.endm + +.macro FFT32_FN name, no_perm +function ff_tx_fft32_\name\()_neon, export=1 + stp d8, d9, [sp, #-16] + stp d10, d11, [sp, #-32] + stp d12, d13, [sp, #-48] + stp d14, d15, [sp, #-64] + + LOAD_SUBADD + SETUP_SR_RECOMB 32, x7, x8, x9 + + SETUP_LUT \no_perm + LOAD_INPUT 0, 1, 2, 3, x2, \no_perm + LOAD_INPUT 4, 5, 6, 7, x2, \no_perm + LOAD_INPUT 8, 9, 10, 11, x2, \no_perm + LOAD_INPUT 12, 13, 14, 15, x2, \no_perm + + FFT8_X2 v8, v9, v10, v11, v12, v13, v14, v15 + FFT16 v0, v1, v2, v3, v4, v5, v6, v7 + + SR_COMBINE v0, v1, v2, v3, v4, v5, v6, v7, \ + v8, v9, v10, v11, v12, v13, v14, v15, \ + x7, x8, x9, 0 + + zip1 v16.2d, v0.2d, v4.2d + zip2 v17.2d, v0.2d, v4.2d + zip1 v18.2d, v1.2d, v6.2d + zip2 v19.2d, v1.2d, v6.2d + st1 { v16.4s, v17.4s, v18.4s, v19.4s }, [x1], #64 + + zip1 v20.2d, v2.2d, v5.2d + zip2 v21.2d, v2.2d, v5.2d + zip1 v22.2d, v3.2d, v7.2d + zip2 v23.2d, v3.2d, v7.2d + st1 { v20.4s, v21.4s, v22.4s, v23.4s }, [x1], #64 + + zip1 v24.2d, v8.2d, v12.2d + zip2 v25.2d, v8.2d, v12.2d + zip1 v26.2d, v9.2d, v13.2d + zip2 v27.2d, v9.2d, v13.2d + st1 { v24.4s, v25.4s, v26.4s, v27.4s }, [x1], #64 + + zip1 v28.2d, v10.2d, v14.2d + zip2 v29.2d, v10.2d, v14.2d + zip1 v30.2d, v11.2d, v15.2d + zip2 v31.2d, v11.2d, v15.2d + st1 { v28.4s, v29.4s, v30.4s, v31.4s }, [x1] + + ldp d14, d15, [sp, #-64] + ldp d12, d13, [sp, #-48] + ldp d10, d11, [sp, #-32] + ldp d8, d9, [sp, #-16] + + ret +endfunc +.endm + +FFT32_FN float, 0 +FFT32_FN ns_float, 1 + +.macro cmp_imm reg, imm +.if \imm >= 4096 + cmp \reg, #((\imm)/4096), lsl #12 +.else + cmp \reg, #(\imm) +.endif +.endm + +.macro SR_TRANSFORM_DEF len, next=0 +\len: + stp x20, x30, [sp, #-16]! + mov w20, #(\len/4) + mov x5, #((\len*4) - (\len/1)) + add x1, x1, x5 + bl 32b + mov x5, #((\len*2) - (\len/2)) + add x1, x1, x5 + bl 32b + ldp x20, x30, [sp], #16 + ldr w5, =(\len*6 + \len/2) + sub x1, x1, x5 + + SETUP_SR_RECOMB \len, x7, x8, x9 + +.if \next\() != 0 + cmp_imm w19, \len + b.eq 0f + + mov w5, #(\len/128) +\len\()5: + SR_COMBINE_FULL \len + add x1, x1, 8*32 + subs w5, w5, 1 + b.gt \len\()5b + + cmp_imm w20, \len + b.gt \next\()f + ret +.endif +.endm + +.macro FFT_SPLIT_RADIX_FN name, no_perm +function ff_tx_fft_sr_\name\()_neon, export=1 + stp d8, d9, [sp, #-16]! + stp d10, d11, [sp, #-16]! + stp d12, d13, [sp, #-16]! + stp d14, d15, [sp, #-16]! + stp x19, x20, [sp, #-16]! + stp x21, x22, [sp, #-16]! + + ldr w19, [x0, #0] // global target + mov w20, w19 // local length + + LOAD_SUBADD + SETUP_LUT \no_perm + +32: + SETUP_SR_RECOMB 32, x7, x8, x9 + + LOAD_INPUT 0, 1, 2, 3, x2, \no_perm + LOAD_INPUT 4, 6, 5, 7, x2, \no_perm, 1 + LOAD_INPUT 8, 9, 10, 11, x2, \no_perm + LOAD_INPUT 12, 13, 14, 15, x2, \no_perm + + FFT8_X2 v8, v9, v10, v11, v12, v13, v14, v15 + FFT16 v0, v1, v2, v3, v4, v6, v5, v7 + + SR_COMBINE v0, v1, v2, v3, v4, v6, v5, v7, \ + v8, v9, v10, v11, v12, v13, v14, v15, \ + x7, x8, x9, 0 + + stp q2, q3, [x1, #32*1] + stp q6, q7, [x1, #32*3] + stp q10, q11, [x1, #32*5] + stp q14, q15, [x1, #32*7] + + cmp w20, #32 + b.gt 64f + + stp q0, q1, [x1, #32*0] + stp q4, q5, [x1, #32*2] + stp q8, q9, [x1, #32*4] + stp q12, q13, [x1, #32*6] + + ret +64: + SETUP_SR_RECOMB 64, x7, x8, x9 + + LOAD_INPUT 2, 3, 10, 11, x2, \no_perm, 1 + LOAD_INPUT 6, 14, 7, 15, x2, \no_perm, 1 + + FFT16 v2, v3, v10, v11, v6, v14, v7, v15 + + LOAD_INPUT 16, 17, 18, 19, x2, \no_perm + LOAD_INPUT 20, 22, 21, 23, x2, \no_perm, 1 + + FFT16 v16, v17, v18, v19, v20, v22, v21, v23, \ + v24, v25, v26, v27, v28, v29, v30 + + ld1 { v26.4s, v27.4s }, [x8], x9 + ldp q24, q25, [x7], #32 + + ext v26.16b, v26.16b, v26.16b, #8 + ext v27.16b, v27.16b, v27.16b, #8 + + cmp w19, #64 + b.eq 2f // custom deinterleave + + // TODO: investigate doing the 2 combines like in deinterleave + // TODO: experiment with spilling to gprs and converting to HALF or full + SR_COMBINE_LITE v0, v1, v8, v9, \ + v2, v3, v16, v17, \ + v24, v25, v26, v27, \ + v28, v29, v30, 0 + + stp q0, q1, [x1, #32* 0] + stp q8, q9, [x1, #32* 4] + stp q2, q3, [x1, #32* 8] + stp q16, q17, [x1, #32*12] + + SR_COMBINE_HALF v4, v5, v12, v13, \ + v6, v7, v20, v21, \ + v24, v25, v26, v27, \ + v28, v29, v30, v0, v1, v8, 1 + + stp q4, q20, [x1, #32* 2] + stp q12, q21, [x1, #32* 6] + stp q6, q5, [x1, #32*10] + stp q7, q13, [x1, #32*14] + + ldp q2, q3, [x1, #32*1] + ldp q6, q7, [x1, #32*3] + ldp q12, q13, [x1, #32*5] + ldp q16, q17, [x1, #32*7] + + SR_COMBINE v2, v3, v12, v13, v6, v16, v7, v17, \ + v10, v11, v14, v15, v18, v19, v22, v23, \ + x7, x8, x9, 0, \ + v24, v25, v26, v27, v28, v29, v30, v8, v0, v1, v4, v5 + + stp q2, q3, [x1, #32* 1] + stp q6, q7, [x1, #32* 3] + stp q12, q13, [x1, #32* 5] + stp q16, q17, [x1, #32* 7] + + stp q10, q11, [x1, #32* 9] + stp q18, q19, [x1, #32*11] + stp q14, q15, [x1, #32*13] + stp q22, q23, [x1, #32*15] + + cmp w20, #64 + b.gt 128f + ret +128: + stp x20, x30, [sp, #-16]! + mov w20, #32 + add x1, x1, #16*32 + bl 32b + add x1, x1, #8*32 + bl 32b + ldp x20, x30, [sp], #16 + sub x1, x1, #24*32 + + SETUP_SR_RECOMB 128, x7, x8, x9 + + cmp w19, #128 + b.eq 0f + + SR_COMBINE_FULL 128 + + cmp w20, #128 + b.gt 256f + ret +256: + stp x20, x30, [sp, #-16]! + mov w20, #64 + add x1, x1, #32*32 + bl 32b + add x1, x1, #16*32 + bl 32b + ldp x20, x30, [sp], #16 + sub x1, x1, #48*32 + + SETUP_SR_RECOMB 256, x7, x8, x9 + + cmp w19, #256 + b.eq 0f + + SR_COMBINE_FULL 256 + SR_COMBINE_FULL 256, 8*32 + + cmp w20, #256 + b.gt 512f + ret +512: + stp x20, x30, [sp, #-16]! + mov w20, #128 + add x1, x1, #64*32 + bl 32b + add x1, x1, #32*32 + bl 32b + ldp x20, x30, [sp], #16 + sub x1, x1, #96*32 + + SETUP_SR_RECOMB 512, x7, x8, x9 + + cmp w19, #512 + b.eq 0f + + mov x5, 4 +5125: + SR_COMBINE_FULL 512 + add x1, x1, 8*32 + subs w5, w5, 1 + b.gt 5125b + + cmp w20, #512 + b.gt 1024f + + ret +1024: + stp x20, x30, [sp, #-16]! + mov w20, #256 + add x1, x1, #96*32 + bl 32b + add x1, x1, #64*32 + bl 32b + ldp x20, x30, [sp], #16 + mov x5, #192*32 + sub x1, x1, x5 + + SETUP_SR_RECOMB 1024, x7, x8, x9 + + cmp w19, #1024 + b.eq 0f + + mov w5, 8 +10245: + SR_COMBINE_FULL 1024 + add x1, x1, 8*32 + subs w5, w5, 1 + b.gt 10245b + + cmp w20, #1024 + b.gt 2048f + + ret + +SR_TRANSFORM_DEF 2048, 4096 +SR_TRANSFORM_DEF 4096, 8192 +SR_TRANSFORM_DEF 8192, 16384 +SR_TRANSFORM_DEF 16384, 32768 +SR_TRANSFORM_DEF 32768, 65536 +SR_TRANSFORM_DEF 65536, 131072 +SR_TRANSFORM_DEF 131072 + +0: // general deinterleave loop + SR_COMBINE_DINT + add x1, x1, #32*8 + subs w19, w19, #32*4 + b.gt 0b + + ldp x21, x22, [sp], #16 + ldp x19, x20, [sp], #16 + ldp d14, d15, [sp], #16 + ldp d12, d13, [sp], #16 + ldp d10, d11, [sp], #16 + ldp d8, d9, [sp], #16 + + ret + +2: // special case for 64 point deinterleave + mov x10, v23.d[0] + mov x11, v23.d[1] + + SR_COMBINE_LITE v0, v1, v8, v9, \ + v2, v3, v16, v17, \ + v24, v25, v26, v27, \ + v28, v29, v30, 0 + + SR_COMBINE_HALF v4, v5, v12, v13, \ + v6, v7, v20, v21, \ + v24, v25, v26, v27, \ + v28, v29, v30, v23, v24, v26, 1 + + zip1 v23.2d, v0.2d, v4.2d + zip2 v24.2d, v0.2d, v4.2d + zip1 v25.2d, v1.2d, v20.2d + zip2 v26.2d, v1.2d, v20.2d + + zip1 v27.2d, v8.2d, v12.2d + zip2 v28.2d, v8.2d, v12.2d + zip1 v29.2d, v9.2d, v21.2d + zip2 v30.2d, v9.2d, v21.2d + + mov v20.16b, v5.16b + mov v21.16b, v7.16b + mov x12, x1 + add x13, x1, #32* 4 + add x14, x1, #32* 8 + add x15, x1, #32*12 + + zip1 v4.2d, v2.2d, v6.2d + zip2 v5.2d, v2.2d, v6.2d + zip1 v6.2d, v3.2d, v20.2d + zip2 v7.2d, v3.2d, v20.2d + + zip1 v0.2d, v16.2d, v21.2d + zip2 v1.2d, v16.2d, v21.2d + zip1 v2.2d, v17.2d, v13.2d + zip2 v3.2d, v17.2d, v13.2d + + // stp is faster by a little on A53, but this is faster on M1s (theory) + ldp q8, q9, [x1, #32*1] + ldp q12, q13, [x1, #32*5] + + st1 { v23.4s, v24.4s, v25.4s, v26.4s }, [x12], #64 // 32* 0...1 + st1 { v27.4s, v28.4s, v29.4s, v30.4s }, [x13], #64 // 32* 4...5 + st1 { v4.4s, v5.4s, v6.4s, v7.4s }, [x14], #64 // 32* 8...9 + st1 { v0.4s, v1.4s, v2.4s, v3.4s }, [x15], #64 // 32*12..13 + + mov v23.d[0], x10 + mov v23.d[1], x11 + + ldp q6, q7, [x1, #32*3] + ldp q16, q17, [x1, #32*7] + + SR_COMBINE v8, v9, v12, v13, v6, v16, v7, v17, \ + v10, v11, v14, v15, v18, v19, v22, v23, \ + x7, x8, x9, 0, \ + v24, v25, v26, v27, v28, v29, v30, v4, v0, v1, v5, v20 + + zip1 v0.2d, v8.2d, v6.2d + zip2 v1.2d, v8.2d, v6.2d + zip1 v2.2d, v9.2d, v7.2d + zip2 v3.2d, v9.2d, v7.2d + st1 { v0.4s, v1.4s, v2.4s, v3.4s }, [x12] + + zip1 v4.2d, v12.2d, v16.2d + zip2 v5.2d, v12.2d, v16.2d + zip1 v6.2d, v13.2d, v17.2d + zip2 v7.2d, v13.2d, v17.2d + st1 { v4.4s, v5.4s, v6.4s, v7.4s }, [x13] + + zip1 v0.2d, v10.2d, v18.2d + zip2 v1.2d, v10.2d, v18.2d + zip1 v2.2d, v11.2d, v19.2d + zip2 v3.2d, v11.2d, v19.2d + st1 { v0.4s, v1.4s, v2.4s, v3.4s }, [x14] + + zip1 v4.2d, v14.2d, v22.2d + zip2 v5.2d, v14.2d, v22.2d + zip1 v6.2d, v15.2d, v23.2d + zip2 v7.2d, v15.2d, v23.2d + st1 { v4.4s, v5.4s, v6.4s, v7.4s }, [x15] + + ldp x21, x22, [sp], #16 + ldp x19, x20, [sp], #16 + ldp d14, d15, [sp], #16 + ldp d12, d13, [sp], #16 + ldp d10, d11, [sp], #16 + ldp d8, d9, [sp], #16 + + ret +endfunc +.endm + +FFT_SPLIT_RADIX_FN float, 0 +FFT_SPLIT_RADIX_FN ns_float, 1 diff --git a/libavutil/tx.c b/libavutil/tx.c index c90ca509f5..28e49a5d41 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -457,6 +457,9 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, ff_tx_null_list, #if HAVE_X86ASM ff_tx_codelet_list_float_x86, +#endif +#if ARCH_AARCH64 + ff_tx_codelet_list_float_aarch64, #endif }; int codelet_list_num = FF_ARRAY_ELEMS(codelet_list); diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h index e6b0326cd9..e38490bd56 100644 --- a/libavutil/tx_priv.h +++ b/libavutil/tx_priv.h @@ -308,6 +308,7 @@ int ff_tx_mdct_gen_exp_int32 (AVTXContext *s, int *pre_tab); /* Lists of codelets */ extern const FFTXCodelet * const ff_tx_codelet_list_float_c []; extern const FFTXCodelet * const ff_tx_codelet_list_float_x86 []; +extern const FFTXCodelet * const ff_tx_codelet_list_float_aarch64 []; extern const FFTXCodelet * const ff_tx_codelet_list_double_c []; From 5bab794e4aaed55d3146723974ffb5ad792617ab Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 25 Aug 2022 14:11:54 -0300 Subject: [PATCH 023/590] avcodec/libaomenc: add init cleanup flag Signed-off-by: James Almer --- libavcodec/libaomenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 485f554165..fb9a6ff8b2 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -400,7 +400,7 @@ static av_cold int aom_free(AVCodecContext *avctx) #if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \ defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \ defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX) - if (!(avctx->flags & AV_CODEC_FLAG_PASS1)) { + if (ctx->encoder->iface && !(avctx->flags & AV_CODEC_FLAG_PASS1)) { int num_operating_points; int levels[32]; int target_levels[32]; @@ -1544,6 +1544,7 @@ FFCodec ff_libaom_av1_encoder = { FF_CODEC_ENCODE_CB(aom_encode), .close = aom_free, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .defaults = defaults, .init_static_data = av1_init_static, From 9f323cb04c30742e77e6aa95fe158d7dc5cad369 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 25 Aug 2022 14:22:35 -0300 Subject: [PATCH 024/590] avcodec/libaomenc: check return value of queue_frames() Signed-off-by: James Almer --- libavcodec/libaomenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index fb9a6ff8b2..a82b933c18 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1307,6 +1307,8 @@ static int aom_encode(AVCodecContext *avctx, AVPacket *pkt, return AVERROR_INVALIDDATA; } coded_size = queue_frames(avctx, pkt); + if (coded_size < 0) + return coded_size; if (!frame && avctx->flags & AV_CODEC_FLAG_PASS1) { size_t b64_size = AV_BASE64_SIZE(ctx->twopass_stats.sz); From adc38738cb47b4dfff50506514f33940273ba410 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 25 Aug 2022 16:25:55 -0300 Subject: [PATCH 025/590] avcodec/libaomenc: fix the check for presence of encoder interface ctx->encoder is not a pointer. Signed-off-by: James Almer --- libavcodec/libaomenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index a82b933c18..1e89b7e3a8 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -400,7 +400,7 @@ static av_cold int aom_free(AVCodecContext *avctx) #if defined(AOM_CTRL_AV1E_GET_NUM_OPERATING_POINTS) && \ defined(AOM_CTRL_AV1E_GET_SEQ_LEVEL_IDX) && \ defined(AOM_CTRL_AV1E_GET_TARGET_SEQ_LEVEL_IDX) - if (ctx->encoder->iface && !(avctx->flags & AV_CODEC_FLAG_PASS1)) { + if (ctx->encoder.iface && !(avctx->flags & AV_CODEC_FLAG_PASS1)) { int num_operating_points; int levels[32]; int target_levels[32]; From 61fa1e14e4178d3f2550c76f7a36484220f6dc0c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 23:00:29 +0200 Subject: [PATCH 026/590] avformat/imf_cpl: Check the right variable Fixes Coverity issue #1512407. Reviewed-by: Pierre-Anthony Lemieux Signed-off-by: Andreas Rheinhardt --- libavformat/imf_cpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 4acc20feee..474db6b7f5 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -625,7 +625,7 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) av_log(NULL, AV_LOG_DEBUG, "Processing IMF CPL Segment\n"); sequence_list_elem = ff_imf_xml_get_child_element_by_name(segment_elem, "SequenceList"); - if (!segment_list_elem) + if (!sequence_list_elem) continue; sequence_elem = xmlFirstElementChild(sequence_list_elem); From cc5a5c986047d38b53c0f12a227b04487624e7cb Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Fri, 19 Aug 2022 16:50:44 -0700 Subject: [PATCH 027/590] lavu/pixfmt: Introduce VUYX format This is the alphaless version of VUYA that I introduced recently. After further discussion and noting that the Intel vaapi driver explicitly lists XYUV as a support format for encoding and decoding 8bit 444 content, we decided to switch our usage and avoid the overhead of having a declared alpha channel around. Note that I am not removing VUYA, as this turned out to have another use, which was to replace the need for v408enc/dec when dealing with the format. The vaapi switching will happen in the next change --- doc/APIchanges | 3 +++ libavutil/pixdesc.c | 11 +++++++++++ libavutil/pixfmt.h | 2 ++ libavutil/tests/pixfmt_best.c | 1 + libavutil/version.h | 4 ++-- tests/ref/fate/imgutils | 1 + tests/ref/fate/pixfmt_best | 2 +- tests/ref/fate/sws-pixdesc-query | 3 +++ 8 files changed, 24 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4c0c9db628..1cd13d4ed3 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-08-03 - xxxxxxxxxx - lavu 57.34.100 - pixfmt.h + Add AV_PIX_FMT_VUYX. + 2022-08-xx - xxxxxxxxxx - lavf 59 - avformat.h Deprecate av_stream_get_end_pts() without replacement. diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index f7558ff8b9..79ebfd3f16 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2504,6 +2504,17 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_ALPHA, }, + [AV_PIX_FMT_VUYX] = { + .name = "vuyx", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 2, 0, 8 }, /* Y */ + { 0, 4, 1, 0, 8 }, /* U */ + { 0, 4, 0, 0, 8 }, /* V */ + }, + }, [AV_PIX_FMT_RGBAF16BE] = { .name = "rgbaf16be", .nb_components = 4, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 86c9bdefeb..7d45561395 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -372,6 +372,8 @@ enum AVPixelFormat { AV_PIX_FMT_RGBAF16BE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., big-endian AV_PIX_FMT_RGBAF16LE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., little-endian + AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/libavutil/tests/pixfmt_best.c b/libavutil/tests/pixfmt_best.c index de53baf092..0542af494f 100644 --- a/libavutil/tests/pixfmt_best.c +++ b/libavutil/tests/pixfmt_best.c @@ -84,6 +84,7 @@ int main(void) TEST(AV_PIX_FMT_GBRP, AV_PIX_FMT_RGB24); TEST(AV_PIX_FMT_0RGB, AV_PIX_FMT_RGB24); TEST(AV_PIX_FMT_GBRP16, AV_PIX_FMT_RGB48); + TEST(AV_PIX_FMT_VUYX, AV_PIX_FMT_YUV444P); // Formats additionally containing alpha (here ignored). TEST(AV_PIX_FMT_YA8, AV_PIX_FMT_GRAY8); diff --git a/libavutil/version.h b/libavutil/version.h index 05661922b3..5d0df781cc 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 33 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MINOR 34 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 01c9877de5..47b73b1b64 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -249,3 +249,4 @@ p416le planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 vuya planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 rgbaf16be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 rgbaf16le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 +vuyx planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 diff --git a/tests/ref/fate/pixfmt_best b/tests/ref/fate/pixfmt_best index 1da1846275..783c5fe640 100644 --- a/tests/ref/fate/pixfmt_best +++ b/tests/ref/fate/pixfmt_best @@ -1 +1 @@ -74 tests passed, 0 tests failed. +75 tests passed, 0 tests failed. diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index f79d99e513..f54372d364 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -219,6 +219,7 @@ isYUV: uyvy422 uyyvyy411 vuya + vuyx xyz12be xyz12le y210be @@ -753,6 +754,7 @@ Packed: uyvy422 uyyvyy411 vuya + vuyx x2bgr10be x2bgr10le x2rgb10be @@ -984,5 +986,6 @@ SwappedChroma: nv21 nv42 vuya + vuyx yvyu422 From 45726aa1177ee7d9d17435f879c96ab3537d8ad3 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Fri, 19 Aug 2022 16:53:37 -0700 Subject: [PATCH 028/590] libswscale: add support for VUYX format As we already have support for VUYA, I figured I should do the small amount of work to support VUYX as well. That means a little refactoring to share code. --- libswscale/input.c | 10 ++++--- libswscale/output.c | 35 +++++++++++++++++++++--- libswscale/utils.c | 1 + libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-vuyx | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 1 + tests/ref/fate/filter-pixfmts-il | 1 + tests/ref/fate/filter-pixfmts-null | 1 + tests/ref/fate/filter-pixfmts-pad | 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 16 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-vuyx diff --git a/libswscale/input.c b/libswscale/input.c index 1077d01e91..92681c9c53 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -659,7 +659,7 @@ static void read_ayuv64le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *u AV_WN16(dst + i * 2, AV_RL16(src + i * 8)); } -static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, +static void read_vuyx_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { int i; @@ -669,7 +669,7 @@ static void read_vuya_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, } } -static void read_vuya_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, +static void read_vuyx_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { int i; @@ -1375,7 +1375,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) break; #endif case AV_PIX_FMT_VUYA: - c->chrToYV12 = read_vuya_UV_c; + case AV_PIX_FMT_VUYX: + c->chrToYV12 = read_vuyx_UV_c; break; case AV_PIX_FMT_AYUV64LE: c->chrToYV12 = read_ayuv64le_UV_c; @@ -1752,7 +1753,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->lumToYV12 = read_ya16be_gray_c; break; case AV_PIX_FMT_VUYA: - c->lumToYV12 = read_vuya_Y_c; + case AV_PIX_FMT_VUYX: + c->lumToYV12 = read_vuyx_Y_c; break; case AV_PIX_FMT_AYUV64LE: c->lumToYV12 = read_ayuv64le_Y_c; diff --git a/libswscale/output.c b/libswscale/output.c index 74f992ae80..40a4476c6d 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2585,13 +2585,14 @@ yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, } static void -yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter, +yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, int dstW, int y) + const int16_t **alpSrc, uint8_t *dest, int dstW, int y, + int destHasAlpha) { - int hasAlpha = !!alpSrc; + int hasAlpha = destHasAlpha && (!!alpSrc); int i; for (i = 0; i < dstW; i++) { @@ -2634,10 +2635,33 @@ yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter, dest[4 * i ] = V; dest[4 * i + 1] = U; dest[4 * i + 2] = Y; - dest[4 * i + 3] = A; + if (destHasAlpha) + dest[4 * i + 3] = A; } } +static void +yuv2vuya_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + yuv2vuyX_X_c(c, lumFilter, lumSrc, lumFilterSize, chrFilter, + chrUSrc, chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 1); +} + +static void +yuv2vuyx_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + yuv2vuyX_X_c(c, lumFilter, lumSrc, lumFilterSize, chrFilter, + chrUSrc, chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 0); +} + av_cold void ff_sws_init_output_funcs(SwsContext *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, @@ -3143,5 +3167,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_VUYA: *yuv2packedX = yuv2vuya_X_c; break; + case AV_PIX_FMT_VUYX: + *yuv2packedX = yuv2vuyx_X_c; + break; } } diff --git a/libswscale/utils.c b/libswscale/utils.c index 9ef157c006..a621a35862 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -259,6 +259,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_P416LE] = { 1, 1 }, [AV_PIX_FMT_NV16] = { 1, 1 }, [AV_PIX_FMT_VUYA] = { 1, 1 }, + [AV_PIX_FMT_VUYX] = { 1, 1 }, [AV_PIX_FMT_RGBAF16BE] = { 1, 0 }, [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, }; diff --git a/libswscale/version.h b/libswscale/version.h index d8694bb5c0..17264b45da 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 103 +#define LIBSWSCALE_VERSION_MICRO 104 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/filter-pixdesc-vuyx b/tests/ref/fate/filter-pixdesc-vuyx new file mode 100644 index 0000000000..99871e05d0 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-vuyx @@ -0,0 +1 @@ +pixdesc-vuyx ebc83f9793eb4eddbb0a37fdcb67a33d diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 93dd611f97..371b94c62e 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -90,6 +90,7 @@ rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea rgba64le b91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d vuya 3d5e934651cae1ce334001cb1829ad22 +vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xyz12be a1ef56bf746d71f59669c28e48fc8450 diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 739b99713a..364e881aef 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -87,6 +87,7 @@ rgba 9488ac85abceaf99a9309eac5a87697e rgba64be 89910046972ab3c68e2a348302cc8ca9 rgba64le fea8ebfc869b52adf353778f29eac7a7 vuya 76578a705ff3a37559653c1289bd03dd +vuyx 5d2bae51a2f4892bd5f177f190cc323b x2bgr10le 84de725b85662c362862820dc4a309aa x2rgb10le f4265aca7a67dbfa9354370098ca6f33 xyz12be cb4571f9aaa7b59f999ef327276104b7 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index e08161bc0d..768b3f474a 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -90,6 +90,7 @@ rgba64be 23c8c0edaabe3eaec89ce69633fb0048 rgba64le dfdba4de4a7cac9abf08852666c341d3 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e vuya f72bcf29d75cd143d0c565f7cc49119a +vuyx 6257cd1ce11330660e9fa9c675acbdcc x2bgr10le dbe21538d7cb1744914f6bd46ec09b55 x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index de5c4fe59b..258c8563f0 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -81,6 +81,7 @@ rgba64be 5598f44514d122b9a57c5c92c20bbc61 rgba64le b34e6e30621ae579519a2d91a96a0acf uyvy422 75de70e31c435dde878002d3f22b238a vuya a3891d4168ff208948fd0b3ba0910495 +vuyx d7a900e970c9a69ed41f8b220114b9fa x2bgr10le 86474d84f26c5c51d6f75bf7e1de8da8 x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index b0f6754bbf..6fbc472a4e 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -87,6 +87,7 @@ rgba 51961c723ea6707e0a410cd3f21f15d3 rgba64be c910444019f4cfbf4d995227af55da8d rgba64le 0c810d8b3a6bca10321788e1cb145340 vuya 7e530261e7ac4eae4fd616fd7572d0b8 +vuyx 3ce9890363cad3984521293be1eb679c x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a x2rgb10le d4a8189b65395a88d0a38a7053f3359f xyz12be 25f90259ff8a226befdaec3dfe82996e diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 04efcb8a56..09748c2d08 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -89,6 +89,7 @@ rgba64be db70d33aa6c06f3e0a1c77bd11284261 rgba64le a8a2daae04374a27219bc1c890204007 uyvy422 d6ee3ca43356d08c392382b24b22cda5 vuya b9deab5ba249dd608b709c09255a4932 +vuyx 49cc92fcc002ec0f312017014dd68c0c x2bgr10le 135acaff8318cf9861bb0f7849a9e5e9 x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 93dd611f97..371b94c62e 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -90,6 +90,7 @@ rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea rgba64le b91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d vuya 3d5e934651cae1ce334001cb1829ad22 +vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xyz12be a1ef56bf746d71f59669c28e48fc8450 diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad index 0f00affdce..07aaea6b06 100644 --- a/tests/ref/fate/filter-pixfmts-pad +++ b/tests/ref/fate/filter-pixfmts-pad @@ -36,6 +36,7 @@ rgb0 0984eb985dabbe757ed6beb53db84eff rgb24 17f9e2e0c609009acaf2175c42d4a2a5 rgba b157c90191463d34fb3ce77b36c96386 vuya 44368c0a758ee68e24ce976e3b1b8535 +vuyx bc7c4f693a22cd1ac95e33d473086474 xyz12le 23dadbbba70b2925ce75fb8ba8080ba3 ya16le 8dbfcb586abf626da7d1aca887a581b9 ya8 495daaca2dcb4f7aeba7652768b41ced diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index f4822f5bae..e1bbe961e1 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -90,6 +90,7 @@ rgba64be ee73e57923af984b31cc7795d13929da rgba64le 783d2779adfafe3548bdb671ec0de69e uyvy422 aeb4ba4f9f003ae21f6d18089198244f vuya ffa817e283bf6a0b6fba21b07523ccaa +vuyx ba182200e20e0c82765eba15217848d3 x2bgr10le d57b9a99033cc7b65ddd111578f2d385 x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 xyz12be c7ba8345998c0141ddc079cdd29b1a40 diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index b3f2d5c5a0..0c2993d5b0 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -81,6 +81,7 @@ rgba 4d76a9542143752a4ac30f82f88f68f1 rgba64be a60041217f4c0cd796d19d3940a12a41 rgba64le ad47197774858858ae7b0c177dffa459 vuya 9ece18a345beb17cd19e09e443eca4bf +vuyx 4c2929cd1c6e5512f62e802f482f0ef2 x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 xyz12be 68e5cba640f6e4ef72dff950e88b5342 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 9081ce4f18..5cac61a9d2 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -90,6 +90,7 @@ rgba64be 17e6273323b5779b5f3f775f150c1011 rgba64le 48f45b10503b7dd140329c3dd0d54c98 uyvy422 3a237e8376264e0cfa78f8a3fdadec8a vuya fb849f76e56181e005c31fce75d7038c +vuyx 7a8079a97610e2c1c97aa8832b58a102 x2bgr10le 795b66a5fc83cd2cf300aae51c230f80 x2rgb10le 262c502230cf3724f8e2cf4737f18a42 xyz12be 810644e008deb231850d779aaa27cc7e From caf26a8a126d7b9853568ce0db2f6e04029fd1a2 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Fri, 19 Aug 2022 16:55:44 -0700 Subject: [PATCH 029/590] lavc/vaapi: Switch preferred 8bit 444 format to VUYX As vaapi doesn't actually do anything useful with the alpha channel, and we have an alphaless format available, let's use that instead. The changes here are mostly 1:1 switching, but do note the explicit change in the number of declared channels from 4 to 3 to reflect that the alpha is being ignored. --- libavcodec/vaapi_decode.c | 4 +++- libavcodec/vaapi_encode.c | 2 +- libavcodec/vaapi_encode_h265.c | 3 +-- libavcodec/vaapi_encode_vp9.c | 3 +-- libavcodec/version.h | 2 +- libavutil/hwcontext_vaapi.c | 7 ++++++- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index bc2d3ed803..8c13a4f098 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -267,7 +267,9 @@ static const struct { MAP(422V, YUV440P), // 4:4:4 MAP(444P, YUV444P), - MAP(AYUV, VUYA), +#ifdef VA_FOURCC_XYUV + MAP(XYUV, VUYX), +#endif // 4:2:0 10-bit #ifdef VA_FOURCC_P010 MAP(P010, P010), diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index f13daa5cff..2dc5c96f7b 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1308,7 +1308,7 @@ static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[] = { { "YUV422_10", VA_RT_FORMAT_YUV422_10, 10, 3, 1, 0 }, #endif { "YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, - { "AYUV", VA_RT_FORMAT_YUV444, 8, 4, 0, 0 }, + { "XYUV", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, { "YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 }, #if VA_CHECK_VERSION(0, 38, 1) { "YUV420_10", VA_RT_FORMAT_YUV420_10BPP, 10, 3, 1, 1 }, diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 1de323af78..967d71e998 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1278,8 +1278,7 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { #if VA_CHECK_VERSION(1, 2, 0) { FF_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 }, { FF_PROFILE_HEVC_REXT, 10, 3, 1, 0, VAProfileHEVCMain422_10 }, - // Four channels because this uses the AYUV format which has Alpha - { FF_PROFILE_HEVC_REXT, 8, 4, 0, 0, VAProfileHEVCMain444 }, + { FF_PROFILE_HEVC_REXT, 8, 3, 0, 0, VAProfileHEVCMain444 }, #endif { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 9b455e10c9..9530b2f462 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -228,8 +228,7 @@ static av_cold int vaapi_encode_vp9_configure(AVCodecContext *avctx) static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[] = { { FF_PROFILE_VP9_0, 8, 3, 1, 1, VAProfileVP9Profile0 }, - // Four channels because this uses the AYUV format which has Alpha - { FF_PROFILE_VP9_1, 8, 4, 0, 0, VAProfileVP9Profile1 }, + { FF_PROFILE_VP9_1, 8, 3, 0, 0, VAProfileVP9Profile1 }, { FF_PROFILE_VP9_2, 10, 3, 1, 1, VAProfileVP9Profile2 }, { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 12421666b9..d7d5fca6b2 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 42 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MICRO 103 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 2ee5145727..78205425ee 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -125,7 +125,9 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { MAP(411P, YUV411, YUV411P, 0), MAP(422V, YUV422, YUV440P, 0), MAP(444P, YUV444, YUV444P, 0), - MAP(AYUV, YUV444, VUYA, 0), +#ifdef VA_FOURCC_XYUV + MAP(XYUV, YUV444, VUYX, 0), +#endif MAP(Y800, YUV400, GRAY8, 0), #ifdef VA_FOURCC_P010 MAP(P010, YUV420_10BPP, P010, 0), @@ -1009,6 +1011,9 @@ static const struct { #endif DRM_MAP(ARGB, 1, DRM_FORMAT_BGRA8888), DRM_MAP(XRGB, 1, DRM_FORMAT_BGRX8888), +#if defined(VA_FOURCC_XYUV) && defined(DRM_FORMAT_XYUV8888) + DRM_MAP(XYUV, 1, DRM_FORMAT_XYUV8888), +#endif }; #undef DRM_MAP From d27c5bce333d6c9c74b855b1f2e747fd541cf37f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 22:55:05 +0200 Subject: [PATCH 030/590] avformat/tests/imf: Test ff_imf_parse_cpl_from_xml_dom cleanup on error Improves the test; also should fix Coverity issue #1512408. Reviewed-by: Pierre-Anthony Lemieux Signed-off-by: Andreas Rheinhardt --- libavformat/tests/imf.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index e65629ccbc..a71de692f9 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -338,10 +338,9 @@ static int test_cpl_parsing(void) return 0; } -static int test_bad_cpl_parsing(void) +static int test_bad_cpl_parsing(FFIMFCPL **cpl) { xmlDocPtr doc; - FFIMFCPL *cpl; int ret; doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0); @@ -350,7 +349,7 @@ static int test_bad_cpl_parsing(void) return 1; } - ret = ff_imf_parse_cpl_from_xml_dom(doc, &cpl); + ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); xmlFreeDoc(doc); if (ret) { printf("CPL parsing failed.\n"); @@ -506,6 +505,7 @@ static int test_path_type_functions(void) int main(int argc, char *argv[]) { + FFIMFCPL *cpl; int ret = 0; if (test_cpl_parsing() != 0) @@ -518,8 +518,12 @@ int main(int argc, char *argv[]) ret = 1; printf("#### The following should fail ####\n"); - if (test_bad_cpl_parsing() == 0) + if (test_bad_cpl_parsing(&cpl) == 0) { ret = 1; + } else if (cpl) { + printf("Improper cleanup after failed CPL parsing\n"); + ret = 1; + } printf("#### End failing test ####\n"); return ret; From e405298ebded794a4ad84222c56b6c0245530afc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 17:28:57 +0200 Subject: [PATCH 031/590] avcodec/tests/avcodec: Mark frame-thrd encoder incompatible with delay The API for frame-threaded encoders only works for one-in-one-out encoders. Signed-off-by: Andreas Rheinhardt --- libavcodec/tests/avcodec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/tests/avcodec.c b/libavcodec/tests/avcodec.c index 08b5fbede1..3288a85f64 100644 --- a/libavcodec/tests/avcodec.c +++ b/libavcodec/tests/avcodec.c @@ -155,6 +155,9 @@ int main(void){ if (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS && codec->capabilities & AV_CODEC_CAP_ENCODER_FLUSH) ERR("Frame-threaded encoder %s claims to support flushing\n"); + if (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS && + codec->capabilities & AV_CODEC_CAP_DELAY) + ERR("Frame-threaded encoder %s claims to have delay\n"); } else { if ((codec->type == AVMEDIA_TYPE_SUBTITLE) != (codec2->cb_type == FF_CODEC_CB_TYPE_DECODE_SUB)) ERR("Subtitle decoder %s does not implement decode_sub callback\n"); From 8e56e6b2be454b7f4f27110793bbf585649f111e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 17:56:31 +0200 Subject: [PATCH 032/590] avcodec/encode: Apply intra_only_flag for receive_packet-API, too Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index bd66f138a3..9f413095e4 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -240,7 +240,6 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { avpkt->dts = avpkt->pts; } - avpkt->flags |= avci->intra_only_flag; } if (avci->draining && !got_packet) @@ -301,6 +300,8 @@ static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt av_assert0(!avpkt->data || avpkt->buf); } else ret = encode_simple_receive_packet(avctx, avpkt); + if (ret >= 0) + avpkt->flags |= avci->intra_only_flag; if (ret == AVERROR_EOF) avci->draining_done = 1; From 18e55de45a4d0ea197eaeae3a3a9daea186159b9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 18:12:23 +0200 Subject: [PATCH 033/590] avcodec/aptx: Move AudioFrameQueue to aptxenc.c It is only used by the encoder. Signed-off-by: Andreas Rheinhardt --- libavcodec/aptx.c | 1 - libavcodec/aptx.h | 2 -- libavcodec/aptxenc.c | 32 ++++++++++++++++++++++++-------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c index f2604be60c..8e110acc97 100644 --- a/libavcodec/aptx.c +++ b/libavcodec/aptx.c @@ -534,6 +534,5 @@ av_cold int ff_aptx_init(AVCodecContext *avctx) } } - ff_af_queue_init(avctx, &s->afq); return 0; } diff --git a/libavcodec/aptx.h b/libavcodec/aptx.h index abb49e6faa..da0697e652 100644 --- a/libavcodec/aptx.h +++ b/libavcodec/aptx.h @@ -26,7 +26,6 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "mathops.h" -#include "audio_frame_queue.h" enum channels { @@ -95,7 +94,6 @@ typedef struct { int block_size; int32_t sync_idx; Channel channels[NB_CHANNELS]; - AudioFrameQueue afq; } AptXContext; typedef const struct { diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index 453146f154..2a0d8e06eb 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -24,9 +24,15 @@ #include "libavutil/channel_layout.h" #include "aptx.h" +#include "audio_frame_queue.h" #include "codec_internal.h" #include "encode.h" +typedef struct AptXEncContext { + AptXContext common; + AudioFrameQueue afq; +} AptXEncContext; + /* * Half-band QMF analysis filter realized with a polyphase FIR filter. * Split into 2 subbands and downsample by 2. @@ -212,10 +218,11 @@ static void aptx_encode_samples(AptXContext *ctx, static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { - AptXContext *s = avctx->priv_data; + AptXEncContext *const s0 = avctx->priv_data; + AptXContext *const s = &s0->common; int pos, ipos, channel, sample, output_size, ret; - if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) + if ((ret = ff_af_queue_add(&s0->afq, frame)) < 0) return ret; output_size = s->block_size * frame->nb_samples/4; @@ -232,18 +239,27 @@ static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, aptx_encode_samples(s, samples, avpkt->data + pos); } - ff_af_queue_remove(&s->afq, frame->nb_samples, &avpkt->pts, &avpkt->duration); + ff_af_queue_remove(&s0->afq, frame->nb_samples, &avpkt->pts, &avpkt->duration); *got_packet_ptr = 1; return 0; } static av_cold int aptx_close(AVCodecContext *avctx) { - AptXContext *s = avctx->priv_data; + AptXEncContext *const s = avctx->priv_data; ff_af_queue_close(&s->afq); return 0; } +static av_cold int aptx_encode_init(AVCodecContext *avctx) +{ + AptXEncContext *const s = avctx->priv_data; + + ff_af_queue_init(avctx, &s->afq); + + return ff_aptx_init(avctx); +} + #if CONFIG_APTX_ENCODER const FFCodec ff_aptx_encoder = { .p.name = "aptx", @@ -251,8 +267,8 @@ const FFCodec ff_aptx_encoder = { .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, - .priv_data_size = sizeof(AptXContext), - .init = ff_aptx_init, + .priv_data_size = sizeof(AptXEncContext), + .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), .close = aptx_close, #if FF_API_OLD_CHANNEL_LAYOUT @@ -272,8 +288,8 @@ const FFCodec ff_aptx_hd_encoder = { .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX_HD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, - .priv_data_size = sizeof(AptXContext), - .init = ff_aptx_init, + .priv_data_size = sizeof(AptXEncContext), + .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), .close = aptx_close, #if FF_API_OLD_CHANNEL_LAYOUT From 312d4467f379d34257f60aeb7ad88fb29b11caeb Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 19:48:58 +0200 Subject: [PATCH 034/590] avcodec/encode: Simplify check for frame-threaded encoder AVCodecInternal.frame_thread_encoder is only set iff active_thread_type is FF_THREAD_FRAME. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 9f413095e4..01b59bbf70 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -192,7 +192,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) if (!frame->buf[0]) { if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY || - (avci->frame_thread_encoder && avctx->active_thread_type & FF_THREAD_FRAME))) + avci->frame_thread_encoder)) return AVERROR_EOF; // Flushing is signaled with a NULL frame @@ -203,8 +203,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE); - if (CONFIG_FRAME_THREAD_ENCODER && - avci->frame_thread_encoder && (avctx->active_thread_type & FF_THREAD_FRAME)) + if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder) /* This might modify frame, but it doesn't matter, because * the frame properties used below are not used for video * (due to the delay inherent in frame threaded encoding, it makes From 4dddcd08c47850fbf3cef2ff6b31f65133856e0f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 22:38:24 +0200 Subject: [PATCH 035/590] avcodec/frame_thread_encoder: Forward got_packet directly Instead of indicating whether we got a packet by setting pkt->data and pkt->size to zero. Signed-off-by: Andreas Rheinhardt --- libavcodec/frame_thread_encoder.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 07d310a986..b5765b6343 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -45,6 +45,7 @@ typedef struct{ AVPacket *outdata; int return_code; int finished; + int got_packet; } Task; typedef struct{ @@ -110,10 +111,8 @@ static void * attribute_align_arg worker(void *v){ if (ret >= 0 && ret2 < 0) ret = ret2; pkt->pts = pkt->dts = frame->pts; - } else { - pkt->data = NULL; - pkt->size = 0; } + task->got_packet = got_packet; pthread_mutex_lock(&c->buffer_mutex); av_frame_unref(frame); pthread_mutex_unlock(&c->buffer_mutex); @@ -315,8 +314,7 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, * because there is no outstanding task with this index. */ outtask->finished = 0; av_packet_move_ref(pkt, outtask->outdata); - if(pkt->data) - *got_packet_ptr = 1; + *got_packet_ptr = outtask->got_packet; c->finished_task_index = (c->finished_task_index + 1) % c->max_tasks; return outtask->return_code; From 1e6307f46c486d17f670043672d49335ea1bae97 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 23:26:57 +0200 Subject: [PATCH 036/590] avcodec/encode, frame_thread_encoder: Unify calling encode callback The encode-callback (the callback used by the FF_CODEC_CB_TYPE_ENCODE encoders) is currently called in two places: encode_simple_internal() and by the worker threads of frame-threaded encoders. After the call, some packet properties are set based upon the corresponding AVFrame properties and the packet is made refcounted if it isn't already. So there is some code duplication. There was also non-duplicated code in encode_simple_internal() which is executed even when using frame-threading. This included an emms_c() (which is needed for frame-threading, too, if it is needed for the single-threaded case, because there are allocations (via av_packet_make_refcounted()) immediately after returning from the encode-callback). Furthermore, some further properties are only set in encode_simple_internal(): For audio, pts and duration are derived from the corresponding fields of the frame if the encoder does not have the AV_CODEC_CAP_DELAY set. Yet this is wrong for frame-threaded encoders, because frame-threading always introduces delay regardless of whether the underlying codec has said cap. This only worked because there are no frame-threaded audio encoders. This commit fixes the code duplication and the above issue by factoring this code out and reusing it in both places. It would work in case of audio codecs with frame-threading, because now the values are derived from the correct AVFrame. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 86 ++++++++++++++++--------------- libavcodec/encode.h | 3 ++ libavcodec/frame_thread_encoder.c | 15 ++---- 3 files changed, 50 insertions(+), 54 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 01b59bbf70..f7b13c8ba1 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -172,6 +172,48 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame) return 0; } +int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet) +{ + const FFCodec *const codec = ffcodec(avctx->codec); + int ret; + + ret = codec->cb.encode(avctx, avpkt, frame, got_packet); + emms_c(); + av_assert0(ret <= 0); + + if (!ret && *got_packet) { + if (avpkt->data) { + ret = av_packet_make_refcounted(avpkt); + if (ret < 0) + goto unref; + // Date returned by encoders must always be ref-counted + av_assert0(avpkt->buf); + } + + if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && + !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) + avpkt->pts = avpkt->dts = frame->pts; + if (frame && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { + if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { + if (avpkt->pts == AV_NOPTS_VALUE) + avpkt->pts = frame->pts; + if (!avpkt->duration) + avpkt->duration = ff_samples_to_time_base(avctx, + frame->nb_samples); + } + } + if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { + avpkt->dts = avpkt->pts; + } + } else { +unref: + av_packet_unref(avpkt); + } + + return ret; +} + static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) { AVCodecInternal *avci = avctx->internal; @@ -204,58 +246,18 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE); if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder) - /* This might modify frame, but it doesn't matter, because - * the frame properties used below are not used for video - * (due to the delay inherent in frame threaded encoding, it makes - * no sense to use the properties of the current frame anyway). */ + /* This might unref frame. */ ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet); else { - ret = codec->cb.encode(avctx, avpkt, frame, &got_packet); - if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && !ret && got_packet && - !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) - avpkt->pts = avpkt->dts = frame->pts; - } - - av_assert0(ret <= 0); - - emms_c(); - - if (!ret && got_packet) { - if (avpkt->data) { - ret = av_packet_make_refcounted(avpkt); - if (ret < 0) - goto end; - } - - if (frame && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { - if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { - if (avpkt->pts == AV_NOPTS_VALUE) - avpkt->pts = frame->pts; - if (!avpkt->duration) - avpkt->duration = ff_samples_to_time_base(avctx, - frame->nb_samples); - } - } - if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { - avpkt->dts = avpkt->pts; - } + ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet); } if (avci->draining && !got_packet) avci->draining_done = 1; -end: - if (ret < 0 || !got_packet) - av_packet_unref(avpkt); - if (frame) av_frame_unref(frame); - if (got_packet) - // Encoders must always return ref-counted buffers. - // Side-data only packets have no data and can be not ref-counted. - av_assert0(!avpkt->data || avpkt->buf); - return ret; } diff --git a/libavcodec/encode.h b/libavcodec/encode.h index bc77918d8f..10c36435ad 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -75,4 +75,7 @@ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); */ int ff_encode_preinit(AVCodecContext *avctx); +int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet); + #endif /* AVCODEC_ENCODE_H */ diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index b5765b6343..1faaef522e 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -24,14 +24,12 @@ #include "libavutil/avassert.h" #include "libavutil/cpu.h" -#include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/thread.h" #include "avcodec.h" -#include "codec_internal.h" +#include "encode.h" #include "internal.h" #include "pthread_internal.h" -#include "thread.h" #define MAX_THREADS 64 /* There can be as many as MAX_THREADS + 1 outstanding tasks. @@ -80,7 +78,7 @@ static void * attribute_align_arg worker(void *v){ ThreadContext *c = avctx->internal->frame_thread_encoder; while (!atomic_load(&c->exit)) { - int got_packet = 0, ret; + int ret; AVPacket *pkt; AVFrame *frame; Task *task; @@ -105,14 +103,7 @@ static void * attribute_align_arg worker(void *v){ frame = task->indata; pkt = task->outdata; - ret = ffcodec(avctx->codec)->cb.encode(avctx, pkt, frame, &got_packet); - if(got_packet) { - int ret2 = av_packet_make_refcounted(pkt); - if (ret >= 0 && ret2 < 0) - ret = ret2; - pkt->pts = pkt->dts = frame->pts; - } - task->got_packet = got_packet; + ret = ff_encode_encode_cb(avctx, pkt, frame, &task->got_packet); pthread_mutex_lock(&c->buffer_mutex); av_frame_unref(frame); pthread_mutex_unlock(&c->buffer_mutex); From 52dcf0e0f56b4a696ba134221c03facdc166c7fc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 23 Aug 2022 21:16:00 +0200 Subject: [PATCH 037/590] avcodec/encode: Remove redundant check frame is always set at this point for no-delay encoders. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index f7b13c8ba1..f66e2f9ba8 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -194,7 +194,7 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) avpkt->pts = avpkt->dts = frame->pts; - if (frame && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) { if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { if (avpkt->pts == AV_NOPTS_VALUE) avpkt->pts = frame->pts; From 7360e97e4beec13ef5aa87657490d8f272be9f26 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 00:33:40 +0200 Subject: [PATCH 038/590] avcodec/(dca|tta|pcm-bluray|pcm-dvd|wavpack)enc: Set pts+dur generically Signed-off-by: Andreas Rheinhardt --- libavcodec/dcaenc.c | 4 ---- libavcodec/pcm-blurayenc.c | 3 --- libavcodec/pcm-dvdenc.c | 3 --- libavcodec/ttaenc.c | 3 --- libavcodec/wavpackenc.c | 3 --- 5 files changed, 16 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 2481c4d3ec..6901e67860 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -39,8 +39,6 @@ #include "dcaenc.h" #include "encode.h" #include "fft.h" -#include "internal.h" -#include "mathops.h" #include "put_bits.h" #define MAX_CHANNELS 6 @@ -1215,8 +1213,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, flush_put_bits(&c->pb); memset(put_bits_ptr(&c->pb), 0, put_bytes_left(&c->pb, 0)); - avpkt->pts = frame->pts; - avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; return 0; } diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c index 6a5cdb2dcd..6543bc2213 100644 --- a/libavcodec/pcm-blurayenc.c +++ b/libavcodec/pcm-blurayenc.c @@ -23,7 +23,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" typedef struct BlurayPCMEncContext { uint16_t header; // Header added to every frame @@ -266,8 +265,6 @@ static int pcm_bluray_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return AVERROR_BUG; } - avpkt->pts = frame->pts; - avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; return 0; diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index a7023d148f..4bc635ab1f 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -24,7 +24,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" typedef struct PCMDVDContext { uint8_t header[3]; // Header added to every frame @@ -167,8 +166,6 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, break; } - avpkt->pts = frame->pts; - avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; return 0; diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c index 25113d4a72..6a8c2b122d 100644 --- a/libavcodec/ttaenc.c +++ b/libavcodec/ttaenc.c @@ -25,7 +25,6 @@ #include "codec_internal.h" #include "encode.h" #include "put_bits.h" -#include "internal.h" #include "libavutil/crc.h" typedef struct TTAEncContext { @@ -188,9 +187,7 @@ static int tta_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, put_bits32(&pb, av_crc(s->crc_table, UINT32_MAX, avpkt->data, out_bytes) ^ UINT32_MAX); flush_put_bits(&pb); - avpkt->pts = frame->pts; avpkt->size = out_bytes + 4; - avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; return 0; } diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c index 7f7ed804ee..07dfb22bbd 100644 --- a/libavcodec/wavpackenc.c +++ b/libavcodec/wavpackenc.c @@ -26,7 +26,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "put_bits.h" #include "bytestream.h" #include "wavpackenc.h" @@ -2905,9 +2904,7 @@ static int wavpack_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } s->sample_index += frame->nb_samples; - avpkt->pts = frame->pts; avpkt->size = buf - avpkt->data; - avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; return 0; } From a499b4345b2dbc731d6c24aa6a9b319d4c3a0d4c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 11 May 2021 20:52:13 +0200 Subject: [PATCH 039/590] avcodec: Make ff_alloc_packet() based encoders accept user buffers Up until now, these encoders received non-refcounted packets (whose data was owned by the corresponding AVCodecContext) from ff_alloc_packet(); these packets were made refcounted lateron by av_packet_make_refcounted() generically. This commit makes these encoders accept user-supplied buffers by replacing av_packet_make_refcounted() with an equivalent function that is based upon get_encode_buffer(). (I am pretty certain that one can also set the flag for mpegvideo- based encoders, but I want to double-check this later. What is certain is that it reallocates the buffer owned by the AVCodecContext which should maybe be moved to encode.c, so that proresenc_kostya.c and ttaenc.c can make use of it, too.) Signed-off-by: Andreas Rheinhardt --- libavcodec/aacenc.c | 3 ++- libavcodec/alacenc.c | 2 +- libavcodec/aliaspixenc.c | 1 + libavcodec/asvenc.c | 2 ++ libavcodec/cfhdenc.c | 2 +- libavcodec/cinepakenc.c | 1 + libavcodec/encode.c | 19 ++++++++++++++++++- libavcodec/ffv1enc.c | 3 ++- libavcodec/flashsv2enc.c | 1 + libavcodec/flashsvenc.c | 1 + libavcodec/gif.c | 1 + libavcodec/hapenc.c | 2 +- libavcodec/huffyuvenc.c | 4 ++-- libavcodec/j2kenc.c | 1 + libavcodec/lclenc.c | 2 +- libavcodec/libfdk-aacenc.c | 3 ++- libavcodec/libilbc.c | 1 + libavcodec/libopencore-amr.c | 3 ++- libavcodec/libopusenc.c | 3 ++- libavcodec/libspeexenc.c | 2 +- libavcodec/libtwolame.c | 2 +- libavcodec/libvo-amrwbenc.c | 1 + libavcodec/libxvid.c | 1 + libavcodec/ljpegenc.c | 2 +- libavcodec/magicyuvenc.c | 2 +- libavcodec/mlpenc.c | 7 +++++-- libavcodec/mpegaudioenc_fixed.c | 1 + libavcodec/mpegaudioenc_float.c | 1 + libavcodec/opusenc.c | 3 ++- libavcodec/pcxenc.c | 1 + libavcodec/pngenc.c | 2 +- libavcodec/proresenc_anatoliy.c | 4 ++-- libavcodec/qoienc.c | 2 +- libavcodec/qtrleenc.c | 1 + libavcodec/roqvideoenc.c | 1 + libavcodec/rpzaenc.c | 1 + libavcodec/sgienc.c | 1 + libavcodec/smcenc.c | 1 + libavcodec/snowenc.c | 1 + libavcodec/sonic.c | 4 ++-- libavcodec/sunrastenc.c | 1 + libavcodec/svq1enc.c | 1 + libavcodec/targaenc.c | 1 + libavcodec/tiffenc.c | 2 +- libavcodec/ttaenc.c | 2 +- libavcodec/utvideoenc.c | 2 +- libavcodec/vorbisenc.c | 3 ++- libavcodec/wavpackenc.c | 2 +- libavcodec/wmaenc.c | 2 ++ libavcodec/xbmenc.c | 1 + 50 files changed, 83 insertions(+), 30 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 4f51485fc4..a0e5d2942e 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -1417,6 +1417,8 @@ const FFCodec ff_aac_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(AACEncContext), .init = aac_encode_init, FF_CODEC_ENCODE_CB(aac_encode_frame), @@ -1424,7 +1426,6 @@ const FFCodec ff_aac_encoder = { .defaults = aac_encode_defaults, .p.supported_samplerates = ff_mpeg4audio_sample_rates, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, - .p.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .p.priv_class = &aacenc_class, diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 10dab0a67c..20711d242f 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -654,12 +654,12 @@ const FFCodec ff_alac_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ALAC, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(AlacEncodeContext), .p.priv_class = &alacenc_class, .init = alac_encode_init, FF_CODEC_ENCODE_CB(alac_encode_frame), .close = alac_encode_close, - .p.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, #if FF_API_OLD_CHANNEL_LAYOUT .p.channel_layouts = alac_channel_layouts, #endif diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c index 9c43cfa9e7..ec1cba9a57 100644 --- a/libavcodec/aliaspixenc.c +++ b/libavcodec/aliaspixenc.c @@ -106,6 +106,7 @@ const FFCodec ff_alias_pix_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ALIAS_PIX, + .p.capabilities = AV_CODEC_CAP_DR1, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index 8b94868c93..4f14cbdb64 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -348,6 +348,7 @@ const FFCodec ff_asv1_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("ASUS V1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV1, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(ASV1Context), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), @@ -362,6 +363,7 @@ const FFCodec ff_asv2_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("ASUS V2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV2, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(ASV1Context), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index c2f42c14dd..75858624b4 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -851,12 +851,12 @@ const FFCodec ff_cfhd_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("GoPro CineForm HD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CFHD, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(CFHDEncContext), .p.priv_class = &cfhd_class, .init = cfhd_encode_init, .close = cfhd_encode_close, FF_CODEC_ENCODE_CB(cfhd_encode_frame), - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV422P10, AV_PIX_FMT_GBRP12, diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c index 5e59af1235..bff6833ceb 100644 --- a/libavcodec/cinepakenc.c +++ b/libavcodec/cinepakenc.c @@ -1219,6 +1219,7 @@ const FFCodec ff_cinepak_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Cinepak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CINEPAK, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(CinepakEncContext), .init = cinepak_encode_init, FF_CODEC_ENCODE_CB(cinepak_encode_frame), diff --git a/libavcodec/encode.c b/libavcodec/encode.c index f66e2f9ba8..2c02b24cf2 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -107,6 +107,23 @@ int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, i return ret; } +static int encode_make_refcounted(AVCodecContext *avctx, AVPacket *avpkt) +{ + uint8_t *data = avpkt->data; + int ret; + + if (avpkt->buf) + return 0; + + avpkt->data = NULL; + ret = ff_get_encode_buffer(avctx, avpkt, avpkt->size, 0); + if (ret < 0) + return ret; + memcpy(avpkt->data, data, avpkt->size); + + return 0; +} + /** * Pad last frame with silence. */ @@ -184,7 +201,7 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, if (!ret && *got_packet) { if (avpkt->data) { - ret = av_packet_make_refcounted(avpkt); + ret = encode_make_refcounted(avctx, avpkt); if (ret < 0) goto unref; // Date returned by encoders must always be ref-counted diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index b939871664..422bc1d231 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1271,11 +1271,12 @@ const FFCodec ff_ffv1_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFV1, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SLICE_THREADS, .priv_data_size = sizeof(FFV1Context), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .close = ff_ffv1_close, - .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_DELAY, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV411P, diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index b2a15fd491..a924092c52 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -915,6 +915,7 @@ const FFCodec ff_flashsv2_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video Version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV2, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(FlashSV2Context), .init = flashsv2_encode_init, FF_CODEC_ENCODE_CB(flashsv2_encode_frame), diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 30c4e43154..e6c9f640ae 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -261,6 +261,7 @@ const FFCodec ff_flashsv_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(FlashSVContext), .init = flashsv_encode_init, FF_CODEC_ENCODE_CB(flashsv_encode_frame), diff --git a/libavcodec/gif.c b/libavcodec/gif.c index a0406f5544..6adbf880ae 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -553,6 +553,7 @@ const FFCodec ff_gif_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_GIF, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(GIFContext), .init = gif_encode_init, FF_CODEC_ENCODE_CB(gif_encode_frame), diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c index 3dca25b74d..fc533164c4 100644 --- a/libavcodec/hapenc.c +++ b/libavcodec/hapenc.c @@ -351,9 +351,9 @@ const FFCodec ff_hap_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HAP, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, .priv_data_size = sizeof(HapContext), .p.priv_class = &hapenc_class, - .p.capabilities = AV_CODEC_CAP_SLICE_THREADS, .init = hap_init, FF_CODEC_ENCODE_CB(hap_encode), .close = hap_close, diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index c585d007b4..9e4a1ddfba 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1054,11 +1054,11 @@ const FFCodec ff_huffyuv_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HUFFYUV, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(HYuvContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .close = encode_end, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.priv_class = &normal_class, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P, AV_PIX_FMT_RGB24, @@ -1073,11 +1073,11 @@ const FFCodec ff_ffvhuff_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFVHUFF, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(HYuvContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .close = encode_end, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.priv_class = &ff_class, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV411P, diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 5ef7f24b6d..5e6872080c 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -1835,6 +1835,7 @@ const FFCodec ff_jpeg2000_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEG2000, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(Jpeg2000EncoderContext), .init = j2kenc_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c index f08cec11f5..cbe336155e 100644 --- a/libavcodec/lclenc.c +++ b/libavcodec/lclenc.c @@ -156,11 +156,11 @@ const FFCodec ff_zlib_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZLIB, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(LclEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .close = encode_end, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index 2ffbc180ba..f53f5e97a9 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -480,12 +480,13 @@ const FFCodec ff_libfdk_aac_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Fraunhofer FDK AAC"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(AACContext), .init = aac_encode_init, FF_CODEC_ENCODE_CB(aac_encode_frame), .close = aac_encode_close, - .p.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .p.priv_class = &aac_enc_class, diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c index 0b6b1fbb24..250c5fde5b 100644 --- a/libavcodec/libilbc.c +++ b/libavcodec/libilbc.c @@ -205,6 +205,7 @@ const FFCodec ff_libilbc_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ILBC, + .p.capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(ILBCEncContext), .init = ilbc_encode_init, diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index 014dd53fa5..46c8516010 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -294,12 +294,13 @@ const FFCodec ff_libopencore_amrnb_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("OpenCORE AMR-NB (Adaptive Multi-Rate Narrow-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_NB, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(AMRContext), .init = amr_nb_encode_init, FF_CODEC_ENCODE_CB(amr_nb_encode_frame), .close = amr_nb_encode_close, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .p.priv_class = &amrnb_class, diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index b8ab184109..dd4c5f3e8d 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -588,12 +588,13 @@ const FFCodec ff_libopus_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("libopus Opus"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_OPUS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(LibopusEncContext), .init = libopus_encode_init, FF_CODEC_ENCODE_CB(libopus_encode), .close = libopus_encode_close, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 9eab8f8af0..411d9f0290 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -353,12 +353,12 @@ const FFCodec ff_libspeex_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SPEEX, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(LibSpeexEncContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), .close = encode_close, - .p.capabilities = AV_CODEC_CAP_DELAY, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, #if FF_API_OLD_CHANNEL_LAYOUT diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c index 98df38d013..9929248485 100644 --- a/libavcodec/libtwolame.c +++ b/libavcodec/libtwolame.c @@ -214,12 +214,12 @@ const FFCodec ff_libtwolame_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("libtwolame MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, .priv_data_size = sizeof(TWOLAMEContext), .init = twolame_encode_init, FF_CODEC_ENCODE_CB(twolame_encode_frame), .close = twolame_encode_close, - .p.capabilities = AV_CODEC_CAP_DELAY, .defaults = twolame_defaults, .p.priv_class = &twolame_class, .p.sample_fmts = (const enum AVSampleFormat[]) { diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index e58c980b5c..3c94bcba32 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -146,6 +146,7 @@ const FFCodec ff_libvo_amrwbenc_encoder = { "(Adaptive Multi-Rate Wide-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_WB, + .p.capabilities = AV_CODEC_CAP_DR1, .p.priv_class = &amrwb_class, .p.wrapper_name = "libvo_amrwbenc", .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index fb08d0991e..aed8699fe1 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -902,6 +902,7 @@ const FFCodec ff_libxvid_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG4, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(struct xvid_context), .init = xvid_encode_init, FF_CODEC_ENCODE_CB(xvid_encode_frame), diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 26f42a2db6..7aab915d01 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -328,12 +328,12 @@ const FFCodec ff_ljpeg_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_LJPEG, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(LJpegEncContext), .p.priv_class = &ljpeg_class, .init = ljpeg_encode_init, FF_CODEC_ENCODE_CB(ljpeg_encode_frame), .close = ljpeg_encode_close, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_BGR24 , AV_PIX_FMT_BGRA , AV_PIX_FMT_BGR0, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index 7d77ef7bba..b2846948e6 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -569,12 +569,12 @@ const FFCodec ff_magicyuv_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MAGICYUV, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(MagicYUVContext), .p.priv_class = &magicyuv_class, .init = magy_encode_init, .close = magy_encode_close, FF_CODEC_ENCODE_CB(magy_encode_frame), - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_GRAY8, diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index c25f48fabe..c986a0395f 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -2213,11 +2213,12 @@ const FFCodec ff_mlp_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MLP, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_EXPERIMENTAL, .priv_data_size = sizeof(MLPEncodeContext), .init = mlp_encode_init, FF_CODEC_ENCODE_CB(mlp_encode_frame), .close = mlp_encode_close, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL, .p.sample_fmts = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .p.supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, #if FF_API_OLD_CHANNEL_LAYOUT @@ -2233,11 +2234,13 @@ const FFCodec ff_truehd_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("TrueHD"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TRUEHD, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME | + AV_CODEC_CAP_EXPERIMENTAL, .priv_data_size = sizeof(MLPEncodeContext), .init = mlp_encode_init, FF_CODEC_ENCODE_CB(mlp_encode_frame), .close = mlp_encode_close, - .p.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL, .p.sample_fmts = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .p.supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, #if FF_API_OLD_CHANNEL_LAYOUT diff --git a/libavcodec/mpegaudioenc_fixed.c b/libavcodec/mpegaudioenc_fixed.c index 0176011f26..1191bbc752 100644 --- a/libavcodec/mpegaudioenc_fixed.c +++ b/libavcodec/mpegaudioenc_fixed.c @@ -28,6 +28,7 @@ const FFCodec ff_mp2fixed_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("MP2 fixed point (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(MpegAudioContext), .init = MPA_encode_init, FF_CODEC_ENCODE_CB(MPA_encode_frame), diff --git a/libavcodec/mpegaudioenc_float.c b/libavcodec/mpegaudioenc_float.c index 2bcad42e23..6a5bc59bf3 100644 --- a/libavcodec/mpegaudioenc_float.c +++ b/libavcodec/mpegaudioenc_float.c @@ -29,6 +29,7 @@ const FFCodec ff_mp2_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(MpegAudioContext), .init = MPA_encode_init, FF_CODEC_ENCODE_CB(MPA_encode_frame), diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index 703c802a5c..7380051a7d 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -730,6 +730,8 @@ const FFCodec ff_opus_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Opus"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_OPUS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_EXPERIMENTAL, .defaults = opusenc_defaults, .p.priv_class = &opusenc_class, .priv_data_size = sizeof(OpusEncContext), @@ -737,7 +739,6 @@ const FFCodec ff_opus_encoder = { FF_CODEC_ENCODE_CB(opus_encode_frame), .close = opus_encode_end, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, - .p.capabilities = AV_CODEC_CAP_EXPERIMENTAL | AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .p.supported_samplerates = (const int []){ 48000, 0 }, #if FF_API_OLD_CHANNEL_LAYOUT .p.channel_layouts = (const uint64_t []){ AV_CH_LAYOUT_MONO, diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 8d3178e335..1d344994de 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -197,6 +197,7 @@ const FFCodec ff_pcx_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PCX, + .p.capabilities = AV_CODEC_CAP_DR1, FF_CODEC_ENCODE_CB(pcx_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGB24, diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index ca9873f673..7c1cc55c34 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -1196,11 +1196,11 @@ const FFCodec ff_png_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PNG, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(PNGEncContext), .init = png_enc_init, .close = png_enc_close, FF_CODEC_ENCODE_CB(encode_png), - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48BE, AV_PIX_FMT_RGBA64BE, diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index cfc735bcec..482f09415d 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -945,12 +945,12 @@ const FFCodec ff_prores_aw_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = pix_fmts, .priv_data_size = sizeof(ProresContext), .init = prores_encode_init, .close = prores_encode_close, FF_CODEC_ENCODE_CB(prores_encode_frame), - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.priv_class = &prores_enc_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, @@ -961,12 +961,12 @@ const FFCodec ff_prores_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = pix_fmts, .priv_data_size = sizeof(ProresContext), .init = prores_encode_init, .close = prores_encode_close, FF_CODEC_ENCODE_CB(prores_encode_frame), - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.priv_class = &prores_enc_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/qoienc.c b/libavcodec/qoienc.c index 110297dbda..9a18c2a357 100644 --- a/libavcodec/qoienc.c +++ b/libavcodec/qoienc.c @@ -131,7 +131,7 @@ const FFCodec ff_qoi_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("QOI (Quite OK Image format) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QOI, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, FF_CODEC_ENCODE_CB(qoi_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB24, diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index e0b1ecb9eb..3962c08356 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -404,6 +404,7 @@ const FFCodec ff_qtrle_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QTRLE, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(QtrleEncContext), .init = qtrle_encode_init, FF_CODEC_ENCODE_CB(qtrle_encode_frame), diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index ebbcb2128b..0a418c3b89 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1123,6 +1123,7 @@ const FFCodec ff_roq_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("id RoQ video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ROQ, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(RoqEncContext), .init = roq_encode_init, FF_CODEC_ENCODE_CB(roq_encode_frame), diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c index a470f5d101..e9f035c510 100644 --- a/libavcodec/rpzaenc.c +++ b/libavcodec/rpzaenc.c @@ -849,6 +849,7 @@ const FFCodec ff_rpza_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime video (RPZA)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RPZA, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(RpzaContext), .p.priv_class = &rpza_class, .init = rpza_encode_init, diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index 7edc7cca83..109dbdc1fc 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -275,6 +275,7 @@ const FFCodec ff_sgi_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("SGI image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SGI, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(SgiContext), .p.priv_class = &sgi_class, .init = encode_init, diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c index 0b7b030ebe..f97e06c07c 100644 --- a/libavcodec/smcenc.c +++ b/libavcodec/smcenc.c @@ -553,6 +553,7 @@ const FFCodec ff_smc_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SMC, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(SMCContext), .init = smc_encode_init, FF_CODEC_ENCODE_CB(smc_encode_frame), diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index a295ff8085..351ee0abc4 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1933,6 +1933,7 @@ const FFCodec ff_snow_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Snow"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SNOW, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(SnowContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_frame), diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index c635831358..2dc6ac3f2d 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -1096,11 +1096,11 @@ const FFCodec ff_sonic_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Sonic"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, .priv_data_size = sizeof(SonicContext), .init = sonic_encode_init, FF_CODEC_ENCODE_CB(sonic_encode_frame), .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_EXPERIMENTAL, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .close = sonic_encode_close, }; @@ -1112,11 +1112,11 @@ const FFCodec ff_sonic_ls_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC_LS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, .priv_data_size = sizeof(SonicContext), .init = sonic_encode_init, FF_CODEC_ENCODE_CB(sonic_encode_frame), .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_EXPERIMENTAL, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .close = sonic_encode_close, }; diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c index 4fcc0e3309..2f0c033b46 100644 --- a/libavcodec/sunrastenc.c +++ b/libavcodec/sunrastenc.c @@ -213,6 +213,7 @@ const FFCodec ff_sunrast_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SUNRAST, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(SUNRASTContext), .init = sunrast_encode_init, FF_CODEC_ENCODE_CB(sunrast_encode_frame), diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 36bc214d76..f92ede867c 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -682,6 +682,7 @@ const FFCodec ff_svq1_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SVQ1, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(SVQ1EncContext), .p.priv_class = &svq1enc_class, .init = svq1_encode_init, diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index 7fb8e28c85..d93a698e24 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -207,6 +207,7 @@ const FFCodec ff_targa_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TARGA, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(TargaContext), .p.priv_class = &targa_class, .init = targa_encode_init, diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index dba0e89640..2dc31345d4 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -574,10 +574,10 @@ const FFCodec ff_tiff_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("TIFF image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TIFF, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(TiffEncoderContext), .init = encode_init, .close = encode_close, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, FF_CODEC_ENCODE_CB(encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48LE, AV_PIX_FMT_PAL8, diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c index 6a8c2b122d..20a711ede6 100644 --- a/libavcodec/ttaenc.c +++ b/libavcodec/ttaenc.c @@ -204,11 +204,11 @@ const FFCodec ff_tta_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("TTA (True Audio)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TTA, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(TTAEncContext), .init = tta_encode_init, .close = tta_encode_close, FF_CODEC_ENCODE_CB(tta_encode_frame), - .p.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index f38db96e51..191d271ca2 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -648,12 +648,12 @@ const FFCodec ff_utvideo_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Ut Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_UTVIDEO, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(UtvideoContext), .p.priv_class = &utvideo_class, .init = utvideo_encode_init, FF_CODEC_ENCODE_CB(utvideo_encode_frame), .close = utvideo_encode_close, - .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index c8bbbf02d8..20abb2a670 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1300,11 +1300,12 @@ const FFCodec ff_vorbis_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Vorbis"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_VORBIS, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_EXPERIMENTAL, .priv_data_size = sizeof(vorbis_enc_context), .init = vorbis_encode_init, FF_CODEC_ENCODE_CB(vorbis_encode_frame), .close = vorbis_encode_close, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_EXPERIMENTAL, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c index 07dfb22bbd..d813d7a63f 100644 --- a/libavcodec/wavpackenc.c +++ b/libavcodec/wavpackenc.c @@ -2963,12 +2963,12 @@ const FFCodec ff_wavpack_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("WavPack"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WAVPACK, + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(WavPackEncodeContext), .p.priv_class = &wavpack_encoder_class, .init = wavpack_encode_init, FF_CODEC_ENCODE_CB(wavpack_encode_frame), .close = wavpack_encode_close, - .p.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 03a5d788c8..99f0100dc1 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -438,6 +438,7 @@ const FFCodec ff_wmav1_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV1, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(WMACodecContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_superframe), @@ -453,6 +454,7 @@ const FFCodec ff_wmav2_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV2, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(WMACodecContext), .init = encode_init, FF_CODEC_ENCODE_CB(encode_superframe), diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index 8369f5370c..d4b8a542d9 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -82,6 +82,7 @@ const FFCodec ff_xbm_encoder = { .p.long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XBM, + .p.capabilities = AV_CODEC_CAP_DR1, FF_CODEC_ENCODE_CB(xbm_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, From 3fdfd4b725cf84b6dd9dddb53cd37c12cb3ce76f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 03:18:47 +0200 Subject: [PATCH 040/590] avcodec/encode: Fix outdated comment Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/encode.h b/libavcodec/encode.h index 10c36435ad..e5d6b754b1 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -57,7 +57,7 @@ int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame); /** * Check AVPacket size and allocate data. * - * Encoders supporting FFCodec.encode2() can use this as a convenience to + * Encoders of type FF_CODEC_CB_TYPE_ENCODE can use this as a convenience to * obtain a big enough buffer for the encoded bitstream. * * @param avctx the AVCodecContext of the encoder From 5c217119c84a2b2b02b421d2c2e3aa0dee22e11f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 03:19:05 +0200 Subject: [PATCH 041/590] avcodec/internal: Fix outdated comment The legacy API is long gone. Signed-off-by: Andreas Rheinhardt --- libavcodec/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 52e7f111c1..e8c24d81bd 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -137,7 +137,7 @@ typedef struct AVCodecInternal { int draining; /** - * buffers for using new encode/decode API through legacy API + * Temporary buffers for newly received or not yet output packets/frames. */ AVPacket *buffer_pkt; AVFrame *buffer_frame; From 6be4b534ce83d28382209991b9441d3c64ca4472 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 23:22:49 +0200 Subject: [PATCH 042/590] avcodec/roqvideoenc: Remove internal.h inclusion Possible since c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a. Signed-off-by: Andreas Rheinhardt --- libavcodec/roqvideoenc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 0a418c3b89..9f03107d81 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -64,7 +64,6 @@ #include "codec_internal.h" #include "elbg.h" #include "encode.h" -#include "internal.h" #include "mathops.h" #define CHROMA_BIAS 1 From 17e23aed41c37e130ec38b9f682c5cde990eefcc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 19:54:25 +0200 Subject: [PATCH 043/590] avcodec/internal: Move ff_get_format() to decode.h Signed-off-by: Andreas Rheinhardt --- libavcodec/decode.h | 13 +++++++++++++ libavcodec/h263dec.c | 1 + libavcodec/internal.h | 13 ------------- libavcodec/mediacodecdec_common.c | 1 + libavcodec/pthread_frame.c | 1 + libavcodec/utils.c | 1 + libavcodec/vc1dec.c | 1 + libavcodec/vp8.c | 1 + 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/libavcodec/decode.h b/libavcodec/decode.h index f7828fbff4..81767f73fd 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -99,4 +99,17 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); */ int ff_decode_preinit(AVCodecContext *avctx); +/** + * Select the (possibly hardware accelerated) pixel format. + * This is a wrapper around AVCodecContext.get_format() and should be used + * instead of calling get_format() directly. + * + * The list of pixel formats must contain at least one valid entry, and is + * terminated with AV_PIX_FMT_NONE. If it is possible to decode to software, + * the last entry in the list must be the most accurate software format. + * If it is not possible to decode to software, AVCodecContext.sw_pix_fmt + * must be set before calling this function. + */ +int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt); + #endif /* AVCODEC_DECODE_H */ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 8728cfa6e9..87fbf87c8a 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "error_resilience.h" #include "flvdec.h" #include "h263.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index e8c24d81bd..1d80fb03dc 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -248,19 +248,6 @@ int ff_set_sar(AVCodecContext *avctx, AVRational sar); int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding); -/** - * Select the (possibly hardware accelerated) pixel format. - * This is a wrapper around AVCodecContext.get_format() and should be used - * instead of calling get_format() directly. - * - * The list of pixel formats must contain at least one valid entry, and is - * terminated with AV_PIX_FMT_NONE. If it is possible to decode to software, - * the last entry in the list must be the most accurate software format. - * If it is not possible to decode to software, AVCodecContext.sw_pix_fmt - * must be set before calling this function. - */ -int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt); - /** * Add a CPB properties side data to an encoding context. */ diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index cb18aed401..7952c3c34c 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -32,6 +32,7 @@ #include "libavutil/timestamp.h" #include "avcodec.h" +#include "decode.h" #include "internal.h" #include "mediacodec.h" diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 726bd1bcc7..08a6f98898 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -29,6 +29,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "hwconfig.h" #include "internal.h" #include "pthread_internal.h" diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e73e3a7d08..2f57418ff7 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -36,6 +36,7 @@ #include "avcodec.h" #include "codec.h" #include "codec_internal.h" +#include "decode.h" #include "hwconfig.h" #include "thread.h" #include "threadframe.h" diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index b53490b3ab..065b43cb11 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "hwconfig.h" #include "internal.h" diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 7a151feb79..6bf846dbfe 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "hwconfig.h" #include "internal.h" #include "mathops.h" From e2c24e6a299b7e0e5387bdc50c11d16857b950a0 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 20:49:25 +0200 Subject: [PATCH 044/590] avcodec/internal: Move ff_reget_buffer() to decode.h Only used by decoders. Also clean up the headers a bit while removing now unnecessary internal.h inclusions. Signed-off-by: Andreas Rheinhardt --- libavcodec/aasc.c | 4 +--- libavcodec/anm.c | 2 +- libavcodec/ansi.c | 1 + libavcodec/argo.c | 5 +---- libavcodec/avs.c | 1 + libavcodec/bethsoftvideo.c | 2 +- libavcodec/bink.c | 1 + libavcodec/c93.c | 1 + libavcodec/cdgraphics.c | 1 + libavcodec/cdtoons.c | 2 +- libavcodec/cinepak.c | 2 -- libavcodec/clearvideo.c | 1 + libavcodec/cpia.c | 4 ++-- libavcodec/cscd.c | 4 +--- libavcodec/decode.h | 7 +++++++ libavcodec/dsicinvideo.c | 2 +- libavcodec/fic.c | 2 +- libavcodec/flashsv.c | 1 + libavcodec/flicvideo.c | 4 +--- libavcodec/gifdec.c | 1 + libavcodec/imx.c | 1 - libavcodec/indeo2.c | 3 +-- libavcodec/internal.h | 7 ------- libavcodec/jvdec.c | 1 + libavcodec/lscrdec.c | 2 +- libavcodec/midivid.c | 7 +------ libavcodec/mmvideo.c | 2 +- libavcodec/mobiclip.c | 4 ++-- libavcodec/motionpixels.c | 2 +- libavcodec/msrle.c | 3 --- libavcodec/mss1.c | 2 +- libavcodec/mss2.c | 1 + libavcodec/mss3.c | 2 +- libavcodec/mss4.c | 2 +- libavcodec/msvideo1.c | 3 --- libavcodec/nuv.c | 1 + libavcodec/pafvideo.c | 2 +- libavcodec/qtrle.c | 3 --- libavcodec/roqvideodec.c | 3 +-- libavcodec/rpza.c | 5 +---- libavcodec/rscc.c | 1 - libavcodec/scpr.c | 1 + libavcodec/screenpresso.c | 3 +-- libavcodec/smacker.c | 1 + libavcodec/smc.c | 4 ---- libavcodec/tiertexseqv.c | 1 + libavcodec/truemotion1.c | 1 + libavcodec/truemotion2.c | 2 +- libavcodec/tscc.c | 4 ---- libavcodec/tscc2.c | 2 +- libavcodec/ulti.c | 6 +----- libavcodec/vmnc.c | 6 +----- libavcodec/vqavideo.c | 1 + libavcodec/wcmv.c | 4 +--- libavcodec/xxan.c | 2 +- libavcodec/yop.c | 3 +-- 56 files changed, 55 insertions(+), 91 deletions(-) diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c index d6afa35b86..db9fc834b7 100644 --- a/libavcodec/aasc.c +++ b/libavcodec/aasc.c @@ -24,13 +24,11 @@ * Autodesk RLE Video Decoder by Konstantin Shishkov */ -#include -#include #include #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "msrledec.h" typedef struct AascContext { diff --git a/libavcodec/anm.c b/libavcodec/anm.c index a66ee1e65b..c7256fe6d3 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct AnmContext { AVFrame *frame; diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index a6b15c728f..1cd9ebceba 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "cga_data.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define ATTR_BOLD 0x01 /**< Bold/Bright-foreground (mode 1) */ diff --git a/libavcodec/argo.c b/libavcodec/argo.c index b772e9c565..a863373af2 100644 --- a/libavcodec/argo.c +++ b/libavcodec/argo.c @@ -19,18 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include -#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct ArgoContext { GetByteContext gb; diff --git a/libavcodec/avs.c b/libavcodec/avs.c index 20c07aeeed..86a41a31be 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index a2e8f412d6..ea5016bae5 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -32,7 +32,7 @@ #include "bethsoftvideo.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct BethsoftvidContext { AVFrame *frame; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 09be0488de..e6d9bdc2fa 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -32,6 +32,7 @@ #include "binkdsp.h" #include "blockdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "hpeldsp.h" #include "internal.h" diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 196b95e428..871ae589e6 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -22,6 +22,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" typedef struct C93DecoderContext { diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 0070d9b8e6..240c57d5f8 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -22,6 +22,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" /** diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c index c1b4577dca..00fbe58c26 100644 --- a/libavcodec/cdtoons.c +++ b/libavcodec/cdtoons.c @@ -32,7 +32,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define CDTOONS_HEADER_SIZE 44 #define CDTOONS_MAX_SPRITES 1200 diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 4cbbac8e36..480afbc81d 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -34,7 +34,6 @@ */ #include -#include #include #include "libavutil/common.h" @@ -42,7 +41,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef uint8_t cvid_codebook[12]; diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 47570a95c2..4e5fc02e23 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "idctdsp.h" #include "internal.h" diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c index 8b8c59f40f..c798038161 100644 --- a/libavcodec/cpia.c +++ b/libavcodec/cpia.c @@ -22,10 +22,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "get_bits.h" -#include "internal.h" +#include "decode.h" #define FRAME_HEADER_SIZE 64 diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c index 64d29a942c..51756b6d12 100644 --- a/libavcodec/cscd.c +++ b/libavcodec/cscd.c @@ -18,12 +18,10 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/common.h" #if CONFIG_ZLIB diff --git a/libavcodec/decode.h b/libavcodec/decode.h index 81767f73fd..d9014d3e0f 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -112,4 +112,11 @@ int ff_decode_preinit(AVCodecContext *avctx); */ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt); +#define FF_REGET_BUFFER_FLAG_READONLY 1 ///< the returned buffer does not need to be writable +/** + * Identical in function to ff_get_buffer(), except it reuses the existing buffer + * if available. + */ +int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); + #endif /* AVCODEC_DECODE_H */ diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c index e8d79bfb5d..32efefade1 100644 --- a/libavcodec/dsicinvideo.c +++ b/libavcodec/dsicinvideo.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef enum CinVideoBitmapIndex { CIN_CUR_BMP = 0, /* current */ diff --git a/libavcodec/fic.c b/libavcodec/fic.c index 3a0211ebe0..cb536cf36e 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -26,7 +26,7 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "golomb.h" diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 8215d04ce8..11d6657394 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -43,6 +43,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" #include "zlib_wrapper.h" diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index 50b317d974..e141d90a37 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -34,15 +34,13 @@ * in which the header is only 12 bytes. */ -#include -#include #include #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mathops.h" #define FLI_256_COLOR 4 diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 84ff8aa789..15d4f9743f 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "lzw.h" #include "gif.h" diff --git a/libavcodec/imx.c b/libavcodec/imx.c index 4856de0c70..68fdbc4ae9 100644 --- a/libavcodec/imx.c +++ b/libavcodec/imx.c @@ -23,7 +23,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct SimbiosisIMXContext { AVFrame *frame; diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 9bad9bf0b3..8a4b1a584a 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -30,10 +30,9 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "indeo2data.h" -#include "internal.h" -#include "mathops.h" typedef struct Ir2Context{ AVCodecContext *avctx; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 1d80fb03dc..039093ed41 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -219,13 +219,6 @@ static av_always_inline float ff_exp2fi(int x) { */ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); -#define FF_REGET_BUFFER_FLAG_READONLY 1 ///< the returned buffer does not need to be writable -/** - * Identical in function to ff_get_buffer(), except it reuses the existing buffer - * if available. - */ -int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); - int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index bca2603330..420a00a790 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/lscrdec.c b/libavcodec/lscrdec.c index 0d6b29cced..cd7dc8b2b7 100644 --- a/libavcodec/lscrdec.c +++ b/libavcodec/lscrdec.c @@ -29,7 +29,7 @@ #include "bytestream.h" #include "codec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "packet.h" #include "png.h" #include "pngdsp.h" diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c index 7448c8c797..49f31b0fa7 100644 --- a/libavcodec/midivid.c +++ b/libavcodec/midivid.c @@ -19,13 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - #include "libavutil/imgutils.h" #include "libavutil/internal.h" -#include "libavutil/intreadwrite.h" #include "libavutil/mem.h" #define BITSTREAM_READER_LE @@ -33,7 +28,7 @@ #include "get_bits.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct MidiVidContext { GetByteContext gb; diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index 85e126b17e..97e55119e4 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -35,7 +35,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define MM_PREAMBLE_SIZE 6 diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index b5ec806e89..b99b070c56 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -27,12 +27,12 @@ #include "libavutil/thread.h" #include "avcodec.h" -#include "bytestream.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "golomb.h" -#include "internal.h" +#include "mathops.h" #define MOBI_RL_VLC_BITS 12 #define MOBI_MV_VLC_BITS 6 diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 8b4f5c1017..51e22c04c8 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -27,7 +27,7 @@ #include "get_bits.h" #include "bswapdsp.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define MAX_HUFF_CODES 16 diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index 72134bc4a6..447d18002c 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -28,14 +28,11 @@ * The MS RLE decoder outputs PAL8 colorspace data. */ -#include -#include #include #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "msrledec.h" #include "libavutil/imgutils.h" diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c index d130a8f29c..8a5f00674a 100644 --- a/libavcodec/mss1.c +++ b/libavcodec/mss1.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mss12.h" typedef struct MSS1Context { diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 6019368e07..f7dade4a29 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -25,6 +25,7 @@ #include "libavutil/avassert.h" #include "codec_internal.h" +#include "decode.h" #include "error_resilience.h" #include "internal.h" #include "mpeg_er.h" diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c index 2e331ac802..0464bd12a6 100644 --- a/libavcodec/mss3.c +++ b/libavcodec/mss3.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mathops.h" #include "mss34dsp.h" diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index 53b7910097..21e0536319 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @@ -31,8 +31,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "jpegtables.h" #include "mss34dsp.h" #include "unary.h" diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index 8db31676f0..aeb3027b5f 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -26,8 +26,6 @@ * http://www.pcisys.net/~melanson/codecs/ */ -#include -#include #include #include "libavutil/internal.h" @@ -35,7 +33,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define PALETTE_COUNT 256 #define CHECK_STREAM_PTR(n) \ diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 3f03775b7f..c404bd8cf0 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -30,6 +30,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "idctdsp.h" #include "internal.h" #include "rtjpeg.h" diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c index d9fbd19543..cb57b2a5a6 100644 --- a/libavcodec/pafvideo.c +++ b/libavcodec/pafvideo.c @@ -25,7 +25,7 @@ #include "bytestream.h" #include "copy_block.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static const uint8_t block_sequences[16][8] = { diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index 2c070c0bc2..569c68359b 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -31,15 +31,12 @@ * data. 24-bit data is RGB24 and 32-bit data is RGB32. */ -#include -#include #include #include "avcodec.h" #include "decode.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" typedef struct QtrleContext { AVCodecContext *avctx; diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 4fbb0ca94d..2f7f91d41f 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -26,12 +26,11 @@ */ #include "libavutil/avassert.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "roqvideo.h" static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb) diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index d5ece16c32..f9ab3a7647 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -35,15 +35,12 @@ */ #include -#include -#include -#include #include "libavutil/internal.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct RpzaContext { diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c index eff4f87750..e74f2defe7 100644 --- a/libavcodec/rscc.c +++ b/libavcodec/rscc.c @@ -45,7 +45,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define TILE_SIZE 8 diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index ed129a507d..ff78041386 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "scpr.h" #include "scpr3.h" diff --git a/libavcodec/screenpresso.c b/libavcodec/screenpresso.c index f5bc46ff99..a5ca32765f 100644 --- a/libavcodec/screenpresso.c +++ b/libavcodec/screenpresso.c @@ -34,7 +34,6 @@ */ #include -#include #include #include "libavutil/imgutils.h" @@ -43,7 +42,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct ScreenpressoContext { AVFrame *current; diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 06af0fb7b6..5ef84a068f 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -51,6 +51,7 @@ #define BITSTREAM_READER_LE #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" #include "mathops.h" diff --git a/libavcodec/smc.c b/libavcodec/smc.c index 28dc2b4d3c..c4364cfe8c 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -28,16 +28,12 @@ * The SMC decoder outputs PAL8 colorspace data. */ -#include -#include #include -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define CPAIR 2 #define CQUAD 4 diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 26711a3bc4..9e1b10a40c 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -27,6 +27,7 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index fc9f8118be..ee41b0ed4d 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -35,6 +35,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index ec3f0d0d08..3784733bee 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -30,8 +30,8 @@ #include "bswapdsp.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #define TM2_ESCAPE 0x80000000 #define TM2_DELTAS 64 diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index 601ee198b1..89c4413647 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -34,13 +34,9 @@ * Supports: BGR8,BGR555,BGR24 - only BGR8 and BGR555 tested */ -#include -#include - #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "msrledec.h" #include "zlib_wrapper.h" diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index a50a8da738..ba84a07da7 100644 --- a/libavcodec/tscc2.c +++ b/libavcodec/tscc2.c @@ -32,8 +32,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "mathops.h" #include "tscc2data.h" diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index b9d17da60e..a3abec3d5a 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -24,14 +24,10 @@ * IBM Ultimotion Video Decoder. */ -#include -#include -#include - #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "ulti_cb.h" diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c index e6e5442a16..2d47f8ec0f 100644 --- a/libavcodec/vmnc.c +++ b/libavcodec/vmnc.c @@ -25,14 +25,10 @@ * As Alex Beregszaszi discovered, this is effectively RFB data dump */ -#include -#include - #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "bytestream.h" enum EncTypes { diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index a195eae584..61c30c2a62 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -78,6 +78,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define PALETTE_COUNT 256 diff --git a/libavcodec/wcmv.c b/libavcodec/wcmv.c index d2fdb30662..8bc900f304 100644 --- a/libavcodec/wcmv.c +++ b/libavcodec/wcmv.c @@ -21,15 +21,13 @@ */ #include -#include -#include #include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "zlib_wrapper.h" #include diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c index 79edc16335..555925e5b5 100644 --- a/libavcodec/xxan.c +++ b/libavcodec/xxan.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct XanContext { AVCodecContext *avctx; diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 50bb64bf87..33d8c8b815 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -26,11 +26,10 @@ #include "libavutil/imgutils.h" #include "libavutil/internal.h" -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct YopDecContext { AVCodecContext *avctx; From 66b691f99f77ebb59d5c192aab4eefec4d200be8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 21:28:16 +0200 Subject: [PATCH 045/590] avcodec/internal: Move ff_get_buffer() to decode.h Only used by decoders (encoders have ff_encode_alloc_frame()). Also clean up the other headers a bit while removing now redundant internal.h inclusions. Signed-off-by: Andreas Rheinhardt --- libavcodec/012v.c | 2 +- libavcodec/4xm.c | 2 +- libavcodec/8bps.c | 5 +---- libavcodec/8svx.c | 2 +- libavcodec/aacdec_template.c | 1 + libavcodec/ac3dec.c | 1 + libavcodec/adpcm.c | 2 +- libavcodec/adxdec.c | 2 +- libavcodec/agm.c | 1 + libavcodec/aliaspixdec.c | 1 + libavcodec/alsdec.c | 1 + libavcodec/amrnbdec.c | 3 +-- libavcodec/amrwbdec.c | 3 +-- libavcodec/apedec.c | 2 +- libavcodec/aptxdec.c | 2 +- libavcodec/arbc.c | 7 +------ libavcodec/asvdec.c | 2 +- libavcodec/atrac1.c | 4 +--- libavcodec/atrac3.c | 3 +-- libavcodec/atrac3plusdec.c | 2 +- libavcodec/atrac9dec.c | 2 +- libavcodec/audiotoolboxdec.c | 2 +- libavcodec/aura.c | 2 +- libavcodec/avrndec.c | 2 +- libavcodec/avuidec.c | 2 +- libavcodec/bfi.c | 2 +- libavcodec/bink.c | 2 -- libavcodec/bintext.c | 2 +- libavcodec/bmp.c | 1 + libavcodec/bmvaudio.c | 2 +- libavcodec/bmvvideo.c | 2 +- libavcodec/brenderpix.c | 1 + libavcodec/cavsdec.c | 1 + libavcodec/cdxl.c | 1 + libavcodec/cljrdec.c | 2 +- libavcodec/cngdec.c | 1 + libavcodec/cook.c | 2 +- libavcodec/cyuv.c | 4 +--- libavcodec/dca_core.c | 1 + libavcodec/dca_lbr.c | 1 + libavcodec/dca_xll.c | 1 + libavcodec/dds.c | 1 + libavcodec/decode.h | 7 +++++++ libavcodec/dfa.c | 2 +- libavcodec/dfpwmdec.c | 2 +- libavcodec/diracdec.c | 1 + libavcodec/dolby_e.c | 2 +- libavcodec/dpcm.c | 3 +-- libavcodec/dpx.c | 1 + libavcodec/dsddec.c | 1 + libavcodec/dsicinaudio.c | 4 ++-- libavcodec/dss_sp.c | 3 +-- libavcodec/dstdec.c | 3 +-- libavcodec/dvaudiodec.c | 2 +- libavcodec/dxa.c | 5 +---- libavcodec/eacmv.c | 1 + libavcodec/eamad.c | 1 + libavcodec/eatgq.c | 1 + libavcodec/eatgv.c | 1 + libavcodec/eatqi.c | 1 + libavcodec/escape124.c | 2 +- libavcodec/escape130.c | 2 +- libavcodec/evrcdec.c | 2 +- libavcodec/fastaudio.c | 5 +---- libavcodec/ffwavesynth.c | 2 +- libavcodec/fitsdec.c | 1 + libavcodec/fmvc.c | 3 +-- libavcodec/frwu.c | 2 +- libavcodec/g2meet.c | 1 + libavcodec/g722dec.c | 2 +- libavcodec/g723_1dec.c | 3 +-- libavcodec/g726.c | 2 +- libavcodec/g729dec.c | 3 +-- libavcodec/gdv.c | 1 - libavcodec/gemdec.c | 1 + libavcodec/gsmdec.c | 2 +- libavcodec/hcadec.c | 3 +-- libavcodec/hcom.c | 2 +- libavcodec/hnm4video.c | 2 +- libavcodec/hq_hqa.c | 1 + libavcodec/idcinvideo.c | 4 +--- libavcodec/iff.c | 3 +-- libavcodec/ilbcdec.c | 2 +- libavcodec/imc.c | 3 +-- libavcodec/imm4.c | 1 + libavcodec/indeo3.c | 1 + libavcodec/internal.h | 7 ------- libavcodec/interplayacm.c | 2 +- libavcodec/interplayvideo.c | 2 -- libavcodec/ivi.c | 1 + libavcodec/jvdec.c | 1 - libavcodec/kgv1dec.c | 1 + libavcodec/kmvc.c | 2 -- libavcodec/libaomdec.c | 1 + libavcodec/libcelt_dec.c | 2 +- libavcodec/libcodec2.c | 2 +- libavcodec/libfdk-aacdec.c | 2 +- libavcodec/libgsmdec.c | 2 +- libavcodec/libilbc.c | 2 +- libavcodec/libjxldec.c | 1 + libavcodec/libopencore-amr.c | 2 +- libavcodec/libopenh264dec.c | 1 + libavcodec/libopusdec.c | 1 + libavcodec/librsvgdec.c | 1 + libavcodec/libspeexdec.c | 2 +- libavcodec/libuavs3d.c | 1 + libavcodec/libvorbisdec.c | 2 +- libavcodec/loco.c | 2 +- libavcodec/m101.c | 2 +- libavcodec/mace.c | 2 +- libavcodec/mlpdec.c | 1 + libavcodec/mpc7.c | 2 +- libavcodec/mpc8.c | 2 +- libavcodec/mpeg12dec.c | 1 + libavcodec/mpegaudiodec_template.c | 2 +- libavcodec/mscc.c | 3 +-- libavcodec/msp2dec.c | 2 +- libavcodec/mss2.c | 1 - libavcodec/mv30.c | 5 ++--- libavcodec/mvcdec.c | 1 + libavcodec/mvha.c | 7 +------ libavcodec/mwsc.c | 4 +--- libavcodec/mxpegdec.c | 2 +- libavcodec/nellymoserdec.c | 3 +-- libavcodec/on2avc.c | 2 +- libavcodec/opusdec.c | 4 +--- libavcodec/pafaudio.c | 2 +- libavcodec/pcm-bluray.c | 2 +- libavcodec/pcm-dvd.c | 2 +- libavcodec/pcm.c | 3 +-- libavcodec/pcx.c | 1 + libavcodec/pgxdec.c | 2 +- libavcodec/pictordec.c | 1 + libavcodec/pnmdec.c | 2 +- libavcodec/prosumer.c | 3 +-- libavcodec/psd.c | 1 + libavcodec/ptx.c | 2 +- libavcodec/qcelpdec.c | 4 +--- libavcodec/qdm2.c | 3 +-- libavcodec/qdmc.c | 3 +-- libavcodec/qdrw.c | 1 + libavcodec/qpeg.c | 1 - libavcodec/r210dec.c | 2 +- libavcodec/ra144dec.c | 2 +- libavcodec/ra288.c | 2 +- libavcodec/ralf.c | 2 +- libavcodec/rasc.c | 3 +-- libavcodec/rl2.c | 1 + libavcodec/s302m.c | 3 +-- libavcodec/sanm.c | 1 + libavcodec/sbcdec.c | 2 +- libavcodec/scpr.c | 3 --- libavcodec/scpr3.c | 1 - libavcodec/sga.c | 1 + libavcodec/sgidec.c | 1 + libavcodec/sgirledec.c | 2 +- libavcodec/shorten.c | 2 +- libavcodec/sipr.c | 2 +- libavcodec/siren.c | 3 +-- libavcodec/smacker.c | 5 +---- libavcodec/snow.c | 7 +------ libavcodec/sonic.c | 2 +- libavcodec/speedhq.c | 3 +-- libavcodec/speexdec.c | 2 +- libavcodec/sunrast.c | 1 + libavcodec/svq1dec.c | 1 + libavcodec/svq3.c | 1 + libavcodec/targa.c | 1 + libavcodec/targa_y216dec.c | 2 +- libavcodec/tdsc.c | 1 + libavcodec/tmv.c | 2 +- libavcodec/truemotion2rt.c | 1 + libavcodec/truespeech.c | 3 +-- libavcodec/twinvq.c | 2 +- libavcodec/txd.c | 1 + libavcodec/v210x.c | 2 +- libavcodec/v308dec.c | 2 +- libavcodec/v408dec.c | 2 +- libavcodec/vb.c | 5 +---- libavcodec/vbndec.c | 1 + libavcodec/vc1dec.c | 1 - libavcodec/vcr1.c | 2 +- libavcodec/vima.c | 2 +- libavcodec/vmdaudio.c | 2 +- libavcodec/vmdvideo.c | 2 +- libavcodec/vorbisdec.c | 2 +- libavcodec/vp56.c | 1 + libavcodec/wmadec.c | 1 + libavcodec/wmalosslessdec.c | 3 +-- libavcodec/wmaprodec.c | 3 ++- libavcodec/wmavoice.c | 2 +- libavcodec/wnv1.c | 2 +- libavcodec/ws-snd1.c | 2 +- libavcodec/xan.c | 4 +--- libavcodec/xbmdec.c | 1 + libavcodec/xfacedec.c | 4 +--- libavcodec/xl.c | 2 +- libavcodec/xpmdec.c | 2 +- libavcodec/xwddec.c | 1 + libavcodec/y41pdec.c | 2 +- libavcodec/yuv4dec.c | 2 +- libavcodec/zerocodec.c | 2 +- libavcodec/zmbv.c | 5 ++--- 203 files changed, 202 insertions(+), 229 deletions(-) diff --git a/libavcodec/012v.c b/libavcodec/012v.c index 805aaed221..700feb3024 100644 --- a/libavcodec/012v.c +++ b/libavcodec/012v.c @@ -22,7 +22,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/intreadwrite.h" static av_cold int zero12v_decode_init(AVCodecContext *avctx) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 94d1cbe98a..2ee05766ab 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -37,8 +37,8 @@ #include "bswapdsp.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #define BLOCK_TYPE_VLC_BITS 5 diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 3bac9f64c4..c7dfeb81ee 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -30,16 +30,13 @@ * : RGB32 (RGB 32bpp, 4th plane is alpha) */ -#include -#include #include +#include "libavutil/bswap.h" #include "libavutil/internal.h" -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" static const enum AVPixelFormat pixfmt_rgb24[] = { diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c index 0af68d2d9a..1c6d78379d 100644 --- a/libavcodec/8svx.c +++ b/libavcodec/8svx.c @@ -42,7 +42,7 @@ #include "libavutil/avassert.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/common.h" /** decoder context */ diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 149c171c83..4a9513d53e 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -91,6 +91,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/thread.h" +#include "decode.h" #include "internal.h" static VLC vlc_scalefactors; diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index ad2b3615c8..b1db3dc9e6 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -44,6 +44,7 @@ #include "ac3dec.h" #include "ac3dec_data.h" #include "ac3defs.h" +#include "decode.h" #include "kbdwin.h" /** diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index c4bcafbb7e..5db46752ab 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -43,7 +43,7 @@ #include "adpcm.h" #include "adpcm_data.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" /** * @file diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index b5c09eaae5..cdded477ca 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -23,8 +23,8 @@ #include "avcodec.h" #include "adx.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" /** * @file diff --git a/libavcodec/agm.c b/libavcodec/agm.c index 0f65a820ca..08a5f05b91 100644 --- a/libavcodec/agm.c +++ b/libavcodec/agm.c @@ -32,6 +32,7 @@ #include "bytestream.h" #include "codec_internal.h" #include "copy_block.h" +#include "decode.h" #include "get_bits.h" #include "idctdsp.h" #include "internal.h" diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c index 73c83528f5..522b894af5 100644 --- a/libavcodec/aliaspixdec.c +++ b/libavcodec/aliaspixdec.c @@ -24,6 +24,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define ALIAS_HEADER_SIZE 10 diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 38c823ffa1..4bb232c42a 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -34,6 +34,7 @@ #include "bgmc.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "mlz.h" #include "libavutil/samplefmt.h" diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index 8c1073916e..dcf66c1dde 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -44,7 +44,6 @@ #include #include "libavutil/channel_layout.h" -#include "libavutil/float_dsp.h" #include "avcodec.h" #include "libavutil/common.h" #include "libavutil/avassert.h" @@ -56,7 +55,7 @@ #include "lsp.h" #include "amr.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "amrnbdata.h" diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 6a5b79f52c..f9a67c43b7 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -26,7 +26,6 @@ #include "libavutil/channel_layout.h" #include "libavutil/common.h" -#include "libavutil/float_dsp.h" #include "libavutil/lfg.h" #include "avcodec.h" @@ -37,7 +36,7 @@ #include "acelp_vectors.h" #include "acelp_pitch_delay.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define AMR_USE_16BIT_TABLES #include "amr.h" diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index e7baa2e77f..805b9af3c3 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -31,7 +31,7 @@ #include "bswapdsp.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "unary.h" diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c index 27cf056751..1d7a7842f7 100644 --- a/libavcodec/aptxdec.c +++ b/libavcodec/aptxdec.c @@ -25,7 +25,7 @@ #include "libavutil/channel_layout.h" #include "aptx.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" /* * Half-band QMF synthesis filter realized with a polyphase FIR filter. diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c index d981d2228b..7155d65196 100644 --- a/libavcodec/arbc.c +++ b/libavcodec/arbc.c @@ -19,18 +19,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - -#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct ARBCContext { GetByteContext gb; diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index 5bb4600084..2105d55e33 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -32,8 +32,8 @@ #include "blockdsp.h" #include "codec_internal.h" #include "config_components.h" +#include "decode.h" #include "idctdsp.h" -#include "internal.h" #include "mpeg12data.h" #define CCP_VLC_BITS 5 diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index a05fb6e801..3b60cee259 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -29,17 +29,15 @@ /* Many thanks to Tim Craig for all the help! */ #include -#include -#include #include "libavutil/float_dsp.h" #include "libavutil/mem_internal.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "fft.h" -#include "internal.h" #include "sinewin.h" #include "atrac.h" diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 93f5f4d2d6..79260c8760 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -34,7 +34,6 @@ #include #include -#include #include "libavutil/attributes.h" #include "libavutil/float_dsp.h" @@ -45,9 +44,9 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "fft.h" #include "get_bits.h" -#include "internal.h" #include "atrac.h" #include "atrac3data.h" diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index 644a7e87c6..771c213bad 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -43,8 +43,8 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "atrac.h" #include "atrac3plus.h" diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index 3c572560c1..71ff6e0151 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -23,7 +23,7 @@ #include "libavutil/thread.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "fft.h" #include "atrac9tab.h" diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index dc3f790636..220101e9eb 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -28,7 +28,7 @@ #include "ac3_parser_internal.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mpegaudiodecheader.h" #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" diff --git a/libavcodec/aura.c b/libavcodec/aura.c index 23e976f219..938706629d 100644 --- a/libavcodec/aura.c +++ b/libavcodec/aura.c @@ -25,7 +25,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/internal.h" static av_cold int aura_decode_init(AVCodecContext *avctx) diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index 10bde74172..f0257cd860 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -21,7 +21,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/imgutils.h" typedef struct { diff --git a/libavcodec/avuidec.c b/libavcodec/avuidec.c index ce96219bf5..9e698b02ec 100644 --- a/libavcodec/avuidec.c +++ b/libavcodec/avuidec.c @@ -22,7 +22,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/intreadwrite.h" static av_cold int avui_decode_init(AVCodecContext *avctx) diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index 12eba8f399..9df5bcdf5e 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -30,7 +30,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct BFIContext { AVCodecContext *avctx; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index e6d9bdc2fa..a3cd4667d6 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -35,8 +35,6 @@ #include "decode.h" #include "get_bits.h" #include "hpeldsp.h" -#include "internal.h" -#include "mathops.h" #define BINK_FLAG_ALPHA 0x00100000 #define BINK_FLAG_GRAY 0x00020000 diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c index 7039760c19..c3cf14f6dd 100644 --- a/libavcodec/bintext.c +++ b/libavcodec/bintext.c @@ -36,7 +36,7 @@ #include "cga_data.h" #include "bintext.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define FONT_WIDTH 8 diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 410065aba1..7bbaabcda4 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -25,6 +25,7 @@ #include "bytestream.h" #include "bmp.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "msrledec.h" diff --git a/libavcodec/bmvaudio.c b/libavcodec/bmvaudio.c index 08f24c3c8b..d772f72d71 100644 --- a/libavcodec/bmvaudio.c +++ b/libavcodec/bmvaudio.c @@ -24,7 +24,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static const int bmv_aud_mults[16] = { 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32 diff --git a/libavcodec/bmvvideo.c b/libavcodec/bmvvideo.c index 9872396990..6a55d49494 100644 --- a/libavcodec/bmvvideo.c +++ b/libavcodec/bmvvideo.c @@ -25,7 +25,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" enum BMVFlags{ BMV_NOP = 0, diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c index 9807a11cf9..2d8e978c1e 100644 --- a/libavcodec/brenderpix.c +++ b/libavcodec/brenderpix.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define HEADER1_CHUNK 0x03 diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 7ac4359123..417c73bd2e 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -31,6 +31,7 @@ #include "golomb.h" #include "cavs.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "mathops.h" #include "mpeg12data.h" diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c index b005442fdc..64fcdffba4 100644 --- a/libavcodec/cdxl.c +++ b/libavcodec/cdxl.c @@ -32,6 +32,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/cljrdec.c b/libavcodec/cljrdec.c index 21fa8ee019..0550e1dc05 100644 --- a/libavcodec/cljrdec.c +++ b/libavcodec/cljrdec.c @@ -26,8 +26,8 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" static int decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c index c89dfee033..e698d142dd 100644 --- a/libavcodec/cngdec.c +++ b/libavcodec/cngdec.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "celp_filters.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "libavutil/lfg.h" diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 01005d3a50..5ccabb03ed 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -52,8 +52,8 @@ #include "get_bits.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "fft.h" -#include "internal.h" #include "sinewin.h" #include "unary.h" diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index 48846b56c2..8a7cef6b74 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -30,13 +30,11 @@ #include "config_components.h" -#include -#include #include #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/internal.h" diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 2b19807ef4..b181171104 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -25,6 +25,7 @@ #include "dcahuff.h" #include "dcamath.h" #include "dca_syncwords.h" +#include "decode.h" #include "internal.h" #if ARCH_ARM diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index 2b8594cd75..ec55404c7b 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -28,6 +28,7 @@ #include "dcahuff.h" #include "dca_syncwords.h" #include "bytestream.h" +#include "decode.h" #include "internal.h" #define AMP_MAX 56 diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index 17626b3614..242c3a13fe 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -23,6 +23,7 @@ #include "dcadata.h" #include "dcamath.h" #include "dca_syncwords.h" +#include "decode.h" #include "internal.h" #include "unary.h" diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 1e3901111c..63f63efca2 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -34,6 +34,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "texturedsp.h" #include "thread.h" diff --git a/libavcodec/decode.h b/libavcodec/decode.h index d9014d3e0f..25db4a9e4d 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -112,6 +112,13 @@ int ff_decode_preinit(AVCodecContext *avctx); */ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt); +/** + * Get a buffer for a frame. This is a wrapper around + * AVCodecContext.get_buffer() and should be used instead calling get_buffer() + * directly. + */ +int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); + #define FF_REGET_BUFFER_FLAG_READONLY 1 ///< the returned buffer does not need to be writable /** * Identical in function to ff_get_buffer(), except it reuses the existing buffer diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c index 0996bf5a7e..dadb64d87e 100644 --- a/libavcodec/dfa.c +++ b/libavcodec/dfa.c @@ -25,7 +25,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/avassert.h" #include "libavutil/imgutils.h" diff --git a/libavcodec/dfpwmdec.c b/libavcodec/dfpwmdec.c index c036f8e141..975afba4cc 100644 --- a/libavcodec/dfpwmdec.c +++ b/libavcodec/dfpwmdec.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "codec_id.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct { int fq, q, s, lt; diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index aef6ab20a3..59c5e81904 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -33,6 +33,7 @@ #include "get_bits.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "golomb.h" #include "dirac_arith.h" diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index e6a262403d..de852ecc0a 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -26,7 +26,7 @@ #include "libavutil/opt.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "dolby_e.h" #include "kbdwin.h" diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index e360045ec3..34f3799b80 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -37,11 +37,10 @@ * the fourcc 'Axan' in the 'auds' chunk of the AVI header. */ -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mathops.h" typedef struct DPCMContext { diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index bb2c5e588e..c3f0d3f95a 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -27,6 +27,7 @@ #include "bytestream.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" enum DPX_TRC { diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c index d724e427bf..0fdc2af565 100644 --- a/libavcodec/dsddec.c +++ b/libavcodec/dsddec.c @@ -29,6 +29,7 @@ #include "libavcodec/internal.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "dsd.h" #define DSD_SILENCE 0x69 diff --git a/libavcodec/dsicinaudio.c b/libavcodec/dsicinaudio.c index 8be4350625..ea37e68ea2 100644 --- a/libavcodec/dsicinaudio.c +++ b/libavcodec/dsicinaudio.c @@ -25,11 +25,11 @@ */ #include "libavutil/channel_layout.h" +#include "libavutil/intreadwrite.h" #include "avcodec.h" -#include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mathops.h" typedef struct CinAudioContext { diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c index d2f71a4450..74419514d4 100644 --- a/libavcodec/dss_sp.c +++ b/libavcodec/dss_sp.c @@ -22,12 +22,11 @@ #include "libavutil/channel_layout.h" #include "libavutil/common.h" #include "libavutil/mem_internal.h" -#include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #define SUBFRAMES 4 #define PULSE_MAX 8 diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c index 9ad763ab6b..59f8e900d8 100644 --- a/libavcodec/dstdec.c +++ b/libavcodec/dstdec.c @@ -29,11 +29,10 @@ #include "libavutil/mem_internal.h" #include "libavutil/reverse.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "avcodec.h" #include "golomb.h" -#include "mathops.h" #include "dsd.h" #define DST_MAX_CHANNELS 6 diff --git a/libavcodec/dvaudiodec.c b/libavcodec/dvaudiodec.c index d65fc469ff..96bcadeb57 100644 --- a/libavcodec/dvaudiodec.c +++ b/libavcodec/dvaudiodec.c @@ -22,7 +22,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "dvaudio.h" typedef struct DVAudioContext { diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c index fa633cd208..a557501104 100644 --- a/libavcodec/dxa.c +++ b/libavcodec/dxa.c @@ -24,15 +24,12 @@ * DXA Video decoder */ -#include -#include - #include "libavutil/common.h" #include "libavutil/intreadwrite.h" #include "bytestream.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index b05d0f32a9..733cc2a1c0 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -33,6 +33,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" typedef struct CmvContext { diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index ce74bf0c62..70cea0ed6c 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -35,6 +35,7 @@ #include "bytestream.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "aandcttab.h" #include "eaidct.h" diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index a28cc521c3..5d57fb34f8 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -36,6 +36,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "eaidct.h" #include "get_bits.h" #include "idctdsp.h" diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index a6af789552..b1483cc586 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -35,6 +35,7 @@ #include "avcodec.h" #include "get_bits.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define EA_PREAMBLE_SIZE 8 diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index a19202ac1c..013e5415d2 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -32,6 +32,7 @@ #include "blockdsp.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "aandcttab.h" #include "eaidct.h" diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 170d76f052..6906992305 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -22,8 +22,8 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" typedef union MacroBlock { uint16_t pixels[4]; diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c index b292343b20..5bf1a5d745 100644 --- a/libavcodec/escape130.c +++ b/libavcodec/escape130.c @@ -25,8 +25,8 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct Escape130Context { uint8_t *old_y_avg; diff --git a/libavcodec/evrcdec.c b/libavcodec/evrcdec.c index 19e7e58b5f..2ac98b8e76 100644 --- a/libavcodec/evrcdec.c +++ b/libavcodec/evrcdec.c @@ -30,7 +30,7 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "evrcdata.h" #include "acelp_vectors.h" diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c index 6093a06900..262e2bea7c 100644 --- a/libavcodec/fastaudio.c +++ b/libavcodec/fastaudio.c @@ -21,13 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intreadwrite.h" - #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" -#include "mathops.h" +#include "decode.h" typedef struct ChannelItems { float f[8]; diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index 04be7761b2..728650b057 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -23,7 +23,7 @@ #include "libavutil/log.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define SIN_BITS 14 diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c index b60c2bd441..28954f370c 100644 --- a/libavcodec/fitsdec.c +++ b/libavcodec/fitsdec.c @@ -32,6 +32,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include #include "libavutil/intreadwrite.h" diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c index fe86204b2f..b3a4e7184c 100644 --- a/libavcodec/fmvc.c +++ b/libavcodec/fmvc.c @@ -21,13 +21,12 @@ */ #include -#include #include #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define BLOCK_HEIGHT 112u #define BLOCK_WIDTH 84u diff --git a/libavcodec/frwu.c b/libavcodec/frwu.c index e6ee0506ac..225667b4c4 100644 --- a/libavcodec/frwu.c +++ b/libavcodec/frwu.c @@ -23,7 +23,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/opt.h" typedef struct { diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index 66ccd9a28c..f2300e1ca6 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -36,6 +36,7 @@ #include "blockdsp.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "elsdec.h" #include "get_bits.h" #include "idctdsp.h" diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c index de2f666a1f..23598cb71f 100644 --- a/libavcodec/g722dec.c +++ b/libavcodec/g722dec.c @@ -38,9 +38,9 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "g722.h" -#include "internal.h" #define OFFSET(x) offsetof(G722Context, x) #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c index 257a4e6c30..3904840eba 100644 --- a/libavcodec/g723_1dec.c +++ b/libavcodec/g723_1dec.c @@ -33,10 +33,9 @@ #include "acelp_vectors.h" #include "avcodec.h" #include "celp_filters.h" -#include "celp_math.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "g723_1.h" #define CNG_RANDOM_SEED 12345 diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 6c9406d3fd..320bc55d15 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -30,8 +30,8 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "encode.h" -#include "internal.h" #include "get_bits.h" #include "put_bits.h" diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index b678510f34..bcaee44d9d 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -27,12 +27,11 @@ #include "get_bits.h" #include "audiodsp.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "g729.h" #include "lsp.h" -#include "celp_math.h" #include "celp_filters.h" #include "acelp_filters.h" #include "acelp_pitch_delay.h" diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c index 148204d4f8..19b4d4bdbb 100644 --- a/libavcodec/gdv.c +++ b/libavcodec/gdv.c @@ -25,7 +25,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct GDVContext { AVCodecContext *avctx; diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c index 0d6acd5303..39bfedb560 100644 --- a/libavcodec/gemdec.c +++ b/libavcodec/gemdec.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" static const uint32_t gem_color_palette[16]={ diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c index dd8d80e07b..c44c9d992f 100644 --- a/libavcodec/gsmdec.c +++ b/libavcodec/gsmdec.c @@ -29,8 +29,8 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "msgsmdec.h" #include "gsmdec_template.c" diff --git a/libavcodec/hcadec.c b/libavcodec/hcadec.c index 4c81aa405b..82276589fc 100644 --- a/libavcodec/hcadec.c +++ b/libavcodec/hcadec.c @@ -18,15 +18,14 @@ #include "libavutil/crc.h" #include "libavutil/float_dsp.h" -#include "libavutil/intreadwrite.h" #include "libavutil/mem_internal.h" #include "libavutil/tx.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "hca_data.h" typedef struct ChannelContext { diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c index 9fd47b4273..301b1e02d6 100644 --- a/libavcodec/hcom.c +++ b/libavcodec/hcom.c @@ -22,8 +22,8 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct HEntry { int16_t l, r; diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index db4c877ea4..f68badf195 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define HNM4_CHUNK_ID_PL 19536 #define HNM4_CHUNK_ID_IZ 23113 diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index a17fa18bf8..e0fbf7de65 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -27,6 +27,7 @@ #include "bytestream.h" #include "canopus.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c index 1535e6aced..4d3bcd3e86 100644 --- a/libavcodec/idcinvideo.c +++ b/libavcodec/idcinvideo.c @@ -44,14 +44,12 @@ * decoding algorithm and it worked fine on much lower spec machines. */ -#include -#include +#include #include #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libavutil/internal.h" #define HUFFMAN_TABLE_SIZE 64 * 1024 diff --git a/libavcodec/iff.c b/libavcodec/iff.c index cd78352350..e31dc4cbd0 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -33,8 +33,7 @@ #include "bytestream.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" -#include "mathops.h" +#include "decode.h" // TODO: masking bits typedef enum { diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c index 2bc559a3e8..1ee59ef5c9 100644 --- a/libavcodec/ilbcdec.c +++ b/libavcodec/ilbcdec.c @@ -33,7 +33,7 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "ilbcdata.h" diff --git a/libavcodec/imc.c b/libavcodec/imc.c index e9c51a1760..e751c1da8d 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -33,7 +33,6 @@ #include #include -#include #include "libavutil/channel_layout.h" #include "libavutil/ffmath.h" @@ -45,9 +44,9 @@ #include "avcodec.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "fft.h" -#include "internal.h" #include "sinewin.h" #include "imcdata.h" diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index fe4e15f381..b2840a2c3f 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm4.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "copy_block.h" #include "get_bits.h" #include "idctdsp.h" diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index e634cf3dfd..95708f3636 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -34,6 +34,7 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "copy_block.h" #include "bytestream.h" #include "get_bits.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 039093ed41..c1eddd0879 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -212,13 +212,6 @@ static av_always_inline float ff_exp2fi(int x) { return 0; } -/** - * Get a buffer for a frame. This is a wrapper around - * AVCodecContext.get_buffer() and should be used instead calling get_buffer() - * directly. - */ -int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); - int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); diff --git a/libavcodec/interplayacm.c b/libavcodec/interplayacm.c index 3b14919288..069b1ca704 100644 --- a/libavcodec/interplayacm.c +++ b/libavcodec/interplayacm.c @@ -24,8 +24,8 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" static const int8_t map_1bit[] = { -1, +1 }; static const int8_t map_2bit_near[] = { -2, -1, +1, +2 }; diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 75feb8335a..21ceb75210 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -35,7 +35,6 @@ */ #include -#include #include #include "libavutil/intreadwrite.h" @@ -47,7 +46,6 @@ #include "decode.h" #include "get_bits.h" #include "hpeldsp.h" -#include "internal.h" #define PALETTE_COUNT 256 diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c index 6577fa335f..cddef6f51e 100644 --- a/libavcodec/ivi.c +++ b/libavcodec/ivi.c @@ -34,6 +34,7 @@ #define BITSTREAM_READER_LE #include "avcodec.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" #include "ivi.h" diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index 420a00a790..9bca18e32c 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -32,7 +32,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct JvContext { BlockDSPContext bdsp; diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 47c2a31b69..0dfb796483 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -29,6 +29,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" typedef struct KgvContext { diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index d5da5412a0..1e37c233f4 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -25,13 +25,11 @@ */ #include -#include #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libavutil/common.h" #define KMVC_KEYFRAME 0x80 diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c index cb672b0e65..274c67baaa 100644 --- a/libavcodec/libaomdec.c +++ b/libavcodec/libaomdec.c @@ -32,6 +32,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "libaom.h" #include "profiles.h" diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c index a9c9962b71..0c41a660bc 100644 --- a/libavcodec/libcelt_dec.c +++ b/libavcodec/libcelt_dec.c @@ -23,7 +23,7 @@ #include #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/intreadwrite.h" struct libcelt_context { diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 0f2e671ab1..11e9d14d3a 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -24,8 +24,8 @@ #include "avcodec.h" #include "libavutil/opt.h" #include "codec_internal.h" +#include "decode.h" #include "encode.h" -#include "internal.h" #include "codec2utils.h" typedef struct { diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c index 87e412f75c..c148d46208 100644 --- a/libavcodec/libfdk-aacdec.c +++ b/libavcodec/libfdk-aacdec.c @@ -24,7 +24,7 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #ifdef AACDECODER_LIB_VL0 #define FDKDEC_VER_AT_LEAST(vl0, vl1) \ diff --git a/libavcodec/libgsmdec.c b/libavcodec/libgsmdec.c index 6e37122261..ad0b3c2f2a 100644 --- a/libavcodec/libgsmdec.c +++ b/libavcodec/libgsmdec.c @@ -40,7 +40,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "gsm.h" typedef struct LibGSMDecodeContext { diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c index 250c5fde5b..485762f66c 100644 --- a/libavcodec/libilbc.c +++ b/libavcodec/libilbc.c @@ -26,8 +26,8 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "encode.h" -#include "internal.h" #ifndef LIBILBC_VERSION_MAJOR #define LIBILBC_VERSION_MAJOR 2 diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index f54701596b..f0c5533a8b 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -36,6 +36,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index 46c8516010..0d398ff02b 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -30,8 +30,8 @@ #include "avcodec.h" #include "audio_frame_queue.h" #include "codec_internal.h" +#include "decode.h" #include "encode.h" -#include "internal.h" #if CONFIG_LIBOPENCORE_AMRNB_DECODER || CONFIG_LIBOPENCORE_AMRWB_DECODER static int amr_decode_fix_avctx(AVCodecContext *avctx) diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c index 04157d8e34..df270c77df 100644 --- a/libavcodec/libopenh264dec.c +++ b/libavcodec/libopenh264dec.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "libopenh264.h" diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index 7b7d9c8a84..fa7aba9d8a 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -29,6 +29,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "vorbis.h" #include "mathops.h" diff --git a/libavcodec/librsvgdec.c b/libavcodec/librsvgdec.c index 6e949fe3d5..bfb83da614 100644 --- a/libavcodec/librsvgdec.c +++ b/libavcodec/librsvgdec.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "libavutil/opt.h" #include "librsvg-2.0/librsvg/rsvg.h" diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index af0f224b34..b1512549d6 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -27,7 +27,7 @@ #include "libavutil/common.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct LibSpeexContext { SpeexBits bits; diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c index 5ccd9893a5..f2649540be 100644 --- a/libavcodec/libuavs3d.c +++ b/libavcodec/libuavs3d.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "avs3.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "uavs3d.h" diff --git a/libavcodec/libvorbisdec.c b/libavcodec/libvorbisdec.c index 38a8314760..f0f16f27cf 100644 --- a/libavcodec/libvorbisdec.c +++ b/libavcodec/libvorbisdec.c @@ -23,7 +23,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct OggVorbisDecContext { vorbis_info vi; /**< vorbis_info used during init */ diff --git a/libavcodec/loco.c b/libavcodec/loco.c index 4a37cd6fd8..a31bbf38c1 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -26,9 +26,9 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "golomb.h" -#include "internal.h" #include "mathops.h" enum LOCO_MODE { diff --git a/libavcodec/m101.c b/libavcodec/m101.c index 16ea6ede32..7c719006ec 100644 --- a/libavcodec/m101.c +++ b/libavcodec/m101.c @@ -22,7 +22,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int m101_decode_init(AVCodecContext *avctx) diff --git a/libavcodec/mace.c b/libavcodec/mace.c index 675725a60e..bf45b36a20 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/common.h" /* diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 8bf7c1586d..dba2b9ac34 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -36,6 +36,7 @@ #include "libavutil/thread.h" #include "libavutil/opt.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" #include "libavutil/crc.h" diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 5dabc1b5ff..0f203033ef 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -33,8 +33,8 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "mpegaudiodsp.h" #include "mpc.h" diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index f9277e6e62..4ffdb32483 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -30,8 +30,8 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "mpegaudiodsp.h" #include "mpc.h" diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 0e0bb3d762..34e9ed3505 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -40,6 +40,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "error_resilience.h" #include "hwconfig.h" #include "idctdsp.h" diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index a711154a3c..3e4ee79be6 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -36,8 +36,8 @@ #include "libavutil/thread.h" #include "avcodec.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "mathops.h" #include "mpegaudiodsp.h" diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c index f7d33e131c..574a3b1526 100644 --- a/libavcodec/mscc.c +++ b/libavcodec/mscc.c @@ -21,13 +21,12 @@ */ #include -#include #include #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "zlib_wrapper.h" #include diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c index 5374c4be81..f51075e961 100644 --- a/libavcodec/msp2dec.c +++ b/libavcodec/msp2dec.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static int msp2_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index f7dade4a29..7dfb626014 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -27,7 +27,6 @@ #include "codec_internal.h" #include "decode.h" #include "error_resilience.h" -#include "internal.h" #include "mpeg_er.h" #include "mpegvideodec.h" #include "msmpeg4dec.h" diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c index 88c360fbd3..4633fb86bc 100644 --- a/libavcodec/mv30.c +++ b/libavcodec/mv30.c @@ -20,8 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include +#include #include #include "libavutil/thread.h" @@ -30,10 +29,10 @@ #include "bytestream.h" #include "codec_internal.h" #include "copy_block.h" +#include "decode.h" #include "mathops.h" #include "blockdsp.h" #include "get_bits.h" -#include "internal.h" #include "aandcttab.h" #define CBP_VLC_BITS 9 diff --git a/libavcodec/mvcdec.c b/libavcodec/mvcdec.c index 3fa665a5df..d2e9f4b631 100644 --- a/libavcodec/mvcdec.c +++ b/libavcodec/mvcdec.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" typedef struct MvcContext { diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c index 097a52eff7..c58fd239a7 100644 --- a/libavcodec/mvha.c +++ b/libavcodec/mvha.c @@ -20,18 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - #define CACHED_BITSTREAM_READER !ARCH_X86_32 #include "libavutil/intreadwrite.h" #include "avcodec.h" -#include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "lossless_videodsp.h" #include "zlib_wrapper.h" diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c index d804433cbb..8d971fa331 100644 --- a/libavcodec/mwsc.c +++ b/libavcodec/mwsc.c @@ -21,13 +21,11 @@ */ #include -#include -#include #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "zlib_wrapper.h" #include diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c index a9f2a2bc2b..b3862c7791 100644 --- a/libavcodec/mxpegdec.c +++ b/libavcodec/mxpegdec.c @@ -26,7 +26,7 @@ */ #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mjpeg.h" #include "mjpegdec.h" diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 5c8b23ecb3..3f1d1e028c 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -35,14 +35,13 @@ #include "libavutil/float_dsp.h" #include "libavutil/lfg.h" #include "libavutil/mem_internal.h" -#include "libavutil/random_seed.h" #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "fft.h" #include "get_bits.h" -#include "internal.h" #include "nellymoser.h" #include "sinewin.h" diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 1fccdc8745..3aadac4baf 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -28,9 +28,9 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "fft.h" #include "get_bits.h" -#include "internal.h" #include "on2avcdata.h" diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c index 17a4fc96c1..792eeb1507 100644 --- a/libavcodec/opusdec.c +++ b/libavcodec/opusdec.c @@ -44,9 +44,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "get_bits.h" -#include "internal.h" -#include "mathops.h" +#include "decode.h" #include "opus.h" #include "opustab.h" #include "opus_celt.h" diff --git a/libavcodec/pafaudio.c b/libavcodec/pafaudio.c index fc642db2ed..16f440dd87 100644 --- a/libavcodec/pafaudio.c +++ b/libavcodec/pafaudio.c @@ -24,7 +24,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mathops.h" #include "paf.h" diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c index 54338e679f..365b69b599 100644 --- a/libavcodec/pcm-bluray.c +++ b/libavcodec/pcm-bluray.c @@ -28,7 +28,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" /* * Channel Mapping according to diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c index 0f37c6e08e..358c9d5b0f 100644 --- a/libavcodec/pcm-dvd.c +++ b/libavcodec/pcm-dvd.c @@ -27,7 +27,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct PCMDVDContext { uint32_t last_header; // Cached header to see if parsing is needed diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index d097900235..8e87679329 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -33,9 +33,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "encode.h" -#include "internal.h" -#include "mathops.h" #include "pcm_tablegen.h" static av_cold int pcm_encode_init(AVCodecContext *avctx) diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index b21bdce5ce..7a47ef827c 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c index 52e2c2a36c..dcbf2a32dd 100644 --- a/libavcodec/pgxdec.c +++ b/libavcodec/pgxdec.c @@ -23,7 +23,7 @@ #include "internal.h" #include "bytestream.h" #include "codec_internal.h" -#include "libavutil/imgutils.h" +#include "decode.h" static int pgx_get_number(AVCodecContext *avctx, GetByteContext *g, int *number) { int ret = AVERROR_INVALIDDATA; diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index ed0292c797..f215f0d220 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -29,6 +29,7 @@ #include "bytestream.h" #include "cga_data.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" typedef struct PicContext { diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index fbed282e93..6e807a7ac1 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -25,7 +25,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "put_bits.h" #include "pnm.h" diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c index c038b9db64..974b1657c3 100644 --- a/libavcodec/prosumer.c +++ b/libavcodec/prosumer.c @@ -23,7 +23,6 @@ #include #include -#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" @@ -31,7 +30,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" typedef struct ProSumerContext { GetByteContext gb; diff --git a/libavcodec/psd.c b/libavcodec/psd.c index 1d92163408..5a5c57e856 100644 --- a/libavcodec/psd.c +++ b/libavcodec/psd.c @@ -21,6 +21,7 @@ #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" enum PsdCompr { diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index 1102049347..412df4d763 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -21,9 +21,9 @@ #include "libavutil/common.h" #include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" static int ptx_decode_frame(AVCodecContext *avctx, AVFrame *p, diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index 8a46ec5dab..f9da514834 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -27,14 +27,12 @@ * @remark Development mentored by Benjamin Larson */ -#include - #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/float_dsp.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "qcelpdata.h" #include "celp_filters.h" diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 12db585aa2..51ca1fb516 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -33,7 +33,6 @@ #include #include -#include #include "libavutil/channel_layout.h" #include "libavutil/mem_internal.h" @@ -44,7 +43,7 @@ #include "get_bits.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mpegaudio.h" #include "mpegaudiodsp.h" #include "rdft.h" diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index 0a66d66441..77bb8d1742 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @@ -21,7 +21,6 @@ #include #include -#include #define BITSTREAM_READER_LE @@ -32,8 +31,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct QDMCTone { uint8_t mode; diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index ff8f97713d..1aac7c8010 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -31,6 +31,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" enum QuickdrawOpcodes { diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index ea92b693cd..ea11e10b1a 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -28,7 +28,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct QpegContext{ AVCodecContext *avctx; diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c index 5ac285f286..163e203c73 100644 --- a/libavcodec/r210dec.c +++ b/libavcodec/r210dec.c @@ -23,7 +23,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "config_components.h" -#include "internal.h" +#include "decode.h" #include "libavutil/bswap.h" #include "libavutil/common.h" diff --git a/libavcodec/ra144dec.c b/libavcodec/ra144dec.c index a56d4f7d51..f9c0900de0 100644 --- a/libavcodec/ra144dec.c +++ b/libavcodec/ra144dec.c @@ -25,8 +25,8 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "ra144.h" diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 4b2cc188b4..73242669d3 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -28,8 +28,8 @@ #include "avcodec.h" #include "celp_filters.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "lpc.h" #include "ra288.h" diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index ff4556b707..5efa919e09 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -30,9 +30,9 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "golomb.h" -#include "internal.h" #include "unary.h" #include "ralfdata.h" diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c index 805e29338d..a74b4d145c 100644 --- a/libavcodec/rasc.c +++ b/libavcodec/rasc.c @@ -21,15 +21,14 @@ */ #include -#include #include -#include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "zlib_wrapper.h" diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index fc022ff43e..e7c3800f9e 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -35,6 +35,7 @@ #include "libavutil/mem.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index fb7b6e240b..07d036e932 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -27,8 +27,7 @@ #include "libavutil/reverse.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" -#include "mathops.h" +#include "decode.h" #define AES3_HEADER_LEN 4 diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 775768b7a0..064e812e51 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -28,6 +28,7 @@ #include "bytestream.h" #include "copy_block.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define NGLYPHS 256 diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c index b7e59d7124..3c955d5b96 100644 --- a/libavcodec/sbcdec.c +++ b/libavcodec/sbcdec.c @@ -32,7 +32,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem_internal.h" diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index ff78041386..3abde1c17a 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -20,15 +20,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "scpr.h" #include "scpr3.h" diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index 78c58889cb..d9ea6af1c1 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -28,7 +28,6 @@ #include "avcodec.h" #include "bytestream.h" -#include "internal.h" #include "scpr.h" static void renew_table3(uint32_t nsym, uint32_t *cntsum, diff --git a/libavcodec/sga.c b/libavcodec/sga.c index 27918ee2b3..febe950424 100644 --- a/libavcodec/sga.c +++ b/libavcodec/sga.c @@ -23,6 +23,7 @@ #include "get_bits.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define PALDATA_FOLLOWS_TILEDATA 4 diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index 965461de5f..c1070d5c95 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -23,6 +23,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "sgi.h" diff --git a/libavcodec/sgirledec.c b/libavcodec/sgirledec.c index a9fd24c406..c1d1da25c4 100644 --- a/libavcodec/sgirledec.c +++ b/libavcodec/sgirledec.c @@ -30,7 +30,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int sgirle_decode_init(AVCodecContext *avctx) { diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 39aa1475bd..02864d06ae 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -30,9 +30,9 @@ #include "bswapdsp.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "golomb.h" -#include "internal.h" #define MAX_CHANNELS 8 #define MAX_BLOCKSIZE 65535 diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c index bf8d627e16..d28bc760ca 100644 --- a/libavcodec/sipr.c +++ b/libavcodec/sipr.c @@ -32,8 +32,8 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "lsp.h" #include "acelp_vectors.h" #include "acelp_pitch_delay.h" diff --git a/libavcodec/siren.c b/libavcodec/siren.c index e7a5a33553..8a22825615 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -28,9 +28,8 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" -#include "mathops.h" static const uint8_t index_table[8] = {4, 4, 3, 3, 2, 2, 1, 0}; static const uint8_t vector_dimension[8] = { 2, 2, 2, 4, 4, 5, 5, 1 }; diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 5ef84a068f..2b1c4aebb5 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -28,8 +28,7 @@ * Based on http://wiki.multimedia.cx/index.php?title=Smacker */ -#include -#include +#include #include "libavutil/channel_layout.h" @@ -53,8 +52,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" -#include "mathops.h" typedef struct SmackVContext { AVCodecContext *avctx; diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 5e0033063d..aa15fccc42 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -18,21 +18,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intmath.h" #include "libavutil/log.h" -#include "libavutil/opt.h" #include "libavutil/thread.h" #include "avcodec.h" +#include "decode.h" #include "encode.h" #include "me_cmp.h" #include "snow_dwt.h" -#include "internal.h" #include "snow.h" #include "snowdata.h" -#include "rangecoder.h" -#include "mathops.h" - void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){ diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 2dc6ac3f2d..50fd171231 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -23,10 +23,10 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "encode.h" #include "get_bits.h" #include "golomb.h" -#include "internal.h" #include "put_golomb.h" #include "rangecoder.h" diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index c43de4f199..b3b3f091d6 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -26,7 +26,6 @@ #define BITSTREAM_READER_LE -#include "config.h" #include "config_components.h" #include "libavutil/attributes.h" #include "libavutil/mem_internal.h" @@ -34,9 +33,9 @@ #include "avcodec.h" #include "blockdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "idctdsp.h" -#include "internal.h" #include "libavutil/thread.h" #include "mathops.h" #include "mpeg12dec.h" diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c index 92a4f392a7..d16317ddec 100644 --- a/libavcodec/speexdec.c +++ b/libavcodec/speexdec.c @@ -56,8 +56,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "speexdata.h" #define SPEEX_NB_MODES 3 diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index e543757a39..51695c353c 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -24,6 +24,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "sunrast.h" diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index 27feac354c..e091e4279f 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -37,6 +37,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "h263data.h" #include "hpeldsp.h" diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index 1c3ed3c2fd..d4fff0557b 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -47,6 +47,7 @@ #include "libavutil/mem_internal.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "avcodec.h" #include "mpegutils.h" diff --git a/libavcodec/targa.c b/libavcodec/targa.c index 833576c6b3..2901d908de 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -24,6 +24,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "targa.h" diff --git a/libavcodec/targa_y216dec.c b/libavcodec/targa_y216dec.c index 1c19857547..ab98597492 100644 --- a/libavcodec/targa_y216dec.c +++ b/libavcodec/targa_y216dec.c @@ -21,7 +21,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int y216_decode_init(AVCodecContext *avctx) { diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c index 7e16a32093..c4e4d35ee8 100644 --- a/libavcodec/tdsc.c +++ b/libavcodec/tdsc.c @@ -41,6 +41,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define BITMAPINFOHEADER_SIZE 0x28 diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c index 22329f2db0..fff3806e04 100644 --- a/libavcodec/tmv.c +++ b/libavcodec/tmv.c @@ -30,7 +30,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/internal.h" #include "libavutil/xga_font_data.h" diff --git a/libavcodec/truemotion2rt.c b/libavcodec/truemotion2rt.c index 46452a772b..265ca87456 100644 --- a/libavcodec/truemotion2rt.c +++ b/libavcodec/truemotion2rt.c @@ -29,6 +29,7 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index f0cfada11c..2493a944cf 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -20,14 +20,13 @@ */ #include "libavutil/channel_layout.h" -#include "libavutil/intreadwrite.h" #include "libavutil/mem_internal.h" #include "avcodec.h" #include "bswapdsp.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "truespeech_data.h" /** diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index ba84c8c6b0..da10923d78 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -25,8 +25,8 @@ #include "libavutil/channel_layout.h" #include "libavutil/float_dsp.h" #include "avcodec.h" +#include "decode.h" #include "fft.h" -#include "internal.h" #include "lsp.h" #include "sinewin.h" #include "twinvq.h" diff --git a/libavcodec/txd.c b/libavcodec/txd.c index 8b1da773a3..8862f14bd8 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -26,6 +26,7 @@ #include "bytestream.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "texturedsp.h" diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c index f388a1cf9a..dc188eb8a3 100644 --- a/libavcodec/v210x.c +++ b/libavcodec/v210x.c @@ -20,7 +20,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/bswap.h" #include "libavutil/internal.h" diff --git a/libavcodec/v308dec.c b/libavcodec/v308dec.c index a6a699cab7..ee9d723dd6 100644 --- a/libavcodec/v308dec.c +++ b/libavcodec/v308dec.c @@ -21,7 +21,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int v308_decode_init(AVCodecContext *avctx) { diff --git a/libavcodec/v408dec.c b/libavcodec/v408dec.c index 694ee96b77..0c1d0244d0 100644 --- a/libavcodec/v408dec.c +++ b/libavcodec/v408dec.c @@ -23,7 +23,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int v408_decode_init(AVCodecContext *avctx) { diff --git a/libavcodec/vb.c b/libavcodec/vb.c index 0bd2cb6185..9024f0947c 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -24,13 +24,10 @@ * VB Video decoder */ -#include -#include - #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" enum VBFlags { VB_HAS_GMC = 0x01, diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c index 8be625c89e..706760f376 100644 --- a/libavcodec/vbndec.c +++ b/libavcodec/vbndec.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "texturedsp.h" #include "vbn.h" diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 065b43cb11..60e86acfd9 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -34,7 +34,6 @@ #include "decode.h" #include "get_bits.h" #include "hwconfig.h" -#include "internal.h" #include "mpeg_er.h" #include "mpegvideo.h" #include "mpegvideodec.h" diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index b149c9f162..a97412fe7d 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/avassert.h" #include "libavutil/internal.h" diff --git a/libavcodec/vima.c b/libavcodec/vima.c index 9a7726168b..0ccf2dd877 100644 --- a/libavcodec/vima.c +++ b/libavcodec/vima.c @@ -31,8 +31,8 @@ #include "adpcm_data.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" static uint16_t predict_table[5786 * 2]; diff --git a/libavcodec/vmdaudio.c b/libavcodec/vmdaudio.c index e54e341f90..158b02f6d9 100644 --- a/libavcodec/vmdaudio.c +++ b/libavcodec/vmdaudio.c @@ -42,7 +42,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #define BLOCK_TYPE_AUDIO 1 #define BLOCK_TYPE_INITIAL 2 diff --git a/libavcodec/vmdvideo.c b/libavcodec/vmdvideo.c index 131e013a94..3e530e6ee5 100644 --- a/libavcodec/vmdvideo.c +++ b/libavcodec/vmdvideo.c @@ -40,7 +40,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "bytestream.h" #define VMD_HEADER_SIZE 0x330 diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index b94b4a34e0..8addc07dcf 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -35,9 +35,9 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "fft.h" #include "get_bits.h" -#include "internal.h" #include "vorbis.h" #include "vorbisdsp.h" #include "xiph.h" diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 3863af15e5..1c58096bdb 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -25,6 +25,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "decode.h" #include "internal.h" #include "h264chroma.h" #include "vp56.h" diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 755fd39521..c3badcd5f9 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -40,6 +40,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "wma.h" diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 6ba9f04d25..fa4230c1b5 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -30,11 +30,10 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "put_bits.h" #include "lossless_audiodsp.h" -#include "wma.h" #include "wma_common.h" /** current decoder limitations */ diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 136522bbf6..b90fd581f0 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -98,8 +98,9 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" +#include "internal.h" #include "put_bits.h" #include "wmaprodata.h" #include "sinewin.h" diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 6f6cc949f9..6b7e9d5a31 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -33,7 +33,7 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "put_bits.h" #include "wmavoice_data.h" diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 8e568e7386..ff5238eed0 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -29,8 +29,8 @@ #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" static const uint8_t code_tab[16][2] = { { 7, 1 }, { 8, 3 }, { 6, 3 }, { 9, 4 }, { 5, 4 }, { 10, 5 }, { 4, 5 }, diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c index ceda57597f..6dcb8d2a24 100644 --- a/libavcodec/ws-snd1.c +++ b/libavcodec/ws-snd1.c @@ -26,7 +26,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" /** * @file diff --git a/libavcodec/xan.c b/libavcodec/xan.c index cdc302f6d1..d9df569a04 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -28,8 +28,6 @@ * The xan_wc3 decoder outputs PAL8 data. */ -#include -#include #include #include "libavutil/intreadwrite.h" @@ -39,8 +37,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #define RUNTIME_GAMMA 0 diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index 62ce46f3a7..a28da08a29 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -25,6 +25,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "mathops.h" diff --git a/libavcodec/xfacedec.c b/libavcodec/xfacedec.c index 880a62c976..eb16bb6727 100644 --- a/libavcodec/xfacedec.c +++ b/libavcodec/xfacedec.c @@ -24,11 +24,9 @@ * X-Face decoder, based on libcompface, by James Ashton. */ -#include "libavutil/pixdesc.h" #include "avcodec.h" -#include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "xface.h" static int pop_integer(BigInt *b, const ProbRange *pranges) diff --git a/libavcodec/xl.c b/libavcodec/xl.c index 6fb050d71f..ada0959346 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -28,7 +28,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static const int xl_table[32] = { 0, 1, 2, 3, 4, 5, 6, 7, diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index 26d076d2e8..a1d5635874 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -21,10 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/parseutils.h" #include "libavutil/avstring.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #define MIN_ELEMENT ' ' diff --git a/libavcodec/xwddec.c b/libavcodec/xwddec.c index f8afab598d..43d4bb5e84 100644 --- a/libavcodec/xwddec.c +++ b/libavcodec/xwddec.c @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "internal.h" #include "xwd.h" diff --git a/libavcodec/y41pdec.c b/libavcodec/y41pdec.c index 717909745b..7d63228937 100644 --- a/libavcodec/y41pdec.c +++ b/libavcodec/y41pdec.c @@ -22,7 +22,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int y41p_decode_init(AVCodecContext *avctx) { diff --git a/libavcodec/yuv4dec.c b/libavcodec/yuv4dec.c index 4a1551eb6c..274b8b7b2d 100644 --- a/libavcodec/yuv4dec.c +++ b/libavcodec/yuv4dec.c @@ -22,7 +22,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" static av_cold int yuv4_decode_init(AVCodecContext *avctx) { diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c index 8a0d8bc677..c369ff8e3c 100644 --- a/libavcodec/zerocodec.c +++ b/libavcodec/zerocodec.c @@ -20,7 +20,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "zlib_wrapper.h" #include "libavutil/common.h" diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index a6d9824197..edbd88eb73 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -24,15 +24,14 @@ * Zip Motion Blocks Video decoder */ -#include -#include +#include #include "libavutil/common.h" #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "zlib_wrapper.h" #include From b6a680989c2f2428a25bea322ffd2b546474df75 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 21:43:37 +0200 Subject: [PATCH 046/590] avcodec/internal: Move ff_set_sar() to decode.h Only used by decoders, as the SAR has to be set by the user when encoding. Signed-off-by: Andreas Rheinhardt --- libavcodec/av1dec.c | 1 + libavcodec/decode.h | 6 ++++++ libavcodec/dvdec.c | 1 + libavcodec/exr.c | 1 + libavcodec/h264_slice.c | 1 + libavcodec/hevcdec.c | 1 + libavcodec/internal.h | 6 ------ libavcodec/vc1.c | 1 + libavcodec/vp3.c | 1 + 9 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 8abb7b3b34..7b5b2c996a 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -27,6 +27,7 @@ #include "av1dec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "hwconfig.h" #include "internal.h" #include "profiles.h" diff --git a/libavcodec/decode.h b/libavcodec/decode.h index 25db4a9e4d..b82d953516 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -99,6 +99,12 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); */ int ff_decode_preinit(AVCodecContext *avctx); +/** + * Check that the provided sample aspect ratio is valid and set it on the codec + * context. + */ +int ff_set_sar(AVCodecContext *avctx, AVRational sar); + /** * Select the (possibly hardware accelerated) pixel format. * This is a wrapper around AVCodecContext.get_format() and should be used diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index f7423580aa..d1de9cd9e2 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -44,6 +44,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "dv.h" #include "dv_profile_internal.h" #include "dvdata.h" diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 859dd6fedd..a62cc95d28 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -51,6 +51,7 @@ #endif #include "codec_internal.h" +#include "decode.h" #include "exrdsp.h" #include "get_bits.h" #include "internal.h" diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 8f9d0a6231..6f0a7c1fb7 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -36,6 +36,7 @@ #include "internal.h" #include "cabac.h" #include "cabac_functions.h" +#include "decode.h" #include "error_resilience.h" #include "avcodec.h" #include "h264.h" diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 477d6d9d36..ed6cef6bfb 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -42,6 +42,7 @@ #include "bytestream.h" #include "cabac_functions.h" #include "codec_internal.h" +#include "decode.h" #include "golomb.h" #include "hevc.h" #include "hevc_data.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index c1eddd0879..0c1225f98b 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -222,12 +222,6 @@ int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); */ int ff_set_dimensions(AVCodecContext *s, int width, int height); -/** - * Check that the provided sample aspect ratio is valid and set it on the codec - * context. - */ -int ff_set_sar(AVCodecContext *avctx, AVRational sar); - /** * Add or update AV_FRAME_DATA_MATRIXENCODING side data. */ diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index 1070b8ca90..d46f551020 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -30,6 +30,7 @@ #include "libavutil/thread.h" #include "internal.h" #include "avcodec.h" +#include "decode.h" #include "mpegvideo.h" #include "vc1.h" #include "vc1data.h" diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 3f6b0100d9..0f040c338f 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -41,6 +41,7 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "hpeldsp.h" #include "internal.h" From b9eaf77ed1b3b551f71f90b3fb2624379d0b29c3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 22:03:27 +0200 Subject: [PATCH 047/590] avcodec/internal: Move ff_set_dimensions() to decode.h Decoder-only, as the dimensions are set by the user when encoding. Also fixup the other headers a bit while removing unnecessary internal.h inclusions. Signed-off-by: Andreas Rheinhardt --- libavcodec/agm.c | 3 --- libavcodec/aliaspixdec.c | 1 - libavcodec/ansi.c | 2 -- libavcodec/av1dec.c | 1 - libavcodec/avs.c | 1 - libavcodec/bmp.c | 1 - libavcodec/brenderpix.c | 1 - libavcodec/c93.c | 1 - libavcodec/cavsdec.c | 1 - libavcodec/cdgraphics.c | 1 - libavcodec/cdxl.c | 2 -- libavcodec/cfhd.c | 4 ++-- libavcodec/clearvideo.c | 1 - libavcodec/cri.c | 2 +- libavcodec/dds.c | 2 -- libavcodec/decode.h | 6 ++++++ libavcodec/diracdec.c | 3 --- libavcodec/dnxhddec.c | 4 ++-- libavcodec/dpx.c | 2 -- libavcodec/dvbsubdec.c | 2 +- libavcodec/dvdec.c | 3 --- libavcodec/dvdsubdec.c | 2 +- libavcodec/eacmv.c | 1 - libavcodec/eamad.c | 1 - libavcodec/eatgq.c | 1 - libavcodec/eatgv.c | 2 -- libavcodec/eatqi.c | 1 - libavcodec/exr.c | 1 - libavcodec/fitsdec.c | 1 - libavcodec/flashsv.c | 4 +--- libavcodec/g2meet.c | 3 --- libavcodec/gemdec.c | 1 - libavcodec/gifdec.c | 2 -- libavcodec/h261dec.c | 2 +- libavcodec/h263dec.c | 1 - libavcodec/hdrdec.c | 5 +---- libavcodec/hq_hqa.c | 2 -- libavcodec/imm4.c | 4 +--- libavcodec/indeo3.c | 1 - libavcodec/internal.h | 6 ------ libavcodec/ivi.c | 1 - libavcodec/jpeg2000dec.c | 2 +- libavcodec/kgv1dec.c | 1 - libavcodec/libaomdec.c | 1 - libavcodec/libjxldec.c | 1 - libavcodec/libopenh264dec.c | 1 - libavcodec/libopenjpegdec.c | 2 +- libavcodec/librsvgdec.c | 1 - libavcodec/libuavs3d.c | 1 - libavcodec/libvpxdec.c | 1 - libavcodec/magicyuv.c | 3 +-- libavcodec/mediacodecdec_common.c | 1 - libavcodec/mimic.c | 4 +--- libavcodec/mpeg4video_parser.c | 2 +- libavcodec/mpegvideo_parser.c | 2 +- libavcodec/mvcdec.c | 1 - libavcodec/notchlc.c | 4 +--- libavcodec/nuv.c | 6 +----- libavcodec/pcx.c | 2 -- libavcodec/pgssubdec.c | 3 +-- libavcodec/pgxdec.c | 1 - libavcodec/photocd.c | 2 +- libavcodec/pictordec.c | 1 - libavcodec/pixlet.c | 4 +--- libavcodec/pngdec.c | 2 +- libavcodec/pnm.c | 2 +- libavcodec/proresdec2.c | 3 +-- libavcodec/psd.c | 1 - libavcodec/ptx.c | 1 - libavcodec/qdrw.c | 1 - libavcodec/qoidec.c | 5 +---- libavcodec/rasc.c | 1 - libavcodec/rl2.c | 3 --- libavcodec/rv10.c | 2 +- libavcodec/rv34.c | 3 +-- libavcodec/sanm.c | 3 --- libavcodec/sga.c | 1 - libavcodec/sgidec.c | 2 -- libavcodec/sunrast.c | 2 -- libavcodec/svq1dec.c | 1 - libavcodec/svq3.c | 3 --- libavcodec/targa.c | 3 --- libavcodec/tdsc.c | 1 - libavcodec/tiertexseqv.c | 1 - libavcodec/tiff.c | 5 +---- libavcodec/truemotion1.c | 1 - libavcodec/truemotion2rt.c | 6 ------ libavcodec/txd.c | 3 --- libavcodec/v4l2_context.c | 2 +- libavcodec/vbndec.c | 1 - libavcodec/vc1.c | 1 - libavcodec/vp3.c | 4 +--- libavcodec/vp5.c | 3 +-- libavcodec/vp56.c | 1 - libavcodec/vp6.c | 2 +- libavcodec/vp8.c | 3 --- libavcodec/vp9.c | 2 +- libavcodec/vqavideo.c | 3 --- libavcodec/wbmpdec.c | 2 +- libavcodec/webp.c | 2 +- libavcodec/xbmdec.c | 3 --- libavcodec/xpmdec.c | 1 - libavcodec/xwddec.c | 1 - 103 files changed, 42 insertions(+), 178 deletions(-) diff --git a/libavcodec/agm.c b/libavcodec/agm.c index 08a5f05b91..38d9c67f80 100644 --- a/libavcodec/agm.c +++ b/libavcodec/agm.c @@ -20,8 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #define BITSTREAM_READER_LE @@ -35,7 +33,6 @@ #include "decode.h" #include "get_bits.h" #include "idctdsp.h" -#include "internal.h" static const uint8_t unscaled_luma[64] = { 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c index 522b894af5..7dedfe3aa1 100644 --- a/libavcodec/aliaspixdec.c +++ b/libavcodec/aliaspixdec.c @@ -25,7 +25,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define ALIAS_HEADER_SIZE 10 diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index 1cd9ebceba..89bde59b40 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -26,13 +26,11 @@ #include "libavutil/common.h" #include "libavutil/frame.h" -#include "libavutil/lfg.h" #include "libavutil/xga_font_data.h" #include "avcodec.h" #include "cga_data.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define ATTR_BOLD 0x01 /**< Bold/Bright-foreground (mode 1) */ #define ATTR_FAINT 0x02 /**< Faint (mode 2) */ diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 7b5b2c996a..401462701f 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -29,7 +29,6 @@ #include "codec_internal.h" #include "decode.h" #include "hwconfig.h" -#include "internal.h" #include "profiles.h" #include "thread.h" diff --git a/libavcodec/avs.c b/libavcodec/avs.c index 86a41a31be..ca2b2d4701 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -23,7 +23,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct AvsContext { AVFrame *frame; diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 7bbaabcda4..d381eb2eee 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -26,7 +26,6 @@ #include "bmp.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "msrledec.h" static int bmp_decode_frame(AVCodecContext *avctx, AVFrame *p, diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c index 2d8e978c1e..170acc39a3 100644 --- a/libavcodec/brenderpix.c +++ b/libavcodec/brenderpix.c @@ -27,7 +27,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define HEADER1_CHUNK 0x03 #define HEADER2_CHUNK 0x3D diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 871ae589e6..03381f1e88 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -23,7 +23,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct C93DecoderContext { AVFrame *pictures[2]; diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 417c73bd2e..3d4e306c93 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -32,7 +32,6 @@ #include "cavs.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "mathops.h" #include "mpeg12data.h" #include "startcode.h" diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 240c57d5f8..19366bdcfe 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -23,7 +23,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" /** * @file diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c index 64fcdffba4..5821aaeb22 100644 --- a/libavcodec/cdxl.c +++ b/libavcodec/cdxl.c @@ -28,13 +28,11 @@ #define UNCHECKED_BITSTREAM_READER 1 #include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" #define BIT_PLANAR 0x00 #define CHUNKY 0x20 diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 9f218f6384..f908aaf8fb 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -26,13 +26,13 @@ #include "libavutil/attributes.h" #include "libavutil/buffer.h" #include "libavutil/common.h" -#include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" -#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" #include "thread.h" diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 4e5fc02e23..8615bf2a51 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -33,7 +33,6 @@ #include "decode.h" #include "get_bits.h" #include "idctdsp.h" -#include "internal.h" #include "mathops.h" #include "clearvideodata.h" diff --git a/libavcodec/cri.c b/libavcodec/cri.c index 2ac04575b7..65eb53d22e 100644 --- a/libavcodec/cri.c +++ b/libavcodec/cri.c @@ -32,8 +32,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "thread.h" typedef struct CRIContext { diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 63f63efca2..6904191310 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -35,9 +35,7 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "texturedsp.h" -#include "thread.h" #define DDPF_FOURCC (1 << 2) #define DDPF_PALETTE (1 << 5) diff --git a/libavcodec/decode.h b/libavcodec/decode.h index b82d953516..d40327d5ab 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -99,6 +99,12 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); */ int ff_decode_preinit(AVCodecContext *avctx); +/** + * Check that the provided frame dimensions are valid and set them on the codec + * context. + */ +int ff_set_dimensions(AVCodecContext *s, int width, int height); + /** * Check that the provided sample aspect ratio is valid and set it on the codec * context. diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 59c5e81904..ef00c29150 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -31,14 +31,11 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "get_bits.h" -#include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "golomb.h" #include "dirac_arith.h" #include "dirac_vlc.h" -#include "mpeg12data.h" #include "mpegpicture.h" #include "mpegvideoencdsp.h" #include "dirac_dwt.h" diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 8b6c473c5b..1c749d026c 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -24,17 +24,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/imgutils.h" #include "libavutil/mem_internal.h" +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "blockdsp.h" #include "codec_internal.h" +#include "decode.h" #define UNCHECKED_BITSTREAM_READER 1 #include "get_bits.h" #include "dnxhddata.h" #include "idctdsp.h" -#include "internal.h" #include "profiles.h" #include "thread.h" diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index c3f0d3f95a..afd9f17b04 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -24,11 +24,9 @@ #include "libavutil/intfloat.h" #include "libavutil/imgutils.h" #include "libavutil/timecode.h" -#include "bytestream.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" enum DPX_TRC { DPX_TRC_USER_DEFINED = 0, diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 90c062502b..63d4a13bcb 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -23,7 +23,7 @@ #include "get_bits.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "libavutil/colorspace.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index d1de9cd9e2..12e837c9ff 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -36,10 +36,8 @@ */ #include "libavutil/avassert.h" -#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/mem_internal.h" -#include "libavutil/pixdesc.h" #include "libavutil/thread.h" #include "avcodec.h" @@ -49,7 +47,6 @@ #include "dv_profile_internal.h" #include "dvdata.h" #include "get_bits.h" -#include "internal.h" #include "put_bits.h" #include "simple_idct.h" #include "thread.h" diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 7fa3363a9c..4b692c093f 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -21,13 +21,13 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "internal.h" #include "libavutil/attributes.h" #include "libavutil/colorspace.h" #include "libavutil/opt.h" -#include "libavutil/imgutils.h" #include "libavutil/bswap.h" typedef struct DVDSubContext diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index 733cc2a1c0..e8d757ed37 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -34,7 +34,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct CmvContext { AVCodecContext *avctx; diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 70cea0ed6c..4904730c65 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -40,7 +40,6 @@ #include "aandcttab.h" #include "eaidct.h" #include "idctdsp.h" -#include "internal.h" #include "mpeg12data.h" #include "mpeg12vlc.h" diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index 5d57fb34f8..bdf70292fd 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -40,7 +40,6 @@ #include "eaidct.h" #include "get_bits.h" #include "idctdsp.h" -#include "internal.h" typedef struct TgqContext { AVCodecContext *avctx; diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index b1483cc586..02a547b2da 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -28,7 +28,6 @@ * http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TGV */ -#include "libavutil/imgutils.h" #include "libavutil/mem.h" #define BITSTREAM_READER_LE @@ -36,7 +35,6 @@ #include "get_bits.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define EA_PREAMBLE_SIZE 8 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 013e5415d2..1aafd9af0c 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -37,7 +37,6 @@ #include "aandcttab.h" #include "eaidct.h" #include "idctdsp.h" -#include "internal.h" #include "mpeg12data.h" #include "mpeg12dec.h" diff --git a/libavcodec/exr.c b/libavcodec/exr.c index a62cc95d28..f6eab048f4 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -54,7 +54,6 @@ #include "decode.h" #include "exrdsp.h" #include "get_bits.h" -#include "internal.h" #include "mathops.h" #include "thread.h" diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c index 28954f370c..7e45f2a65f 100644 --- a/libavcodec/fitsdec.c +++ b/libavcodec/fitsdec.c @@ -33,7 +33,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 11d6657394..76459df4cb 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -35,8 +35,7 @@ #include "config_components.h" -#include -#include +#include #include #include "libavutil/intreadwrite.h" @@ -45,7 +44,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" #include "zlib_wrapper.h" typedef struct BlockInfo { diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index f2300e1ca6..154ff10aad 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -29,7 +29,6 @@ #include #include "libavutil/imgutils.h" -#include "libavutil/intreadwrite.h" #include "libavutil/mem_internal.h" #include "avcodec.h" @@ -40,9 +39,7 @@ #include "elsdec.h" #include "get_bits.h" #include "idctdsp.h" -#include "internal.h" #include "jpegtables.h" -#include "mjpeg.h" #include "mjpegdec.h" #define EPIC_PIX_STACK_SIZE 1024 diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c index 39bfedb560..5533f981dc 100644 --- a/libavcodec/gemdec.c +++ b/libavcodec/gemdec.c @@ -28,7 +28,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" static const uint32_t gem_color_palette[16]={ 0xFFFFFFFF, 0xFFFF0000, 0xFF00FF00, 0xFFFFFF00, diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index 15d4f9743f..d8638a37be 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -21,13 +21,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "lzw.h" #include "gif.h" diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 97c126ab5a..70a26f443d 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -29,12 +29,12 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodec.h" #include "h261.h" -#include "internal.h" #define H261_MBA_VLC_BITS 8 #define H261_MTYPE_VLC_BITS 6 diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 87fbf87c8a..8b4101272a 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -40,7 +40,6 @@ #include "h263_parser.h" #endif #include "hwconfig.h" -#include "internal.h" #include "mpeg_er.h" #include "mpeg4video.h" #include "mpeg4videodec.h" diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c index 29e87057fa..9079e4a843 100644 --- a/libavcodec/hdrdec.c +++ b/libavcodec/hdrdec.c @@ -18,13 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#include "libavutil/imgutils.h" #include "avcodec.h" -#include "internal.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "thread.h" #define MINELEN 8 diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index e0fbf7de65..075c74d105 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -21,7 +21,6 @@ #include #include "libavutil/attributes.h" -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" @@ -29,7 +28,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" #include "hq_hqa.h" #include "hq_hqadsp.h" diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index b2840a2c3f..96a395a100 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm4.c @@ -20,8 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include +#include #include #include "libavutil/mem_internal.h" @@ -34,7 +33,6 @@ #include "copy_block.h" #include "get_bits.h" #include "idctdsp.h" -#include "internal.h" #define CBPLO_VLC_BITS 6 #define CBPHI_VLC_BITS 6 diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 95708f3636..a41608bb7e 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -39,7 +39,6 @@ #include "bytestream.h" #include "get_bits.h" #include "hpeldsp.h" -#include "internal.h" #include "indeo3data.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 0c1225f98b..823067b7ee 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -216,12 +216,6 @@ int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); -/** - * Check that the provided frame dimensions are valid and set them on the codec - * context. - */ -int ff_set_dimensions(AVCodecContext *s, int width, int height); - /** * Add or update AV_FRAME_DATA_MATRIXENCODING side data. */ diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c index cddef6f51e..43f3cb1da3 100644 --- a/libavcodec/ivi.c +++ b/libavcodec/ivi.c @@ -36,7 +36,6 @@ #include "avcodec.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" #include "ivi.h" #include "ivi_dsp.h" diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 5e177cec25..2c1191035c 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -37,7 +37,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "thread.h" #include "jpeg2000.h" #include "jpeg2000dsp.h" diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 0dfb796483..11dfc1b84f 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -30,7 +30,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct KgvContext { uint16_t *frame_buffer; diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c index 274c67baaa..5ed219b43d 100644 --- a/libavcodec/libaomdec.c +++ b/libavcodec/libaomdec.c @@ -33,7 +33,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libaom.h" #include "profiles.h" diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index f0c5533a8b..0d59160d27 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -37,7 +37,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include #include diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c index df270c77df..3a8be36bf6 100644 --- a/libavcodec/libopenh264dec.c +++ b/libavcodec/libopenh264dec.c @@ -32,7 +32,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libopenh264.h" typedef struct SVCContext { diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c index fa420f145b..be2337d9b2 100644 --- a/libavcodec/libopenjpegdec.c +++ b/libavcodec/libopenjpegdec.c @@ -32,7 +32,7 @@ #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "thread.h" #include diff --git a/libavcodec/librsvgdec.c b/libavcodec/librsvgdec.c index bfb83da614..cfafae2652 100644 --- a/libavcodec/librsvgdec.c +++ b/libavcodec/librsvgdec.c @@ -22,7 +22,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libavutil/opt.h" #include "librsvg-2.0/librsvg/rsvg.h" diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c index f2649540be..95616fcacb 100644 --- a/libavcodec/libuavs3d.c +++ b/libavcodec/libuavs3d.c @@ -31,7 +31,6 @@ #include "avs3.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "uavs3d.h" typedef struct uavs3d_context { diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index c5b95332d3..c7cb744312 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -37,7 +37,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libvpx.h" #include "profiles.h" diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 65dbb6a2f1..8b30ce08ac 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -29,9 +29,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "huffyuvdsp.h" -#include "internal.h" #include "lossless_videodsp.h" #include "thread.h" diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 7952c3c34c..9fa769656c 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -33,7 +33,6 @@ #include "avcodec.h" #include "decode.h" -#include "internal.h" #include "mediacodec.h" #include "mediacodec_surface.h" diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index bcf10b7ae1..f5164e82e7 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #include "libavutil/mem_internal.h" @@ -29,7 +27,7 @@ #include "avcodec.h" #include "blockdsp.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "get_bits.h" #include "bytestream.h" #include "bswapdsp.h" diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index 3d0d0e4714..bbdb2209cf 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -22,7 +22,7 @@ #define UNCHECKED_BITSTREAM_READER 1 -#include "internal.h" +#include "decode.h" #include "parser.h" #include "mpegvideo.h" #include "mpeg4video.h" diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 97da5bfe11..ac6efb6909 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "internal.h" +#include "decode.h" #include "parser.h" #include "mpeg12.h" #include "mpeg12data.h" diff --git a/libavcodec/mvcdec.c b/libavcodec/mvcdec.c index d2e9f4b631..0040ff0853 100644 --- a/libavcodec/mvcdec.c +++ b/libavcodec/mvcdec.c @@ -32,7 +32,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct MvcContext { int vflip; diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c index 7f2bca35f2..fce11e97f2 100644 --- a/libavcodec/notchlc.c +++ b/libavcodec/notchlc.c @@ -20,16 +20,14 @@ */ #include -#include #include #define BITSTREAM_READER_LE -#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "lzf.h" #include "thread.h" diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index c404bd8cf0..8dbfa7f726 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -19,11 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include +#include #include -#include "libavutil/bswap.h" #include "libavutil/common.h" #include "libavutil/intreadwrite.h" #include "libavutil/lzo.h" @@ -31,8 +29,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "idctdsp.h" -#include "internal.h" #include "rtjpeg.h" typedef struct NuvContext { diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 7a47ef827c..3b82e5ba3e 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -22,13 +22,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" #define PCX_HEADER_SIZE 128 diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 13c570c3c2..69aabfe2b0 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -27,11 +27,10 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "mathops.h" #include "libavutil/colorspace.h" -#include "libavutil/imgutils.h" #include "libavutil/opt.h" #define RGBA(r,g,b,a) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b)) diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c index dcbf2a32dd..177ad66468 100644 --- a/libavcodec/pgxdec.c +++ b/libavcodec/pgxdec.c @@ -20,7 +20,6 @@ */ #include "avcodec.h" -#include "internal.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c index 239b7a1b54..b31666d78a 100644 --- a/libavcodec/photocd.c +++ b/libavcodec/photocd.c @@ -36,8 +36,8 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "thread.h" typedef struct PhotoCDContext { diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index f215f0d220..fcd9e8a9ed 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -30,7 +30,6 @@ #include "cga_data.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" typedef struct PicContext { int width, height; diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c index 1f43b4c8e0..d7c40052a5 100644 --- a/libavcodec/pixlet.c +++ b/libavcodec/pixlet.c @@ -21,15 +21,13 @@ #include -#include "libavutil/imgutils.h" #include "libavutil/intmath.h" -#include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" -#include "internal.h" #include "thread.h" #include "unary.h" diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 1d6ca7f4c3..7cb3d98bd6 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -34,7 +34,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "apng.h" #include "png.h" #include "pngdsp.h" diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index aabc788684..77d24eeaf7 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -26,7 +26,7 @@ #include "libavutil/imgutils.h" #include "libavutil/avstring.h" #include "avcodec.h" -#include "internal.h" +#include "decode.h" #include "pnm.h" static inline int pnm_space(int c) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 659f9ff16b..df864c77ec 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -35,12 +35,11 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "hwconfig.h" #include "idctdsp.h" -#include "internal.h" #include "profiles.h" -#include "simple_idct.h" #include "proresdec.h" #include "proresdata.h" #include "thread.h" diff --git a/libavcodec/psd.c b/libavcodec/psd.c index 5a5c57e856..3ac3f46dd5 100644 --- a/libavcodec/psd.c +++ b/libavcodec/psd.c @@ -22,7 +22,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" enum PsdCompr { PSD_RAW, diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index 412df4d763..84fe1872d2 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -24,7 +24,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" static int ptx_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index 1aac7c8010..4405ff2b4e 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -32,7 +32,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" enum QuickdrawOpcodes { CLIP = 0x0001, diff --git a/libavcodec/qoidec.c b/libavcodec/qoidec.c index 1e052f659b..1053d784a2 100644 --- a/libavcodec/qoidec.c +++ b/libavcodec/qoidec.c @@ -18,13 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#include "libavutil/imgutils.h" #include "avcodec.h" -#include "internal.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "thread.h" #include "qoi.h" diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c index a74b4d145c..a04dff6d90 100644 --- a/libavcodec/rasc.c +++ b/libavcodec/rasc.c @@ -29,7 +29,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "zlib_wrapper.h" #include diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index e7c3800f9e..2e6f555b8c 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -26,8 +26,6 @@ * @see http://wiki.multimedia.cx/index.php?title=RL2 */ -#include -#include #include #include "libavutil/internal.h" @@ -36,7 +34,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define EXTRADATA1_SIZE (6 + 256 * 3) ///< video base, clr count, palette diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index abf42612cb..d8b8900795 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -32,11 +32,11 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "error_resilience.h" #include "h263.h" #include "h263data.h" #include "h263dec.h" -#include "internal.h" #include "mpeg_er.h" #include "mpegutils.h" #include "mpegvideo.h" diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 61d1e4c527..acf77d103d 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -29,15 +29,14 @@ #include "libavutil/internal.h" #include "libavutil/mem_internal.h" #include "libavutil/thread.h" -#include "libavutil/video_enc_params.h" #include "avcodec.h" +#include "decode.h" #include "error_resilience.h" #include "mpegutils.h" #include "mpegvideo.h" #include "mpegvideodec.h" #include "golomb.h" -#include "internal.h" #include "mathops.h" #include "mpeg_er.h" #include "qpeldsp.h" diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 064e812e51..aceddaf835 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -21,15 +21,12 @@ */ #include "libavutil/avassert.h" -#include "libavutil/bswap.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "copy_block.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define NGLYPHS 256 #define GLYPH_COORD_VECT_SIZE 16 diff --git a/libavcodec/sga.c b/libavcodec/sga.c index febe950424..296ab5dd5d 100644 --- a/libavcodec/sga.c +++ b/libavcodec/sga.c @@ -24,7 +24,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define PALDATA_FOLLOWS_TILEDATA 4 #define HAVE_COMPRESSED_TILEMAP 32 diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index c1070d5c95..e33a739ecd 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -19,12 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "sgi.h" typedef struct SgiState { diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index 51695c353c..ee648ba95d 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -21,11 +21,9 @@ #include "libavutil/common.h" #include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "sunrast.h" static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p, diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index e091e4279f..c96f65249a 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -41,7 +41,6 @@ #include "get_bits.h" #include "h263data.h" #include "hpeldsp.h" -#include "internal.h" #include "mathops.h" #include "svq1.h" diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index d4fff0557b..ea9842f9b4 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -48,7 +48,6 @@ #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "avcodec.h" #include "mpegutils.h" #include "h264data.h" @@ -66,8 +65,6 @@ #include #endif -#include "svq1.h" - /** * @file * svq3 decoder. diff --git a/libavcodec/targa.c b/libavcodec/targa.c index 2901d908de..bbf4f6ca19 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -19,13 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "targa.h" typedef struct TargaContext { diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c index c4e4d35ee8..aeb1ea363e 100644 --- a/libavcodec/tdsc.c +++ b/libavcodec/tdsc.c @@ -42,7 +42,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define BITMAPINFOHEADER_SIZE 0x28 #define TDSF_HEADER_SIZE 0x56 diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 9e1b10a40c..785ccfbdcf 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -29,7 +29,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct SeqVideoContext { diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 043ff79e0a..b0595b56c0 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -34,19 +34,16 @@ #endif #include "libavutil/attributes.h" -#include "libavutil/avstring.h" #include "libavutil/error.h" #include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/reverse.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "faxcompr.h" -#include "internal.h" #include "lzw.h" -#include "mathops.h" #include "tiff.h" #include "tiff_data.h" #include "mjpegdec.h" diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index ee41b0ed4d..ab632e99dc 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -36,7 +36,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" diff --git a/libavcodec/truemotion2rt.c b/libavcodec/truemotion2rt.c index 265ca87456..a0bf4749f3 100644 --- a/libavcodec/truemotion2rt.c +++ b/libavcodec/truemotion2rt.c @@ -18,11 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - -#include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" @@ -31,7 +26,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" typedef struct TrueMotion2RTContext { GetBitContext gb; diff --git a/libavcodec/txd.c b/libavcodec/txd.c index 8862f14bd8..7e8b33646b 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -21,13 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "bytestream.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "texturedsp.h" #define TXD_DXT1 0x31545844 diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index e891649f92..a40be94690 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -28,7 +28,7 @@ #include #include #include "libavcodec/avcodec.h" -#include "libavcodec/internal.h" +#include "decode.h" #include "v4l2_buffers.h" #include "v4l2_fmt.h" #include "v4l2_m2m.h" diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c index 706760f376..d8a3c61c8c 100644 --- a/libavcodec/vbndec.c +++ b/libavcodec/vbndec.c @@ -27,7 +27,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "texturedsp.h" #include "vbn.h" #include "libavutil/imgutils.h" diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c index d46f551020..c9257b290f 100644 --- a/libavcodec/vc1.c +++ b/libavcodec/vc1.c @@ -28,7 +28,6 @@ #include "libavutil/attributes.h" #include "libavutil/thread.h" -#include "internal.h" #include "avcodec.h" #include "decode.h" #include "mpegvideo.h" diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 0f040c338f..4734025244 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -32,8 +32,7 @@ #include "config_components.h" -#include -#include +#include #include #include "libavutil/imgutils.h" @@ -44,7 +43,6 @@ #include "decode.h" #include "get_bits.h" #include "hpeldsp.h" -#include "internal.h" #include "mathops.h" #include "thread.h" #include "threadframe.h" diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 8ba4de71e5..9ddc6fa70d 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -23,12 +23,11 @@ * VP5 compatible video decoder */ -#include #include #include "avcodec.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "vp56.h" #include "vp56data.h" diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index 1c58096bdb..bd994428a4 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -26,7 +26,6 @@ #include "avcodec.h" #include "bytestream.h" #include "decode.h" -#include "internal.h" #include "h264chroma.h" #include "vp56.h" #include "vp56data.h" diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index ad81060886..f7815d7398 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -31,9 +31,9 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "huffman.h" -#include "internal.h" #include "vp56.h" #include "vp56data.h" diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 6bf846dbfe..ab38c76735 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -26,16 +26,13 @@ #include "config_components.h" -#include "libavutil/imgutils.h" #include "libavutil/mem_internal.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" #include "hwconfig.h" -#include "internal.h" #include "mathops.h" -#include "rectangle.h" #include "thread.h" #include "threadframe.h" #include "vp8.h" diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 621627ddc5..fe85c17133 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -25,9 +25,9 @@ #include "avcodec.h" #include "codec_internal.h" +#include "decode.h" #include "get_bits.h" #include "hwconfig.h" -#include "internal.h" #include "profiles.h" #include "thread.h" #include "threadframe.h" diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 61c30c2a62..4006b1433c 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -70,16 +70,13 @@ */ #include -#include #include #include "libavutil/intreadwrite.h" -#include "libavutil/imgutils.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define PALETTE_COUNT 256 #define VQA_HEADER_SIZE 0x2A diff --git a/libavcodec/wbmpdec.c b/libavcodec/wbmpdec.c index 0d0e574d9c..c289b08bcc 100644 --- a/libavcodec/wbmpdec.c +++ b/libavcodec/wbmpdec.c @@ -21,7 +21,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "decode.h" #include "thread.h" static unsigned int getv(GetByteContext * gb) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index fb5688fc95..dca5e451f2 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -46,9 +46,9 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" +#include "decode.h" #include "exif.h" #include "get_bits.h" -#include "internal.h" #include "thread.h" #include "tiff_common.h" #include "vp8.h" diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index a28da08a29..f38f9dd1e8 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -20,14 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/avstring.h" #include "libavutil/reverse.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" -#include "mathops.h" static int get_nibble(uint8_t x) { diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index a1d5635874..c005dc1e3a 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -25,7 +25,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #define MIN_ELEMENT ' ' #define MAX_ELEMENT 0xfe diff --git a/libavcodec/xwddec.c b/libavcodec/xwddec.c index 43d4bb5e84..f3703292ca 100644 --- a/libavcodec/xwddec.c +++ b/libavcodec/xwddec.c @@ -27,7 +27,6 @@ #include "bytestream.h" #include "codec_internal.h" #include "decode.h" -#include "internal.h" #include "xwd.h" static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, From 59eadb5060acd07ad2d4dc5dbb354ee81f034222 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 24 Aug 2022 23:04:14 +0200 Subject: [PATCH 048/590] avcodec/internal: Move ff_samples_to_time_base() to encode.h It is only used by encoders; in fact, AVCodecContext.time_base is only used by encoders, so it is only useful for encoders. Also constify the AVCodecContext parameter in it. Also fixup the other headers a bit while removing now unnecessary internal.h inclusions. Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 2 -- libavcodec/audio_frame_queue.c | 2 +- libavcodec/encode.h | 12 ++++++++++++ libavcodec/flacenc.c | 1 - libavcodec/g722enc.c | 1 - libavcodec/internal.h | 12 ------------ libavcodec/libtwolame.c | 1 - libavcodec/libvo-amrwbenc.c | 1 - libavcodec/libvorbisenc.c | 1 - libavcodec/mpegaudioenc_template.c | 1 - libavcodec/wmaenc.c | 1 - 11 files changed, 13 insertions(+), 22 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index c57904b01b..3fe625a659 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -30,7 +30,6 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" -#include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/crc.h" #include "libavutil/internal.h" @@ -41,7 +40,6 @@ #include "codec_internal.h" #include "config_components.h" #include "encode.h" -#include "internal.h" #include "me_cmp.h" #include "put_bits.h" #include "audiodsp.h" diff --git a/libavcodec/audio_frame_queue.c b/libavcodec/audio_frame_queue.c index f2ccd69281..08b4b368c7 100644 --- a/libavcodec/audio_frame_queue.c +++ b/libavcodec/audio_frame_queue.c @@ -22,7 +22,7 @@ #include "libavutil/attributes.h" #include "libavutil/common.h" #include "audio_frame_queue.h" -#include "internal.h" +#include "encode.h" #include "libavutil/avassert.h" av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq) diff --git a/libavcodec/encode.h b/libavcodec/encode.h index e5d6b754b1..296ffd312e 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -78,4 +78,16 @@ int ff_encode_preinit(AVCodecContext *avctx); int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet); +/** + * Rescale from sample rate to AVCodecContext.time_base. + */ +static av_always_inline int64_t ff_samples_to_time_base(const AVCodecContext *avctx, + int64_t samples) +{ + if (samples == AV_NOPTS_VALUE) + return AV_NOPTS_VALUE; + return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate }, + avctx->time_base); +} + #endif /* AVCODEC_ENCODE_H */ diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 00f78fc814..73cf185314 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -32,7 +32,6 @@ #include "encode.h" #include "put_bits.h" #include "put_golomb.h" -#include "internal.h" #include "lpc.h" #include "flac.h" #include "flacdata.h" diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index 2c0a5019dd..7ba283df61 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -32,7 +32,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "g722.h" #include "libavutil/common.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 823067b7ee..6f34f98d4e 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -181,18 +181,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]); */ #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) -/** - * Rescale from sample rate to AVCodecContext.time_base. - */ -static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, - int64_t samples) -{ - if(samples == AV_NOPTS_VALUE) - return AV_NOPTS_VALUE; - return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate }, - avctx->time_base); -} - /** * 2^(x) for integer x * @return correctly rounded float diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c index 9929248485..3da57bb779 100644 --- a/libavcodec/libtwolame.c +++ b/libavcodec/libtwolame.c @@ -33,7 +33,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "mpegaudio.h" typedef struct TWOLAMEContext { diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index 3c94bcba32..a2d7f33ef7 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -29,7 +29,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #define MAX_PACKET_SIZE (1 + (477 + 7) / 8) diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index 3353776083..718e9d1912 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -28,7 +28,6 @@ #include "audio_frame_queue.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "version.h" #include "vorbis.h" #include "vorbis_parser.h" diff --git a/libavcodec/mpegaudioenc_template.c b/libavcodec/mpegaudioenc_template.c index 839bd98dd1..67b8069102 100644 --- a/libavcodec/mpegaudioenc_template.c +++ b/libavcodec/mpegaudioenc_template.c @@ -28,7 +28,6 @@ #include "avcodec.h" #include "encode.h" -#include "internal.h" #include "put_bits.h" #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 99f0100dc1..95b992859a 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -27,7 +27,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "encode.h" -#include "internal.h" #include "wma.h" #include "libavutil/avassert.h" From d1a5ef406946d7a9b9abbe3c8373d258a69deedf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 02:00:21 +0200 Subject: [PATCH 049/590] avcodec/internal: Move ff_side_data_update_matrix_encoding to decode.h Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3dec.c | 1 - libavcodec/dca_core.c | 1 - libavcodec/dca_lbr.c | 1 - libavcodec/dca_xll.c | 1 - libavcodec/decode.h | 6 ++++++ libavcodec/internal.h | 6 ------ libavcodec/mlpdec.c | 3 --- 7 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index b1db3dc9e6..5d0add40fe 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -38,7 +38,6 @@ #include "libavutil/opt.h" #include "libavutil/thread.h" #include "bswapdsp.h" -#include "internal.h" #include "aac_ac3_parser.h" #include "ac3_parser_internal.h" #include "ac3dec.h" diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index b181171104..1655116eed 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -26,7 +26,6 @@ #include "dcamath.h" #include "dca_syncwords.h" #include "decode.h" -#include "internal.h" #if ARCH_ARM #include "arm/dca.h" diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index ec55404c7b..5343bcde8a 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -29,7 +29,6 @@ #include "dca_syncwords.h" #include "bytestream.h" #include "decode.h" -#include "internal.h" #define AMP_MAX 56 diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c index 242c3a13fe..fe2c766d98 100644 --- a/libavcodec/dca_xll.c +++ b/libavcodec/dca_xll.c @@ -24,7 +24,6 @@ #include "dcamath.h" #include "dca_syncwords.h" #include "decode.h" -#include "internal.h" #include "unary.h" static int get_linear(GetBitContext *gb, int n) diff --git a/libavcodec/decode.h b/libavcodec/decode.h index d40327d5ab..5d95369b5e 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -138,4 +138,10 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); */ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags); +/** + * Add or update AV_FRAME_DATA_MATRIXENCODING side data. + */ +int ff_side_data_update_matrix_encoding(AVFrame *frame, + enum AVMatrixEncoding matrix_encoding); + #endif /* AVCODEC_DECODE_H */ diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 6f34f98d4e..0065ccec8c 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -204,12 +204,6 @@ int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); -/** - * Add or update AV_FRAME_DATA_MATRIXENCODING side data. - */ -int ff_side_data_update_matrix_encoding(AVFrame *frame, - enum AVMatrixEncoding matrix_encoding); - /** * Add a CPB properties side data to an encoding context. */ diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index dba2b9ac34..bfd0091323 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -38,9 +38,6 @@ #include "codec_internal.h" #include "decode.h" #include "get_bits.h" -#include "internal.h" -#include "libavutil/crc.h" -#include "parser.h" #include "mlp_parse.h" #include "mlpdsp.h" #include "mlp.h" From 5714cf1b5bf520192ddfde4115f3c447a86ba061 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 02:31:18 +0200 Subject: [PATCH 050/590] avcodec/internal: Move ff_dvdsub_parse_palette() to new header dvdsub.h Signed-off-by: Andreas Rheinhardt --- libavcodec/dvdsub.c | 3 ++- libavcodec/dvdsub.h | 26 ++++++++++++++++++++++++++ libavcodec/dvdsubdec.c | 2 +- libavcodec/dvdsubenc.c | 2 +- libavcodec/internal.h | 2 -- 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 libavcodec/dvdsub.h diff --git a/libavcodec/dvdsub.c b/libavcodec/dvdsub.c index 87215d2bd1..fb415677d9 100644 --- a/libavcodec/dvdsub.c +++ b/libavcodec/dvdsub.c @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "internal.h" #include "libavutil/avstring.h" #include +#include "dvdsub.h" + void ff_dvdsub_parse_palette(uint32_t *palette, const char *p) { for (int i = 0; i < 16; i++) { diff --git a/libavcodec/dvdsub.h b/libavcodec/dvdsub.h new file mode 100644 index 0000000000..3f51c3f805 --- /dev/null +++ b/libavcodec/dvdsub.h @@ -0,0 +1,26 @@ +/* + * 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_DVDSUB_H +#define AVCODEC_DVDSUB_H + +#include + +void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); + +#endif /* AVCODEC_DVDSUB_H */ diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 4b692c093f..3338cd6b92 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -22,8 +22,8 @@ #include "avcodec.h" #include "codec_internal.h" #include "decode.h" +#include "dvdsub.h" #include "get_bits.h" -#include "internal.h" #include "libavutil/attributes.h" #include "libavutil/colorspace.h" diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index 3fe50ae199..37d6efdd5d 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -21,7 +21,7 @@ #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" -#include "internal.h" +#include "dvdsub.h" #include "libavutil/avassert.h" #include "libavutil/bprint.h" #include "libavutil/imgutils.h" diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 0065ccec8c..e2a914c271 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -243,6 +243,4 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx); int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, const int * array_valid_values, int default_value); -void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); - #endif /* AVCODEC_INTERNAL_H */ From 91ba3f5a8f2de1612e4b496cd0a4ca805a9300ae Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 02:45:27 +0200 Subject: [PATCH 051/590] avcodec/targa: Fix indentation Forgotten after 1e85a698c01133a7f8d35502d5901e3b65fa3317. Signed-off-by: Andreas Rheinhardt --- libavcodec/targa.c | 75 +++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/libavcodec/targa.c b/libavcodec/targa.c index bbf4f6ca19..daade89e28 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -253,49 +253,48 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, } } - if (compr & TGA_RLE) { - int res = targa_decode_rle(avctx, s, dst, w, h, stride, bpp, interleave); - if (res < 0) - return res; - } else { - uint8_t *line; - if (bytestream2_get_bytes_left(&s->gb) < img_size * h) { - av_log(avctx, AV_LOG_ERROR, - "Not enough data available for image\n"); - return AVERROR_INVALIDDATA; - } - - line = dst; - y = 0; - do { - bytestream2_get_buffer(&s->gb, line, img_size); - line = advance_line(dst, line, stride, &y, h, interleave); - } while (line); + if (compr & TGA_RLE) { + int res = targa_decode_rle(avctx, s, dst, w, h, stride, bpp, interleave); + if (res < 0) + return res; + } else { + uint8_t *line; + if (bytestream2_get_bytes_left(&s->gb) < img_size * h) { + av_log(avctx, AV_LOG_ERROR, + "Not enough data available for image\n"); + return AVERROR_INVALIDDATA; } - if (flags & TGA_RIGHTTOLEFT) { // right-to-left, needs horizontal flip - int x; - for (y = 0; y < h; y++) { - void *line = &p->data[0][y * p->linesize[0]]; - for (x = 0; x < w >> 1; x++) { - switch (bpp) { - case 32: - FFSWAP(uint32_t, ((uint32_t *)line)[x], ((uint32_t *)line)[w - x - 1]); - break; - case 24: - FFSWAP(uint8_t, ((uint8_t *)line)[3 * x ], ((uint8_t *)line)[3 * w - 3 * x - 3]); - FFSWAP(uint8_t, ((uint8_t *)line)[3 * x + 1], ((uint8_t *)line)[3 * w - 3 * x - 2]); - FFSWAP(uint8_t, ((uint8_t *)line)[3 * x + 2], ((uint8_t *)line)[3 * w - 3 * x - 1]); - break; - case 16: - FFSWAP(uint16_t, ((uint16_t *)line)[x], ((uint16_t *)line)[w - x - 1]); - break; - case 8: - FFSWAP(uint8_t, ((uint8_t *)line)[x], ((uint8_t *)line)[w - x - 1]); - } + line = dst; + y = 0; + do { + bytestream2_get_buffer(&s->gb, line, img_size); + line = advance_line(dst, line, stride, &y, h, interleave); + } while (line); + } + + if (flags & TGA_RIGHTTOLEFT) { // right-to-left, needs horizontal flip + for (int y = 0; y < h; y++) { + void *line = &p->data[0][y * p->linesize[0]]; + for (int x = 0; x < w >> 1; x++) { + switch (bpp) { + case 32: + FFSWAP(uint32_t, ((uint32_t *)line)[x], ((uint32_t *)line)[w - x - 1]); + break; + case 24: + FFSWAP(uint8_t, ((uint8_t *)line)[3 * x ], ((uint8_t *)line)[3 * w - 3 * x - 3]); + FFSWAP(uint8_t, ((uint8_t *)line)[3 * x + 1], ((uint8_t *)line)[3 * w - 3 * x - 2]); + FFSWAP(uint8_t, ((uint8_t *)line)[3 * x + 2], ((uint8_t *)line)[3 * w - 3 * x - 1]); + break; + case 16: + FFSWAP(uint16_t, ((uint16_t *)line)[x], ((uint16_t *)line)[w - x - 1]); + break; + case 8: + FFSWAP(uint8_t, ((uint8_t *)line)[x], ((uint8_t *)line)[w - x - 1]); } } } + } *got_frame = 1; From a51bdbb0699b4029bc95b7e101e06890c0b5b3f2 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 12:56:26 +0200 Subject: [PATCH 052/590] avcodec/ac3enc: Add missing header Needed for code under #ifdef DEBUG; broken in commit 59eadb5060acd07ad2d4dc5dbb354ee81f034222. Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 3fe625a659..a090576823 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -30,6 +30,7 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" +#include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/crc.h" #include "libavutil/internal.h" From f3e823c2aa04d4f5571a5e04c27a244890704c8d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 18 Aug 2022 00:22:41 +0200 Subject: [PATCH 053/590] avformat/avidec: Prevent entity expansion attacks Fixes: Timeout Fixes no testcase, this is the same idea as similar attacks against XML parsers Signed-off-by: Michael Niedermayer --- libavformat/avidec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 937d9e6ffb..910a4e8792 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -82,6 +82,8 @@ typedef struct AVIContext { int stream_index; DVDemuxContext *dv_demux; int odml_depth; + int64_t odml_read; + int64_t odml_max_pos; int use_odml; #define MAX_ODML_DEPTH 1000 int64_t dts_max; @@ -200,7 +202,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num) st = s->streams[stream_id]; ast = st->priv_data; - if (index_sub_type) + if (index_sub_type || entries_in_use < 0) return AVERROR_INVALIDDATA; avio_rl32(pb); @@ -221,11 +223,18 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num) } for (i = 0; i < entries_in_use; i++) { + avi->odml_max_pos = FFMAX(avi->odml_max_pos, avio_tell(pb)); + + // If we read more than there are bytes then we must have been reading something twice + if (avi->odml_read > avi->odml_max_pos) + return AVERROR_INVALIDDATA; + if (index_type) { int64_t pos = avio_rl32(pb) + base - 8; int len = avio_rl32(pb); int key = len >= 0; len &= 0x7FFFFFFF; + avi->odml_read += 8; av_log(s, AV_LOG_TRACE, "pos:%"PRId64", len:%X\n", pos, len); @@ -244,6 +253,7 @@ static int read_odml_index(AVFormatContext *s, int64_t frame_num) int64_t offset, pos; int duration; int ret; + avi->odml_read += 16; offset = avio_rl64(pb); avio_rl32(pb); /* size */ From e1c0239d5a17f3cbcd69c339ec3eb4917f1f7ddf Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 18 Aug 2022 22:22:45 +0200 Subject: [PATCH 054/590] avcodec/bethsoftvideo: Pass GetByteContext into set_palette() Signed-off-by: Michael Niedermayer --- libavcodec/bethsoftvideo.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index ea5016bae5..9fbfc3db4f 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -51,16 +51,16 @@ static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx) return 0; } -static int set_palette(BethsoftvidContext *ctx) +static int set_palette(BethsoftvidContext *ctx, GetByteContext *g) { uint32_t *palette = (uint32_t *)ctx->frame->data[1]; int a; - if (bytestream2_get_bytes_left(&ctx->g) < 256*3) + if (bytestream2_get_bytes_left(g) < 256*3) return AVERROR_INVALIDDATA; for(a = 0; a < 256; a++){ - palette[a] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->g) * 4; + palette[a] = 0xFFU << 24 | bytestream2_get_be24u(g) * 4; palette[a] |= palette[a] >> 6 & 0x30303; } ctx->frame->palette_has_changed = 1; @@ -85,9 +85,10 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx, AVFrame *rframe, if (avpkt->side_data_elems > 0 && avpkt->side_data[0].type == AV_PKT_DATA_PALETTE) { - bytestream2_init(&vid->g, avpkt->side_data[0].data, + GetByteContext g; + bytestream2_init(&g, avpkt->side_data[0].data, avpkt->side_data[0].size); - if ((ret = set_palette(vid)) < 0) + if ((ret = set_palette(vid, &g)) < 0) return ret; } @@ -98,7 +99,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx, AVFrame *rframe, switch(block_type = bytestream2_get_byte(&vid->g)){ case PALETTE_BLOCK: { *got_frame = 0; - if ((ret = set_palette(vid)) < 0) { + if ((ret = set_palette(vid, &vid->g)) < 0) { av_log(avctx, AV_LOG_ERROR, "error reading palette\n"); return ret; } From d93dccdc9f6fa41dc5ef743bc195c4fc052a34b4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 18 Aug 2022 22:26:38 +0200 Subject: [PATCH 055/590] avcodec/bethsoftvideo: Check block_type before frame alloc Signed-off-by: Michael Niedermayer --- libavcodec/bethsoftvideo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index 9fbfc3db4f..4562053829 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -79,6 +79,11 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int code, ret; int yoffset; + bytestream2_init(&vid->g, avpkt->data, avpkt->size); + block_type = bytestream2_get_byte(&vid->g); + if (block_type < 1 || block_type > 4) + return AVERROR_INVALIDDATA; + if ((ret = ff_reget_buffer(avctx, vid->frame, 0)) < 0) return ret; wrap_to_next_line = vid->frame->linesize[0] - avctx->width; @@ -92,11 +97,10 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return ret; } - bytestream2_init(&vid->g, avpkt->data, avpkt->size); dst = vid->frame->data[0]; frame_end = vid->frame->data[0] + vid->frame->linesize[0] * avctx->height; - switch(block_type = bytestream2_get_byte(&vid->g)){ + switch(block_type){ case PALETTE_BLOCK: { *got_frame = 0; if ((ret = set_palette(vid, &vid->g)) < 0) { From 049ed1dadaa39b150b9718349e98087170a5106d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 18 Aug 2022 22:29:27 +0200 Subject: [PATCH 056/590] tools/target_dec_fuzzer: Adjust threshold for bethsoftvid Fixes: Timeout Fixes: 49791/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BETHSOFTVID_fuzzer-4583956145635328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 28042077c6..0fb9328d2c 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -213,6 +213,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_ANM: maxpixels /= 1024; break; case AV_CODEC_ID_ARBC: maxpixels /= 1024; break; case AV_CODEC_ID_ARGO: maxpixels /= 1024; break; + case AV_CODEC_ID_BETHSOFTVID: maxpixels /= 8192; break; case AV_CODEC_ID_BINKVIDEO: maxpixels /= 32; break; case AV_CODEC_ID_CDTOONS: maxpixels /= 1024; break; case AV_CODEC_ID_CFHD: maxpixels /= 16384; break; From 4d5c0cca94e384a3b50fad40624d7dbdcf2a50ec Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 21 Aug 2022 23:55:39 +0200 Subject: [PATCH 057/590] avcodec/m101: Move checks before ff_get_buffer() Fixes: Timeout Fixes: 50109/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_M101_fuzzer-6553193986785280 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/m101.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/m101.c b/libavcodec/m101.c index 7c719006ec..5a06f02c37 100644 --- a/libavcodec/m101.c +++ b/libavcodec/m101.c @@ -53,11 +53,6 @@ static int m101_decode_frame(AVCodecContext *avctx, AVFrame *frame, int min_stride = 2 * avctx->width; int bits = avctx->extradata[2*4]; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) - return ret; - frame->pict_type = AV_PICTURE_TYPE_I; - frame->key_frame = 1; - stride = AV_RL32(avctx->extradata + 5*4); if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) @@ -69,6 +64,10 @@ static int m101_decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR_INVALIDDATA; } + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + frame->pict_type = AV_PICTURE_TYPE_I; + frame->key_frame = 1; frame->interlaced_frame = ((avctx->extradata[3*4] & 3) != 3); if (frame->interlaced_frame) frame->top_field_first = avctx->extradata[3*4] & 1; From 936f2d2634b57071579221d604062019028f8c9b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 22 Aug 2022 00:23:27 +0200 Subject: [PATCH 058/590] tools/target_dec_fuzzer: Adjust threshold for MTS2 Fixes: Timeout Fixes: 50030/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MTS2_fuzzer-5767793731043328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 0fb9328d2c..e142daefe9 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -254,6 +254,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_MSRLE: maxpixels /= 16; break; case AV_CODEC_ID_MSS2: maxpixels /= 16384; break; case AV_CODEC_ID_MSZH: maxpixels /= 128; break; + case AV_CODEC_ID_MTS2: maxpixels /= 4096; break; case AV_CODEC_ID_MVC2: maxpixels /= 128; break; case AV_CODEC_ID_MWSC: maxpixels /= 256; break; case AV_CODEC_ID_MXPEG: maxpixels /= 128; break; From bcb46903040e5a5199281f4ad0a1fdaf750ebc37 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 22 Aug 2022 20:31:32 +0200 Subject: [PATCH 059/590] libavformat/iff: Check for overflow in body_end calculation Fixes: signed integer overflow: -6322983228386819992 - 5557477266266529857 cannot be represented in type 'long' Fixes: 50112/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6329186221948928 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/iff.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/iff.c b/libavformat/iff.c index b37600605a..b8e8bffe03 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -501,6 +501,9 @@ static int iff_read_header(AVFormatContext *s) case ID_DST: case ID_MDAT: iff->body_pos = avio_tell(pb); + if (iff->body_pos < 0 || iff->body_pos + data_size > INT64_MAX) + return AVERROR_INVALIDDATA; + iff->body_end = iff->body_pos + data_size; iff->body_size = data_size; if (chunk_id == ID_DST) { From 628fb97efb0b6202e56fab89670406261bf86d85 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 22 Aug 2022 21:29:55 +0200 Subject: [PATCH 060/590] avcodec/midivid: Perform lzss_uncompress() before ff_reget_buffer() This would avoid regeting the frame on lzss errors Signed-off-by: Michael Niedermayer --- libavcodec/midivid.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c index 49f31b0fa7..eaf138e87e 100644 --- a/libavcodec/midivid.c +++ b/libavcodec/midivid.c @@ -198,12 +198,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, bytestream2_skip(gb, 8); uncompressed = bytestream2_get_le32(gb); - if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) - return ret; - - if (uncompressed) { - ret = decode_mvdv(s, avctx, frame); - } else { + if (!uncompressed) { av_fast_padded_malloc(&s->uncompressed, &s->uncompressed_size, 16LL * (avpkt->size - 12)); if (!s->uncompressed) return AVERROR(ENOMEM); @@ -212,9 +207,13 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, if (ret < 0) return ret; bytestream2_init(gb, s->uncompressed, ret); - ret = decode_mvdv(s, avctx, frame); } + if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) + return ret; + + ret = decode_mvdv(s, avctx, frame); + if (ret < 0) return ret; key = ret; From e264a4a76e9a7443130a3f4c62fe112ee44d2cad Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 22 Aug 2022 21:32:00 +0200 Subject: [PATCH 061/590] tools/target_dec_fuzzer: Adjust threshold for MVDV Fixes: Timeout Fixes: 50213/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVDV_fuzzer-5228284098510848 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index e142daefe9..aa3ba0e523 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -256,6 +256,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_MSZH: maxpixels /= 128; break; case AV_CODEC_ID_MTS2: maxpixels /= 4096; break; case AV_CODEC_ID_MVC2: maxpixels /= 128; break; + case AV_CODEC_ID_MVDV: maxpixels /= 1024; break; case AV_CODEC_ID_MWSC: maxpixels /= 256; break; case AV_CODEC_ID_MXPEG: maxpixels /= 128; break; case AV_CODEC_ID_NUV: maxpixels /= 128; break; From 2316d5ec1a95b13ff9a0ce80409fa367a041966d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 22 Aug 2022 22:10:09 +0200 Subject: [PATCH 062/590] libavcodec/8bps: Check that line lengths fit within the buffer Fixes: Timeout Fixes: undefined pointer arithmetic Fixes: 50330/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EIGHTBPS_fuzzer-5436287485607936 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/8bps.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index c7dfeb81ee..cda3cdef3a 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -68,6 +68,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, unsigned char *planemap = c->planemap; int ret; + if (buf_size < planes * height *2) + return AVERROR_INVALIDDATA; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; From ced0dc807eb67516b341d68f04ce5a87b02820de Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 9 Aug 2022 21:49:04 +0200 Subject: [PATCH 063/590] doc/git-howto.texi: Document commit signing Signed-off-by: Michael Niedermayer --- doc/git-howto.texi | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/git-howto.texi b/doc/git-howto.texi index 874afabbbc..5bb39bb986 100644 --- a/doc/git-howto.texi +++ b/doc/git-howto.texi @@ -187,11 +187,18 @@ to make sure you don't have untracked files or deletions. git add [-i|-p|-A] @end example -Make sure you have told Git your name and email address +Make sure you have told Git your name, email address and GPG key @example git config --global user.name "My Name" git config --global user.email my@@email.invalid +git config --global user.signingkey ABCDEF0123245 +@end example + +Enable signing all commits or use -S + +@example +git config --global commit.gpgsign true @end example Use @option{--global} to set the global configuration for all your Git checkouts. @@ -423,6 +430,19 @@ git checkout -b svn_23456 $SHA1 where @var{$SHA1} is the commit hash from the @command{git log} output. +@chapter gpg key generation + +If you have no gpg key yet, we recommend that you create a ed25519 based key as it +is small, fast and secure. Especially it results in small signatures in git. + +@example +gpg --default-new-key-algo "ed25519/cert,sign+cv25519/encr" --quick-generate-key "human@@server.com" +@end example + +When generating a key, make sure the email specified matches the email used in git as some sites like +github consider mismatches a reason to declare such commits unverified. After generating a key you +can add it to the MAINTAINER file and upload it to a keyserver. + @chapter Pre-push checklist Once you have a set of commits that you feel are ready for pushing, From c953baa084607dd1d84c3bfcce3cf6a87c3e6e05 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 28 Jul 2022 14:42:43 +0200 Subject: [PATCH 064/590] avformat/mov: Check count sums in build_open_gop_key_points() Fixes: ffmpeg.md Fixes: Out of array access Fixes: CVE-2022-2566 Found-by: Andy Nguyen Found-by: 3pvd <3pvd@google.com> Reviewed-by: Andy Nguyen Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 1d8c5b2904..35e2271b14 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3967,8 +3967,11 @@ static int build_open_gop_key_points(AVStream *st) /* Build an unrolled index of the samples */ sc->sample_offsets_count = 0; - for (uint32_t i = 0; i < sc->ctts_count; i++) + for (uint32_t i = 0; i < sc->ctts_count; i++) { + if (sc->ctts_data[i].count > INT_MAX - sc->sample_offsets_count) + return AVERROR(ENOMEM); sc->sample_offsets_count += sc->ctts_data[i].count; + } av_freep(&sc->sample_offsets); sc->sample_offsets = av_calloc(sc->sample_offsets_count, sizeof(*sc->sample_offsets)); if (!sc->sample_offsets) @@ -3987,8 +3990,11 @@ static int build_open_gop_key_points(AVStream *st) /* Build a list of open-GOP key samples */ sc->open_key_samples_count = 0; for (uint32_t i = 0; i < sc->sync_group_count; i++) - if (sc->sync_group[i].index == cra_index) + if (sc->sync_group[i].index == cra_index) { + if (sc->sync_group[i].count > INT_MAX - sc->open_key_samples_count) + return AVERROR(ENOMEM); sc->open_key_samples_count += sc->sync_group[i].count; + } av_freep(&sc->open_key_samples); sc->open_key_samples = av_calloc(sc->open_key_samples_count, sizeof(*sc->open_key_samples)); if (!sc->open_key_samples) @@ -3999,6 +4005,8 @@ static int build_open_gop_key_points(AVStream *st) if (sg->index == cra_index) for (uint32_t j = 0; j < sg->count; j++) sc->open_key_samples[k++] = sample_id; + if (sg->count > INT_MAX - sample_id) + return AVERROR_PATCHWELCOME; sample_id += sg->count; } From ea56f7d5e71ccab1b6fa44f1091153f91c1d4aeb Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Tue, 23 Aug 2022 14:19:04 +0800 Subject: [PATCH 065/590] lavc/qsvenc: ignore video signal info buffer for VP9 The SDK doesn't support this type of buffer for vp9 encoding Signed-off-by: Haihao Xiang --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 202a645ea2..f1838ce597 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -970,7 +970,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extvsi.MatrixCoefficients = avctx->colorspace; } - if (q->extvsi.VideoFullRange || q->extvsi.ColourDescriptionPresent) { + if ((avctx->codec_id != AV_CODEC_ID_VP9) && (q->extvsi.VideoFullRange || q->extvsi.ColourDescriptionPresent)) { q->extvsi.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO; q->extvsi.Header.BufferSz = sizeof(q->extvsi); q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvsi; From f5c5c04c1452274d223f663bd8ebc9d721acdf0e Mon Sep 17 00:00:00 2001 From: gavin zhang Date: Tue, 23 Aug 2022 14:19:05 +0800 Subject: [PATCH 066/590] lavc/qsvenc: enlarge the SPS buffer to retrieve larger header Increase SPS header buffer to support larger header Signed-off-by: gavin zhang Signed-off-by: Haihao Xiang --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index f1838ce597..7ac5390f10 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1064,7 +1064,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) { AVCPBProperties *cpb_props; - uint8_t sps_buf[128]; + uint8_t sps_buf[512]; uint8_t pps_buf[128]; mfxExtCodingOptionSPSPPS extradata = { From f99d15cca0f6ceedb4f2f38d67a52dacc9556fc7 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 29 Aug 2022 07:09:03 +0200 Subject: [PATCH 067/590] arm/fft: disable NEON optimizations for 131072pt transforms This has been broken since the start, and it was only discovered when I started testing my replacement for the FFT. Disable it, since there's no point in fixing slower code that's about to be removed anyway. The vfp version is not affected. --- libavcodec/aarch64/fft_init_aarch64.c | 6 ++++-- libavcodec/arm/fft_init_arm.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/aarch64/fft_init_aarch64.c b/libavcodec/aarch64/fft_init_aarch64.c index db285205ab..77f5607960 100644 --- a/libavcodec/aarch64/fft_init_aarch64.c +++ b/libavcodec/aarch64/fft_init_aarch64.c @@ -38,8 +38,10 @@ av_cold void ff_fft_init_aarch64(FFTContext *s) int cpu_flags = av_get_cpu_flags(); if (have_neon(cpu_flags)) { - s->fft_permute = ff_fft_permute_neon; - s->fft_calc = ff_fft_calc_neon; + if (s->nbits < 17) { + s->fft_permute = ff_fft_permute_neon; + s->fft_calc = ff_fft_calc_neon; + } #if CONFIG_MDCT s->imdct_calc = ff_imdct_calc_neon; s->imdct_half = ff_imdct_half_neon; diff --git a/libavcodec/arm/fft_init_arm.c b/libavcodec/arm/fft_init_arm.c index 331bd65e5c..8ae22dfb4e 100644 --- a/libavcodec/arm/fft_init_arm.c +++ b/libavcodec/arm/fft_init_arm.c @@ -48,8 +48,10 @@ av_cold void ff_fft_init_arm(FFTContext *s) if (have_neon(cpu_flags)) { #if CONFIG_FFT - s->fft_permute = ff_fft_permute_neon; - s->fft_calc = ff_fft_calc_neon; + if (s->nbits < 17) { + s->fft_permute = ff_fft_permute_neon; + s->fft_calc = ff_fft_calc_neon; + } #endif #if CONFIG_MDCT s->imdct_calc = ff_imdct_calc_neon; From 47b85c5a7642b6ec942c052bbe7d163b70e017a8 Mon Sep 17 00:00:00 2001 From: Sebastian Beckmann Date: Fri, 26 Aug 2022 03:57:24 +0200 Subject: [PATCH 068/590] avcodec/videotoolboxenc: Add CBR option to H264 and HEVC encoder Adds an option to use constant bitrate instead of average bitrate to the videotoolbox encoders. This is enabled via -constant_bit_rate true. macOS 13 is required for this option to work. Signed-off-by: Sebastian Beckmann Signed-off-by: Rick Kern --- libavcodec/videotoolboxenc.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 823e5ad94e..9de86cc4d9 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -101,6 +101,7 @@ static struct{ CFStringRef kVTCompressionPropertyKey_RealTime; CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha; CFStringRef kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality; + CFStringRef kVTCompressionPropertyKey_ConstantBitRate; CFStringRef kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder; CFStringRef kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder; @@ -164,6 +165,7 @@ static void loadVTEncSymbols(){ "TargetQualityForAlpha"); GET_SYM(kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality, "PrioritizeEncodingSpeedOverQuality"); + GET_SYM(kVTCompressionPropertyKey_ConstantBitRate, "ConstantBitRate"); GET_SYM(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, "EnableHardwareAcceleratedVideoEncoder"); @@ -236,6 +238,7 @@ typedef struct VTEncContext { int realtime; int frames_before; int frames_after; + bool constant_bit_rate; int allow_sw; int require_sw; @@ -1079,6 +1082,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, CFNumberRef gamma_level, CFDictionaryRef enc_info, CFDictionaryRef pixel_buffer_info, + bool constant_bit_rate, VTCompressionSessionRef *session) { VTEncContext *vtctx = avctx->priv_data; @@ -1139,9 +1143,20 @@ static int vtenc_create_encoder(AVCodecContext *avctx, &bit_rate); if (!bit_rate_num) return AVERROR(ENOMEM); - status = VTSessionSetProperty(vtctx->session, - kVTCompressionPropertyKey_AverageBitRate, - bit_rate_num); + if (constant_bit_rate) { + status = VTSessionSetProperty(vtctx->session, + compat_keys.kVTCompressionPropertyKey_ConstantBitRate, + bit_rate_num); + if (status == kVTPropertyNotSupportedErr) { + av_log(avctx, AV_LOG_ERROR, "Error: -constant_bit_rate true is not supported by the encoder.\n"); + return AVERROR_EXTERNAL; + } + } else { + status = VTSessionSetProperty(vtctx->session, + kVTCompressionPropertyKey_AverageBitRate, + bit_rate_num); + } + CFRelease(bit_rate_num); } @@ -1530,6 +1545,7 @@ static int vtenc_configure_encoder(AVCodecContext *avctx) gamma_level, enc_info, pixel_buffer_info, + vtctx->constant_bit_rate, &vtctx->session); init_cleanup: @@ -2532,6 +2548,7 @@ static int vtenc_populate_extradata(AVCodecContext *avctx, gamma_level, enc_info, pixel_buffer_info, + vtctx->constant_bit_rate, &vtctx->session); if (status) goto pe_cleanup; @@ -2727,6 +2744,8 @@ static const AVOption h264_options[] = { { "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE }, + { "constant_bit_rate", "Require constant bit rate (macOS 13 or newer)", OFFSET(constant_bit_rate), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + COMMON_OPTIONS { NULL }, }; @@ -2760,6 +2779,8 @@ static const AVOption hevc_options[] = { { "alpha_quality", "Compression quality for the alpha channel", OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE }, + { "constant_bit_rate", "Require constant bit rate (macOS 13 or newer)", OFFSET(constant_bit_rate), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + COMMON_OPTIONS { NULL }, }; From 8d26a21bf63514cc566bf8c9de940a786bb33167 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 18 Aug 2022 11:13:08 +0200 Subject: [PATCH 069/590] fftools/ffmpeg: stop accessing av_stream_get_parser() from the main thread It races with the demuxing thread. Instead, send the information along with the demuxed packets. Ideally, the code should stop using the stream-internal parsing completely, but that requires considerably more effort. Fixes races, e.g. in: - fate-h264-brokensps-2580 - fate-h264-extradata-reload - fate-iv8-demux - fate-m4v-cfr - fate-m4v --- fftools/ffmpeg.c | 8 ++++++-- fftools/ffmpeg.h | 6 ++++++ fftools/ffmpeg_demux.c | 16 ++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ef7177fc33..ff74534ad0 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2452,7 +2452,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo if (pkt && pkt->duration) { duration_dts = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) { - int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict+1 : ist->dec_ctx->ticks_per_frame; + int ticks = ist->last_pkt_repeat_pict >= 0 ? + ist->last_pkt_repeat_pict + 1 : + ist->dec_ctx->ticks_per_frame; duration_dts = ((int64_t)AV_TIME_BASE * ist->dec_ctx->framerate.den * ticks) / ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame; @@ -2555,7 +2557,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } else if (pkt->duration) { ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); } else if(ist->dec_ctx->framerate.num != 0) { - int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame; + int ticks = ist->last_pkt_repeat_pict >= 0 ? + ist->last_pkt_repeat_pict + 1 : + ist->dec_ctx->ticks_per_frame; ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->framerate.den * ticks) / ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 921e579c32..27ef92654c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -348,6 +348,12 @@ typedef struct InputStream { int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units) int wrap_correction_done; + // the value of AVCodecParserContext.repeat_pict from the AVStream parser + // for the last packet returned from ifile_get_packet() + // -1 if unknown + // FIXME: this is a hack, the avstream parser should not be used + int last_pkt_repeat_pict; + int64_t filter_in_rescale_delta_last; int64_t min_pts; /* pts with the smallest value in a current stream */ diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 6dfb5bb35b..6e89f5999a 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -32,6 +32,9 @@ typedef struct DemuxMsg { AVPacket *pkt; int looping; + + // repeat_pict from the demuxer-internal parser + int repeat_pict; } DemuxMsg; static void report_new_stream(InputFile *file, const AVPacket *pkt) @@ -114,7 +117,7 @@ static int seek_to_start(InputFile *ifile) return ret; } -static void ts_fixup(InputFile *ifile, AVPacket *pkt) +static void ts_fixup(InputFile *ifile, AVPacket *pkt, int *repeat_pict) { InputStream *ist = input_streams[ifile->ist_index + pkt->stream_index]; const int64_t start_time = ifile->ctx->start_time; @@ -167,6 +170,11 @@ static void ts_fixup(InputFile *ifile, AVPacket *pkt) if (pkt->dts != AV_NOPTS_VALUE) pkt->dts += duration; + + *repeat_pict = -1; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && + av_stream_get_parser(ist->st)) + *repeat_pict = av_stream_get_parser(ist->st)->repeat_pict; } static void *input_thread(void *arg) @@ -231,7 +239,7 @@ static void *input_thread(void *arg) } } - ts_fixup(f, pkt); + ts_fixup(f, pkt, &msg.repeat_pict); msg.pkt = av_packet_alloc(); if (!msg.pkt) { @@ -352,6 +360,7 @@ int init_input_threads(void) int ifile_get_packet(InputFile *f, AVPacket **pkt) { + InputStream *ist; DemuxMsg msg; int ret; @@ -382,6 +391,9 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) if (msg.looping) return 1; + ist = input_streams[f->ist_index + msg.pkt->stream_index]; + ist->last_pkt_repeat_pict = msg.repeat_pict; + *pkt = msg.pkt; return 0; } From 7c8737548f5426a4b55fdb8771775e9562c8828c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2022 16:39:04 +0200 Subject: [PATCH 070/590] fftools/ffmpeg: remove a stale extern declaration Forgotten in 8cbf229c941b3c77a756bff05d0ceb5f4f2219c5 --- fftools/ffmpeg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 27ef92654c..c461e93ff9 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -656,7 +656,6 @@ extern float audio_drift_threshold; extern float dts_delta_threshold; extern float dts_error_threshold; -extern int audio_volume; extern int audio_sync_method; extern enum VideoSyncMethod video_sync_method; extern float frame_drop_threshold; From c97bb940c28a49ec36d9e7f0514ed1c3403384a9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 25 Aug 2022 09:40:42 +0200 Subject: [PATCH 071/590] fftools/ffmpeg_filter: remove an always-false check This code cannot be triggered, since after 90944ee3ab7 opening the output file will abort if an encoder cannot be found and streamcopy was not explicitly requested. --- fftools/ffmpeg_filter.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 16622e49c1..4e2787eba2 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1095,14 +1095,6 @@ int configure_filtergraph(FilterGraph *fg) for (i = 0; i < fg->nb_outputs; i++) { OutputStream *ost = fg->outputs[i]->ost; - if (!ost->enc) { - /* identical to the same check in ffmpeg.c, needed because - complex filter graphs are initialized earlier */ - av_log(NULL, AV_LOG_ERROR, "Encoder (codec %s) not found for output stream #%d:%d\n", - avcodec_get_name(ost->st->codecpar->codec_id), ost->file_index, ost->index); - ret = AVERROR(EINVAL); - goto fail; - } if (ost->enc->type == AVMEDIA_TYPE_AUDIO && !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, From 4a4a206304e1d168e9a839d1a9c426e459343322 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 25 Aug 2022 09:42:40 +0200 Subject: [PATCH 072/590] fftools/ffmpeg_filter: remove an always-true check ost->enc is always non-NULL here, since - this code is never called for streamcopy - opening the output file will fail if an encoder cannot be found, so filters are never initialized --- fftools/ffmpeg_filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 4e2787eba2..e9479018e4 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -105,7 +105,7 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc, ost->enc_ctx->pix_fmt, ost->enc_ctx->strict_std_compliance)); - } else if (ost->enc && ost->enc->pix_fmts) { + } else if (ost->enc->pix_fmts) { const enum AVPixelFormat *p; p = ost->enc->pix_fmts; From d0f767f81f7b6c4e9a3d29a9fd622ab519461213 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 25 Aug 2022 10:01:19 +0200 Subject: [PATCH 073/590] fftools/ffmpeg: drop OutputStream.enc It is either equal to OutputStream.enc_ctx->codec, or NULL when enc_ctx is NULL. Replace the use of enc with enc_ctx->codec, or the equivalent enc_ctx->codec_* fields where more convenient. --- fftools/ffmpeg.c | 27 +++++++++++---------- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 13 +++++----- fftools/ffmpeg_hw.c | 6 ++--- fftools/ffmpeg_opt.c | 54 +++++++++++++++++++++++------------------ 5 files changed, 55 insertions(+), 46 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ff74534ad0..0ca07873b2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2362,7 +2362,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, OutputStream *ost = output_streams[i]; if (!check_output_constraints(ist, ost) || !ost->enc_ctx - || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) + || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; do_subtitle_out(output_files[ost->file_index], ost, &subtitle); @@ -2869,13 +2869,14 @@ static int init_output_stream_streamcopy(OutputStream *ost) static void set_encoder_id(OutputFile *of, OutputStream *ost) { + const char *cname = ost->enc_ctx->codec->name; uint8_t *encoder_string; int encoder_string_len; if (av_dict_get(ost->st->metadata, "encoder", NULL, 0)) return; - encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(ost->enc->name) + 2; + encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2; encoder_string = av_mallocz(encoder_string_len); if (!encoder_string) exit_program(1); @@ -2884,7 +2885,7 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost) av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); else av_strlcpy(encoder_string, "Lavc ", encoder_string_len); - av_strlcat(encoder_string, ost->enc->name, encoder_string_len); + av_strlcat(encoder_string, cname, encoder_string_len); av_dict_set(&ost->st->metadata, "encoder", encoder_string, AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE); } @@ -3011,9 +3012,9 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) !ost->frame_rate.den)) ost->frame_rate = ost->max_frame_rate; - if (ost->enc->supported_framerates && !ost->force_fps) { - int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); - ost->frame_rate = ost->enc->supported_framerates[idx]; + if (enc_ctx->codec->supported_framerates && !ost->force_fps) { + int idx = av_find_nearest_q_idx(ost->frame_rate, enc_ctx->codec->supported_framerates); + ost->frame_rate = enc_ctx->codec->supported_framerates[idx]; } // reduce frame rate for mpeg4 to be within the spec limits if (enc_ctx->codec_id == AV_CODEC_ID_MPEG4) { @@ -3154,7 +3155,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, int ret = 0; if (ost->enc_ctx) { - const AVCodec *codec = ost->enc; + const AVCodec *codec = ost->enc_ctx->codec; AVCodecContext *dec = NULL; InputStream *ist; @@ -3183,7 +3184,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return ret; } - if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) { + if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && codec->type == AVMEDIA_TYPE_SUBTITLE) { int input_props = 0, output_props = 0; AVCodecDescriptor const *input_descriptor = avcodec_descriptor_get(dec->codec_id); @@ -3210,8 +3211,8 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, ost->file_index, ost->index); return ret; } - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + if (codec->type == AVMEDIA_TYPE_AUDIO && + !(codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, ost->enc_ctx->frame_size); assert_avoptions(ost->encoder_opts); @@ -3423,7 +3424,7 @@ static int transcode_init(void) av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index); av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index, - ost->index, ost->enc ? ost->enc->name : "?"); + ost->index, ost->enc_ctx->codec->name); continue; } @@ -3434,7 +3435,7 @@ static int transcode_init(void) ost->index); if (ost->enc_ctx) { const AVCodec *in_codec = input_streams[ost->source_index]->dec; - const AVCodec *out_codec = ost->enc; + const AVCodec *out_codec = ost->enc_ctx->codec; const char *decoder_name = "?"; const char *in_codec_name = "?"; const char *encoder_name = "?"; @@ -3830,7 +3831,7 @@ static int process_input(int file_index) OutputStream *ost = output_streams[j]; if (ost->source_index == ifile->ist_index + i && - (!ost->enc_ctx || ost->enc->type == AVMEDIA_TYPE_SUBTITLE)) { + (!ost->enc_ctx || ost->enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE)) { OutputFile *of = output_files[ost->file_index]; output_packet(of, ost->pkt, ost, 1); } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index c461e93ff9..937a65b8e8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -515,7 +515,6 @@ typedef struct OutputStream { AVBSFContext *bsf_ctx; AVCodecContext *enc_ctx; - const AVCodec *enc; int64_t max_frames; AVFrame *filtered_frame; AVFrame *last_frame; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index e9479018e4..ac8d81c8aa 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -90,6 +90,7 @@ choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target, static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) { OutputStream *ost = ofilter->ost; + AVCodecContext *enc = ost->enc_ctx; const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); if (strict_dict) // used by choose_pixel_fmt() and below @@ -103,14 +104,14 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); } if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { - return av_get_pix_fmt_name(choose_pixel_fmt(ost->enc, ost->enc_ctx->pix_fmt, + return av_get_pix_fmt_name(choose_pixel_fmt(enc->codec, enc->pix_fmt, ost->enc_ctx->strict_std_compliance)); - } else if (ost->enc->pix_fmts) { + } else if (enc->codec->pix_fmts) { const enum AVPixelFormat *p; - p = ost->enc->pix_fmts; + p = enc->codec->pix_fmts; if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { - p = get_compliance_normal_pix_fmts(ost->enc, p); + p = get_compliance_normal_pix_fmts(enc->codec, p); } for (; *p != AV_PIX_FMT_NONE; p++) { @@ -1095,8 +1096,8 @@ int configure_filtergraph(FilterGraph *fg) for (i = 0; i < fg->nb_outputs; i++) { OutputStream *ost = fg->outputs[i]->ost; - if (ost->enc->type == AVMEDIA_TYPE_AUDIO && - !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO && + !(ost->enc_ctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) av_buffersink_set_frame_size(ost->filter->filter, ost->enc_ctx->frame_size); } diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 8acfeaf08f..88fa782470 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -461,7 +461,7 @@ int hw_device_setup_for_encode(OutputStream *ost) } for (i = 0;; i++) { - config = avcodec_get_hw_config(ost->enc, i); + config = avcodec_get_hw_config(ost->enc_ctx->codec, i); if (!config) break; @@ -472,7 +472,7 @@ int hw_device_setup_for_encode(OutputStream *ost) av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using input " "frames context (format %s) with %s encoder.\n", av_get_pix_fmt_name(ost->enc_ctx->pix_fmt), - ost->enc->name); + ost->enc_ctx->codec->name); ost->enc_ctx->hw_frames_ctx = av_buffer_ref(frames_ref); if (!ost->enc_ctx->hw_frames_ctx) return AVERROR(ENOMEM); @@ -487,7 +487,7 @@ int hw_device_setup_for_encode(OutputStream *ost) if (dev) { av_log(ost->enc_ctx, AV_LOG_VERBOSE, "Using device %s " "(type %s) with %s encoder.\n", dev->name, - av_hwdevice_get_type_name(dev->type), ost->enc->name); + av_hwdevice_get_type_name(dev->type), ost->enc_ctx->codec->name); ost->enc_ctx->hw_device_ctx = av_buffer_ref(dev->device_ref); if (!ost->enc_ctx->hw_device_ctx) return AVERROR(ENOMEM); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 8128dcf9fb..296751e19d 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1513,18 +1513,21 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV return ret; } -static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) +static int choose_encoder(OptionsContext *o, AVFormatContext *s, + OutputStream *ost, const AVCodec **enc) { enum AVMediaType type = ost->st->codecpar->codec_type; char *codec_name = NULL; + *enc = NULL; + if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); if (!codec_name) { ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->st->codecpar->codec_type); - ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id); - if (!ost->enc) { + *enc = avcodec_find_encoder(ost->st->codecpar->codec_id); + if (!*enc) { av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for " "output stream #%d:%d. Default encoder for format %s (codec %s) is " "probably disabled. Please choose an encoder manually.\n", @@ -1533,8 +1536,8 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o return AVERROR_ENCODER_NOT_FOUND; } } else if (strcmp(codec_name, "copy")) { - ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); - ost->st->codecpar->codec_id = ost->enc->id; + *enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); + ost->st->codecpar->codec_id = (*enc)->id; } } @@ -1560,6 +1563,7 @@ static int check_opt_bitexact(void *ctx, const AVDictionary *opts, static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) { OutputStream *ost; + const AVCodec *enc; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; const char *bsfs = NULL, *time_base = NULL; @@ -1583,15 +1587,15 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->forced_kf_ref_pts = AV_NOPTS_VALUE; st->codecpar->codec_type = type; - ret = choose_encoder(o, oc, ost); + ret = choose_encoder(o, oc, ost, &enc); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream " "%d:%d\n", ost->file_index, ost->index); exit_program(1); } - if (ost->enc) { - ost->enc_ctx = avcodec_alloc_context3(ost->enc); + if (enc) { + ost->enc_ctx = avcodec_alloc_context3(enc); if (!ost->enc_ctx) { av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); exit_program(1); @@ -1606,16 +1610,18 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (!ost->pkt) exit_program(1); - if (ost->enc) { + if (ost->enc_ctx) { + AVCodecContext *enc = ost->enc_ctx; AVIOContext *s = NULL; char *buf = NULL, *arg = NULL, *preset = NULL; - ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); + ost->encoder_opts = filter_codec_opts(o->g->codec_opts, enc->codec_id, + oc, st, enc->codec); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); ost->autoscale = 1; MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st); - if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { + if (preset && (!(ret = get_preset_file_2(preset, enc->codec->name, &s)))) { AVBPrint bprint; av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED); do { @@ -1729,7 +1735,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); - if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24) + if (ost->enc_ctx && av_get_exact_bits_per_sample(ost->enc_ctx->codec_id) == 24) av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); ost->source_index = source_index; @@ -1985,7 +1991,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->logfile_prefix ? ost->logfile_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, nb_output_streams - 1); - if (!strcmp(ost->enc->name, "libx264")) { + if (!strcmp(ost->enc_ctx->codec->name, "libx264")) { av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE); } else { if (video_enc->flags & AV_CODEC_FLAG_PASS2) { @@ -2869,6 +2875,7 @@ static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o) } static void set_channel_layout(OutputFilter *f, OutputStream *ost) { + const AVCodec *c = ost->enc_ctx->codec; int i, err; if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) { @@ -2880,7 +2887,7 @@ static void set_channel_layout(OutputFilter *f, OutputStream *ost) } /* Requested layout is of order UNSPEC */ - if (!ost->enc->ch_layouts) { + if (!c->ch_layouts) { /* Use the default native layout for the requested amount of channels when the encoder doesn't have a list of supported layouts */ av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels); @@ -2888,13 +2895,13 @@ static void set_channel_layout(OutputFilter *f, OutputStream *ost) } /* Encoder has a list of supported layouts. Pick the first layout in it with the same amount of channels as the requested layout */ - for (i = 0; ost->enc->ch_layouts[i].nb_channels; i++) { - if (ost->enc->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) + for (i = 0; c->ch_layouts[i].nb_channels; i++) { + if (c->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels) break; } - if (ost->enc->ch_layouts[i].nb_channels) { + if (c->ch_layouts[i].nb_channels) { /* Use it if one is found */ - err = av_channel_layout_copy(&f->ch_layout, &ost->enc->ch_layouts[i]); + err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]); if (err < 0) exit_program(1); return; @@ -3069,6 +3076,7 @@ static int open_output_file(OptionsContext *o, const char *filename) /* set the filter output constraints */ if (ost->filter) { + const AVCodec *c = ost->enc_ctx->codec; OutputFilter *f = ost->filter; switch (ost->enc_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: @@ -3078,24 +3086,24 @@ static int open_output_file(OptionsContext *o, const char *filename) if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { f->format = ost->enc_ctx->pix_fmt; } else { - f->formats = ost->enc->pix_fmts; + f->formats = c->pix_fmts; } break; case AVMEDIA_TYPE_AUDIO: if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { f->format = ost->enc_ctx->sample_fmt; } else { - f->formats = ost->enc->sample_fmts; + f->formats = c->sample_fmts; } if (ost->enc_ctx->sample_rate) { f->sample_rate = ost->enc_ctx->sample_rate; } else { - f->sample_rates = ost->enc->supported_samplerates; + f->sample_rates = c->supported_samplerates; } if (ost->enc_ctx->ch_layout.nb_channels) { set_channel_layout(f, ost); - } else if (ost->enc->ch_layouts) { - f->ch_layouts = ost->enc->ch_layouts; + } else if (c->ch_layouts) { + f->ch_layouts = c->ch_layouts; } break; } From 0dd7347963041667e07366c83460fda8f19f4037 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 25 Aug 2022 10:08:41 +0200 Subject: [PATCH 074/590] fftools/ffmpeg: drop OutputStream.fps_mode It is only used within new_video_stream(), so make it a local variable there. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 937a65b8e8..74bc9220fc 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -528,7 +528,6 @@ typedef struct OutputStream { AVRational max_frame_rate; enum VideoSyncMethod vsync_method; int is_cfr; - const char *fps_mode; int force_fps; int top_field_first; int rotate_overridden; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 296751e19d..b387684daf 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1875,7 +1875,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in if (ost->enc_ctx) { AVCodecContext *video_enc = ost->enc_ctx; - const char *p = NULL; + const char *p = NULL, *fps_mode = NULL; char *frame_size = NULL; char *frame_pix_fmt = NULL; char *intra_matrix = NULL, *inter_matrix = NULL; @@ -2027,9 +2027,9 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st); ost->vsync_method = video_sync_method; - MATCH_PER_STREAM_OPT(fps_mode, str, ost->fps_mode, oc, st); - if (ost->fps_mode) - parse_and_set_vsync(ost->fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0); + MATCH_PER_STREAM_OPT(fps_mode, str, fps_mode, oc, st); + if (fps_mode) + parse_and_set_vsync(fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0); if (ost->vsync_method == VSYNC_AUTO) { if (!strcmp(oc->oformat->name, "avi")) { From 4fce3bab64699092100a65e957be4d1394c0b4d3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 25 Aug 2022 10:44:55 +0200 Subject: [PATCH 075/590] fftools/ffmpeg: use a separate counter for encoded packet data size update_video_stats() currently uses OutputStream.data_size to print the total size of the encoded stream so far and the average bitrate. However, that field is updated in the muxer thread, right before the packet is sent to the muxer. Not only is this racy, but the numbers may not match even if muxing was in the main thread due to bitstream filters, filesize limiting, etc. Introduce a new counter, data_size_enc, for total size of the packets received from the encoder and use that in update_video_stats(). Rename data_size to data_size_mux to indicate its semantics more clearly. No synchronization is needed for data_size_mux, because it is only read in the main thread in print_final_stats(), which runs after the muxer threads are terminated. --- fftools/ffmpeg.c | 22 +++++++++++++--------- fftools/ffmpeg.h | 6 ++++-- fftools/ffmpeg_mux.c | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0ca07873b2..fbabbe6ea2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -901,9 +901,9 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write ti1 = 0.01; bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0; - avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; + avg_bitrate = (double)(ost->data_size_enc * 8) / ti1 / 1000.0; fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", - (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); + (double)ost->data_size_enc / 1024, ti1, bitrate, avg_bitrate); fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); } @@ -979,6 +979,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &enc->time_base)); } + ost->data_size_enc += pkt->size; + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) update_video_stats(ost, pkt, !!vstats_filename); @@ -1454,14 +1456,16 @@ static void print_final_stats(int64_t total_size) for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; AVCodecParameters *par = ost->st->codecpar; + const uint64_t s = ost->data_size_mux; + switch (par->codec_type) { - case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break; - case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break; - case AVMEDIA_TYPE_SUBTITLE: subtitle_size += ost->data_size; break; - default: other_size += ost->data_size; break; + case AVMEDIA_TYPE_VIDEO: video_size += s; break; + case AVMEDIA_TYPE_AUDIO: audio_size += s; break; + case AVMEDIA_TYPE_SUBTITLE: subtitle_size += s; break; + default: other_size += s; break; } extra_size += par->extradata_size; - data_size += ost->data_size; + data_size += s; if (ost->enc_ctx && (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) != AV_CODEC_FLAG_PASS1) @@ -1529,7 +1533,7 @@ static void print_final_stats(int64_t total_size) OutputStream *ost = output_streams[of->ost_index + j]; enum AVMediaType type = ost->st->codecpar->codec_type; - total_size += ost->data_size; + total_size += ost->data_size_mux; total_packets += atomic_load(&ost->packets_written); av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", @@ -1543,7 +1547,7 @@ static void print_final_stats(int64_t total_size) } av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", - atomic_load(&ost->packets_written), ost->data_size); + atomic_load(&ost->packets_written), ost->data_size_mux); av_log(NULL, AV_LOG_VERBOSE, "\n"); } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 74bc9220fc..ede0b2bd96 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -585,8 +585,10 @@ typedef struct OutputStream { int keep_pix_fmt; /* stats */ - // combined size of all the packets written - uint64_t data_size; + // combined size of all the packets sent to the muxer + uint64_t data_size_mux; + // combined size of all the packets received from the encoder + uint64_t data_size_enc; // number of packets send to the muxer atomic_uint_least64_t packets_written; // number of frames/samples sent to the encoder diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index b424ef0021..b781e1f5a6 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -156,7 +156,7 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) } ms->last_mux_dts = pkt->dts; - ost->data_size += pkt->size; + ost->data_size_mux += pkt->size; atomic_fetch_add(&ost->packets_written, 1); pkt->stream_index = ost->index; From 7180416084cd9074e67a039992b43e5dc282fb81 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 31 Aug 2022 16:24:22 +0200 Subject: [PATCH 076/590] lavf/sdp: Add missing version.h include Fixes lavf version output in SDP, regression since 4eb9232c --- libavformat/sdp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 99a19852ff..6888936290 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -33,6 +33,7 @@ #include "avc.h" #include "hevc.h" #include "rtp.h" +#include "version.h" #if CONFIG_NETWORK #include "network.h" #endif From 4a054c3e97b4f30fe517114e381f9a2ee5a92f7c Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 31 Aug 2022 16:25:31 +0200 Subject: [PATCH 077/590] lavc/ass: Add missing version.h include Fixes lavc version output in ass, regression since f2da2e14 --- libavcodec/ass.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/ass.c b/libavcodec/ass.c index a1e560d7ff..728cfb1ab5 100644 --- a/libavcodec/ass.c +++ b/libavcodec/ass.c @@ -24,6 +24,7 @@ #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/common.h" +#include "version.h" int ff_ass_subtitle_header_full(AVCodecContext *avctx, int play_res_x, int play_res_y, From 1f1a368169ef9d945dc4b4764f5c60ba9bbc9134 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 31 Aug 2022 01:21:38 +0200 Subject: [PATCH 078/590] avformat/asfdec_o: limit recursion depth in asf_read_unknown() The threshold of 5 is arbitrary, both smaller and larger should work fine Fixes: Stack overflow Fixes: 50603/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-6049302564175872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/asfdec_o.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index 907be6de04..48b7d17322 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -109,6 +109,7 @@ typedef struct ASFContext { int64_t data_offset; int64_t first_packet_offset; // packet offset int64_t unknown_offset; // for top level header objects or subobjects without specified behavior + int in_asf_read_unknown; // ASF file must not contain more than 128 streams according to the specification ASFStream *asf_st[ASF_MAX_STREAMS]; @@ -173,7 +174,7 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g) uint64_t size = avio_rl64(pb); int ret; - if (size > INT64_MAX) + if (size > INT64_MAX || asf->in_asf_read_unknown > 5) return AVERROR_INVALIDDATA; if (asf->is_header) @@ -182,8 +183,11 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g) if (!g->is_subobject) { if (!(ret = strcmp(g->name, "Header Extension"))) avio_skip(pb, 22); // skip reserved fields and Data Size - if ((ret = detect_unknown_subobject(s, asf->unknown_offset, - asf->unknown_size)) < 0) + asf->in_asf_read_unknown ++; + ret = detect_unknown_subobject(s, asf->unknown_offset, + asf->unknown_size); + asf->in_asf_read_unknown --; + if (ret < 0) return ret; } else { if (size < 24) { From 319e8a49b5bcfa80fcb6f50f0dd78c6408c972ae Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 31 Aug 2022 18:36:04 +0200 Subject: [PATCH 079/590] avcodec/amr*bdec: return only number of consumed bytes --- libavcodec/amrnbdec.c | 2 +- libavcodec/amrwbdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index dcf66c1dde..e07c01923e 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -1091,7 +1091,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, AVFrame *frame, *got_frame_ptr = 1; - return avpkt->size; + return buf - avpkt->data; } diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index f9a67c43b7..1e537e1a3b 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -1288,7 +1288,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, AVFrame *frame, *got_frame_ptr = 1; - return avpkt->size; + return buf - avpkt->data; } const FFCodec ff_amrwb_decoder = { From e157b21a9081e3c4e8e22a4ae764dfbf0cc5b5b3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 14:52:13 +0200 Subject: [PATCH 080/590] fftools/cmdutils: Add function to report error before exit This is designed to improve and unify error handling for allocation failures for the many (often small) allocations that we have in the fftools. These typically either don't return an error message or an error message that is not really helpful to the user and can be replaced by a generic error message without loss of information. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt --- fftools/cmdutils.c | 6 ++++++ fftools/cmdutils.h | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 18e768b386..da3d391694 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -90,6 +90,12 @@ void register_exit(void (*cb)(int ret)) program_exit = cb; } +void report_and_exit(int ret) +{ + av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret)); + exit_program(AVUNERROR(ret)); +} + void exit_program(int ret) { if (program_exit) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index d87e162ccd..4496221983 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -54,6 +54,17 @@ extern int hide_banner; */ void register_exit(void (*cb)(int ret)); +/** + * Reports an error corresponding to the provided + * AVERROR code and calls exit_program() with the + * corresponding POSIX error code. + * @note ret must be an AVERROR-value of a POSIX error code + * (i.e. AVERROR(EFOO) and not AVERROR_FOO). + * library functions can return both, so call this only + * with AVERROR(EFOO) of your own. + */ +void report_and_exit(int ret) av_noreturn; + /** * Wraps exit with a program-specific cleanup routine. */ From 601faaed92de2fb036463b647d5b26cb7c649002 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 15:41:16 +0200 Subject: [PATCH 081/590] fftools: Use report_error_then_exit_program() for allocation failures Signed-off-by: Andreas Rheinhardt --- fftools/cmdutils.c | 21 +++++-------- fftools/ffmpeg.c | 25 ++++++--------- fftools/ffmpeg_filter.c | 10 +++--- fftools/ffmpeg_opt.c | 70 ++++++++++++++++------------------------- fftools/ffprobe.c | 6 ++-- fftools/opt_common.c | 6 ++-- 6 files changed, 52 insertions(+), 86 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index da3d391694..f911c52be2 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -656,7 +656,7 @@ static void init_parse_context(OptionParseContext *octx, octx->nb_groups = nb_groups; octx->groups = av_calloc(octx->nb_groups, sizeof(*octx->groups)); if (!octx->groups) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); for (i = 0; i < octx->nb_groups; i++) octx->groups[i].group_def = &groups[i]; @@ -964,11 +964,8 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, if (!s->nb_streams) return NULL; opts = av_calloc(s->nb_streams, sizeof(*opts)); - if (!opts) { - av_log(NULL, AV_LOG_ERROR, - "Could not alloc memory for stream options.\n"); - exit_program(1); - } + if (!opts) + report_and_exit(AVERROR(ENOMEM)); for (i = 0; i < s->nb_streams; i++) opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, s, s->streams[i], NULL); @@ -983,10 +980,8 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } if (*size < new_size) { uint8_t *tmp = av_realloc_array(array, new_size, elem_size); - if (!tmp) { - av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n"); - exit_program(1); - } + if (!tmp) + report_and_exit(AVERROR(ENOMEM)); memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size); *size = new_size; return tmp; @@ -999,10 +994,8 @@ void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems) void *new_elem; if (!(new_elem = av_mallocz(elem_size)) || - av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) { - av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n"); - exit_program(1); - } + av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) + report_and_exit(AVERROR(ENOMEM)); return new_elem; } diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index fbabbe6ea2..0e1477299d 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1096,10 +1096,8 @@ static void do_subtitle_out(OutputFile *of, return; ret = av_new_packet(pkt, subtitle_out_max_size); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, "Failed to allocate subtitle encode buffer\n"); - exit_program(1); - } + if (ret < 0) + report_and_exit(AVERROR(ENOMEM)); sub->pts = pts; // start_display_time is required to be 0 @@ -2349,7 +2347,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, if (!ist->sub2video.sub_queue) ist->sub2video.sub_queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW); if (!ist->sub2video.sub_queue) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); ret = av_fifo_write(ist->sub2video.sub_queue, &subtitle, 1); if (ret < 0) @@ -2883,7 +2881,7 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost) encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2; encoder_string = av_mallocz(encoder_string_len); if (!encoder_string) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); if (!of->bitexact && !ost->bitexact) av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); @@ -2906,10 +2904,8 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost, n++; size = n; pts = av_malloc_array(size, sizeof(*pts)); - if (!pts) { - av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n"); - exit_program(1); - } + if (!pts) + report_and_exit(AVERROR(ENOMEM)); p = kf; for (i = 0; i < n; i++) { @@ -2928,11 +2924,8 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost, if (nb_ch > INT_MAX - size || !(pts = av_realloc_f(pts, size += nb_ch - 1, - sizeof(*pts)))) { - av_log(NULL, AV_LOG_FATAL, - "Could not allocate forced key frames array.\n"); - exit_program(1); - } + sizeof(*pts)))) + report_and_exit(AVERROR(ENOMEM)); t = p[8] ? parse_time_or_die("force_key_frames", p + 8, 1) : 0; t = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base); @@ -3870,7 +3863,7 @@ static int process_input(int file_index) dst_data = av_packet_new_side_data(pkt, src_sd->type, src_sd->size); if (!dst_data) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); memcpy(dst_data, src_sd->data, src_sd->size); } diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ac8d81c8aa..7a5308425d 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -119,7 +119,7 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|'); } if (!av_bprint_is_complete(bprint)) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); return bprint->str; } else return NULL; @@ -183,7 +183,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) InputFilter *ifilter; if (!fg) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); fg->index = nb_filtergraphs; ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); @@ -200,7 +200,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifilter->frame_queue) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); GROW_ARRAY(ist->filters, ist->nb_filters); ist->filters[ist->nb_filters - 1] = ifilter; @@ -224,7 +224,7 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in) res = av_asprintf("%s:%s", ctx->filter->name, avfilter_pad_get_name(pads, inout->pad_idx)); if (!res) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); return res; } @@ -309,7 +309,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifilter->frame_queue) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); GROW_ARRAY(ist->filters, ist->nb_filters); ist->filters[ist->nb_filters - 1] = ifilter; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index b387684daf..c8d3ec3ea6 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -996,7 +996,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) if (hwaccel_device) { ist->hwaccel_device = av_strdup(hwaccel_device); if (!ist->hwaccel_device) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); } ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE; @@ -1027,10 +1027,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->prev_pkt_pts = AV_NOPTS_VALUE; ist->dec_ctx = avcodec_alloc_context3(ist->dec); - if (!ist->dec_ctx) { - av_log(NULL, AV_LOG_ERROR, "Error allocating the decoder context.\n"); - exit_program(1); - } + if (!ist->dec_ctx) + report_and_exit(AVERROR(ENOMEM)); ret = avcodec_parameters_to_context(ist->dec_ctx, par); if (ret < 0) { @@ -1040,11 +1038,11 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->decoded_frame = av_frame_alloc(); if (!ist->decoded_frame) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); ist->pkt = av_packet_alloc(); if (!ist->pkt) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); if (o->bitexact) ist->dec_ctx->flags |= AV_CODEC_FLAG_BITEXACT; @@ -1094,7 +1092,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->par = avcodec_parameters_alloc(); if (!ist->par) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); ret = avcodec_parameters_from_context(ist->par, ist->dec_ctx); if (ret < 0) { @@ -1224,10 +1222,8 @@ static int open_input_file(OptionsContext *o, const char *filename) /* get default parameters from command line */ ic = avformat_alloc_context(); - if (!ic) { - print_error(filename, AVERROR(ENOMEM)); - exit_program(1); - } + if (!ic) + report_and_exit(AVERROR(ENOMEM)); if (o->nb_audio_sample_rate) { av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0); } @@ -1476,10 +1472,8 @@ static char *get_line(AVIOContext *s, AVBPrint *bprint) while ((c = avio_r8(s)) && c != '\n') av_bprint_chars(bprint, c, 1); - if (!av_bprint_is_complete(bprint)) { - av_log(NULL, AV_LOG_FATAL, "Could not alloc buffer for reading preset.\n"); - exit_program(1); - } + if (!av_bprint_is_complete(bprint)) + report_and_exit(AVERROR(ENOMEM)); return bprint->str; } @@ -1571,10 +1565,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e double qscale = -1; int i; - if (!st) { - av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); - exit_program(1); - } + if (!st) + report_and_exit(AVERROR(ENOMEM)); if (oc->nb_streams - 1 < o->nb_streamid_map) st->id = o->streamid_map[oc->nb_streams - 1]; @@ -1596,19 +1588,17 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e if (enc) { ost->enc_ctx = avcodec_alloc_context3(enc); - if (!ost->enc_ctx) { - av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); - exit_program(1); - } + if (!ost->enc_ctx) + report_and_exit(AVERROR(ENOMEM)); } ost->filtered_frame = av_frame_alloc(); if (!ost->filtered_frame) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); ost->pkt = av_packet_alloc(); if (!ost->pkt) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); if (ost->enc_ctx) { AVCodecContext *enc = ost->enc_ctx; @@ -1903,28 +1893,22 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st); if (intra_matrix) { - if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) { - av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n"); - exit_program(1); - } + if (!(video_enc->intra_matrix = av_mallocz(sizeof(*video_enc->intra_matrix) * 64))) + report_and_exit(AVERROR(ENOMEM)); parse_matrix_coeffs(video_enc->intra_matrix, intra_matrix); } MATCH_PER_STREAM_OPT(chroma_intra_matrices, str, chroma_intra_matrix, oc, st); if (chroma_intra_matrix) { uint16_t *p = av_mallocz(sizeof(*video_enc->chroma_intra_matrix) * 64); - if (!p) { - av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for intra matrix.\n"); - exit_program(1); - } + if (!p) + report_and_exit(AVERROR(ENOMEM)); video_enc->chroma_intra_matrix = p; parse_matrix_coeffs(p, chroma_intra_matrix); } MATCH_PER_STREAM_OPT(inter_matrices, str, inter_matrix, oc, st); if (inter_matrix) { - if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) { - av_log(NULL, AV_LOG_FATAL, "Could not allocate memory for inter matrix.\n"); - exit_program(1); - } + if (!(video_enc->inter_matrix = av_mallocz(sizeof(*video_enc->inter_matrix) * 64))) + report_and_exit(AVERROR(ENOMEM)); parse_matrix_coeffs(video_enc->inter_matrix, inter_matrix); } @@ -1981,7 +1965,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in MATCH_PER_STREAM_OPT(passlogfiles, str, ost->logfile_prefix, oc, st); if (ost->logfile_prefix && !(ost->logfile_prefix = av_strdup(ost->logfile_prefix))) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); if (do_pass) { char logfilename[1024]; @@ -2061,7 +2045,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in ost->last_frame = av_frame_alloc(); if (!ost->last_frame) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); } else check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_VIDEO); @@ -2152,7 +2136,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in ost->audio_channels_mapped + 1, sizeof(*ost->audio_channels_map) ) < 0 ) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); ost->audio_channels_map[ost->audio_channels_mapped++] = map->channel_idx; } @@ -2882,7 +2866,7 @@ static void set_channel_layout(OutputFilter *f, OutputStream *ost) /* Pass the layout through for all orders but UNSPEC */ err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout); if (err < 0) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); return; } @@ -2903,7 +2887,7 @@ static void set_channel_layout(OutputFilter *f, OutputStream *ost) /* Use it if one is found */ err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]); if (err < 0) - exit_program(1); + report_and_exit(AVERROR(ENOMEM)); return; } /* If no layout for the amount of channels requested was found, use the default diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 8983dc28cc..3344a06409 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3291,10 +3291,8 @@ static int open_input_file(InputFile *ifile, const char *filename, int scan_all_pmts_set = 0; fmt_ctx = avformat_alloc_context(); - if (!fmt_ctx) { - print_error(filename, AVERROR(ENOMEM)); - exit_program(1); - } + if (!fmt_ctx) + report_and_exit(AVERROR(ENOMEM)); if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) { av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE); diff --git a/fftools/opt_common.c b/fftools/opt_common.c index ae5e28a5af..7cd8b1c66e 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -639,10 +639,8 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) while ((desc = avcodec_descriptor_next(desc))) nb_codecs++; - if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) { - av_log(NULL, AV_LOG_ERROR, "Out of memory\n"); - exit_program(1); - } + if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) + report_and_exit(AVERROR(ENOMEM)); desc = NULL; while ((desc = avcodec_descriptor_next(desc))) codecs[i++] = desc; From 90aa2a88f98473810bbbf6514a8327ae8ea9208a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 23:11:02 +0200 Subject: [PATCH 082/590] fftools/ffmpeg_opt: Check creation of new program Fixes Coverity issue #1512413. Signed-off-by: Andreas Rheinhardt --- fftools/ffmpeg_opt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index c8d3ec3ea6..5febe319e4 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2759,6 +2759,8 @@ static void of_add_programs(AVFormatContext *oc, const OptionsContext *o) } program = av_new_program(oc, progid); + if (!program) + report_and_exit(AVERROR(ENOMEM)); p = o->program[i].u.str; while(*p) { From ff6044b921ffb59964a126faef5106a391a819eb Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Wed, 31 Aug 2022 19:37:19 +0200 Subject: [PATCH 083/590] lavc/tiff: Support multi-component files without RowsPerStrip tag. Fixes ticket #9514. --- libavcodec/tiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index b0595b56c0..109392ad44 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1367,7 +1367,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) } else s->strippos = off; s->strips = count; - if (s->strips == 1) + if (s->strips == s->bppcount) s->rps = s->height; s->sot = type; break; From b14104a6376cd774b08cbe5fda56b34320a41b2e Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 13 Jun 2022 02:01:20 +0200 Subject: [PATCH 084/590] avcodec/bink: disallow odd positioned scaled blocks Fixes: out of array access Fixes: 47911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINK_fuzzer-6194020855971840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Anton Khirnov Signed-off-by: Michael Niedermayer --- libavcodec/bink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/bink.c b/libavcodec/bink.c index a3cd4667d6..c1960484d6 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1087,7 +1087,7 @@ static int bink_decode_plane(BinkContext *c, AVFrame *frame, GetBitContext *gb, for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { blk = get_value(c, BINK_SRC_BLOCK_TYPES); // 16x16 block type on odd line means part of the already decoded block, so skip it - if ((by & 1) && blk == SCALED_BLOCK) { + if (((by & 1) || (bx & 1)) && blk == SCALED_BLOCK) { bx++; dst += 8; prev += 8; From 8b5d15530127fea54e934043a64653859de07353 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 00:44:26 +0200 Subject: [PATCH 085/590] avformat/hevc: Fix crash on allocation failure, avoid allocations The HEVC code currently uses an array of arrays of NALUs; one such array contains all the SPS NALUs, one all PPS NALUs etc. The array of arrays is grown dynamically via av_reallocp_array(), but given that the latter function automatically frees its buffer upon reallocation error, it may only be used with PODs, which this case is not. Even worse: While the pointer to the arrays is reset, the counter for the number of arrays is not, leading to a segfault in hvcc_close(). Fix this by avoiding the allocations of the array of arrays altogether. This is easily possible because their number is bounded (by five). Furthermore, as a byproduct we can ensure that the code always produces the recommended ordering of VPS-SPS-PPS-SEI (which was not guaranteed before). Signed-off-by: Andreas Rheinhardt --- libavformat/hevc.c | 155 +++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 90 deletions(-) diff --git a/libavformat/hevc.c b/libavformat/hevc.c index 37d97941d5..13951bd9f2 100644 --- a/libavformat/hevc.c +++ b/libavformat/hevc.c @@ -29,6 +29,15 @@ #define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field +enum { + VPS_INDEX, + SPS_INDEX, + PPS_INDEX, + SEI_PREFIX_INDEX, + SEI_SUFFIX_INDEX, + NB_ARRAYS +}; + typedef struct HVCCNALUnitArray { uint8_t array_completeness; uint8_t NAL_unit_type; @@ -56,7 +65,7 @@ typedef struct HEVCDecoderConfigurationRecord { uint8_t temporalIdNested; uint8_t lengthSizeMinusOne; uint8_t numOfArrays; - HVCCNALUnitArray *array; + HVCCNALUnitArray arrays[NB_ARRAYS]; } HEVCDecoderConfigurationRecord; typedef struct HVCCProfileTierLevel { @@ -658,31 +667,10 @@ static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type) static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, - HEVCDecoderConfigurationRecord *hvcc) + HVCCNALUnitArray *array) { int ret; - uint8_t index; - uint16_t numNalus; - HVCCNALUnitArray *array; - - for (index = 0; index < hvcc->numOfArrays; index++) - if (hvcc->array[index].NAL_unit_type == nal_type) - break; - - if (index >= hvcc->numOfArrays) { - uint8_t i; - - ret = av_reallocp_array(&hvcc->array, index + 1, sizeof(HVCCNALUnitArray)); - if (ret < 0) - return ret; - - for (i = hvcc->numOfArrays; i <= index; i++) - memset(&hvcc->array[i], 0, sizeof(HVCCNALUnitArray)); - hvcc->numOfArrays = index + 1; - } - - array = &hvcc->array[index]; - numNalus = array->numNalus; + uint16_t numNalus = array->numNalus; ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t*)); if (ret < 0) @@ -711,7 +699,8 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, int ps_array_completeness, - HEVCDecoderConfigurationRecord *hvcc) + HEVCDecoderConfigurationRecord *hvcc, + unsigned array_idx) { int ret = 0; GetBitContext gbc; @@ -736,17 +725,14 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, * hvcC. Perhaps the SEI playload type should be checked * and non-declarative SEI messages discarded? */ - switch (nal_type) { - case HEVC_NAL_VPS: - case HEVC_NAL_SPS: - case HEVC_NAL_PPS: - case HEVC_NAL_SEI_PREFIX: - case HEVC_NAL_SEI_SUFFIX: - ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type, - ps_array_completeness, hvcc); + ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type, + ps_array_completeness, + &hvcc->arrays[array_idx]); if (ret < 0) goto end; - else if (nal_type == HEVC_NAL_VPS) + if (hvcc->arrays[array_idx].numNalus == 1) + hvcc->numOfArrays++; + if (nal_type == HEVC_NAL_VPS) ret = hvcc_parse_vps(&gbc, hvcc); else if (nal_type == HEVC_NAL_SPS) ret = hvcc_parse_sps(&gbc, hvcc); @@ -754,11 +740,6 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, ret = hvcc_parse_pps(&gbc, hvcc); if (ret < 0) goto end; - break; - default: - ret = AVERROR_INVALIDDATA; - goto end; - } end: av_free(rbsp_buf); @@ -787,22 +768,17 @@ static void hvcc_init(HEVCDecoderConfigurationRecord *hvcc) static void hvcc_close(HEVCDecoderConfigurationRecord *hvcc) { - uint8_t i; - - for (i = 0; i < hvcc->numOfArrays; i++) { - hvcc->array[i].numNalus = 0; - av_freep(&hvcc->array[i].nalUnit); - av_freep(&hvcc->array[i].nalUnitLength); + for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) { + HVCCNALUnitArray *const array = &hvcc->arrays[i]; + array->numNalus = 0; + av_freep(&array->nalUnit); + av_freep(&array->nalUnitLength); } - - hvcc->numOfArrays = 0; - av_freep(&hvcc->array); } static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc) { - uint8_t i; - uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0; + uint16_t vps_count, sps_count, pps_count; /* * We only support writing HEVCDecoderConfigurationRecord version 1. @@ -866,36 +842,31 @@ static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc) hvcc->lengthSizeMinusOne); av_log(NULL, AV_LOG_TRACE, "numOfArrays: %"PRIu8"\n", hvcc->numOfArrays); - for (i = 0; i < hvcc->numOfArrays; i++) { + for (unsigned i = 0, j = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) { + const HVCCNALUnitArray *const array = &hvcc->arrays[i]; + + if (array->numNalus == 0) + continue; + av_log(NULL, AV_LOG_TRACE, "array_completeness[%"PRIu8"]: %"PRIu8"\n", - i, hvcc->array[i].array_completeness); + j, array->array_completeness); av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%"PRIu8"]: %"PRIu8"\n", - i, hvcc->array[i].NAL_unit_type); + j, array->NAL_unit_type); av_log(NULL, AV_LOG_TRACE, "numNalus[%"PRIu8"]: %"PRIu16"\n", - i, hvcc->array[i].numNalus); - for (j = 0; j < hvcc->array[i].numNalus; j++) + j, array->numNalus); + for (unsigned k = 0; k < array->numNalus; k++) av_log(NULL, AV_LOG_TRACE, "nalUnitLength[%"PRIu8"][%"PRIu16"]: %"PRIu16"\n", - i, j, hvcc->array[i].nalUnitLength[j]); + j, k, array->nalUnitLength[k]); + j++; } /* * We need at least one of each: VPS, SPS and PPS. */ - for (i = 0; i < hvcc->numOfArrays; i++) - switch (hvcc->array[i].NAL_unit_type) { - case HEVC_NAL_VPS: - vps_count += hvcc->array[i].numNalus; - break; - case HEVC_NAL_SPS: - sps_count += hvcc->array[i].numNalus; - break; - case HEVC_NAL_PPS: - pps_count += hvcc->array[i].numNalus; - break; - default: - break; - } + vps_count = hvcc->arrays[VPS_INDEX].numNalus; + sps_count = hvcc->arrays[SPS_INDEX].numNalus; + pps_count = hvcc->arrays[PPS_INDEX].numNalus; if (!vps_count || vps_count > HEVC_MAX_VPS_COUNT || !sps_count || sps_count > HEVC_MAX_SPS_COUNT || !pps_count || pps_count > HEVC_MAX_PPS_COUNT) @@ -970,25 +941,29 @@ static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc) /* unsigned int(8) numOfArrays; */ avio_w8(pb, hvcc->numOfArrays); - for (i = 0; i < hvcc->numOfArrays; i++) { + for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) { + const HVCCNALUnitArray *const array = &hvcc->arrays[i]; + + if (!array->numNalus) + continue; /* * bit(1) array_completeness; * unsigned int(1) reserved = 0; * unsigned int(6) NAL_unit_type; */ - avio_w8(pb, hvcc->array[i].array_completeness << 7 | - hvcc->array[i].NAL_unit_type & 0x3f); + avio_w8(pb, array->array_completeness << 7 | + array->NAL_unit_type & 0x3f); /* unsigned int(16) numNalus; */ - avio_wb16(pb, hvcc->array[i].numNalus); + avio_wb16(pb, array->numNalus); - for (j = 0; j < hvcc->array[i].numNalus; j++) { + for (unsigned j = 0; j < array->numNalus; j++) { /* unsigned int(16) nalUnitLength; */ - avio_wb16(pb, hvcc->array[i].nalUnitLength[j]); + avio_wb16(pb, array->nalUnitLength[j]); /* bit(8*nalUnitLength) nalUnit; */ - avio_write(pb, hvcc->array[i].nalUnit[j], - hvcc->array[i].nalUnitLength[j]); + avio_write(pb, array->nalUnit[j], + array->nalUnitLength[j]); } } @@ -1098,18 +1073,18 @@ int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, buf += 4; - switch (type) { - case HEVC_NAL_VPS: - case HEVC_NAL_SPS: - case HEVC_NAL_PPS: - case HEVC_NAL_SEI_PREFIX: - case HEVC_NAL_SEI_SUFFIX: - ret = hvcc_add_nal_unit(buf, len, ps_array_completeness, &hvcc); - if (ret < 0) - goto end; - break; - default: - break; + for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc.arrays); i++) { + static const uint8_t array_idx_to_type[] = + { HEVC_NAL_VPS, HEVC_NAL_SPS, HEVC_NAL_PPS, + HEVC_NAL_SEI_PREFIX, HEVC_NAL_SEI_SUFFIX }; + + if (type == array_idx_to_type[i]) { + ret = hvcc_add_nal_unit(buf, len, ps_array_completeness, + &hvcc, i); + if (ret < 0) + goto end; + break; + } } buf += len; From c421000434b01a9c5cebe44e483d9e206d3ab3df Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 01:32:53 +0200 Subject: [PATCH 086/590] avformat/hevc: Reindent after the previous commit Signed-off-by: Andreas Rheinhardt --- libavformat/hevc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/hevc.c b/libavformat/hevc.c index 13951bd9f2..1841dd5785 100644 --- a/libavformat/hevc.c +++ b/libavformat/hevc.c @@ -728,18 +728,18 @@ static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type, ps_array_completeness, &hvcc->arrays[array_idx]); - if (ret < 0) - goto end; + if (ret < 0) + goto end; if (hvcc->arrays[array_idx].numNalus == 1) hvcc->numOfArrays++; if (nal_type == HEVC_NAL_VPS) - ret = hvcc_parse_vps(&gbc, hvcc); - else if (nal_type == HEVC_NAL_SPS) - ret = hvcc_parse_sps(&gbc, hvcc); - else if (nal_type == HEVC_NAL_PPS) - ret = hvcc_parse_pps(&gbc, hvcc); - if (ret < 0) - goto end; + ret = hvcc_parse_vps(&gbc, hvcc); + else if (nal_type == HEVC_NAL_SPS) + ret = hvcc_parse_sps(&gbc, hvcc); + else if (nal_type == HEVC_NAL_PPS) + ret = hvcc_parse_pps(&gbc, hvcc); + if (ret < 0) + goto end; end: av_free(rbsp_buf); From 500bbd584db8c9f1944aa9c6a31eb94ac5822cd9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 13:09:19 +0200 Subject: [PATCH 087/590] avcodec/mpeg4video: Factor non-codec stuff out into a header of its own This avoids including mpegvideo.h in mpeg4_unpack_bframes_bsf.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/h263dec.c | 1 + libavcodec/ituh263dec.c | 1 + libavcodec/mpeg4_unpack_bframes_bsf.c | 2 +- libavcodec/mpeg4video.h | 42 ----------------- libavcodec/mpeg4video_parser.c | 2 +- libavcodec/mpeg4videodec.c | 1 + libavcodec/mpeg4videodefs.h | 68 +++++++++++++++++++++++++++ libavcodec/mpeg4videoenc.c | 1 + libavcodec/nvdec_mpeg4.c | 2 +- 9 files changed, 75 insertions(+), 45 deletions(-) create mode 100644 libavcodec/mpeg4videodefs.h diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 8b4101272a..a08329a121 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -43,6 +43,7 @@ #include "mpeg_er.h" #include "mpeg4video.h" #include "mpeg4videodec.h" +#include "mpeg4videodefs.h" #if FF_API_FLAG_TRUNCATED #include "mpeg4video_parser.h" #endif diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index af054360d8..200de8527e 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -50,6 +50,7 @@ #include "mpegvideodata.h" #include "mpegvideodec.h" #include "mpeg4videodec.h" +#include "mpeg4videodefs.h" // The defines below define the number of bits that are read at once for // reading vlc values. Changing these may improve speed and data cache needs diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c index 5493dafa97..3a3aad795f 100644 --- a/libavcodec/mpeg4_unpack_bframes_bsf.c +++ b/libavcodec/mpeg4_unpack_bframes_bsf.c @@ -21,7 +21,7 @@ #include "bsf.h" #include "bsf_internal.h" -#include "mpeg4video.h" +#include "mpeg4videodefs.h" #include "startcode.h" typedef struct UnpackBFramesBSFContext { diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index ab65280756..29b11eb92e 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -27,48 +27,6 @@ #include "mpegvideo.h" -// shapes -#define RECT_SHAPE 0 -#define BIN_SHAPE 1 -#define BIN_ONLY_SHAPE 2 -#define GRAY_SHAPE 3 - -#define SIMPLE_VO_TYPE 1 -#define CORE_VO_TYPE 3 -#define MAIN_VO_TYPE 4 -#define NBIT_VO_TYPE 5 -#define ARTS_VO_TYPE 10 -#define ACE_VO_TYPE 12 -#define SIMPLE_STUDIO_VO_TYPE 14 -#define CORE_STUDIO_VO_TYPE 15 -#define ADV_SIMPLE_VO_TYPE 17 - -#define VOT_VIDEO_ID 1 -#define VOT_STILL_TEXTURE_ID 2 - -// aspect_ratio_info -#define EXTENDED_PAR 15 - -//vol_sprite_usage / sprite_enable -#define STATIC_SPRITE 1 -#define GMC_SPRITE 2 - -#define MOTION_MARKER 0x1F001 -#define DC_MARKER 0x6B001 - -#define VOS_STARTCODE 0x1B0 -#define USER_DATA_STARTCODE 0x1B2 -#define GOP_STARTCODE 0x1B3 -#define VISUAL_OBJ_STARTCODE 0x1B5 -#define VOP_STARTCODE 0x1B6 -#define SLICE_STARTCODE 0x1B7 -#define EXT_STARTCODE 0x1B8 - -#define QUANT_MATRIX_EXT_ID 0x3 - -/* smaller packets likely don't contain a real frame */ -#define MAX_NVOP_SIZE 19 - void ff_mpeg4_clean_buffers(MpegEncContext *s); int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s); void ff_mpeg4_init_direct_mv(MpegEncContext *s); diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index bbdb2209cf..e32a93d296 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -25,8 +25,8 @@ #include "decode.h" #include "parser.h" #include "mpegvideo.h" -#include "mpeg4video.h" #include "mpeg4videodec.h" +#include "mpeg4videodefs.h" #if FF_API_FLAG_TRUNCATED /* Nuke this header when removing FF_API_FLAG_TRUNCATED */ #include "mpeg4video_parser.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index d89adf8d63..65f3c89c47 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -38,6 +38,7 @@ #include "mpeg4video.h" #include "mpeg4videodata.h" #include "mpeg4videodec.h" +#include "mpeg4videodefs.h" #include "h263.h" #include "h263data.h" #include "h263dec.h" diff --git a/libavcodec/mpeg4videodefs.h b/libavcodec/mpeg4videodefs.h new file mode 100644 index 0000000000..27155eae5c --- /dev/null +++ b/libavcodec/mpeg4videodefs.h @@ -0,0 +1,68 @@ +/* + * MPEG-4 definitions. + * Copyright (c) 2000,2001 Fabrice Bellard + * Copyright (c) 2002-2010 Michael Niedermayer + * + * 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_MPEG4VIDEODEFS_H +#define AVCODEC_MPEG4VIDEODEFS_H + +// shapes +#define RECT_SHAPE 0 +#define BIN_SHAPE 1 +#define BIN_ONLY_SHAPE 2 +#define GRAY_SHAPE 3 + +#define SIMPLE_VO_TYPE 1 +#define CORE_VO_TYPE 3 +#define MAIN_VO_TYPE 4 +#define NBIT_VO_TYPE 5 +#define ARTS_VO_TYPE 10 +#define ACE_VO_TYPE 12 +#define SIMPLE_STUDIO_VO_TYPE 14 +#define CORE_STUDIO_VO_TYPE 15 +#define ADV_SIMPLE_VO_TYPE 17 + +#define VOT_VIDEO_ID 1 +#define VOT_STILL_TEXTURE_ID 2 + +// aspect_ratio_info +#define EXTENDED_PAR 15 + +//vol_sprite_usage / sprite_enable +#define STATIC_SPRITE 1 +#define GMC_SPRITE 2 + +#define MOTION_MARKER 0x1F001 +#define DC_MARKER 0x6B001 + +#define VOS_STARTCODE 0x1B0 +#define USER_DATA_STARTCODE 0x1B2 +#define GOP_STARTCODE 0x1B3 +#define VISUAL_OBJ_STARTCODE 0x1B5 +#define VOP_STARTCODE 0x1B6 +#define SLICE_STARTCODE 0x1B7 +#define EXT_STARTCODE 0x1B8 + +#define QUANT_MATRIX_EXT_ID 0x3 + +/* smaller packets likely don't contain a real frame */ +#define MAX_NVOP_SIZE 19 + +#endif /* AVCODEC_MPEG4VIDEODEFS_H */ diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 339a3c2152..96c48b2eb2 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -31,6 +31,7 @@ #include "h263enc.h" #include "mpeg4video.h" #include "mpeg4videodata.h" +#include "mpeg4videodefs.h" #include "mpeg4videoenc.h" #include "mpegvideoenc.h" #include "profiles.h" diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index b7e1821754..eac138cc38 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -22,8 +22,8 @@ #include "avcodec.h" #include "internal.h" -#include "mpeg4video.h" #include "mpeg4videodec.h" +#include "mpeg4videodefs.h" #include "nvdec.h" #include "decode.h" From 6713554271f19c95ed0745cbdb9e7eb294337c08 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 14:13:22 +0200 Subject: [PATCH 088/590] avcodec/flac: Remove unnecessary FLACSTREAMINFO define Possible since 38f5a266eed1160e87da8e832a0a07818d7673cb. Signed-off-by: Andreas Rheinhardt --- libavcodec/flac.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/flac.h b/libavcodec/flac.h index cb220ab4c0..315df492a3 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -69,14 +69,11 @@ enum FLACExtradataFormat { * Data needed from the Streaminfo header for use by the raw FLAC demuxer * and/or the FLAC decoder. */ -#define FLACSTREAMINFO \ - FLACCOMMONINFO \ - int max_blocksize; /**< maximum block size, in samples */\ - int max_framesize; /**< maximum frame size, in bytes */\ - int64_t samples; /**< total number of samples */\ - typedef struct FLACStreaminfo { - FLACSTREAMINFO + FLACCOMMONINFO + int max_blocksize; /**< maximum block size, in samples */ + int max_framesize; /**< maximum frame size, in bytes */ + int64_t samples; /**< total number of samples */ } FLACStreaminfo; typedef struct FLACFrameInfo { From bddf1a647991e0dbacf657aa24d4227720cf2bca Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 14:15:40 +0200 Subject: [PATCH 089/590] avcodec/flacdec: Shorten name Signed-off-by: Andreas Rheinhardt --- libavcodec/flacdec.c | 80 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 5ddc5a34d2..d03369eb6d 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -50,7 +50,7 @@ typedef struct FLACContext { AVClass *class; - struct FLACStreaminfo flac_stream_info; + FLACStreaminfo stream_info; AVCodecContext *avctx; ///< parent AVCodecContext GetBitContext gb; ///< GetBitContext initialized to start at the current frame @@ -73,7 +73,7 @@ static int allocate_buffers(FLACContext *s); static void flac_set_bps(FLACContext *s) { enum AVSampleFormat req = s->avctx->request_sample_fmt; - int need32 = s->flac_stream_info.bps > 16; + int need32 = s->stream_info.bps > 16; int want32 = av_get_bytes_per_sample(req) > 2; int planar = av_sample_fmt_is_planar(req); @@ -82,13 +82,13 @@ static void flac_set_bps(FLACContext *s) s->avctx->sample_fmt = AV_SAMPLE_FMT_S32P; else s->avctx->sample_fmt = AV_SAMPLE_FMT_S32; - s->sample_shift = 32 - s->flac_stream_info.bps; + s->sample_shift = 32 - s->stream_info.bps; } else { if (planar) s->avctx->sample_fmt = AV_SAMPLE_FMT_S16P; else s->avctx->sample_fmt = AV_SAMPLE_FMT_S16; - s->sample_shift = 16 - s->flac_stream_info.bps; + s->sample_shift = 16 - s->stream_info.bps; } } @@ -109,7 +109,7 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; /* initialize based on the demuxer-supplied streamdata header */ - ret = ff_flac_parse_streaminfo(avctx, &s->flac_stream_info, streaminfo); + ret = ff_flac_parse_streaminfo(avctx, &s->stream_info, streaminfo); if (ret < 0) return ret; ret = allocate_buffers(s); @@ -117,7 +117,7 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) return ret; flac_set_bps(s); ff_flacdsp_init(&s->dsp, avctx->sample_fmt, - s->flac_stream_info.channels); + s->stream_info.channels); s->got_streaminfo = 1; return 0; @@ -137,10 +137,10 @@ static int allocate_buffers(FLACContext *s) int buf_size; int ret; - av_assert0(s->flac_stream_info.max_blocksize); + av_assert0(s->stream_info.max_blocksize); - buf_size = av_samples_get_buffer_size(NULL, s->flac_stream_info.channels, - s->flac_stream_info.max_blocksize, + buf_size = av_samples_get_buffer_size(NULL, s->stream_info.channels, + s->stream_info.max_blocksize, AV_SAMPLE_FMT_S32P, 0); if (buf_size < 0) return buf_size; @@ -151,8 +151,8 @@ static int allocate_buffers(FLACContext *s) ret = av_samples_fill_arrays((uint8_t **)s->decoded, NULL, s->decoded_buffer, - s->flac_stream_info.channels, - s->flac_stream_info.max_blocksize, + s->stream_info.channels, + s->stream_info.max_blocksize, AV_SAMPLE_FMT_S32P, 0); return ret < 0 ? ret : 0; } @@ -177,7 +177,7 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size) metadata_size != FLAC_STREAMINFO_SIZE) { return AVERROR_INVALIDDATA; } - ret = ff_flac_parse_streaminfo(s->avctx, &s->flac_stream_info, &buf[8]); + ret = ff_flac_parse_streaminfo(s->avctx, &s->stream_info, &buf[8]); if (ret < 0) return ret; ret = allocate_buffers(s); @@ -185,7 +185,7 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size) return ret; flac_set_bps(s); ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, - s->flac_stream_info.channels); + s->stream_info.channels); s->got_streaminfo = 1; return 0; @@ -389,13 +389,13 @@ static int decode_subframe_lpc(FLACContext *s, int32_t *decoded, int pred_order, if ((ret = decode_residuals(s, decoded, pred_order)) < 0) return ret; - if ( ( s->buggy_lpc && s->flac_stream_info.bps <= 16) + if ( ( s->buggy_lpc && s->stream_info.bps <= 16) || ( !s->buggy_lpc && bps <= 16 && bps + coeff_prec + av_log2(pred_order) <= 32)) { s->dsp.lpc16(decoded, coeffs, pred_order, qlevel, s->blocksize); } else { s->dsp.lpc32(decoded, coeffs, pred_order, qlevel, s->blocksize); - if (s->flac_stream_info.bps <= 16) + if (s->stream_info.bps <= 16) lpc_analyze_remodulate(decoded, coeffs, pred_order, qlevel, s->blocksize, bps); } @@ -406,7 +406,7 @@ static inline int decode_subframe(FLACContext *s, int channel) { int32_t *decoded = s->decoded[channel]; int type, wasted = 0; - int bps = s->flac_stream_info.bps; + int bps = s->stream_info.bps; int i, tmp, ret; if (channel == 0) { @@ -480,68 +480,68 @@ static int decode_frame(FLACContext *s) return ret; } - if ( s->flac_stream_info.channels - && fi.channels != s->flac_stream_info.channels + if ( s->stream_info.channels + && fi.channels != s->stream_info.channels && s->got_streaminfo) { - s->flac_stream_info.channels = fi.channels; + s->stream_info.channels = fi.channels; ff_flac_set_channel_layout(s->avctx, fi.channels); ret = allocate_buffers(s); if (ret < 0) return ret; } - s->flac_stream_info.channels = fi.channels; + s->stream_info.channels = fi.channels; ff_flac_set_channel_layout(s->avctx, fi.channels); s->ch_mode = fi.ch_mode; - if (!s->flac_stream_info.bps && !fi.bps) { + if (!s->stream_info.bps && !fi.bps) { av_log(s->avctx, AV_LOG_ERROR, "bps not found in STREAMINFO or frame header\n"); return AVERROR_INVALIDDATA; } if (!fi.bps) { - fi.bps = s->flac_stream_info.bps; - } else if (s->flac_stream_info.bps && fi.bps != s->flac_stream_info.bps) { + fi.bps = s->stream_info.bps; + } else if (s->stream_info.bps && fi.bps != s->stream_info.bps) { av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not " "supported\n"); return AVERROR_INVALIDDATA; } - if (!s->flac_stream_info.bps) { - s->flac_stream_info.bps = s->avctx->bits_per_raw_sample = fi.bps; + if (!s->stream_info.bps) { + s->stream_info.bps = s->avctx->bits_per_raw_sample = fi.bps; flac_set_bps(s); } - if (!s->flac_stream_info.max_blocksize) - s->flac_stream_info.max_blocksize = FLAC_MAX_BLOCKSIZE; - if (fi.blocksize > s->flac_stream_info.max_blocksize) { + if (!s->stream_info.max_blocksize) + s->stream_info.max_blocksize = FLAC_MAX_BLOCKSIZE; + if (fi.blocksize > s->stream_info.max_blocksize) { av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", fi.blocksize, - s->flac_stream_info.max_blocksize); + s->stream_info.max_blocksize); return AVERROR_INVALIDDATA; } s->blocksize = fi.blocksize; - if (!s->flac_stream_info.samplerate && !fi.samplerate) { + if (!s->stream_info.samplerate && !fi.samplerate) { av_log(s->avctx, AV_LOG_ERROR, "sample rate not found in STREAMINFO" " or frame header\n"); return AVERROR_INVALIDDATA; } if (fi.samplerate == 0) - fi.samplerate = s->flac_stream_info.samplerate; - s->flac_stream_info.samplerate = s->avctx->sample_rate = fi.samplerate; + fi.samplerate = s->stream_info.samplerate; + s->stream_info.samplerate = s->avctx->sample_rate = fi.samplerate; if (!s->got_streaminfo) { ret = allocate_buffers(s); if (ret < 0) return ret; s->got_streaminfo = 1; - dump_headers(s->avctx, &s->flac_stream_info); + dump_headers(s->avctx, &s->stream_info); } ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, - s->flac_stream_info.channels); + s->stream_info.channels); -// dump_headers(s->avctx, &s->flac_stream_info); +// dump_headers(s->avctx, &s->stream_info); /* subframes */ - for (i = 0; i < s->flac_stream_info.channels; i++) { + for (i = 0; i < s->stream_info.channels; i++) { if ((ret = decode_subframe(s, i)) < 0) return ret; } @@ -565,9 +565,9 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame, *got_frame_ptr = 0; - if (s->flac_stream_info.max_framesize == 0) { - s->flac_stream_info.max_framesize = - ff_flac_get_max_frame_size(s->flac_stream_info.max_blocksize ? s->flac_stream_info.max_blocksize : FLAC_MAX_BLOCKSIZE, + if (s->stream_info.max_framesize == 0) { + s->stream_info.max_framesize = + ff_flac_get_max_frame_size(s->stream_info.max_blocksize ? s->stream_info.max_blocksize : FLAC_MAX_BLOCKSIZE, FLAC_MAX_CHANNELS, 32); } @@ -619,7 +619,7 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; s->dsp.decorrelate[s->ch_mode](frame->data, s->decoded, - s->flac_stream_info.channels, + s->stream_info.channels, s->blocksize, s->sample_shift); if (bytes_read > buf_size) { From ff1f5b407df8e8740eb6eeee83b202284f6ace7a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 15:01:34 +0200 Subject: [PATCH 090/590] avcodec/flacdec: Don't infer max_framesize unnecessarily This field is not really used by the decoder at all: It is only output in some debug log message, but this debug log message should better use the value read from the streaminfo instead of a second-guessed value from the decoder. Signed-off-by: Andreas Rheinhardt --- libavcodec/flacdec.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index d03369eb6d..3b16426e73 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -565,12 +565,6 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame, *got_frame_ptr = 0; - if (s->stream_info.max_framesize == 0) { - s->stream_info.max_framesize = - ff_flac_get_max_frame_size(s->stream_info.max_blocksize ? s->stream_info.max_blocksize : FLAC_MAX_BLOCKSIZE, - FLAC_MAX_CHANNELS, 32); - } - if (buf_size > 5 && !memcmp(buf, "\177FLAC", 5)) { av_log(s->avctx, AV_LOG_DEBUG, "skipping flac header packet 1\n"); return buf_size; From 17b1375965593e688c3e12ddbbb7298c5140b9e1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 15:21:27 +0200 Subject: [PATCH 091/590] avcodec/flac: Move ff_flac_get_max_frame_size() to flacenc.c It is its only user. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- libavcodec/flac.c | 21 --------------------- libavcodec/flac.h | 8 -------- libavcodec/flacenc.c | 40 ++++++++++++++++++++++++++++++++++------ 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cb80f73d99..945908e3b8 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -347,7 +347,7 @@ OBJS-$(CONFIG_FIC_DECODER) += fic.o OBJS-$(CONFIG_FITS_DECODER) += fitsdec.o fits.o OBJS-$(CONFIG_FITS_ENCODER) += fitsenc.o OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flacdsp.o flac.o -OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flacencdsp.o flac.o +OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flacencdsp.o OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o OBJS-$(CONFIG_FLASHSV_ENCODER) += flashsvenc.o OBJS-$(CONFIG_FLASHSV2_ENCODER) += flashsv2enc.o diff --git a/libavcodec/flac.c b/libavcodec/flac.c index dd68830622..03c7bfb9e6 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -145,27 +145,6 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, return 0; } -int ff_flac_get_max_frame_size(int blocksize, int ch, int bps) -{ - /* Technically, there is no limit to FLAC frame size, but an encoder - should not write a frame that is larger than if verbatim encoding mode - were to be used. */ - - int count; - - count = 16; /* frame header */ - count += ch * ((7+bps+7)/8); /* subframe headers */ - if (ch == 2) { - /* for stereo, need to account for using decorrelation */ - count += (( 2*bps+1) * blocksize + 7) / 8; - } else { - count += ( ch*bps * blocksize + 7) / 8; - } - count += 2; /* frame footer */ - - return count; -} - int ff_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start) diff --git a/libavcodec/flac.h b/libavcodec/flac.h index 315df492a3..239e842716 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -109,14 +109,6 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start); -/** - * Calculate an estimate for the maximum frame size based on verbatim mode. - * @param blocksize block size, in samples - * @param ch number of channels - * @param bps bits-per-sample - */ -int ff_flac_get_max_frame_size(int blocksize, int ch, int bps); - /** * Validate and decode a frame header. * @param avctx AVCodecContext to use as av_log() context diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 73cf185314..0170e02ae8 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -157,6 +157,34 @@ static void write_streaminfo(FlacEncodeContext *s, uint8_t *header) } +/** + * Calculate an estimate for the maximum frame size based on verbatim mode. + * @param blocksize block size, in samples + * @param ch number of channels + * @param bps bits-per-sample + */ +static int flac_get_max_frame_size(int blocksize, int ch, int bps) +{ + /* Technically, there is no limit to FLAC frame size, but an encoder + should not write a frame that is larger than if verbatim encoding mode + were to be used. */ + + int count; + + count = 16; /* frame header */ + count += ch * ((7+bps+7)/8); /* subframe headers */ + if (ch == 2) { + /* for stereo, need to account for using decorrelation */ + count += (( 2*bps+1) * blocksize + 7) / 8; + } else { + count += ( ch*bps * blocksize + 7) / 8; + } + count += 2; /* frame footer */ + + return count; +} + + /** * Set blocksize based on samplerate. * Choose the closest predefined blocksize >= BLOCK_TIME_MS milliseconds. @@ -378,9 +406,9 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) s->max_blocksize = s->avctx->frame_size; /* set maximum encoded frame size in verbatim mode */ - s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size, - s->channels, - s->avctx->bits_per_raw_sample); + s->max_framesize = flac_get_max_frame_size(s->avctx->frame_size, + s->channels, + s->avctx->bits_per_raw_sample); /* initialize MD5 context */ s->md5ctx = av_md5_alloc(); @@ -1353,9 +1381,9 @@ static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, /* change max_framesize for small final frame */ if (frame->nb_samples < s->frame.blocksize) { - s->max_framesize = ff_flac_get_max_frame_size(frame->nb_samples, - s->channels, - avctx->bits_per_raw_sample); + s->max_framesize = flac_get_max_frame_size(frame->nb_samples, + s->channels, + avctx->bits_per_raw_sample); } init_frame(s, frame->nb_samples); From 6699ed38f37d2b6a9512cf61b8f51a7c38ffc988 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 16:27:06 +0200 Subject: [PATCH 092/590] avcodec/flac: Remove unused parameter from ff_flac_is_extradata_valid() format is write-only. Signed-off-by: Andreas Rheinhardt --- libavcodec/flac.c | 3 --- libavcodec/flac.h | 6 ------ libavcodec/flacdec.c | 3 +-- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/libavcodec/flac.c b/libavcodec/flac.c index 03c7bfb9e6..1da8aed21b 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -146,7 +146,6 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, } int ff_flac_is_extradata_valid(AVCodecContext *avctx, - enum FLACExtradataFormat *format, uint8_t **streaminfo_start) { if (!avctx->extradata || avctx->extradata_size < FLAC_STREAMINFO_SIZE) { @@ -159,14 +158,12 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, av_log(avctx, AV_LOG_WARNING, "extradata contains %d bytes too many.\n", FLAC_STREAMINFO_SIZE-avctx->extradata_size); } - *format = FLAC_EXTRADATA_FORMAT_STREAMINFO; *streaminfo_start = avctx->extradata; } else { if (avctx->extradata_size < 8+FLAC_STREAMINFO_SIZE) { av_log(avctx, AV_LOG_ERROR, "extradata too small.\n"); return 0; } - *format = FLAC_EXTRADATA_FORMAT_FULL_HEADER; *streaminfo_start = &avctx->extradata[8]; } return 1; diff --git a/libavcodec/flac.h b/libavcodec/flac.h index 239e842716..7d6286bf0f 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -55,11 +55,6 @@ enum { FLAC_METADATA_TYPE_INVALID = 127 }; -enum FLACExtradataFormat { - FLAC_EXTRADATA_FORMAT_STREAMINFO = 0, - FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1 -}; - #define FLACCOMMONINFO \ int samplerate; /**< sample rate */\ int channels; /**< number of channels */\ @@ -106,7 +101,6 @@ int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, * @return 1 if valid, 0 if not valid. */ int ff_flac_is_extradata_valid(AVCodecContext *avctx, - enum FLACExtradataFormat *format, uint8_t **streaminfo_start); /** diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 3b16426e73..23e9eba4ad 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -94,7 +94,6 @@ static void flac_set_bps(FLACContext *s) static av_cold int flac_decode_init(AVCodecContext *avctx) { - enum FLACExtradataFormat format; uint8_t *streaminfo; int ret; FLACContext *s = avctx->priv_data; @@ -105,7 +104,7 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) if (!avctx->extradata) return 0; - if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) + if (!ff_flac_is_extradata_valid(avctx, &streaminfo)) return AVERROR_INVALIDDATA; /* initialize based on the demuxer-supplied streamdata header */ From f118b2aa46aa176d41acc05e65a30b64f8d6e564 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 16:34:28 +0200 Subject: [PATCH 093/590] avcodec/flac: Remove pointless define Signed-off-by: Andreas Rheinhardt --- libavcodec/flac.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/flac.h b/libavcodec/flac.h index 7d6286bf0f..dbfca546cf 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -55,24 +55,23 @@ enum { FLAC_METADATA_TYPE_INVALID = 127 }; -#define FLACCOMMONINFO \ - int samplerate; /**< sample rate */\ - int channels; /**< number of channels */\ - int bps; /**< bits-per-sample */\ - /** * Data needed from the Streaminfo header for use by the raw FLAC demuxer * and/or the FLAC decoder. */ typedef struct FLACStreaminfo { - FLACCOMMONINFO + int samplerate; /**< sample rate */ + int channels; /**< number of channels */ + int bps; /**< bits-per-sample */ int max_blocksize; /**< maximum block size, in samples */ int max_framesize; /**< maximum frame size, in bytes */ int64_t samples; /**< total number of samples */ } FLACStreaminfo; typedef struct FLACFrameInfo { - FLACCOMMONINFO + int samplerate; /**< sample rate */ + int channels; /**< number of channels */ + int bps; /**< bits-per-sample */ int blocksize; /**< block size of the frame */ int ch_mode; /**< channel decorrelation mode */ int64_t frame_or_sample_num; /**< frame number or sample number */ From 5089884e3c9d7369c7a6bae6da7f28de41365ec7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 17:12:30 +0200 Subject: [PATCH 094/590] avcodec/flac: Move decoder+parser stuff into a new header, flac_parse.h (The FLAC parser currently ignores the streaminfo block; therefore some of this is decoder-only. Given that the FLAC parser should probably use the streaminfo block, this stuff is moved to flac_parse.h.) Signed-off-by: Andreas Rheinhardt --- libavcodec/flac.c | 1 + libavcodec/flac.h | 66 +---------------------------- libavcodec/flac_parse.h | 89 ++++++++++++++++++++++++++++++++++++++++ libavcodec/flac_parser.c | 2 +- libavcodec/flacdec.c | 1 + 5 files changed, 94 insertions(+), 65 deletions(-) create mode 100644 libavcodec/flac_parse.h diff --git a/libavcodec/flac.c b/libavcodec/flac.c index 1da8aed21b..352d663c67 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -26,6 +26,7 @@ #include "get_bits.h" #include "flac.h" #include "flacdata.h" +#include "flac_parse.h" static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; diff --git a/libavcodec/flac.h b/libavcodec/flac.h index dbfca546cf..fd899ef72c 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -1,5 +1,5 @@ /* - * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions + * FLAC (Free Lossless Audio Codec) common stuff * Copyright (c) 2008 Justin Ruggles * * This file is part of FFmpeg. @@ -21,15 +21,13 @@ /** * @file - * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions + * FLAC (Free Lossless Audio Codec) common stuff */ #ifndef AVCODEC_FLAC_H #define AVCODEC_FLAC_H -#include "avcodec.h" #include "bytestream.h" -#include "get_bits.h" #define FLAC_STREAMINFO_SIZE 34 #define FLAC_MAX_CHANNELS 8 @@ -55,66 +53,6 @@ enum { FLAC_METADATA_TYPE_INVALID = 127 }; -/** - * Data needed from the Streaminfo header for use by the raw FLAC demuxer - * and/or the FLAC decoder. - */ -typedef struct FLACStreaminfo { - int samplerate; /**< sample rate */ - int channels; /**< number of channels */ - int bps; /**< bits-per-sample */ - int max_blocksize; /**< maximum block size, in samples */ - int max_framesize; /**< maximum frame size, in bytes */ - int64_t samples; /**< total number of samples */ -} FLACStreaminfo; - -typedef struct FLACFrameInfo { - int samplerate; /**< sample rate */ - int channels; /**< number of channels */ - int bps; /**< bits-per-sample */ - int blocksize; /**< block size of the frame */ - int ch_mode; /**< channel decorrelation mode */ - int64_t frame_or_sample_num; /**< frame number or sample number */ - int is_var_size; /**< specifies if the stream uses variable - block sizes or a fixed block size; - also determines the meaning of - frame_or_sample_num */ -} FLACFrameInfo; - -/** - * Parse the Streaminfo metadata block - * @param[out] avctx codec context to set basic stream parameters - * @param[out] s where parsed information is stored - * @param[in] buffer pointer to start of 34-byte streaminfo data - * - * @return negative error code on faiure or >= 0 on success - */ -int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, - const uint8_t *buffer); - -/** - * Validate the FLAC extradata. - * @param[in] avctx codec context containing the extradata. - * @param[out] format extradata format. - * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data. - * @return 1 if valid, 0 if not valid. - */ -int ff_flac_is_extradata_valid(AVCodecContext *avctx, - uint8_t **streaminfo_start); - -/** - * Validate and decode a frame header. - * @param avctx AVCodecContext to use as av_log() context - * @param gb GetBitContext from which to read frame header - * @param[out] fi frame information - * @param log_level_offset log level offset. can be used to silence error messages. - * @return non-zero on error, 0 if ok - */ -int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, - FLACFrameInfo *fi, int log_level_offset); - -void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels); - /** * Parse the metadata block parameters from the header. * @param[in] block_header header data, at least 4 bytes diff --git a/libavcodec/flac_parse.h b/libavcodec/flac_parse.h new file mode 100644 index 0000000000..67a7320bea --- /dev/null +++ b/libavcodec/flac_parse.h @@ -0,0 +1,89 @@ +/* + * FLAC (Free Lossless Audio Codec) decoder/parser common functions + * Copyright (c) 2008 Justin Ruggles + * + * 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 + */ + +/** + * @file + * FLAC (Free Lossless Audio Codec) decoder/parser common functions + */ + +#ifndef AVCODEC_FLAC_PARSE_H +#define AVCODEC_FLAC_PARSE_H + +#include "avcodec.h" +#include "get_bits.h" + +typedef struct FLACStreaminfo { + int samplerate; /**< sample rate */ + int channels; /**< number of channels */ + int bps; /**< bits-per-sample */ + int max_blocksize; /**< maximum block size, in samples */ + int max_framesize; /**< maximum frame size, in bytes */ + int64_t samples; /**< total number of samples */ +} FLACStreaminfo; + +typedef struct FLACFrameInfo { + int samplerate; /**< sample rate */ + int channels; /**< number of channels */ + int bps; /**< bits-per-sample */ + int blocksize; /**< block size of the frame */ + int ch_mode; /**< channel decorrelation mode */ + int64_t frame_or_sample_num; /**< frame number or sample number */ + int is_var_size; /**< specifies if the stream uses variable + block sizes or a fixed block size; + also determines the meaning of + frame_or_sample_num */ +} FLACFrameInfo; + +/** + * Parse the Streaminfo metadata block + * @param[out] avctx codec context to set basic stream parameters + * @param[out] s where parsed information is stored + * @param[in] buffer pointer to start of 34-byte streaminfo data + * + * @return negative error code on faiure or >= 0 on success + */ +int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, + const uint8_t *buffer); + +/** + * Validate the FLAC extradata. + * @param[in] avctx codec context containing the extradata. + * @param[out] format extradata format. + * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data. + * @return 1 if valid, 0 if not valid. + */ +int ff_flac_is_extradata_valid(AVCodecContext *avctx, + uint8_t **streaminfo_start); + +/** + * Validate and decode a frame header. + * @param avctx AVCodecContext to use as av_log() context + * @param gb GetBitContext from which to read frame header + * @param[out] fi frame information + * @param log_level_offset log level offset. can be used to silence error messages. + * @return non-zero on error, 0 if ok + */ +int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, + FLACFrameInfo *fi, int log_level_offset); + +void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels); + +#endif /* AVCODEC_FLAC_PARSE_H */ diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 81b6f12ab3..a1d9cd7f29 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -36,7 +36,7 @@ #include "libavutil/crc.h" #include "bytestream.h" #include "parser.h" -#include "flac.h" +#include "flac_parse.h" /** maximum number of adjacent headers that compare CRCs against each other */ #define FLAC_MAX_SEQUENTIAL_HEADERS 4 diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 23e9eba4ad..c5d9e95168 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -44,6 +44,7 @@ #include "flac.h" #include "flacdata.h" #include "flacdsp.h" +#include "flac_parse.h" #include "thread.h" #include "unary.h" From 7de9c0e9d7f537389a238b30d40eac57a2fbaf6d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 17:21:03 +0200 Subject: [PATCH 095/590] avcodec/flac: Don't use bytestream API unnecessarily It makes no sense here, as flac_parse_block_header() is not even supposed to advance the caller's pointer. Signed-off-by: Andreas Rheinhardt --- libavcodec/flac.h | 6 +++--- libavformat/flacdec.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/flac.h b/libavcodec/flac.h index fd899ef72c..f118dbbff3 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -27,7 +27,7 @@ #ifndef AVCODEC_FLAC_H #define AVCODEC_FLAC_H -#include "bytestream.h" +#include "libavutil/intreadwrite.h" #define FLAC_STREAMINFO_SIZE 34 #define FLAC_MAX_CHANNELS 8 @@ -63,13 +63,13 @@ enum { static av_always_inline void flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size) { - int tmp = bytestream_get_byte(&block_header); + int tmp = *block_header; if (last) *last = tmp & 0x80; if (type) *type = tmp & 0x7F; if (size) - *size = bytestream_get_be24(&block_header); + *size = AV_RB24(block_header + 1); } #endif /* AVCODEC_FLAC_H */ diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 09404b67bb..eadd41fc36 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -20,6 +20,7 @@ */ #include "libavutil/channel_layout.h" +#include "libavcodec/bytestream.h" #include "libavcodec/flac.h" #include "avformat.h" #include "demux.h" From 826cd5e0984ee85ffee58bed699368ae8bc8b695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 9 Aug 2022 15:41:56 +0300 Subject: [PATCH 096/590] arm: vc1sdp: Change stride parameters to ptrdiff_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was missed in db54426975e124e98e5130ad01316cb7afd60630. Signed-off-by: Martin Storsjö --- libavcodec/arm/vc1dsp_init_neon.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/arm/vc1dsp_init_neon.c b/libavcodec/arm/vc1dsp_init_neon.c index 46fd80a837..b5615624d5 100644 --- a/libavcodec/arm/vc1dsp_init_neon.c +++ b/libavcodec/arm/vc1dsp_init_neon.c @@ -33,12 +33,12 @@ void ff_vc1_inv_trans_4x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *bloc void ff_vc1_inv_trans_8x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); void ff_vc1_inv_trans_4x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); -void ff_vc1_v_loop_filter4_neon(uint8_t *src, int stride, int pq); -void ff_vc1_h_loop_filter4_neon(uint8_t *src, int stride, int pq); -void ff_vc1_v_loop_filter8_neon(uint8_t *src, int stride, int pq); -void ff_vc1_h_loop_filter8_neon(uint8_t *src, int stride, int pq); -void ff_vc1_v_loop_filter16_neon(uint8_t *src, int stride, int pq); -void ff_vc1_h_loop_filter16_neon(uint8_t *src, int stride, int pq); +void ff_vc1_v_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_h_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_v_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_h_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_v_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_h_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq); void ff_put_pixels8x8_neon(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int rnd); From 3f456dc245d975de2c39caa641568e0898d5f316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 9 Aug 2022 15:44:38 +0300 Subject: [PATCH 097/590] arm: rv40dsp: Change stride parameters to ptrdiff_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These were missed when h264_chroma_mc_func was changed in e4a94d8b36c48d95a7d412c40d7b558422ff659c. Signed-off-by: Martin Storsjö --- libavcodec/arm/rv40dsp_init_arm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/arm/rv40dsp_init_arm.c b/libavcodec/arm/rv40dsp_init_arm.c index 92d2867e04..2e584af475 100644 --- a/libavcodec/arm/rv40dsp_init_arm.c +++ b/libavcodec/arm/rv40dsp_init_arm.c @@ -49,11 +49,11 @@ DECL_QPEL_Y(1); DECL_QPEL_Y(2); DECL_QPEL_Y(3); -void ff_put_rv40_chroma_mc8_neon(uint8_t *, const uint8_t *, int, int, int, int); -void ff_put_rv40_chroma_mc4_neon(uint8_t *, const uint8_t *, int, int, int, int); +void ff_put_rv40_chroma_mc8_neon(uint8_t *, const uint8_t *, ptrdiff_t, int, int, int); +void ff_put_rv40_chroma_mc4_neon(uint8_t *, const uint8_t *, ptrdiff_t, int, int, int); -void ff_avg_rv40_chroma_mc8_neon(uint8_t *, const uint8_t *, int, int, int, int); -void ff_avg_rv40_chroma_mc4_neon(uint8_t *, const uint8_t *, int, int, int, int); +void ff_avg_rv40_chroma_mc8_neon(uint8_t *, const uint8_t *, ptrdiff_t, int, int, int); +void ff_avg_rv40_chroma_mc4_neon(uint8_t *, const uint8_t *, ptrdiff_t, int, int, int); void ff_rv40_weight_func_16_neon(uint8_t *, uint8_t *, uint8_t *, int, int, ptrdiff_t); void ff_rv40_weight_func_8_neon(uint8_t *, uint8_t *, uint8_t *, int, int, ptrdiff_t); From 0dd8fe6f4b072077d2d87eb3a2933e145ac41df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 26 Aug 2022 11:26:32 +0300 Subject: [PATCH 098/590] arm: Check the build time constants in av_clip_*intp2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes building for arm targets with optimizations disabled. Signed-off-by: Martin Storsjö --- libavutil/arm/intmath.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/libavutil/arm/intmath.h b/libavutil/arm/intmath.h index 5311a7d52b..f19b21e98d 100644 --- a/libavutil/arm/intmath.h +++ b/libavutil/arm/intmath.h @@ -65,17 +65,29 @@ static av_always_inline av_const int av_clip_int16_arm(int a) #define av_clip_intp2 av_clip_intp2_arm static av_always_inline av_const int av_clip_intp2_arm(int a, int p) { - unsigned x; - __asm__ ("ssat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p+1)); - return x; + if (av_builtin_constant_p(p)) { + unsigned x; + __asm__ ("ssat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p+1)); + return x; + } else { + if (((unsigned)a + (1 << p)) & ~((2 << p) - 1)) + return (a >> 31) ^ ((1 << p) - 1); + else + return a; + } } #define av_clip_uintp2 av_clip_uintp2_arm static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p) { - unsigned x; - __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p)); - return x; + if (av_builtin_constant_p(p)) { + unsigned x; + __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p)); + return x; + } else { + if (a & ~((1<> 31 & ((1< Date: Mon, 11 Jul 2022 12:02:23 +0300 Subject: [PATCH 099/590] libavcodec: Set hidden visibility on global symbols accessed from AArch64 assembly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The AArch64 assembly accesses those symbols directly, without indirection via e.g. the GOT on ELF. In order for this not to require text relocations, those symbols need to be resolved fully at link time, i.e. those symbols can't be interposable. Normally, so far, this is achieved when linking shared libraries in two ways; we have a version script (libavcodec/libavcodec.v) which marks all symbols that don't start with av* as local. Additionally, we try to add -Wl,-Bsymbolic to the linker options if supported, making sure that such symbol references are resolved fully at link time, instead of making them interposable. When the libavcodec static library is linked into another shared library, there's no guarantee that it uses similar options (even though that would be favourable), which would end up requiring text relocations in the AArch64 assembly. Explicitly mark the symbols that are accessed from AArch64 assembly as hidden, so that they are resolved fully at link time even without the version script and -Wl,-Bsymbolic. Signed-off-by: Martin Storsjö --- libavcodec/aacsbrdata.h | 3 ++- libavcodec/fft.h | 3 ++- libavcodec/vp9dsp.h | 3 ++- libavutil/attributes_internal.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 libavutil/attributes_internal.h diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index 7a11594c9b..7bb45b229e 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -29,6 +29,7 @@ #define AVCODEC_AACSBRDATA_H #include +#include "libavutil/attributes_internal.h" #include "libavutil/mem_internal.h" #include "aac_defines.h" @@ -268,7 +269,7 @@ static const int8_t sbr_offset[6][16] = { }; /* First eight entries repeated at end to simplify SIMD implementations. */ -const DECLARE_ALIGNED(16, INTFLOAT, AAC_RENAME(ff_sbr_noise_table))[][2] = { +const attribute_visibility_hidden DECLARE_ALIGNED(16, INTFLOAT, AAC_RENAME(ff_sbr_noise_table))[][2] = { {Q31(-0.99948153278296f), Q31(-0.59483417516607f)}, {Q31( 0.97113454393991f), Q31(-0.67528515225647f)}, {Q31( 0.14130051758487f), Q31(-0.95090983575689f)}, {Q31(-0.47005496701697f), Q31(-0.37340549728647f)}, {Q31( 0.80705063769351f), Q31( 0.29653668284408f)}, {Q31(-0.38981478896926f), Q31( 0.89572605717087f)}, diff --git a/libavcodec/fft.h b/libavcodec/fft.h index 706c9d07f5..d46e5a3f0b 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -29,6 +29,7 @@ #include #include "config.h" +#include "libavutil/attributes_internal.h" #include "libavutil/mem_internal.h" #if FFT_FLOAT @@ -114,7 +115,7 @@ void ff_init_ff_cos_tabs(int index); #endif #define COSTABLE(size) \ - COSTABLE_CONST DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2] + COSTABLE_CONST attribute_visibility_hidden DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2] extern COSTABLE(16); extern COSTABLE(32); diff --git a/libavcodec/vp9dsp.h b/libavcodec/vp9dsp.h index 700dd72de8..be0ac0b181 100644 --- a/libavcodec/vp9dsp.h +++ b/libavcodec/vp9dsp.h @@ -28,6 +28,7 @@ #include #include "libavcodec/vp9.h" +#include "libavutil/attributes_internal.h" typedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, @@ -120,7 +121,7 @@ typedef struct VP9DSPContext { vp9_scaled_mc_func smc[5][N_FILTERS][2]; } VP9DSPContext; -extern const int16_t ff_vp9_subpel_filters[3][16][8]; +extern const int16_t attribute_visibility_hidden ff_vp9_subpel_filters[3][16][8]; void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact); diff --git a/libavutil/attributes_internal.h b/libavutil/attributes_internal.h new file mode 100644 index 0000000000..9d3d10b63e --- /dev/null +++ b/libavutil/attributes_internal.h @@ -0,0 +1,30 @@ +/* + * 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 AVUTIL_ATTRIBUTES_INTERNAL_H +#define AVUTIL_ATTRIBUTES_INTERNAL_H + +#include "attributes.h" + +#if (AV_GCC_VERSION_AT_LEAST(4,0) || defined(__clang__)) && (defined(__ELF__) || defined(__MACH__)) +# define attribute_visibility_hidden __attribute__((visibility("hidden"))) +#else +# define attribute_visibility_hidden +#endif + +#endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */ From 10ed73e933bbc9261c7637652c533ee508e60bca Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 3 Sep 2022 09:23:39 +0200 Subject: [PATCH 100/590] avcodec/cfhddata: remove unused defines --- libavcodec/cfhddata.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 55c8004bdd..8079fdf542 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -24,14 +24,6 @@ #include "cfhd.h" -/* some special codewords, not sure what they all mean */ -#define TABLE_9_BAND_END1 0x1C7859Eh -#define TABLE_9_BAND_END_LEN1 25 -#define TABLE_9_BAND_END2 0x38F0B3Fh -#define TABLE_9_BAND_END_LEN2 26 -#define TABLE_9_BAND_END3 0x38F0B3Eh -#define TABLE_9_BAND_END_LEN3 26 - #define NB_VLC_TABLE_9 (71 + 3) #define NB_VLC_TABLE_18 (263 + 1) From 4beac58e901ac4ffc6d264ae0a5a98ed76e73447 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 3 Sep 2022 11:06:14 +0200 Subject: [PATCH 101/590] avcodec/cfhd: fix escape handling for old codebook --- libavcodec/cfhd.c | 2 +- libavcodec/cfhddata.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index f908aaf8fb..e72512707e 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -819,7 +819,7 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic, VLC_BITS, 3, 1); /* escape */ - if (level == 64) + if (level == 64 && run == 2) break; count += run; diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 8079fdf542..67bd8e66db 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -72,7 +72,7 @@ static const uint16_t table_9_vlc_run[NB_VLC_TABLE_9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1 + 1, 2, }; static const uint8_t table_9_vlc_level[NB_VLC_TABLE_9] = { From d1513e7f9c473dc45c4a1e060a187c32f10c4a2f Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 17 Jun 2022 18:27:19 +0200 Subject: [PATCH 102/590] avfilter: add 3D scope multimedia filter --- Changelog | 1 + doc/filters.texi | 55 ++++++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/avf_a3dscope.c | 357 +++++++++++++++++++++++++++++++++++++ libavfilter/version.h | 4 +- 6 files changed, 417 insertions(+), 2 deletions(-) create mode 100644 libavfilter/avf_a3dscope.c diff --git a/Changelog b/Changelog index fa83786a20..c98f18f97a 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,7 @@ version : - Add new mode to cropdetect filter to detect crop-area based on motion vectors and edges - VAAPI decoding and encoding for 8bit 444 HEVC and VP9 - WBMP (Wireless Application Protocol Bitmap) image format +- a3dscope filter version 5.1: diff --git a/doc/filters.texi b/doc/filters.texi index 01a359f20f..1e7e98c350 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -27232,6 +27232,61 @@ tools. Below is a description of the currently available multimedia filters. +@section a3dscope + +Convert input audio to 3d scope video output. + +The filter accepts the following options: + +@table @option +@item rate, r +Set frame rate, expressed as number of frames per second. Default +value is "25". + +@item size, s +Specify the video size for the output. For the syntax of this option, check the +@ref{video size syntax,,"Video size" section in the ffmpeg-utils manual,ffmpeg-utils}. +Default value is @code{hd720}. + +@item fov +Set the camera field of view. Default is 90 degrees. +Allowed range is from 40 to 150. + +@item roll +Set the camera roll. + +@item pitch +Set the camera pitch. + +@item yaw +Set the camera yaw. + +@item xzoom +Set the camera zoom on X-axis. + +@item yzoom +Set the camera zoom on Y-axis. + +@item zzoom +Set the camera zoom on Z-axis. + +@item xpos +Set the camera position on X-axis. + +@item ypos +Set the camera position on Y-axis. + +@item zpos +Set the camera position on Z-axis. + +@item length +Set the length of displayed audio waves in number of frames. +@end table + +@subsection Commands + +Filter supports the some above options as @ref{commands}. + @section abitscope Convert input audio to a video output, displaying the audio bit scope. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 3187f99a50..c5c44db440 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -579,6 +579,7 @@ OBJS-$(CONFIG_YUVTESTSRC_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o # multimedia filters +OBJS-$(CONFIG_A3DSCOPE_FILTER) += avf_a3dscope.o OBJS-$(CONFIG_ABITSCOPE_FILTER) += avf_abitscope.o OBJS-$(CONFIG_ADRAWGRAPH_FILTER) += f_drawgraph.o OBJS-$(CONFIG_AGRAPHMONITOR_FILTER) += f_graphmonitor.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 8372c4c003..0285889e70 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -546,6 +546,7 @@ extern const AVFilter ff_vsrc_yuvtestsrc; extern const AVFilter ff_vsink_nullsink; /* multimedia filters */ +extern const AVFilter ff_avf_a3dscope; extern const AVFilter ff_avf_abitscope; extern const AVFilter ff_avf_adrawgraph; extern const AVFilter ff_avf_agraphmonitor; diff --git a/libavfilter/avf_a3dscope.c b/libavfilter/avf_a3dscope.c new file mode 100644 index 0000000000..f3bb39feaf --- /dev/null +++ b/libavfilter/avf_a3dscope.c @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2022 Paul B Mahol + * + * 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 "libavutil/avassert.h" +#include "libavutil/channel_layout.h" +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" +#include "avfilter.h" +#include "filters.h" +#include "formats.h" +#include "audio.h" +#include "video.h" +#include "internal.h" + +typedef struct Audio3dScopeContext { + const AVClass *class; + int w, h; + int size; + float fov; + float roll; + float pitch; + float yaw; + float zoom[3]; + float eye[3]; + + AVRational frame_rate; + int nb_samples; + + float view_matrix[4][4]; + float projection_matrix[4][4]; + + AVFrame *frames[60]; +} Audio3dScopeContext; + +#define OFFSET(x) offsetof(Audio3dScopeContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +#define TFLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM + +static const AVOption a3dscope_options[] = { + { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS }, + { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS }, + { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS }, + { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS }, + { "fov", "set camera FoV", OFFSET(fov), AV_OPT_TYPE_FLOAT, {.dbl=90.f}, 40, 150, TFLAGS }, + { "roll", "set camera roll",OFFSET(roll), AV_OPT_TYPE_FLOAT, {.dbl=0.f}, -180, 180, TFLAGS }, + { "pitch","set camera pitch",OFFSET(pitch), AV_OPT_TYPE_FLOAT, {.dbl=0.f}, -180, 180, TFLAGS }, + { "yaw", "set camera yaw", OFFSET(yaw), AV_OPT_TYPE_FLOAT, {.dbl=0.f}, -180, 180, TFLAGS }, + { "xzoom","set camera zoom", OFFSET(zoom[0]),AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.01, 10, TFLAGS }, + { "yzoom","set camera zoom", OFFSET(zoom[1]),AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.01, 10, TFLAGS }, + { "zzoom","set camera zoom", OFFSET(zoom[2]),AV_OPT_TYPE_FLOAT, {.dbl=1.f}, 0.01, 10, TFLAGS }, + { "xpos", "set camera position", OFFSET(eye[0]), AV_OPT_TYPE_FLOAT, {.dbl=0.f},-60.f, 60.f, TFLAGS }, + { "ypos", "set camera position", OFFSET(eye[1]), AV_OPT_TYPE_FLOAT, {.dbl=0.f},-60.f, 60.f, TFLAGS }, + { "zpos", "set camera position", OFFSET(eye[2]), AV_OPT_TYPE_FLOAT, {.dbl=0.f},-60.f, 60.f, TFLAGS }, + { "length","set length", OFFSET(size), AV_OPT_TYPE_INT, {.i64=15}, 1, 60, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(a3dscope); + +static int query_formats(AVFilterContext *ctx) +{ + AVFilterFormats *formats = NULL; + AVFilterChannelLayouts *layouts = NULL; + AVFilterLink *inlink = ctx->inputs[0]; + AVFilterLink *outlink = ctx->outputs[0]; + static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; + static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; + int ret; + + formats = ff_make_format_list(sample_fmts); + if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0) + return ret; + + formats = ff_all_samplerates(); + if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0) + return ret; + + formats = ff_make_format_list(pix_fmts); + if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0) + return ret; + + layouts = ff_all_channel_counts(); + if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + return ret; + + return 0; +} + +static int config_input(AVFilterLink *inlink) +{ + AVFilterContext *ctx = inlink->dst; + Audio3dScopeContext *s = ctx->priv; + + s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num)); + + return 0; +} + +static int config_output(AVFilterLink *outlink) +{ + Audio3dScopeContext *s = outlink->src->priv; + + outlink->w = s->w; + outlink->h = s->h; + outlink->sample_aspect_ratio = (AVRational){1,1}; + outlink->frame_rate = s->frame_rate; + outlink->time_base = av_inv_q(outlink->frame_rate); + + return 0; +} + +static void projection_matrix(float fov, float a, float near, float far, + float matrix[4][4]) +{ + float f; + + memset(matrix, 0, sizeof(*matrix)); + + f = 1.0f / tanf(fov * 0.5f * M_PI / 180.f); + matrix[0][0] = f * a; + matrix[1][1] = f; + matrix[2][2] = -(far + near) / (far - near); + matrix[2][3] = -1.f; + matrix[3][2] = -(near * far) / (far - near); +} + +static inline void vmultiply(const float v[4], const float m[4][4], float d[4]) +{ + d[0] = v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0] + v[3] * m[3][0]; + d[1] = v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1] + v[3] * m[3][1]; + d[2] = v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2] + v[3] * m[3][2]; + d[3] = v[0] * m[0][3] + v[1] * m[1][3] + v[2] * m[2][3] + v[3] * m[3][3]; +} + +static void mmultiply(const float m2[4][4], const float m1[4][4], float m[4][4]) +{ + vmultiply(m2[0], m1, m[0]); + vmultiply(m2[1], m1, m[1]); + vmultiply(m2[2], m1, m[2]); + vmultiply(m2[3], m1, m[3]); +} + +static float vdot(const float x[3], const float y[3]) +{ + return x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; +} + +static void view_matrix(const float eye[3], + const float z[3], + const float roll, + const float pitch, + const float yaw, float m[4][4]) +{ + float cr = cosf(roll * M_PI / 180.f); + float sr = sinf(roll * M_PI / 180.f); + float cp = cosf(pitch * M_PI / 180.f); + float sp = sinf(pitch * M_PI / 180.f); + float cy = cosf(yaw * M_PI / 180.f); + float sy = sinf(yaw * M_PI / 180.f); + float t[4][4]; + float rx[4][4] = { + {z[0], 0.f, 0.f, 0.f }, + { 0.f, cy, -sy, 0.f }, + { 0.f, sy, cy, 0.f }, + { 0.f, 0.f, 0.f, 1.f }, + }; + + float ry[4][4] = { + { cp, 0.f, sp, 0.f }, + { 0.f,z[1], 0.f, 0.f }, + {-sp, 0.f, cp, 0.f }, + { 0.f, 0.f, 0.f, 1.f }, + }; + + float rz[4][4] = { + { cr, -sr, 0.f, 0.f }, + { sr, cr, 0.f, 0.f }, + { 0.f, 0.f,z[2], 0.f }, + { 0.f, 0.f, 0.f, 1.f }, + }; + + memset(m, 0, sizeof(*m)); + + mmultiply(rx, ry, t); + mmultiply(rz, t, m); + + m[3][0] = -vdot(m[0], eye); + m[3][1] = -vdot(m[1], eye); + m[3][2] = -vdot(m[2], eye); +} + +static void draw_dot(AVFrame *out, unsigned x, unsigned y, float z, + int r, int g, int b) +{ + const int linesize = out->linesize[0]; + uint8_t *dst; + + dst = out->data[0] + y * linesize + x * 4; + dst[0] = r * z; + dst[1] = g * z; + dst[2] = b * z; + dst[3] = 255 * z; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ + AVFilterContext *ctx = inlink->dst; + AVFilterLink *outlink = ctx->outputs[0]; + Audio3dScopeContext *s = ctx->priv; + const float half_height = (s->h - 1) * 0.5f; + const float half_width = (s->w - 1) * 0.5f; + float matrix[4][4]; + const int w = s->w; + const int h = s->h; + AVFrame *out; + + out = ff_get_video_buffer(outlink, outlink->w, outlink->h); + if (!out) { + av_frame_free(&in); + return AVERROR(ENOMEM); + } + + s->frames[0] = in; + + out->sample_aspect_ratio = (AVRational){1,1}; + for (int y = 0; y < outlink->h; y++) + memset(out->data[0] + y * out->linesize[0], 0, outlink->w * 4); + out->pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base); + + projection_matrix(s->fov, half_width / half_height, 0.1f, 1000000.f, s->projection_matrix); + view_matrix(s->eye, s->zoom, s->roll, s->pitch, s->yaw, s->view_matrix); + mmultiply(s->projection_matrix, s->view_matrix, matrix); + + for (int nb_frame = s->size - 1; nb_frame >= 0; nb_frame--) { + const float scale = 1.f / s->nb_samples; + AVFrame *frame = s->frames[nb_frame]; + float channels; + + if (!frame) + continue; + + channels = frame->ch_layout.nb_channels; + for (int ch = 0; ch < channels; ch++) { + const float *src = (float *)frame->extended_data[ch]; + const int r = 128.f + 127.f * sinf(ch / (channels - 1) * M_PI); + const int g = 128.f + 127.f * ch / (channels - 1); + const int b = 128.f + 127.f * cosf(ch / (channels - 1) * M_PI); + + for (int n = frame->nb_samples - 1, nn = s->nb_samples * nb_frame; n >= 0; n--, nn++) { + float v[4] = { src[n], ch - (channels - 1) * 0.5f, -0.1f + -nn * scale, 1.f }; + float d[4]; + int x, y; + + vmultiply(v, matrix, d); + + d[0] /= d[3]; + d[1] /= d[3]; + + x = d[0] * half_width + half_width; + y = d[1] * half_height + half_height; + + if (x >= w || y >= h || x < 0 || y < 0) + continue; + + draw_dot(out, x, y, av_clipf(1.f / d[3], 0.f, 1.f), + r, g, b); + } + } + } + + av_frame_free(&s->frames[59]); + memmove(&s->frames[1], &s->frames[0], 59 * sizeof(AVFrame *)); + s->frames[0] = NULL; + + return ff_filter_frame(outlink, out); +} + +static int activate(AVFilterContext *ctx) +{ + AVFilterLink *inlink = ctx->inputs[0]; + AVFilterLink *outlink = ctx->outputs[0]; + Audio3dScopeContext *s = ctx->priv; + AVFrame *in; + int ret; + + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + + ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in); + if (ret < 0) + return ret; + if (ret > 0) + return filter_frame(inlink, in); + + if (ff_inlink_queued_samples(inlink) >= s->nb_samples) { + ff_filter_set_ready(ctx, 10); + return 0; + } + + FF_FILTER_FORWARD_STATUS(inlink, outlink); + FF_FILTER_FORWARD_WANTED(outlink, inlink); + + return FFERROR_NOT_READY; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + Audio3dScopeContext *s = ctx->priv; + + for (int n = 0; n < 60; n++) + av_frame_free(&s->frames[n]); +} + +static const AVFilterPad audio3dscope_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_input, + }, +}; + +static const AVFilterPad audio3dscope_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = config_output, + }, +}; + +const AVFilter ff_avf_a3dscope = { + .name = "a3dscope", + .description = NULL_IF_CONFIG_SMALL("Convert input audio to 3d scope video output."), + .uninit = uninit, + .priv_size = sizeof(Audio3dScopeContext), + .activate = activate, + FILTER_INPUTS(audio3dscope_inputs), + FILTER_OUTPUTS(audio3dscope_outputs), + FILTER_QUERY_FUNC(query_formats), + .priv_class = &a3dscope_class, + .process_command = ff_filter_process_command, +}; diff --git a/libavfilter/version.h b/libavfilter/version.h index f3c1964cac..fb21fad979 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFILTER_VERSION_MINOR 46 -#define LIBAVFILTER_VERSION_MICRO 103 +#define LIBAVFILTER_VERSION_MINOR 47 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ From 1a5cd79f518268203c4fff7c664b387e5720f1f4 Mon Sep 17 00:00:00 2001 From: Mohamed Khaled Mohamed Date: Tue, 30 Aug 2022 21:13:27 +0200 Subject: [PATCH 103/590] avfilter: add bilateral_cuda filter GSoC 2022 Signed-off-by: Mohamed Khaled Signed-off-by: Timo Rothenpieler --- Changelog | 1 + compat/cuda/cuda_runtime.h | 1 + configure | 2 + doc/filters.texi | 39 +++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 2 +- libavfilter/vf_bilateral_cuda.c | 479 +++++++++++++++++++++++++++++++ libavfilter/vf_bilateral_cuda.cu | 191 ++++++++++++ 9 files changed, 716 insertions(+), 1 deletion(-) create mode 100644 libavfilter/vf_bilateral_cuda.c create mode 100644 libavfilter/vf_bilateral_cuda.cu diff --git a/Changelog b/Changelog index c98f18f97a..70c12df8dc 100644 --- a/Changelog +++ b/Changelog @@ -37,6 +37,7 @@ version 5.1: - PHM image format support - remap_opencl filter - added chromakey_cuda filter +- added bilateral_cuda filter version 5.0: diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h index 5837c1ad37..082e4a8ba3 100644 --- a/compat/cuda/cuda_runtime.h +++ b/compat/cuda/cuda_runtime.h @@ -182,6 +182,7 @@ static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); } static inline __device__ float fabs(float a) { return __builtin_fabsf(a); } static inline __device__ double fabs(double a) { return __builtin_fabs(a); } static inline __device__ float sqrtf(float a) { return __builtin_sqrtf(a); } +static inline __device__ float powf(float a, float y) { return __builtin_powf(a,y); } static inline __device__ float __saturatef(float a) { return __nvvm_saturate_f(a); } static inline __device__ float __sinf(float a) { return __nvvm_sin_approx_f(a); } diff --git a/configure b/configure index 932ea5b553..b9e1e403b1 100755 --- a/configure +++ b/configure @@ -3151,6 +3151,8 @@ v4l2_m2m_deps="linux_videodev2_h sem_timedwait" chromakey_cuda_filter_deps="ffnvcodec" chromakey_cuda_filter_deps_any="cuda_nvcc cuda_llvm" +bilateral_cuda_filter_deps="ffnvcodec" +bilateral_cuda_filter_deps_any="cuda_nvcc cuda_llvm" hwupload_cuda_filter_deps="ffnvcodec" scale_npp_filter_deps="ffnvcodec libnpp" scale2ref_npp_filter_deps="ffnvcodec libnpp" diff --git a/doc/filters.texi b/doc/filters.texi index 1e7e98c350..dbc08163d8 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -7980,6 +7980,45 @@ Set planes to filter. Default is first only. This filter supports the all above options as @ref{commands}. +@section bilateral_cuda +CUDA accelerated bilateral filter, an edge preserving filter. +This filter is mathematically accurate thanks to the use of GPU acceleration. +For best output quality, use one to one chroma subsampling, i.e. yuv444p format. + +The filter accepts the following options: +@table @option +@item sigmaS +Set sigma of gaussian function to calculate spatial weight, also called sigma space. +Allowed range is 0.1 to 512. Default is 0.1. + +@item sigmaR +Set sigma of gaussian function to calculate color range weight, also called sigma color. +Allowed range is 0.1 to 512. Default is 0.1. + +@item window_size +Set window size of the bilateral function to determine the number of neighbours to loop on. +If the number entered is even, one will be added automatically. +Allowed range is 1 to 255. Default is 1. +@end table +@subsection Examples + +@itemize +@item +Apply the bilateral filter on a video. + +@example +./ffmpeg -v verbose \ +-hwaccel cuda -hwaccel_output_format cuda -i input.mp4 \ +-init_hw_device cuda \ +-filter_complex \ +" \ +[0:v]scale_cuda=format=yuv444p[scaled_video]; +[scaled_video]bilateral_cuda=window_size=9:sigmaS=3.0:sigmaR=50.0" \ +-an -sn -c:v h264_nvenc -cq 20 out.mp4 +@end example + +@end itemize + @section bitplanenoise Show and measure bit plane noise. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index c5c44db440..841ec47141 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -194,6 +194,7 @@ OBJS-$(CONFIG_AVGBLUR_VULKAN_FILTER) += vf_avgblur_vulkan.o vulkan.o vul OBJS-$(CONFIG_BBOX_FILTER) += bbox.o vf_bbox.o OBJS-$(CONFIG_BENCH_FILTER) += f_bench.o OBJS-$(CONFIG_BILATERAL_FILTER) += vf_bilateral.o +OBJS-$(CONFIG_BILATERAL_CUDA_FILTER) += vf_bilateral_cuda.o vf_bilateral_cuda.ptx.o OBJS-$(CONFIG_BITPLANENOISE_FILTER) += vf_bitplanenoise.o OBJS-$(CONFIG_BLACKDETECT_FILTER) += vf_blackdetect.o OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 0285889e70..79e8a16bbc 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -180,6 +180,7 @@ extern const AVFilter ff_vf_avgblur_vulkan; extern const AVFilter ff_vf_bbox; extern const AVFilter ff_vf_bench; extern const AVFilter ff_vf_bilateral; +extern const AVFilter ff_vf_bilateral_cuda; extern const AVFilter ff_vf_bitplanenoise; extern const AVFilter ff_vf_blackdetect; extern const AVFilter ff_vf_blackframe; diff --git a/libavfilter/version.h b/libavfilter/version.h index fb21fad979..fc0df70dee 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFILTER_VERSION_MINOR 47 +#define LIBAVFILTER_VERSION_MINOR 48 #define LIBAVFILTER_VERSION_MICRO 100 diff --git a/libavfilter/vf_bilateral_cuda.c b/libavfilter/vf_bilateral_cuda.c new file mode 100644 index 0000000000..7a271f1ce0 --- /dev/null +++ b/libavfilter/vf_bilateral_cuda.c @@ -0,0 +1,479 @@ +/* + * Copyright (c) 2022 Mohamed Khaled + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include + +#include "libavutil/avstring.h" +#include "libavutil/common.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/cuda_check.h" +#include "libavutil/internal.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +#include "cuda/load_helper.h" + +static const enum AVPixelFormat supported_formats[] = { + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_NV12, + AV_PIX_FMT_YUV444P +}; + +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) +#define BLOCKX 32 +#define BLOCKY 16 + +#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x) + + +typedef struct CUDABilateralContext { + const AVClass *class; + AVCUDADeviceContext *hwctx; + + enum AVPixelFormat in_fmt, out_fmt; + const AVPixFmtDescriptor *in_desc, *out_desc; + int in_planes, out_planes; + int in_plane_depths[4]; + int in_plane_channels[4]; + + int window_size; + float sigmaS; + float sigmaR; + + AVBufferRef *frames_ctx; + AVFrame *frame; + AVFrame *tmp_frame; + + CUcontext cu_ctx; + CUmodule cu_module; + CUfunction cu_func; + CUfunction cu_func_uv; + CUstream cu_stream; +} CUDABilateralContext; + +static av_cold int cudabilateral_init(AVFilterContext *ctx) +{ + CUDABilateralContext *s = ctx->priv; + + s->frame = av_frame_alloc(); + if (!s->frame) + return AVERROR(ENOMEM); + + s->tmp_frame = av_frame_alloc(); + if (!s->tmp_frame) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold void cudabilateral_uninit(AVFilterContext *ctx) +{ + CUDABilateralContext *s = ctx->priv; + + if (s->hwctx && s->cu_module) { + CudaFunctions *cu = s->hwctx->internal->cuda_dl; + CUcontext bilateral; + + CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx)); + CHECK_CU(cu->cuModuleUnload(s->cu_module)); + s->cu_module = NULL; + CHECK_CU(cu->cuCtxPopCurrent(&bilateral)); + } + + av_frame_free(&s->frame); + av_buffer_unref(&s->frames_ctx); + av_frame_free(&s->tmp_frame); +} + +static av_cold int init_hwframe_ctx(CUDABilateralContext *s, AVBufferRef *device_ctx, int width, int height) +{ + AVBufferRef *out_ref = NULL; + AVHWFramesContext *out_ctx; + int ret; + + out_ref = av_hwframe_ctx_alloc(device_ctx); + if (!out_ref) + return AVERROR(ENOMEM); + out_ctx = (AVHWFramesContext*)out_ref->data; + + out_ctx->format = AV_PIX_FMT_CUDA; + out_ctx->sw_format = s->out_fmt; + out_ctx->width = width; + out_ctx->height = height; + + ret = av_hwframe_ctx_init(out_ref); + if (ret < 0) + goto fail; + + av_frame_unref(s->frame); + ret = av_hwframe_get_buffer(out_ref, s->frame, 0); + if (ret < 0) + goto fail; + + av_buffer_unref(&s->frames_ctx); + s->frames_ctx = out_ref; + + return 0; +fail: + av_buffer_unref(&out_ref); + return ret; +} + +static int format_is_supported(enum AVPixelFormat fmt) +{ + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) + if (supported_formats[i] == fmt) + return 1; + return 0; +} + +static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format) +{ + CUDABilateralContext *s = ctx->priv; + int i, p, d; + + s->in_fmt = in_format; + s->out_fmt = out_format; + + s->in_desc = av_pix_fmt_desc_get(s->in_fmt); + s->out_desc = av_pix_fmt_desc_get(s->out_fmt); + s->in_planes = av_pix_fmt_count_planes(s->in_fmt); + s->out_planes = av_pix_fmt_count_planes(s->out_fmt); + + // find maximum step of each component of each plane + // For our subset of formats, this should accurately tell us how many channels CUDA needs + // i.e. 1 for Y plane, 2 for UV plane of NV12, 4 for single plane of RGB0 formats + + for (i = 0; i < s->in_desc->nb_components; i++) { + d = (s->in_desc->comp[i].depth + 7) / 8; + p = s->in_desc->comp[i].plane; + s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d); + + s->in_plane_depths[p] = s->in_desc->comp[i].depth; + } +} + +static av_cold int init_processing_chain(AVFilterContext *ctx, int width, int height) +{ + CUDABilateralContext *s = ctx->priv; + AVHWFramesContext *in_frames_ctx; + int ret; + + /* check that we have a hw context */ + if (!ctx->inputs[0]->hw_frames_ctx) { + av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n"); + return AVERROR(EINVAL); + } + in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; + + if (!format_is_supported(in_frames_ctx->sw_format)) { + av_log(ctx, AV_LOG_ERROR, "Unsupported format: %s\n", av_get_pix_fmt_name(in_frames_ctx->sw_format)); + return AVERROR(ENOSYS); + } + + set_format_info(ctx, in_frames_ctx->sw_format, in_frames_ctx->sw_format); + + ret = init_hwframe_ctx(s, in_frames_ctx->device_ref, width, height); + if (ret < 0) + return ret; + + ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->frames_ctx); + if (!ctx->outputs[0]->hw_frames_ctx) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold int cuda_bilateral_load_functions(AVFilterContext *ctx) +{ + CUDABilateralContext *s = ctx->priv; + CUcontext bilateral, cuda_ctx = s->hwctx->cuda_ctx; + CudaFunctions *cu = s->hwctx->internal->cuda_dl; + int ret; + + extern const unsigned char ff_vf_bilateral_cuda_ptx_data[]; + extern const unsigned int ff_vf_bilateral_cuda_ptx_len; + + ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx)); + if (ret < 0) + return ret; + + ret = ff_cuda_load_module(ctx, s->hwctx, &s->cu_module, + ff_vf_bilateral_cuda_ptx_data, ff_vf_bilateral_cuda_ptx_len); + if (ret < 0) + goto fail; + + ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func, s->cu_module, "Process_uchar")); + if (ret < 0) { + av_log(ctx, AV_LOG_FATAL, "Failed loading Process_uchar\n"); + goto fail; + } + + ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uv, s->cu_module, "Process_uchar2")); + if (ret < 0) { + av_log(ctx, AV_LOG_FATAL, "Failed loading Process_uchar2\n"); + goto fail; + } + +fail: + CHECK_CU(cu->cuCtxPopCurrent(&bilateral)); + + return ret; +} + +static av_cold int cuda_bilateral_config_props(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = outlink->src->inputs[0]; + CUDABilateralContext *s = ctx->priv; + AVHWFramesContext *frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data; + AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx; + int ret; + + s->hwctx = device_hwctx; + s->cu_stream = s->hwctx->stream; + + ret = init_processing_chain(ctx, inlink->w, inlink->h); + if (ret < 0) + return ret; + + outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; + + // the window_size makes more sense when it is odd, so add 1 if even + s->window_size= (s->window_size%2) ? s->window_size : s->window_size+1; + + ret = cuda_bilateral_load_functions(ctx); + if (ret < 0) + return ret; + + return 0; +} + +static int call_cuda_kernel(AVFilterContext *ctx, CUfunction func, + CUtexObject src_tex[3], AVFrame *out_frame, + int width, int height, int pitch, + int width_uv, int height_uv, int pitch_uv, + int window_size, float sigmaS, float sigmaR) +{ + CUDABilateralContext *s = ctx->priv; + CudaFunctions *cu = s->hwctx->internal->cuda_dl; + int ret; + + CUdeviceptr dst_devptr[3] = { + (CUdeviceptr)out_frame->data[0], (CUdeviceptr)out_frame->data[1], (CUdeviceptr)out_frame->data[2] + }; + + void *args_uchar[] = { + &src_tex[0], &src_tex[1], &src_tex[2], + &dst_devptr[0], &dst_devptr[1], &dst_devptr[2], + &width, &height, &pitch, + &width_uv, &height_uv, &pitch_uv, + &window_size, &sigmaS, &sigmaR + }; + + ret = CHECK_CU(cu->cuLaunchKernel(func, + DIV_UP(width, BLOCKX), DIV_UP(height, BLOCKY), 1, + BLOCKX, BLOCKY, 1, 0, s->cu_stream, args_uchar, NULL)); + if (ret < 0) + return ret; + + return ret; +} + +static int cuda_bilateral_process_internal(AVFilterContext *ctx, + AVFrame *out, AVFrame *in) +{ + CUDABilateralContext *s = ctx->priv; + CudaFunctions *cu = s->hwctx->internal->cuda_dl; + CUcontext bilateral, cuda_ctx = s->hwctx->cuda_ctx; + int i, ret; + + CUtexObject tex[3] = { 0, 0, 0 }; + + ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx)); + if (ret < 0) + return ret; + + for (i = 0; i < s->in_planes; i++) { + CUDA_TEXTURE_DESC tex_desc = { + .filterMode = CU_TR_FILTER_MODE_LINEAR, + .flags = 0, // CU_TRSF_READ_AS_INTEGER to get raw ints instead of normalized floats from tex2D + }; + + CUDA_RESOURCE_DESC res_desc = { + .resType = CU_RESOURCE_TYPE_PITCH2D, + .res.pitch2D.format = CU_AD_FORMAT_UNSIGNED_INT8, + .res.pitch2D.numChannels = s->in_plane_channels[i], + .res.pitch2D.pitchInBytes = in->linesize[i], + .res.pitch2D.devPtr = (CUdeviceptr)in->data[i], + }; + + if (i == 1 || i == 2) { + res_desc.res.pitch2D.width = AV_CEIL_RSHIFT(in->width, s->in_desc->log2_chroma_w); + res_desc.res.pitch2D.height = AV_CEIL_RSHIFT(in->height, s->in_desc->log2_chroma_h); + } else { + res_desc.res.pitch2D.width = in->width; + res_desc.res.pitch2D.height = in->height; + } + + ret = CHECK_CU(cu->cuTexObjectCreate(&tex[i], &res_desc, &tex_desc, NULL)); + if (ret < 0) + goto exit; + } + + ret = call_cuda_kernel(ctx, (s->in_plane_channels[1] > 1) ? s->cu_func_uv : s->cu_func, + tex, out, + out->width, out->height, out->linesize[0], + AV_CEIL_RSHIFT(out->width, s->out_desc->log2_chroma_w), + AV_CEIL_RSHIFT(out->height, s->out_desc->log2_chroma_h), + out->linesize[1] >> ((s->in_plane_channels[1] > 1) ? 1 : 0), + s->window_size, s->sigmaS, s->sigmaR); + if (ret < 0) + goto exit; + +exit: + for (i = 0; i < s->in_planes; i++) + if (tex[i]) + CHECK_CU(cu->cuTexObjectDestroy(tex[i])); + + CHECK_CU(cu->cuCtxPopCurrent(&bilateral)); + + return ret; +} + +static int cuda_bilateral_process(AVFilterContext *ctx, AVFrame *out, AVFrame *in) +{ + CUDABilateralContext *s = ctx->priv; + AVFrame *src = in; + int ret; + + ret = cuda_bilateral_process_internal(ctx, s->frame, src); + if (ret < 0) + return ret; + + src = s->frame; + ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0); + if (ret < 0) + return ret; + + av_frame_move_ref(out, s->frame); + av_frame_move_ref(s->frame, s->tmp_frame); + + ret = av_frame_copy_props(out, in); + if (ret < 0) + return ret; + + return 0; +} + +static int cuda_bilateral_filter_frame(AVFilterLink *link, AVFrame *in) +{ + AVFilterContext *ctx = link->dst; + CUDABilateralContext *s = ctx->priv; + AVFilterLink *outlink = ctx->outputs[0]; + CudaFunctions *cu = s->hwctx->internal->cuda_dl; + + AVFrame *out = NULL; + CUcontext bilateral; + int ret = 0; + + out = av_frame_alloc(); + if (!out) { + ret = AVERROR(ENOMEM); + goto fail; + } + + ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx)); + if (ret < 0) + goto fail; + + ret = cuda_bilateral_process(ctx, out, in); + + CHECK_CU(cu->cuCtxPopCurrent(&bilateral)); + if (ret < 0) + goto fail; + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +fail: + av_frame_free(&in); + av_frame_free(&out); + return ret; +} + +#define OFFSET(x) offsetof(CUDABilateralContext, x) +#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM) +static const AVOption options[] = { + { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.1, 512, FLAGS }, + { "sigmaR", "set range sigma", OFFSET(sigmaR), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.1, 512, FLAGS }, + { "window_size", "set neighbours window_size", OFFSET(window_size), AV_OPT_TYPE_INT, {.i64=1}, 1, 255, FLAGS }, + { NULL } +}; + +static const AVClass cuda_bilateral_class = { + .class_name = "cudabilateral", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVFilterPad cuda_bilateral_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = cuda_bilateral_filter_frame, + }, +}; + +static const AVFilterPad cuda_bilateral_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = cuda_bilateral_config_props, + }, +}; + +const AVFilter ff_vf_bilateral_cuda = { + .name = "bilateral_cuda", + .description = NULL_IF_CONFIG_SMALL("GPU accelerated bilateral filter"), + + .init = cudabilateral_init, + .uninit = cudabilateral_uninit, + + .priv_size = sizeof(CUDABilateralContext), + .priv_class = &cuda_bilateral_class, + + FILTER_INPUTS(cuda_bilateral_inputs), + FILTER_OUTPUTS(cuda_bilateral_outputs), + + FILTER_SINGLE_PIXFMT(AV_PIX_FMT_CUDA), + + .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, +}; diff --git a/libavfilter/vf_bilateral_cuda.cu b/libavfilter/vf_bilateral_cuda.cu new file mode 100644 index 0000000000..8aba3a079f --- /dev/null +++ b/libavfilter/vf_bilateral_cuda.cu @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2022 Mohamed Khaled + * + * 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 "cuda/vector_helpers.cuh" + +extern "C" +{ + +/** + * @brief calculated squared norm difference between two 3-dimension vecors ||first_vector-second_vector||^2 + * used float4 for better performance + * + * @param first_yuv first color vector + * @param second_yuv second color vecotr + * @return answer of squared norm difference + */ +__device__ static inline float norm_squared(float4 first_yuv, float4 second_yuv) +{ + float ans = 0; + ans += powf(first_yuv.x - second_yuv.x, 2); + ans += powf(first_yuv.y - second_yuv.y, 2); + ans += powf(first_yuv.z - second_yuv.z, 2); + return ans; +} + +/** + * @brief calculate w as stated in bilateral filter research paper + * + * @param first_yuv first color vector + * @param second_yuv second color vecotr + * @return the calculated w + */ +__device__ static inline float calculate_w(int x, int y, int r, int c, + float4 pixel_value, float4 neighbor_value, + float sigma_space, float sigma_color) +{ + float first_term, second_term; + first_term = (powf(x - r, 2) + powf(y - c, 2)) / (2 * sigma_space * sigma_space); + second_term = norm_squared(pixel_value, neighbor_value) / (2 * sigma_color * sigma_color); + return __expf(-first_term - second_term); +} + +/** + * @brief apply the bilateral filter on the pixel sent + * + * @param src_tex_Y Y channel of source image + * @param src_tex U channel of source image if yuv, or UV channels if format is nv12 + * @param src_tex_V V channel of source image + * @param dst_Y Y channel of destination image + * @param dst_U U channel of destination image if format is in yuv + * @param dst_V V channel of destination image if format is in yuv + * @param dst_UV UV channels of destination image if format is in nv12 + * @param width width of Y channel + * @param height height of Y channel + * @param width_uv width of UV channels + * @param height_uv height of UV channels + * @param pitch pitch of Y channel + * @param pitch_uv pitch of UV channels + * @param x x coordinate of pixel to be filtered + * @param y y coordinate of pixel to be filtered + * @param sigma_space sigma space parameter + * @param sigma_color sigma color parameter + * @param window_size window size parameter + * @return void + */ +__device__ static inline void apply_biltaeral( + cudaTextureObject_t src_tex_Y, cudaTextureObject_t src_tex, cudaTextureObject_t src_tex_V, + uchar *dst_Y, uchar *dst_U, uchar *dst_V, uchar2 *dst_UV, + int width, int height, int width_uv, int height_uv, int pitch, int pitch_uv, + int x, int y, + float sigma_space, float sigma_color, int window_size) +{ + int start_r = x - window_size / 2; + int start_c = y - window_size / 2; + float4 neighbor_pixel = make_float4(0.f, 0.f, 0.f, 0.f); + float Wp = 0.f; + float4 new_pixel_value = make_float4(0.f, 0.f, 0.f, 0.f); + float w = 0.f; + + int channel_ratio = width / width_uv; // ratio between Y channel and UV channels + float4 currrent_pixel; + + if (!src_tex_V) { // format is in nv12 + float2 temp_uv = tex2D(src_tex, x/channel_ratio, y/channel_ratio) * 255.f; + currrent_pixel.x = tex2D(src_tex_Y, x, y) * 255.f; + currrent_pixel.y = temp_uv.x; + currrent_pixel.z = temp_uv.y; + currrent_pixel.w = 0.f; + } else { // format is fully planar + currrent_pixel = make_float4(tex2D(src_tex_Y, x, y) * 255.f, + tex2D(src_tex, x/channel_ratio, y/channel_ratio) * 255.f, + tex2D(src_tex_V, x/channel_ratio, y/channel_ratio) * 255.f, + 0.f); + } + + for (int i=0; i < window_size; i++) + { + for (int j=0; j < window_size; j++) + { + int r=start_r+i; + int c=start_c+j; + bool in_bounds=r>=0 && r=0 && c(src_tex, r/channel_ratio, c/channel_ratio); + neighbor_pixel=make_float4(tex2D(src_tex_Y, r, c) * 255.f, + temp_uv.x * 255.f, + temp_uv.y * 255.f, 0.f); + } else { + neighbor_pixel=make_float4(tex2D(src_tex_Y, r, c) * 255.f, + tex2D(src_tex, r/channel_ratio, c/channel_ratio) * 255.f, + tex2D(src_tex_V, r/channel_ratio, c/channel_ratio) * 255.f, 0.f); + } + w=calculate_w(x,y,r,c,currrent_pixel,neighbor_pixel,sigma_space,sigma_color); + Wp+=w; + new_pixel_value+= neighbor_pixel*w; + } + } + } + + new_pixel_value = new_pixel_value / Wp; + dst_Y[y*pitch + x] = new_pixel_value.x; + + if (!src_tex_V) { + dst_UV[(y/channel_ratio) * pitch_uv + (x/channel_ratio)] = make_uchar2(new_pixel_value.y, new_pixel_value.z); + } else { + dst_U[(y/channel_ratio) * pitch_uv + (x/channel_ratio)] = new_pixel_value.y; + dst_V[(y/channel_ratio) * pitch_uv + (x/channel_ratio)] = new_pixel_value.z; + } + + return; +} + + +__global__ void Process_uchar(cudaTextureObject_t src_tex_Y, cudaTextureObject_t src_tex_U, cudaTextureObject_t src_tex_V, + uchar *dst_Y, uchar *dst_U, uchar *dst_V, + int width, int height, int pitch, + int width_uv, int height_uv, int pitch_uv, + int window_size, float sigmaS, float sigmaR) +{ + + int x = blockIdx.x * blockDim.x + threadIdx.x; + int y = blockIdx.y * blockDim.y + threadIdx.y; + if (y >= height || x >= width) + return; + + apply_biltaeral(src_tex_Y, src_tex_U, src_tex_V, + dst_Y, dst_U, dst_V, (uchar2*)nullptr, + width, height, width_uv, height_uv, pitch, pitch_uv, + x, y, + sigmaS, sigmaR, window_size); +} + + +__global__ void Process_uchar2(cudaTextureObject_t src_tex_Y, cudaTextureObject_t src_tex_UV, cudaTextureObject_t unused1, + uchar *dst_Y, uchar2 *dst_UV, uchar *unused2, + int width, int height, int pitch, + int width_uv, int height_uv, int pitch_uv, + int window_size, float sigmaS, float sigmaR) +{ + int x = blockIdx.x * blockDim.x + threadIdx.x; + int y = blockIdx.y * blockDim.y + threadIdx.y; + if (y >= height || x >= width) + return; + + apply_biltaeral(src_tex_Y, src_tex_UV, (cudaTextureObject_t)nullptr, + dst_Y, (uchar*)nullptr, (uchar*)nullptr, dst_UV, + width, height, width_uv, height_uv, pitch, pitch_uv, + x, y, + sigmaS, sigmaR, window_size); +} + +} From 25ea90b733883d0cbfdb76014b619a1b37489fca Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 18:42:10 +0200 Subject: [PATCH 104/590] avcodec/encode: Avoid unreferencing blank AVFrames ff_thread_video_encode_frame() already returns blank frames. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 2c02b24cf2..8c6d81286c 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -263,18 +263,17 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE); if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder) - /* This might unref frame. */ + /* This will unref frame. */ ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet); else { ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet); + if (frame) + av_frame_unref(frame); } if (avci->draining && !got_packet) avci->draining_done = 1; - if (frame) - av_frame_unref(frame); - return ret; } From 65f68514486fade5c6ab973c90047a422198ce07 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 25 Aug 2022 18:59:58 +0200 Subject: [PATCH 105/590] avcodec/frame_thread_encoder: Stop serializing unreferencing AVFrames Currently, the frame-threaded decoding API still supports thread-unsafe callbacks. If one uses a thread-unsafe get_buffer2() callback, calls to av_frame_unref() by the decoder are serialized, because it is presumed that the underlying deallocator is thread-unsafe. The frame-threaded encoder seems to have been written with this restriction in mind: It always serializes unreferencing its AVFrames, although no documentation forces it to do so. This commit schedules to change this behaviour as soon as thread-unsafe callbacks are removed. For this reason, the FF_API_THREAD_SAFE_CALLBACKS define is reused. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 8 +++++++- libavcodec/encode.h | 2 +- libavcodec/frame_thread_encoder.c | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 8c6d81286c..ade4d458e7 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -190,7 +190,7 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame) } int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet) + AVFrame *frame, int *got_packet) { const FFCodec *const codec = ffcodec(avctx->codec); int ret; @@ -227,6 +227,10 @@ int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, unref: av_packet_unref(avpkt); } +#if !FF_API_THREAD_SAFE_CALLBACKS + if (frame) + av_frame_unref(frame); +#endif return ret; } @@ -267,8 +271,10 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet); else { ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet); +#if FF_API_THREAD_SAFE_CALLBACKS if (frame) av_frame_unref(frame); +#endif } if (avci->draining && !got_packet) diff --git a/libavcodec/encode.h b/libavcodec/encode.h index 296ffd312e..81d18d6ead 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -76,7 +76,7 @@ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); int ff_encode_preinit(AVCodecContext *avctx); int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet); + AVFrame *frame, int *got_packet); /** * Rescale from sample rate to AVCodecContext.time_base. diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 1faaef522e..35775ae823 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -48,7 +48,9 @@ typedef struct{ typedef struct{ AVCodecContext *parent_avctx; +#if FF_API_THREAD_SAFE_CALLBACKS pthread_mutex_t buffer_mutex; +#endif pthread_mutex_t task_fifo_mutex; /* Used to guard (next_)task_index */ pthread_cond_t task_fifo_cond; @@ -68,9 +70,15 @@ typedef struct{ } ThreadContext; #define OFF(member) offsetof(ThreadContext, member) +#if FF_API_THREAD_SAFE_CALLBACKS DEFINE_OFFSET_ARRAY(ThreadContext, thread_ctx, pthread_init_cnt, (OFF(buffer_mutex), OFF(task_fifo_mutex), OFF(finished_task_mutex)), (OFF(task_fifo_cond), OFF(finished_task_cond))); +#else +DEFINE_OFFSET_ARRAY(ThreadContext, thread_ctx, pthread_init_cnt, + (OFF(task_fifo_mutex), OFF(finished_task_mutex)), + (OFF(task_fifo_cond), OFF(finished_task_cond))); +#endif #undef OFF static void * attribute_align_arg worker(void *v){ @@ -104,9 +112,11 @@ static void * attribute_align_arg worker(void *v){ pkt = task->outdata; ret = ff_encode_encode_cb(avctx, pkt, frame, &task->got_packet); +#if FF_API_THREAD_SAFE_CALLBACKS pthread_mutex_lock(&c->buffer_mutex); av_frame_unref(frame); pthread_mutex_unlock(&c->buffer_mutex); +#endif pthread_mutex_lock(&c->finished_task_mutex); task->return_code = ret; task->finished = 1; @@ -114,9 +124,13 @@ static void * attribute_align_arg worker(void *v){ pthread_mutex_unlock(&c->finished_task_mutex); } end: +#if FF_API_THREAD_SAFE_CALLBACKS pthread_mutex_lock(&c->buffer_mutex); +#endif avcodec_close(avctx); +#if FF_API_THREAD_SAFE_CALLBACKS pthread_mutex_unlock(&c->buffer_mutex); +#endif av_freep(&avctx); return NULL; } From 5b0856d2b9f6ca843a9a0aa0117121f5bdc9746f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 17:30:36 +0200 Subject: [PATCH 106/590] avutil/internal: Remove unused ff_rint64_clip() Signed-off-by: Andreas Rheinhardt --- libavutil/internal.h | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index b44cbaaa7b..c118936598 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -217,42 +217,6 @@ void avpriv_request_sample(void *avc, #define SUINT32 uint32_t #endif -/** - * Clip and convert a double value into the long long amin-amax range. - * This function is needed because conversion of floating point to integers when - * it does not fit in the integer's representation does not necessarily saturate - * correctly (usually converted to a cvttsd2si on x86) which saturates numbers - * > INT64_MAX to INT64_MIN. The standard marks such conversions as undefined - * behavior, allowing this sort of mathematically bogus conversions. This provides - * a safe alternative that is slower obviously but assures safety and better - * mathematical behavior. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static av_always_inline av_const int64_t ff_rint64_clip(double a, int64_t amin, int64_t amax) -{ - int64_t res; -#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 - if (amin > amax) abort(); -#endif - // INT64_MAX+1,INT64_MIN are exactly representable as IEEE doubles - // do range checks first - if (a >= 9223372036854775808.0) - return amax; - if (a <= -9223372036854775808.0) - return amin; - - // safe to call llrint and clip accordingly - res = llrint(a); - if (res > amax) - return amax; - if (res < amin) - return amin; - return res; -} - /** * A wrapper for open() setting O_CLOEXEC. */ From 26325cceb020608928800b8fe5f4a0f6e60468eb Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 17:31:44 +0200 Subject: [PATCH 107/590] avutil/internal: Remove unused FF_SYMVER They are unused since d63443b9684fa7b3e086634f7b44b203b6d9221e. Furthermore, they were always in the wrong header: libavutil/internal.h is auto-included almost everywhere, but FF_SYMVER would only ever be used at a few places, so a proper header of its own would be appropriate for it. Signed-off-by: Andreas Rheinhardt --- libavutil/internal.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index c118936598..8ee5a101c6 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -117,34 +117,6 @@ # define NULL_IF_CONFIG_SMALL(x) x #endif -/** - * Define a function with only the non-default version specified. - * - * On systems with ELF shared libraries, all symbols exported from - * FFmpeg libraries are tagged with the name and major version of the - * library to which they belong. If a function is moved from one - * library to another, a wrapper must be retained in the original - * location to preserve binary compatibility. - * - * Functions defined with this macro will never be used to resolve - * symbols by the build-time linker. - * - * @param type return type of function - * @param name name of function - * @param args argument list of function - * @param ver version tag to assign function - */ -#if HAVE_SYMVER_ASM_LABEL -# define FF_SYMVER(type, name, args, ver) \ - type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \ - type ff_##name args -#elif HAVE_SYMVER_GNU_ASM -# define FF_SYMVER(type, name, args, ver) \ - __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \ - type ff_##name args; \ - type ff_##name args -#endif - /** * Return NULL if a threading library has not been enabled. * Used to disable threading functions in AVCodec definitions From 04b72178724ed08934e276c959a6f1a154e1e7d4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 17:49:52 +0200 Subject: [PATCH 108/590] avutil/dict: Move avpriv_dict_set_timestamp() to a header of its own It is used almost nowhere, so it needn't be auto-included almost everywhere. Signed-off-by: Andreas Rheinhardt --- libavformat/flvdec.c | 1 + libavformat/ifv.c | 1 + libavformat/matroskadec.c | 1 + libavformat/mov.c | 1 + libavformat/mux_utils.c | 1 + libavformat/mxfdec.c | 1 + libavutil/dict.c | 1 + libavutil/dict_internal.h | 37 +++++++++++++++++++++++++++++++++++++ libavutil/internal.h | 12 ------------ 9 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 libavutil/dict_internal.h diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 10f0ea7736..7f9d795044 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -28,6 +28,7 @@ #include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/dict.h" +#include "libavutil/dict_internal.h" #include "libavutil/opt.h" #include "libavutil/internal.h" #include "libavutil/intfloat.h" diff --git a/libavformat/ifv.c b/libavformat/ifv.c index 490608c5de..694abd951b 100644 --- a/libavformat/ifv.c +++ b/libavformat/ifv.c @@ -21,6 +21,7 @@ */ #include "libavutil/channel_layout.h" +#include "libavutil/dict_internal.h" #include "avformat.h" #include "internal.h" #include "avio_internal.h" diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index ad7ee390a2..16a3e93611 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -38,6 +38,7 @@ #include "libavutil/base64.h" #include "libavutil/bprint.h" #include "libavutil/dict.h" +#include "libavutil/dict_internal.h" #include "libavutil/display.h" #include "libavutil/intfloat.h" #include "libavutil/intreadwrite.h" diff --git a/libavformat/mov.c b/libavformat/mov.c index 35e2271b14..df45408060 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -32,6 +32,7 @@ #include "libavutil/attributes.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/dict_internal.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c index 8b95fc5e7e..764c834fa2 100644 --- a/libavformat/mux_utils.c +++ b/libavformat/mux_utils.c @@ -20,6 +20,7 @@ */ #include "libavutil/dict.h" +#include "libavutil/dict_internal.h" #include "libavutil/internal.h" #include "libavutil/log.h" #include "libavutil/mem.h" diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index feebff67aa..e63e803aa5 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -53,6 +53,7 @@ #include "libavcodec/bytestream.h" #include "libavcodec/internal.h" #include "libavutil/channel_layout.h" +#include "libavutil/dict_internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/parseutils.h" #include "libavutil/timecode.h" diff --git a/libavutil/dict.c b/libavutil/dict.c index 9d3d96c58b..a4f638a1fc 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -22,6 +22,7 @@ #include "avstring.h" #include "dict.h" +#include "dict_internal.h" #include "internal.h" #include "mem.h" #include "time_internal.h" diff --git a/libavutil/dict_internal.h b/libavutil/dict_internal.h new file mode 100644 index 0000000000..6d5b0dc2b0 --- /dev/null +++ b/libavutil/dict_internal.h @@ -0,0 +1,37 @@ +/* + * 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 AVUTIL_DICT_INTERNAL_H +#define AVUTIL_DICT_INTERNAL_H + +#include + +#include "dict.h" + +/** + * Set a dictionary value to an ISO-8601 compliant timestamp string. + * + * @param dict pointer to a pointer to a dictionary struct. If *dict is NULL + * a dictionary struct is allocated and put in *dict. + * @param key metadata key + * @param timestamp unix timestamp in microseconds + * @return <0 on error + */ +int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp); + +#endif /* AVUTIL_DICT_INTERNAL_H */ diff --git a/libavutil/internal.h b/libavutil/internal.h index 8ee5a101c6..8bdc7b3ac8 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -41,7 +41,6 @@ #include "config.h" #include "attributes.h" #include "timer.h" -#include "dict.h" #include "macros.h" #include "pixfmt.h" @@ -230,15 +229,4 @@ static av_always_inline av_const int avpriv_mirror(int x, int w) void ff_check_pixfmt_descriptors(void); -/** - * Set a dictionary value to an ISO-8601 compliant timestamp string. - * - * @param dict pointer to a pointer to a dictionary struct. If *dict is NULL - * a dictionary struct is allocated and put in *dict. - * @param key metadata key - * @param timestamp unix timestamp in microseconds - * @return <0 on error - */ -int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp); - #endif /* AVUTIL_INTERNAL_H */ From 72c601e0f71d3c71a53d43bdac935489ed86e3c5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 27 Aug 2022 23:33:06 +0200 Subject: [PATCH 109/590] avutil/internal: Move avpriv-file API to a header of its own It is not used by the large majority of files that include lavu/internal.h. Signed-off-by: Andreas Rheinhardt --- libavcodec/dvdsubdec.c | 1 + libavcodec/libxvid.c | 2 +- libavdevice/bktr.c | 1 + libavdevice/fbdev_common.c | 1 + libavdevice/fbdev_dec.c | 1 + libavdevice/fbdev_enc.c | 1 + libavdevice/oss.c | 1 + libavfilter/af_arnndn.c | 4 +-- libavfilter/af_firequalizer.c | 1 + libavfilter/opencl.c | 1 + libavfilter/vf_curves.c | 2 +- libavfilter/vf_deshake.c | 2 +- libavfilter/vf_dnn_classify.c | 6 +--- libavfilter/vf_dnn_detect.c | 6 +--- libavfilter/vf_fieldhint.c | 1 + libavfilter/vf_lut3d.c | 4 +-- libavfilter/vf_nnedi.c | 2 +- libavfilter/vf_paletteuse.c | 1 + libavfilter/vf_psnr.c | 3 +- libavfilter/vf_signature.c | 4 +-- libavfilter/vf_ssim.c | 3 +- libavfilter/vf_vidstabdetect.c | 3 +- libavfilter/vf_vidstabtransform.c | 3 +- libavfilter/vf_vmafmotion.c | 1 + libavformat/cache.c | 4 +-- libavformat/file.c | 3 +- libavformat/ipfsgateway.c | 1 + libavutil/file.c | 1 + libavutil/file_open.c | 3 +- libavutil/file_open.h | 57 +++++++++++++++++++++++++++++++ libavutil/internal.h | 28 --------------- libavutil/random_seed.c | 1 + 32 files changed, 92 insertions(+), 61 deletions(-) create mode 100644 libavutil/file_open.h diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 3338cd6b92..e1ae441880 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -27,6 +27,7 @@ #include "libavutil/attributes.h" #include "libavutil/colorspace.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" #include "libavutil/bswap.h" diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index aed8699fe1..3845905555 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -30,7 +30,7 @@ #include #include "libavutil/avassert.h" -#include "libavutil/file.h" +#include "libavutil/file_open.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index e96c4a359e..196637852f 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -25,6 +25,7 @@ */ #include "libavformat/internal.h" +#include "libavutil/file_open.h" #include "libavutil/internal.h" #include "libavutil/log.h" #include "libavutil/opt.h" diff --git a/libavdevice/fbdev_common.c b/libavdevice/fbdev_common.c index 91bd8e1a91..47e7edde5c 100644 --- a/libavdevice/fbdev_common.c +++ b/libavdevice/fbdev_common.c @@ -26,6 +26,7 @@ #include #include "fbdev_common.h" #include "libavutil/common.h" +#include "libavutil/file_open.h" #include "avdevice.h" struct rgb_pixfmt_map_entry { diff --git a/libavdevice/fbdev_dec.c b/libavdevice/fbdev_dec.c index 368907037b..460a71d13f 100644 --- a/libavdevice/fbdev_dec.c +++ b/libavdevice/fbdev_dec.c @@ -34,6 +34,7 @@ #include #include +#include "libavutil/file_open.h" #include "libavutil/internal.h" #include "libavutil/log.h" #include "libavutil/opt.h" diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c index 84ec6733ff..77233880e7 100644 --- a/libavdevice/fbdev_enc.c +++ b/libavdevice/fbdev_enc.c @@ -23,6 +23,7 @@ #include #include #include +#include "libavutil/file_open.h" #include "libavutil/pixdesc.h" #include "libavutil/log.h" #include "libavutil/opt.h" diff --git a/libavdevice/oss.c b/libavdevice/oss.c index b042f58875..5c3eb6d4c3 100644 --- a/libavdevice/oss.c +++ b/libavdevice/oss.c @@ -30,6 +30,7 @@ #include #include +#include "libavutil/file_open.h" #include "libavutil/log.h" #include "avdevice.h" diff --git a/libavfilter/af_arnndn.c b/libavfilter/af_arnndn.c index 5e3403ca6a..3ef222bc8e 100644 --- a/libavfilter/af_arnndn.c +++ b/libavfilter/af_arnndn.c @@ -31,10 +31,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include - #include "libavutil/avassert.h" -#include "libavutil/avstring.h" +#include "libavutil/file_open.h" #include "libavutil/float_dsp.h" #include "libavutil/mem_internal.h" #include "libavutil/opt.h" diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c index 85bdb59209..e0f35c139e 100644 --- a/libavfilter/af_firequalizer.c +++ b/libavfilter/af_firequalizer.c @@ -19,6 +19,7 @@ */ #include "libavutil/channel_layout.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" #include "libavutil/eval.h" #include "libavutil/avassert.h" diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c index c8e7e6e1a5..5d1e297af8 100644 --- a/libavfilter/opencl.c +++ b/libavfilter/opencl.c @@ -19,6 +19,7 @@ #include #include +#include "libavutil/file_open.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c index 82e2753f01..498b06f6e5 100644 --- a/libavfilter/vf_curves.c +++ b/libavfilter/vf_curves.c @@ -22,12 +22,12 @@ #include "libavutil/bprint.h" #include "libavutil/eval.h" #include "libavutil/file.h" +#include "libavutil/file_open.h" #include "libavutil/intreadwrite.h" #include "libavutil/avassert.h" #include "libavutil/pixdesc.h" #include "avfilter.h" #include "drawutils.h" -#include "formats.h" #include "internal.h" #include "video.h" diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index b37cffba9d..142f88541d 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -50,10 +50,10 @@ */ #include "avfilter.h" -#include "formats.h" #include "internal.h" #include "video.h" #include "libavutil/common.h" +#include "libavutil/file_open.h" #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" diff --git a/libavfilter/vf_dnn_classify.c b/libavfilter/vf_dnn_classify.c index 852f5ddcee..d242aebcfb 100644 --- a/libavfilter/vf_dnn_classify.c +++ b/libavfilter/vf_dnn_classify.c @@ -21,14 +21,10 @@ * implementing an classification filter using deep learning networks. */ -#include "libavformat/avio.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" -#include "libavutil/pixdesc.h" -#include "libavutil/avassert.h" -#include "libavutil/imgutils.h" #include "filters.h" #include "dnn_filter_common.h" -#include "formats.h" #include "internal.h" #include "libavutil/time.h" #include "libavutil/avstring.h" diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index 68bd2cd0c3..7e133f6af5 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -21,14 +21,10 @@ * implementing an object detecting filter using deep learning networks. */ -#include "libavformat/avio.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" -#include "libavutil/pixdesc.h" -#include "libavutil/avassert.h" -#include "libavutil/imgutils.h" #include "filters.h" #include "dnn_filter_common.h" -#include "formats.h" #include "internal.h" #include "libavutil/time.h" #include "libavutil/avstring.h" diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c index e6061c6d3c..4af9e26925 100644 --- a/libavfilter/vf_fieldhint.c +++ b/libavfilter/vf_fieldhint.c @@ -19,6 +19,7 @@ */ #include "libavutil/avassert.h" +#include "libavutil/file_open.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/opt.h" diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index 358fe13e09..1ca448fcb3 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -29,13 +29,11 @@ #include "float.h" #include "libavutil/opt.h" -#include "libavutil/file.h" -#include "libavutil/intreadwrite.h" +#include "libavutil/file_open.h" #include "libavutil/intfloat.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "drawutils.h" -#include "formats.h" #include "internal.h" #include "video.h" #include "lut3d.h" diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c index e5a16918bd..63b83e5efd 100644 --- a/libavfilter/vf_nnedi.c +++ b/libavfilter/vf_nnedi.c @@ -22,13 +22,13 @@ #include #include "libavutil/common.h" +#include "libavutil/file_open.h" #include "libavutil/float_dsp.h" #include "libavutil/imgutils.h" #include "libavutil/mem_internal.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" -#include "formats.h" #include "internal.h" #include "video.h" diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index 5c491a290c..a6b5d5a5fa 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -24,6 +24,7 @@ */ #include "libavutil/bprint.h" +#include "libavutil/file_open.h" #include "libavutil/internal.h" #include "libavutil/opt.h" #include "libavutil/qsort.h" diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c index fa2e887e9b..15cde7e8c8 100644 --- a/libavfilter/vf_psnr.c +++ b/libavfilter/vf_psnr.c @@ -26,15 +26,14 @@ */ #include "libavutil/avstring.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" #include "drawutils.h" -#include "formats.h" #include "framesync.h" #include "internal.h" #include "psnr.h" -#include "video.h" typedef struct PSNRContext { const AVClass *class; diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c index 7d434328b7..4896e8f2c1 100644 --- a/libavfilter/vf_signature.c +++ b/libavfilter/vf_signature.c @@ -24,13 +24,11 @@ * @see http://epubs.surrey.ac.uk/531590/1/MPEG-7%20Video%20Signature%20Author%27s%20Copy.pdf */ -#include #include "libavcodec/put_bits.h" #include "libavformat/avformat.h" #include "libavutil/opt.h" #include "libavutil/avstring.h" -#include "libavutil/intreadwrite.h" -#include "libavutil/timestamp.h" +#include "libavutil/file_open.h" #include "avfilter.h" #include "internal.h" #include "signature.h" diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c index 37094b23f9..1933b9b82d 100644 --- a/libavfilter/vf_ssim.c +++ b/libavfilter/vf_ssim.c @@ -35,15 +35,14 @@ */ #include "libavutil/avstring.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" #include "drawutils.h" -#include "formats.h" #include "framesync.h" #include "internal.h" #include "ssim.h" -#include "video.h" typedef struct SSIMContext { const AVClass *class; diff --git a/libavfilter/vf_vidstabdetect.c b/libavfilter/vf_vidstabdetect.c index 044911ec27..62b998e171 100644 --- a/libavfilter/vf_vidstabdetect.c +++ b/libavfilter/vf_vidstabdetect.c @@ -23,8 +23,9 @@ #include #include "libavutil/common.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" -#include "libavutil/imgutils.h" +#include "libavutil/pixdesc.h" #include "avfilter.h" #include "internal.h" diff --git a/libavfilter/vf_vidstabtransform.c b/libavfilter/vf_vidstabtransform.c index de303554cd..1914d7b348 100644 --- a/libavfilter/vf_vidstabtransform.c +++ b/libavfilter/vf_vidstabtransform.c @@ -23,8 +23,9 @@ #include #include "libavutil/common.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" -#include "libavutil/imgutils.h" +#include "libavutil/pixdesc.h" #include "avfilter.h" #include "internal.h" diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c index 6ae968f7e9..137afd9245 100644 --- a/libavfilter/vf_vmafmotion.c +++ b/libavfilter/vf_vmafmotion.c @@ -24,6 +24,7 @@ * Calculate VMAF Motion score. */ +#include "libavutil/file_open.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" diff --git a/libavformat/cache.c b/libavformat/cache.c index 1e19dafc6a..115c2c2490 100644 --- a/libavformat/cache.c +++ b/libavformat/cache.c @@ -29,10 +29,10 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" -#include "libavutil/internal.h" +#include "libavutil/file_open.h" #include "libavutil/opt.h" #include "libavutil/tree.h" -#include "avformat.h" +#include "avio.h" #include #if HAVE_IO_H #include diff --git a/libavformat/file.c b/libavformat/file.c index 98c9e81bcb..6103c37b34 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -22,9 +22,10 @@ #include "config_components.h" #include "libavutil/avstring.h" +#include "libavutil/file_open.h" #include "libavutil/internal.h" #include "libavutil/opt.h" -#include "avformat.h" +#include "avio.h" #if HAVE_DIRENT_H #include #endif diff --git a/libavformat/ipfsgateway.c b/libavformat/ipfsgateway.c index 907b61b017..ce69d9055a 100644 --- a/libavformat/ipfsgateway.c +++ b/libavformat/ipfsgateway.c @@ -20,6 +20,7 @@ */ #include "libavutil/avstring.h" +#include "libavutil/file_open.h" #include "libavutil/getenv_utf8.h" #include "libavutil/opt.h" #include diff --git a/libavutil/file.c b/libavutil/file.c index f228b723ec..edee6aaf80 100644 --- a/libavutil/file.c +++ b/libavutil/file.c @@ -18,6 +18,7 @@ #include "config.h" #include "file.h" +#include "file_open.h" #include "internal.h" #include "log.h" #include "mem.h" diff --git a/libavutil/file_open.c b/libavutil/file_open.c index 58a6073353..9aa4e4ac61 100644 --- a/libavutil/file_open.c +++ b/libavutil/file_open.c @@ -17,7 +17,8 @@ */ #include "config.h" -#include "internal.h" +#include "avutil.h" +#include "file_open.h" #include "mem.h" #include #include diff --git a/libavutil/file_open.h b/libavutil/file_open.h new file mode 100644 index 0000000000..6a00004741 --- /dev/null +++ b/libavutil/file_open.h @@ -0,0 +1,57 @@ +/* + * 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 AVUTIL_FILE_OPEN_H +#define AVUTIL_FILE_OPEN_H + +#include + +#include "config.h" +#include "attributes.h" + +#if HAVE_LIBC_MSVCRT +#define avpriv_fopen_utf8 ff_fopen_utf8 +#define avpriv_open ff_open +#define avpriv_tempfile ff_tempfile +#endif + + /** + * A wrapper for open() setting O_CLOEXEC. + */ +av_warn_unused_result +int avpriv_open(const char *filename, int flags, ...); + +/** + * Open a file using a UTF-8 filename. + */ +FILE *avpriv_fopen_utf8(const char *path, const char *mode); + +/** + * Wrapper to work around the lack of mkstemp() on mingw. + * Also, tries to create file in /tmp first, if possible. + * *prefix can be a character constant; *filename will be allocated internally. + * @return file descriptor of opened file (or negative value corresponding to an + * AVERROR code on error) + * and opened file name in **filename. + * @note On very old libcs it is necessary to set a secure umask before + * calling this, av_tempfile() can't call umask itself as it is used in + * libraries and could interfere with the calling application. + */ +int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); + +#endif /* AVUTIL_FILE_OPEN_H */ diff --git a/libavutil/internal.h b/libavutil/internal.h index 8bdc7b3ac8..14f3acec58 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -155,10 +155,6 @@ void avpriv_request_sample(void *avc, #pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_snprintf") #endif -#define avpriv_fopen_utf8 ff_fopen_utf8 -#define avpriv_open ff_open -#define avpriv_tempfile ff_tempfile - #define PTRDIFF_SPECIFIER "Id" #define SIZE_SPECIFIER "Iu" #else @@ -188,30 +184,6 @@ void avpriv_request_sample(void *avc, #define SUINT32 uint32_t #endif -/** - * A wrapper for open() setting O_CLOEXEC. - */ -av_warn_unused_result -int avpriv_open(const char *filename, int flags, ...); - -/** - * Open a file using a UTF-8 filename. - */ -FILE *avpriv_fopen_utf8(const char *path, const char *mode); - -/** - * Wrapper to work around the lack of mkstemp() on mingw. - * Also, tries to create file in /tmp first, if possible. - * *prefix can be a character constant; *filename will be allocated internally. - * @return file descriptor of opened file (or negative value corresponding to an - * AVERROR code on error) - * and opened file name in **filename. - * @note On very old libcs it is necessary to set a secure umask before - * calling this, av_tempfile() can't call umask itself as it is used in - * libraries and could interfere with the calling application. - */ -int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); - int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt); static av_always_inline av_const int avpriv_mirror(int x, int w) diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 70dc509d2f..66dd504ef0 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -35,6 +35,7 @@ #include #include #include "avassert.h" +#include "file_open.h" #include "internal.h" #include "intreadwrite.h" #include "timer.h" From dea974456035d8d43c69a23b9db036a544bb0455 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 28 Aug 2022 00:13:24 +0200 Subject: [PATCH 110/590] avutil/file: Properly deprecate av_tempfile() It has been deprecated in b4f59beeb4c2171879d0d7607a4a7d6165f07791, but the attribute_deprecated was not set and there was no entry in APIchanges. This commit adds these and schedules it for removal. Given that the reason behind the deprecation is exactly the same as in av_fopen_utf8(), reuse its FF_API_AV_FOPEN_UTF8. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 3 +++ libavutil/file.c | 2 ++ libavutil/file.h | 4 ++++ libavutil/version.h | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 1cd13d4ed3..b0d0757b13 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-03 - xxxxxxxxxx - lavu 57.35.100 - file.h + Deprecate av_tempfile() without replacement. + 2022-08-03 - xxxxxxxxxx - lavu 57.34.100 - pixfmt.h Add AV_PIX_FMT_VUYX. diff --git a/libavutil/file.c b/libavutil/file.c index edee6aaf80..6a2f3aa91c 100644 --- a/libavutil/file.c +++ b/libavutil/file.c @@ -155,6 +155,8 @@ void av_file_unmap(uint8_t *bufptr, size_t size) #endif } +#if FF_API_AV_FOPEN_UTF8 int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx) { return avpriv_tempfile(prefix, filename, log_offset, log_ctx); } +#endif diff --git a/libavutil/file.h b/libavutil/file.h index 8ec210e783..511c100db4 100644 --- a/libavutil/file.h +++ b/libavutil/file.h @@ -22,6 +22,7 @@ #include #include +#include "version.h" #include "attributes.h" /** @@ -55,6 +56,7 @@ int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, */ void av_file_unmap(uint8_t *bufptr, size_t size); +#if FF_API_AV_FOPEN_UTF8 /** * Wrapper to work around the lack of mkstemp() on mingw. * Also, tries to create file in /tmp first, if possible. @@ -67,6 +69,8 @@ void av_file_unmap(uint8_t *bufptr, size_t size); * libraries and could interfere with the calling application. * @deprecated as fd numbers cannot be passed saftely between libs on some platforms */ +attribute_deprecated int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); +#endif #endif /* AVUTIL_FILE_H */ diff --git a/libavutil/version.h b/libavutil/version.h index 5d0df781cc..f33b3d1b49 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 34 +#define LIBAVUTIL_VERSION_MINOR 35 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From 48286d4d98e6417dff397d6f15e6b2ca3310f0ca Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 29 Aug 2022 13:38:02 +0200 Subject: [PATCH 111/590] avcodec/codec_internal: Add macro to set AVCodec.long_name It reduces typing: Before this patch, there were 105 codecs whose long_name-definition exceeded the 80 char line length limit. Now there are only nine of them. Signed-off-by: Andreas Rheinhardt --- libavcodec/012v.c | 2 +- libavcodec/4xm.c | 2 +- libavcodec/8bps.c | 2 +- libavcodec/8svx.c | 4 ++-- libavcodec/a64multienc.c | 4 ++-- libavcodec/aacdec.c | 4 ++-- libavcodec/aacdec_fixed.c | 2 +- libavcodec/aacenc.c | 2 +- libavcodec/aasc.c | 2 +- libavcodec/ac3dec_fixed.c | 2 +- libavcodec/ac3dec_float.c | 4 ++-- libavcodec/ac3enc_fixed.c | 2 +- libavcodec/ac3enc_float.c | 2 +- libavcodec/adpcm.c | 2 +- libavcodec/adpcmenc.c | 2 +- libavcodec/adxdec.c | 2 +- libavcodec/adxenc.c | 2 +- libavcodec/agm.c | 2 +- libavcodec/aic.c | 2 +- libavcodec/alac.c | 2 +- libavcodec/alacenc.c | 2 +- libavcodec/aliaspixdec.c | 2 +- libavcodec/aliaspixenc.c | 2 +- libavcodec/alsdec.c | 2 +- libavcodec/amfenc_h264.c | 2 +- libavcodec/amfenc_hevc.c | 2 +- libavcodec/amrnbdec.c | 2 +- libavcodec/amrwbdec.c | 2 +- libavcodec/anm.c | 2 +- libavcodec/ansi.c | 2 +- libavcodec/apedec.c | 2 +- libavcodec/aptxdec.c | 4 ++-- libavcodec/aptxenc.c | 4 ++-- libavcodec/arbc.c | 2 +- libavcodec/argo.c | 2 +- libavcodec/assdec.c | 4 ++-- libavcodec/assenc.c | 4 ++-- libavcodec/asvdec.c | 4 ++-- libavcodec/asvenc.c | 4 ++-- libavcodec/atrac1.c | 2 +- libavcodec/atrac3.c | 4 ++-- libavcodec/atrac3plusdec.c | 4 ++-- libavcodec/atrac9dec.c | 2 +- libavcodec/audiotoolboxdec.c | 2 +- libavcodec/audiotoolboxenc.c | 2 +- libavcodec/aura.c | 2 +- libavcodec/av1dec.c | 2 +- libavcodec/avrndec.c | 2 +- libavcodec/avs.c | 2 +- libavcodec/avuidec.c | 2 +- libavcodec/avuienc.c | 2 +- libavcodec/bethsoftvideo.c | 2 +- libavcodec/bfi.c | 2 +- libavcodec/bink.c | 2 +- libavcodec/binkaudio.c | 4 ++-- libavcodec/bintext.c | 6 +++--- libavcodec/bitpacked_dec.c | 2 +- libavcodec/bitpacked_enc.c | 2 +- libavcodec/bmp.c | 2 +- libavcodec/bmpenc.c | 2 +- libavcodec/bmvaudio.c | 2 +- libavcodec/bmvvideo.c | 2 +- libavcodec/brenderpix.c | 2 +- libavcodec/c93.c | 2 +- libavcodec/cavsdec.c | 2 +- libavcodec/ccaption_dec.c | 2 +- libavcodec/cdgraphics.c | 2 +- libavcodec/cdtoons.c | 2 +- libavcodec/cdxl.c | 2 +- libavcodec/cfhd.c | 2 +- libavcodec/cfhdenc.c | 2 +- libavcodec/cinepak.c | 2 +- libavcodec/cinepakenc.c | 2 +- libavcodec/clearvideo.c | 2 +- libavcodec/cljrdec.c | 2 +- libavcodec/cljrenc.c | 2 +- libavcodec/cllc.c | 2 +- libavcodec/cngdec.c | 2 +- libavcodec/cngenc.c | 2 +- libavcodec/codec_internal.h | 7 +++++++ libavcodec/cook.c | 2 +- libavcodec/cpia.c | 2 +- libavcodec/cri.c | 2 +- libavcodec/crystalhd.c | 2 +- libavcodec/cscd.c | 2 +- libavcodec/cuviddec.c | 2 +- libavcodec/cyuv.c | 4 ++-- libavcodec/dcadec.c | 2 +- libavcodec/dcaenc.c | 2 +- libavcodec/dds.c | 2 +- libavcodec/dfa.c | 2 +- libavcodec/dfpwmdec.c | 2 +- libavcodec/dfpwmenc.c | 2 +- libavcodec/diracdec.c | 2 +- libavcodec/dnxhddec.c | 2 +- libavcodec/dnxhdenc.c | 2 +- libavcodec/dolby_e.c | 2 +- libavcodec/dpcm.c | 2 +- libavcodec/dpx.c | 2 +- libavcodec/dpxenc.c | 2 +- libavcodec/dsddec.c | 2 +- libavcodec/dsicinaudio.c | 2 +- libavcodec/dsicinvideo.c | 2 +- libavcodec/dss_sp.c | 2 +- libavcodec/dstdec.c | 2 +- libavcodec/dvaudiodec.c | 2 +- libavcodec/dvbsubdec.c | 2 +- libavcodec/dvbsubenc.c | 2 +- libavcodec/dvdec.c | 2 +- libavcodec/dvdsubdec.c | 2 +- libavcodec/dvdsubenc.c | 2 +- libavcodec/dvenc.c | 2 +- libavcodec/dxa.c | 2 +- libavcodec/dxtory.c | 2 +- libavcodec/dxv.c | 2 +- libavcodec/eac3enc.c | 2 +- libavcodec/eacmv.c | 2 +- libavcodec/eamad.c | 2 +- libavcodec/eatgq.c | 2 +- libavcodec/eatgv.c | 2 +- libavcodec/eatqi.c | 2 +- libavcodec/escape124.c | 2 +- libavcodec/escape130.c | 2 +- libavcodec/evrcdec.c | 2 +- libavcodec/exr.c | 2 +- libavcodec/exrenc.c | 2 +- libavcodec/fastaudio.c | 2 +- libavcodec/ffv1dec.c | 2 +- libavcodec/ffv1enc.c | 2 +- libavcodec/ffwavesynth.c | 2 +- libavcodec/fic.c | 2 +- libavcodec/fitsdec.c | 2 +- libavcodec/fitsenc.c | 2 +- libavcodec/flacdec.c | 2 +- libavcodec/flacenc.c | 2 +- libavcodec/flashsv.c | 4 ++-- libavcodec/flashsv2enc.c | 2 +- libavcodec/flashsvenc.c | 2 +- libavcodec/flicvideo.c | 2 +- libavcodec/flvdec.c | 2 +- libavcodec/flvenc.c | 2 +- libavcodec/fmvc.c | 2 +- libavcodec/fraps.c | 2 +- libavcodec/frwu.c | 2 +- libavcodec/g2meet.c | 2 +- libavcodec/g722dec.c | 2 +- libavcodec/g722enc.c | 2 +- libavcodec/g723_1dec.c | 2 +- libavcodec/g723_1enc.c | 2 +- libavcodec/g726.c | 8 ++++---- libavcodec/g729dec.c | 4 ++-- libavcodec/gdv.c | 2 +- libavcodec/gemdec.c | 2 +- libavcodec/gif.c | 2 +- libavcodec/gifdec.c | 2 +- libavcodec/gsmdec.c | 4 ++-- libavcodec/h261dec.c | 2 +- libavcodec/h261enc.c | 2 +- libavcodec/h263dec.c | 4 ++-- libavcodec/h264dec.c | 2 +- libavcodec/hapdec.c | 2 +- libavcodec/hapenc.c | 2 +- libavcodec/hcadec.c | 2 +- libavcodec/hcom.c | 2 +- libavcodec/hdrdec.c | 2 +- libavcodec/hdrenc.c | 2 +- libavcodec/hevcdec.c | 2 +- libavcodec/hnm4video.c | 2 +- libavcodec/hq_hqa.c | 2 +- libavcodec/hqx.c | 2 +- libavcodec/huffyuvdec.c | 6 +++--- libavcodec/huffyuvenc.c | 4 ++-- libavcodec/idcinvideo.c | 2 +- libavcodec/iff.c | 2 +- libavcodec/ilbcdec.c | 2 +- libavcodec/imc.c | 4 ++-- libavcodec/imm4.c | 2 +- libavcodec/imm5.c | 2 +- libavcodec/imx.c | 2 +- libavcodec/indeo2.c | 2 +- libavcodec/indeo3.c | 2 +- libavcodec/indeo4.c | 2 +- libavcodec/indeo5.c | 2 +- libavcodec/intelh263dec.c | 2 +- libavcodec/interplayacm.c | 2 +- libavcodec/interplayvideo.c | 2 +- libavcodec/ituh263enc.c | 4 ++-- libavcodec/j2kenc.c | 2 +- libavcodec/jacosubdec.c | 2 +- libavcodec/jpeg2000dec.c | 2 +- libavcodec/jpeglsdec.c | 2 +- libavcodec/jpeglsenc.c | 2 +- libavcodec/jvdec.c | 2 +- libavcodec/kgv1dec.c | 2 +- libavcodec/kmvc.c | 2 +- libavcodec/lagarith.c | 2 +- libavcodec/lcldec.c | 4 ++-- libavcodec/lclenc.c | 2 +- libavcodec/libaomdec.c | 2 +- libavcodec/libaomenc.c | 2 +- libavcodec/libaribb24.c | 2 +- libavcodec/libcelt_dec.c | 2 +- libavcodec/libcodec2.c | 4 ++-- libavcodec/libdav1d.c | 2 +- libavcodec/libdavs2.c | 2 +- libavcodec/libfdk-aacdec.c | 2 +- libavcodec/libfdk-aacenc.c | 2 +- libavcodec/libgsmdec.c | 4 ++-- libavcodec/libgsmenc.c | 4 ++-- libavcodec/libilbc.c | 4 ++-- libavcodec/libjxldec.c | 2 +- libavcodec/libjxlenc.c | 2 +- libavcodec/libkvazaar.c | 2 +- libavcodec/libmp3lame.c | 2 +- libavcodec/libopencore-amr.c | 6 +++--- libavcodec/libopenh264dec.c | 2 +- libavcodec/libopenh264enc.c | 2 +- libavcodec/libopenjpegdec.c | 2 +- libavcodec/libopenjpegenc.c | 2 +- libavcodec/libopusdec.c | 2 +- libavcodec/libopusenc.c | 2 +- libavcodec/librav1e.c | 2 +- libavcodec/librsvgdec.c | 2 +- libavcodec/libshine.c | 2 +- libavcodec/libspeexdec.c | 2 +- libavcodec/libspeexenc.c | 2 +- libavcodec/libsvtav1.c | 2 +- libavcodec/libtheoraenc.c | 2 +- libavcodec/libtwolame.c | 2 +- libavcodec/libuavs3d.c | 2 +- libavcodec/libvo-amrwbenc.c | 3 +-- libavcodec/libvorbisdec.c | 2 +- libavcodec/libvorbisenc.c | 2 +- libavcodec/libvpxdec.c | 4 ++-- libavcodec/libvpxenc.c | 4 ++-- libavcodec/libwebpenc.c | 2 +- libavcodec/libwebpenc_animencoder.c | 2 +- libavcodec/libx264.c | 6 +++--- libavcodec/libx265.c | 2 +- libavcodec/libxavs.c | 2 +- libavcodec/libxavs2.c | 2 +- libavcodec/libxvid.c | 2 +- libavcodec/libzvbi-teletextdec.c | 2 +- libavcodec/ljpegenc.c | 2 +- libavcodec/loco.c | 2 +- libavcodec/lscrdec.c | 2 +- libavcodec/m101.c | 2 +- libavcodec/mace.c | 4 ++-- libavcodec/magicyuv.c | 2 +- libavcodec/magicyuvenc.c | 2 +- libavcodec/mdec.c | 2 +- libavcodec/mediacodecdec.c | 2 +- libavcodec/metasound.c | 2 +- libavcodec/mfenc.c | 2 +- libavcodec/microdvddec.c | 2 +- libavcodec/midivid.c | 2 +- libavcodec/mimic.c | 2 +- libavcodec/mjpegbdec.c | 2 +- libavcodec/mjpegdec.c | 6 +++--- libavcodec/mjpegenc.c | 4 ++-- libavcodec/mlpdec.c | 4 ++-- libavcodec/mlpenc.c | 4 ++-- libavcodec/mmaldec.c | 2 +- libavcodec/mmvideo.c | 2 +- libavcodec/mobiclip.c | 2 +- libavcodec/motionpixels.c | 2 +- libavcodec/movtextdec.c | 2 +- libavcodec/movtextenc.c | 2 +- libavcodec/mpc7.c | 2 +- libavcodec/mpc8.c | 2 +- libavcodec/mpeg12dec.c | 8 ++++---- libavcodec/mpeg12enc.c | 4 ++-- libavcodec/mpeg4videodec.c | 2 +- libavcodec/mpeg4videoenc.c | 2 +- libavcodec/mpegaudiodec_fixed.c | 10 +++++----- libavcodec/mpegaudiodec_float.c | 10 +++++----- libavcodec/mpegaudioenc_fixed.c | 2 +- libavcodec/mpegaudioenc_float.c | 2 +- libavcodec/mpl2dec.c | 2 +- libavcodec/mscc.c | 4 ++-- libavcodec/msmpeg4dec.c | 8 ++++---- libavcodec/msmpeg4enc.c | 6 +++--- libavcodec/msp2dec.c | 2 +- libavcodec/msrle.c | 2 +- libavcodec/mss1.c | 2 +- libavcodec/mss2.c | 2 +- libavcodec/mss3.c | 2 +- libavcodec/mss4.c | 2 +- libavcodec/msvideo1.c | 2 +- libavcodec/msvideo1enc.c | 2 +- libavcodec/mv30.c | 2 +- libavcodec/mvcdec.c | 4 ++-- libavcodec/mvha.c | 2 +- libavcodec/mwsc.c | 2 +- libavcodec/mxpegdec.c | 2 +- libavcodec/nellymoserdec.c | 2 +- libavcodec/nellymoserenc.c | 2 +- libavcodec/notchlc.c | 2 +- libavcodec/nuv.c | 2 +- libavcodec/nvenc_h264.c | 2 +- libavcodec/nvenc_hevc.c | 2 +- libavcodec/omx.c | 4 ++-- libavcodec/on2avc.c | 2 +- libavcodec/opusdec.c | 2 +- libavcodec/opusenc.c | 2 +- libavcodec/pafaudio.c | 2 +- libavcodec/pafvideo.c | 2 +- libavcodec/pamenc.c | 2 +- libavcodec/pcm-bluray.c | 2 +- libavcodec/pcm-blurayenc.c | 2 +- libavcodec/pcm-dvd.c | 2 +- libavcodec/pcm-dvdenc.c | 2 +- libavcodec/pcm.c | 4 ++-- libavcodec/pcx.c | 2 +- libavcodec/pcxenc.c | 2 +- libavcodec/pgssubdec.c | 2 +- libavcodec/pgxdec.c | 2 +- libavcodec/photocd.c | 2 +- libavcodec/pictordec.c | 2 +- libavcodec/pixlet.c | 2 +- libavcodec/pngdec.c | 4 ++-- libavcodec/pngenc.c | 4 ++-- libavcodec/pnmdec.c | 14 +++++++------- libavcodec/pnmenc.c | 12 ++++++------ libavcodec/proresdec2.c | 2 +- libavcodec/proresenc_anatoliy.c | 4 ++-- libavcodec/proresenc_kostya.c | 2 +- libavcodec/prosumer.c | 2 +- libavcodec/psd.c | 2 +- libavcodec/ptx.c | 2 +- libavcodec/qcelpdec.c | 2 +- libavcodec/qdm2.c | 2 +- libavcodec/qdmc.c | 2 +- libavcodec/qdrw.c | 2 +- libavcodec/qoidec.c | 2 +- libavcodec/qoienc.c | 2 +- libavcodec/qpeg.c | 2 +- libavcodec/qsvdec.c | 2 +- libavcodec/qsvenc_h264.c | 2 +- libavcodec/qsvenc_hevc.c | 2 +- libavcodec/qsvenc_jpeg.c | 2 +- libavcodec/qsvenc_mpeg2.c | 2 +- libavcodec/qsvenc_vp9.c | 2 +- libavcodec/qtrle.c | 2 +- libavcodec/qtrleenc.c | 2 +- libavcodec/r210dec.c | 6 +++--- libavcodec/r210enc.c | 6 +++--- libavcodec/ra144dec.c | 2 +- libavcodec/ra144enc.c | 2 +- libavcodec/ra288.c | 2 +- libavcodec/ralf.c | 2 +- libavcodec/rasc.c | 2 +- libavcodec/rawdec.c | 2 +- libavcodec/rawenc.c | 2 +- libavcodec/realtextdec.c | 2 +- libavcodec/rkmppdec.c | 2 +- libavcodec/rl2.c | 2 +- libavcodec/roqaudioenc.c | 2 +- libavcodec/roqvideodec.c | 2 +- libavcodec/roqvideoenc.c | 2 +- libavcodec/rpza.c | 2 +- libavcodec/rpzaenc.c | 2 +- libavcodec/rscc.c | 2 +- libavcodec/rv10.c | 4 ++-- libavcodec/rv10enc.c | 2 +- libavcodec/rv20enc.c | 2 +- libavcodec/rv30.c | 2 +- libavcodec/rv40.c | 2 +- libavcodec/s302m.c | 2 +- libavcodec/s302menc.c | 2 +- libavcodec/samidec.c | 2 +- libavcodec/sanm.c | 2 +- libavcodec/sbcdec.c | 2 +- libavcodec/sbcenc.c | 2 +- libavcodec/scpr.c | 2 +- libavcodec/screenpresso.c | 2 +- libavcodec/sga.c | 2 +- libavcodec/sgidec.c | 2 +- libavcodec/sgienc.c | 2 +- libavcodec/sgirledec.c | 2 +- libavcodec/sheervideo.c | 2 +- libavcodec/shorten.c | 2 +- libavcodec/sipr.c | 2 +- libavcodec/siren.c | 4 ++-- libavcodec/smacker.c | 4 ++-- libavcodec/smc.c | 2 +- libavcodec/smcenc.c | 2 +- libavcodec/snowdec.c | 2 +- libavcodec/snowenc.c | 2 +- libavcodec/sonic.c | 6 +++--- libavcodec/sp5xdec.c | 4 ++-- libavcodec/speedhq.c | 2 +- libavcodec/speedhqenc.c | 2 +- libavcodec/speexdec.c | 2 +- libavcodec/srtdec.c | 4 ++-- libavcodec/srtenc.c | 6 +++--- libavcodec/subviewerdec.c | 2 +- libavcodec/sunrast.c | 2 +- libavcodec/sunrastenc.c | 2 +- libavcodec/svq1dec.c | 2 +- libavcodec/svq1enc.c | 2 +- libavcodec/svq3.c | 2 +- libavcodec/takdec.c | 2 +- libavcodec/targa.c | 2 +- libavcodec/targa_y216dec.c | 2 +- libavcodec/targaenc.c | 2 +- libavcodec/tdsc.c | 2 +- libavcodec/textdec.c | 10 +++++----- libavcodec/tiertexseqv.c | 2 +- libavcodec/tiff.c | 2 +- libavcodec/tiffenc.c | 2 +- libavcodec/tmv.c | 2 +- libavcodec/truemotion1.c | 2 +- libavcodec/truemotion2.c | 2 +- libavcodec/truemotion2rt.c | 2 +- libavcodec/truespeech.c | 2 +- libavcodec/tscc.c | 2 +- libavcodec/tscc2.c | 2 +- libavcodec/tta.c | 2 +- libavcodec/ttaenc.c | 2 +- libavcodec/ttmlenc.c | 2 +- libavcodec/twinvqdec.c | 2 +- libavcodec/txd.c | 2 +- libavcodec/ulti.c | 2 +- libavcodec/utvideodec.c | 2 +- libavcodec/utvideoenc.c | 2 +- libavcodec/v210dec.c | 2 +- libavcodec/v210enc.c | 2 +- libavcodec/v210x.c | 2 +- libavcodec/v308dec.c | 2 +- libavcodec/v308enc.c | 2 +- libavcodec/v408dec.c | 4 ++-- libavcodec/v408enc.c | 4 ++-- libavcodec/v410dec.c | 2 +- libavcodec/v410enc.c | 2 +- libavcodec/v4l2_m2m_dec.c | 2 +- libavcodec/v4l2_m2m_enc.c | 2 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 2 +- libavcodec/vaapi_encode_mpeg2.c | 2 +- libavcodec/vaapi_encode_vp8.c | 2 +- libavcodec/vaapi_encode_vp9.c | 2 +- libavcodec/vb.c | 2 +- libavcodec/vble.c | 2 +- libavcodec/vbndec.c | 2 +- libavcodec/vbnenc.c | 2 +- libavcodec/vc1dec.c | 8 ++++---- libavcodec/vc2enc.c | 2 +- libavcodec/vcr1.c | 2 +- libavcodec/videotoolboxenc.c | 6 +++--- libavcodec/vima.c | 2 +- libavcodec/vmdaudio.c | 2 +- libavcodec/vmdvideo.c | 2 +- libavcodec/vmnc.c | 2 +- libavcodec/vorbisdec.c | 2 +- libavcodec/vorbisenc.c | 2 +- libavcodec/vp3.c | 6 +++--- libavcodec/vp5.c | 2 +- libavcodec/vp6.c | 6 +++--- libavcodec/vp8.c | 4 ++-- libavcodec/vp9.c | 2 +- libavcodec/vqavideo.c | 2 +- libavcodec/wavpack.c | 2 +- libavcodec/wavpackenc.c | 2 +- libavcodec/wbmpdec.c | 2 +- libavcodec/wbmpenc.c | 2 +- libavcodec/wcmv.c | 2 +- libavcodec/webp.c | 2 +- libavcodec/webvttdec.c | 2 +- libavcodec/webvttenc.c | 2 +- libavcodec/wmadec.c | 4 ++-- libavcodec/wmaenc.c | 4 ++-- libavcodec/wmalosslessdec.c | 2 +- libavcodec/wmaprodec.c | 6 +++--- libavcodec/wmavoice.c | 2 +- libavcodec/wmv2dec.c | 2 +- libavcodec/wmv2enc.c | 2 +- libavcodec/wnv1.c | 2 +- libavcodec/wrapped_avframe.c | 4 ++-- libavcodec/ws-snd1.c | 2 +- libavcodec/xan.c | 2 +- libavcodec/xbmdec.c | 2 +- libavcodec/xbmenc.c | 2 +- libavcodec/xfacedec.c | 2 +- libavcodec/xfaceenc.c | 2 +- libavcodec/xl.c | 2 +- libavcodec/xpmdec.c | 2 +- libavcodec/xsubdec.c | 2 +- libavcodec/xsubenc.c | 2 +- libavcodec/xwddec.c | 2 +- libavcodec/xwdenc.c | 2 +- libavcodec/xxan.c | 2 +- libavcodec/y41pdec.c | 2 +- libavcodec/y41penc.c | 2 +- libavcodec/ylc.c | 2 +- libavcodec/yop.c | 2 +- libavcodec/yuv4dec.c | 2 +- libavcodec/yuv4enc.c | 2 +- libavcodec/zerocodec.c | 2 +- libavcodec/zmbv.c | 2 +- libavcodec/zmbvenc.c | 2 +- libavutil/internal.h | 3 +-- 503 files changed, 623 insertions(+), 618 deletions(-) diff --git a/libavcodec/012v.c b/libavcodec/012v.c index 700feb3024..2d89a86b98 100644 --- a/libavcodec/012v.c +++ b/libavcodec/012v.c @@ -146,7 +146,7 @@ static int zero12v_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_zero12v_decoder = { .p.name = "012v", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), + CODEC_LONG_NAME("Uncompressed 4:2:2 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_012V, .init = zero12v_decode_init, diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 2ee05766ab..6015fe5299 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -1028,7 +1028,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_fourxm_decoder = { .p.name = "4xm", - .p.long_name = NULL_IF_CONFIG_SMALL("4X Movie"), + CODEC_LONG_NAME("4X Movie"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_4XM, .priv_data_size = sizeof(FourXContext), diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index cda3cdef3a..6870e7a938 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -175,7 +175,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_eightbps_decoder = { .p.name = "8bps", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"), + CODEC_LONG_NAME("QuickTime 8BPS video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_8BPS, .priv_data_size = sizeof(EightBpsContext), diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c index 1c6d78379d..ed635f9ede 100644 --- a/libavcodec/8svx.c +++ b/libavcodec/8svx.c @@ -189,7 +189,7 @@ static av_cold int eightsvx_decode_close(AVCodecContext *avctx) #if CONFIG_EIGHTSVX_FIB_DECODER const FFCodec ff_eightsvx_fib_decoder = { .p.name = "8svx_fib", - .p.long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"), + CODEC_LONG_NAME("8SVX fibonacci"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_8SVX_FIB, .priv_data_size = sizeof (EightSvxContext), @@ -204,7 +204,7 @@ const FFCodec ff_eightsvx_fib_decoder = { #if CONFIG_EIGHTSVX_EXP_DECODER const FFCodec ff_eightsvx_exp_decoder = { .p.name = "8svx_exp", - .p.long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"), + CODEC_LONG_NAME("8SVX exponential"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_8SVX_EXP, .priv_data_size = sizeof (EightSvxContext), diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 043ffabd7c..26a9debc22 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -395,7 +395,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, #if CONFIG_A64MULTI_ENCODER const FFCodec ff_a64multi_encoder = { .p.name = "a64multi", - .p.long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64"), + CODEC_LONG_NAME("Multicolor charset for Commodore 64"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_A64_MULTI, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, @@ -410,7 +410,7 @@ const FFCodec ff_a64multi_encoder = { #if CONFIG_A64MULTI5_ENCODER const FFCodec ff_a64multi5_encoder = { .p.name = "a64multi5", - .p.long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64, extended with 5th color (colram)"), + CODEC_LONG_NAME("Multicolor charset for Commodore 64, extended with 5th color (colram)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_A64_MULTI5, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index c09c3ee547..2d448103df 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -554,7 +554,7 @@ static av_cold int latm_decode_init(AVCodecContext *avctx) const FFCodec ff_aac_decoder = { .p.name = "aac", - .p.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), + CODEC_LONG_NAME("AAC (Advanced Audio Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, .priv_data_size = sizeof(AACContext), @@ -582,7 +582,7 @@ const FFCodec ff_aac_decoder = { */ const FFCodec ff_aac_latm_decoder = { .p.name = "aac_latm", - .p.long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Coding LATM syntax)"), + CODEC_LONG_NAME("AAC LATM (Advanced Audio Coding LATM syntax)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC_LATM, .priv_data_size = sizeof(struct LATMContext), diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index ddfa160adc..4b2085335d 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -452,7 +452,7 @@ static void apply_independent_coupling_fixed(AACContext *ac, const FFCodec ff_aac_fixed_decoder = { .p.name = "aac_fixed", - .p.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), + CODEC_LONG_NAME("AAC (Advanced Audio Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, .priv_data_size = sizeof(AACContext), diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index a0e5d2942e..6fe738e172 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -1414,7 +1414,7 @@ static const FFCodecDefault aac_encode_defaults[] = { const FFCodec ff_aac_encoder = { .p.name = "aac", - .p.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), + CODEC_LONG_NAME("AAC (Advanced Audio Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c index db9fc834b7..c8e15772b1 100644 --- a/libavcodec/aasc.c +++ b/libavcodec/aasc.c @@ -149,7 +149,7 @@ static av_cold int aasc_decode_end(AVCodecContext *avctx) const FFCodec ff_aasc_decoder = { .p.name = "aasc", - .p.long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"), + CODEC_LONG_NAME("Autodesk RLE"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AASC, .priv_data_size = sizeof(AascContext), diff --git a/libavcodec/ac3dec_fixed.c b/libavcodec/ac3dec_fixed.c index 29f2acc6f2..0a7ae6cfbf 100644 --- a/libavcodec/ac3dec_fixed.c +++ b/libavcodec/ac3dec_fixed.c @@ -171,7 +171,7 @@ static const AVClass ac3_decoder_class = { const FFCodec ff_ac3_fixed_decoder = { .p.name = "ac3_fixed", - .p.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), + CODEC_LONG_NAME("ATSC A/52A (AC-3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AC3, .p.priv_class = &ac3_decoder_class, diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c index 26fbd78d8b..8c1adb3e01 100644 --- a/libavcodec/ac3dec_float.c +++ b/libavcodec/ac3dec_float.c @@ -69,7 +69,7 @@ const FFCodec ff_ac3_decoder = { FF_CODEC_DECODE_CB(ac3_decode_frame), .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, - .p.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), + CODEC_LONG_NAME("ATSC A/52A (AC-3)"), .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .p.priv_class = &ac3_eac3_decoder_class, @@ -87,7 +87,7 @@ const FFCodec ff_eac3_decoder = { FF_CODEC_DECODE_CB(ac3_decode_frame), .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, - .p.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"), + CODEC_LONG_NAME("ATSC A/52B (AC-3, E-AC-3)"), .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .p.priv_class = &ac3_eac3_decoder_class, diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index fe434afc26..a22d3b4abf 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -122,7 +122,7 @@ static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx) FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_ac3_fixed_encoder = { .p.name = "ac3_fixed", - .p.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), + CODEC_LONG_NAME("ATSC A/52A (AC-3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AC3, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 666b53708b..6238980690 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -126,7 +126,7 @@ av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx) FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_ac3_encoder = { .p.name = "ac3", - .p.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), + CODEC_LONG_NAME("ATSC A/52A (AC-3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AC3, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 5db46752ab..841538b138 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -2287,7 +2287,7 @@ static const enum AVSampleFormat sample_fmts_both[] = { AV_SAMPLE_FMT_S16, #define ADPCM_DECODER_1(id_, sample_fmts_, name_, long_name_) \ const FFCodec ff_ ## name_ ## _decoder = { \ .p.name = #name_, \ - .p.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = id_, \ .p.capabilities = AV_CODEC_CAP_DR1, \ diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index e27febfd74..1ffc5b410f 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -998,7 +998,7 @@ static const AVClass adpcm_encoder_class = { #define ADPCM_ENCODER_1(id_, name_, sample_fmts_, capabilities_, long_name_) \ const FFCodec ff_ ## name_ ## _encoder = { \ .p.name = #name_, \ - .p.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = id_, \ .p.sample_fmts = sample_fmts_, \ diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index cdded477ca..a2701608ff 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -192,7 +192,7 @@ static void adx_decode_flush(AVCodecContext *avctx) const FFCodec ff_adpcm_adx_decoder = { .p.name = "adpcm_adx", - .p.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), + CODEC_LONG_NAME("SEGA CRI ADX ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_ADX, .priv_data_size = sizeof(ADXContext), diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index 0a2e5092cd..153c91b852 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -191,7 +191,7 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_adpcm_adx_encoder = { .p.name = "adpcm_adx", - .p.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), + CODEC_LONG_NAME("SEGA CRI ADX ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_ADX, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/agm.c b/libavcodec/agm.c index 38d9c67f80..017aa0e1fa 100644 --- a/libavcodec/agm.c +++ b/libavcodec/agm.c @@ -1285,7 +1285,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_agm_decoder = { .p.name = "agm", - .p.long_name = NULL_IF_CONFIG_SMALL("Amuse Graphics Movie"), + CODEC_LONG_NAME("Amuse Graphics Movie"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AGM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/aic.c b/libavcodec/aic.c index 21ce778146..49d08f0556 100644 --- a/libavcodec/aic.c +++ b/libavcodec/aic.c @@ -497,7 +497,7 @@ static av_cold int aic_decode_close(AVCodecContext *avctx) const FFCodec ff_aic_decoder = { .p.name = "aic", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple Intermediate Codec"), + CODEC_LONG_NAME("Apple Intermediate Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AIC, .priv_data_size = sizeof(AICContext), diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 8b87d78dd3..d10ecba7e6 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -614,7 +614,7 @@ static const AVClass alac_class = { const FFCodec ff_alac_decoder = { .p.name = "alac", - .p.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), + CODEC_LONG_NAME("ALAC (Apple Lossless Audio Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ALAC, .priv_data_size = sizeof(ALACContext), diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 20711d242f..362d4f8ba6 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -651,7 +651,7 @@ static const AVClass alacenc_class = { FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_alac_encoder = { .p.name = "alac", - .p.long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"), + CODEC_LONG_NAME("ALAC (Apple Lossless Audio Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ALAC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/aliaspixdec.c b/libavcodec/aliaspixdec.c index 7dedfe3aa1..45155d79cd 100644 --- a/libavcodec/aliaspixdec.c +++ b/libavcodec/aliaspixdec.c @@ -123,7 +123,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, const FFCodec ff_alias_pix_decoder = { .p.name = "alias_pix", - .p.long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"), + CODEC_LONG_NAME("Alias/Wavefront PIX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ALIAS_PIX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c index ec1cba9a57..6593d3f047 100644 --- a/libavcodec/aliaspixenc.c +++ b/libavcodec/aliaspixenc.c @@ -103,7 +103,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_alias_pix_encoder = { .p.name = "alias_pix", - .p.long_name = NULL_IF_CONFIG_SMALL("Alias/Wavefront PIX image"), + CODEC_LONG_NAME("Alias/Wavefront PIX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ALIAS_PIX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 4bb232c42a..17937ad928 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -2181,7 +2181,7 @@ static av_cold void flush(AVCodecContext *avctx) const FFCodec ff_als_decoder = { .p.name = "als", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"), + CODEC_LONG_NAME("MPEG-4 Audio Lossless Coding (ALS)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP4ALS, .priv_data_size = sizeof(ALSDecContext), diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index eba8c23cdd..eaf7f974f3 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -380,7 +380,7 @@ static const AVClass h264_amf_class = { const FFCodec ff_h264_amf_encoder = { .p.name = "h264_amf", - .p.long_name = NULL_IF_CONFIG_SMALL("AMD AMF H.264 Encoder"), + CODEC_LONG_NAME("AMD AMF H.264 Encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .init = amf_encode_init_h264, diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 5aaaa83e39..9b46946f1e 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -312,7 +312,7 @@ static const AVClass hevc_amf_class = { const FFCodec ff_hevc_amf_encoder = { .p.name = "hevc_amf", - .p.long_name = NULL_IF_CONFIG_SMALL("AMD AMF HEVC encoder"), + CODEC_LONG_NAME("AMD AMF HEVC encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .init = amf_encode_init_hevc, diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index e07c01923e..bfdcbba778 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -1097,7 +1097,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_amrnb_decoder = { .p.name = "amrnb", - .p.long_name = NULL_IF_CONFIG_SMALL("AMR-NB (Adaptive Multi-Rate NarrowBand)"), + CODEC_LONG_NAME("AMR-NB (Adaptive Multi-Rate NarrowBand)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_NB, .priv_data_size = sizeof(AMRChannelsContext), diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index 1e537e1a3b..ea3812cd9a 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -1293,7 +1293,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_amrwb_decoder = { .p.name = "amrwb", - .p.long_name = NULL_IF_CONFIG_SMALL("AMR-WB (Adaptive Multi-Rate WideBand)"), + CODEC_LONG_NAME("AMR-WB (Adaptive Multi-Rate WideBand)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_WB, .priv_data_size = sizeof(AMRWBChannelsContext), diff --git a/libavcodec/anm.c b/libavcodec/anm.c index c7256fe6d3..4aabe853b4 100644 --- a/libavcodec/anm.c +++ b/libavcodec/anm.c @@ -191,7 +191,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_anm_decoder = { .p.name = "anm", - .p.long_name = NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"), + CODEC_LONG_NAME("Deluxe Paint Animation"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ANM, .priv_data_size = sizeof(AnmContext), diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index 89bde59b40..e15c1bb097 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -481,7 +481,7 @@ static const FFCodecDefault ansi_defaults[] = { const FFCodec ff_ansi_decoder = { .p.name = "ansi", - .p.long_name = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"), + CODEC_LONG_NAME("ASCII/ANSI art"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ANSI, .priv_data_size = sizeof(AnsiContext), diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 805b9af3c3..4e3ddfea01 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -1659,7 +1659,7 @@ static const AVClass ape_decoder_class = { const FFCodec ff_ape_decoder = { .p.name = "ape", - .p.long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), + CODEC_LONG_NAME("Monkey's Audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APE, .priv_data_size = sizeof(APEContext), diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c index 1d7a7842f7..878c9ffe1b 100644 --- a/libavcodec/aptxdec.c +++ b/libavcodec/aptxdec.c @@ -176,7 +176,7 @@ static int aptx_decode_frame(AVCodecContext *avctx, AVFrame *frame, #if CONFIG_APTX_DECODER const FFCodec ff_aptx_decoder = { .p.name = "aptx", - .p.long_name = NULL_IF_CONFIG_SMALL("aptX (Audio Processing Technology for Bluetooth)"), + CODEC_LONG_NAME("aptX (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX, .priv_data_size = sizeof(AptXContext), @@ -195,7 +195,7 @@ const FFCodec ff_aptx_decoder = { #if CONFIG_APTX_HD_DECODER const FFCodec ff_aptx_hd_decoder = { .p.name = "aptx_hd", - .p.long_name = NULL_IF_CONFIG_SMALL("aptX HD (Audio Processing Technology for Bluetooth)"), + CODEC_LONG_NAME("aptX HD (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX_HD, .priv_data_size = sizeof(AptXContext), diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index 2a0d8e06eb..f9347853d2 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -263,7 +263,7 @@ static av_cold int aptx_encode_init(AVCodecContext *avctx) #if CONFIG_APTX_ENCODER const FFCodec ff_aptx_encoder = { .p.name = "aptx", - .p.long_name = NULL_IF_CONFIG_SMALL("aptX (Audio Processing Technology for Bluetooth)"), + CODEC_LONG_NAME("aptX (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, @@ -284,7 +284,7 @@ const FFCodec ff_aptx_encoder = { #if CONFIG_APTX_HD_ENCODER const FFCodec ff_aptx_hd_encoder = { .p.name = "aptx_hd", - .p.long_name = NULL_IF_CONFIG_SMALL("aptX HD (Audio Processing Technology for Bluetooth)"), + CODEC_LONG_NAME("aptX HD (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX_HD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c index 7155d65196..343c56695e 100644 --- a/libavcodec/arbc.c +++ b/libavcodec/arbc.c @@ -208,7 +208,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_arbc_decoder = { .p.name = "arbc", - .p.long_name = NULL_IF_CONFIG_SMALL("Gryphon's Anim Compressor"), + CODEC_LONG_NAME("Gryphon's Anim Compressor"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ARBC, .priv_data_size = sizeof(ARBCContext), diff --git a/libavcodec/argo.c b/libavcodec/argo.c index a863373af2..9bedb1394d 100644 --- a/libavcodec/argo.c +++ b/libavcodec/argo.c @@ -732,7 +732,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_argo_decoder = { .p.name = "argo", - .p.long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"), + CODEC_LONG_NAME("Argonaut Games Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ARGO, .priv_data_size = sizeof(ArgoContext), diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c index b189645545..89d7b51894 100644 --- a/libavcodec/assdec.c +++ b/libavcodec/assdec.c @@ -64,7 +64,7 @@ static int ass_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, #if CONFIG_SSA_DECODER const FFCodec ff_ssa_decoder = { .p.name = "ssa", - .p.long_name = NULL_IF_CONFIG_SMALL("ASS (Advanced SubStation Alpha) subtitle"), + CODEC_LONG_NAME("ASS (Advanced SubStation Alpha) subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ASS, .init = ass_decode_init, @@ -75,7 +75,7 @@ const FFCodec ff_ssa_decoder = { #if CONFIG_ASS_DECODER const FFCodec ff_ass_decoder = { .p.name = "ass", - .p.long_name = NULL_IF_CONFIG_SMALL("ASS (Advanced SubStation Alpha) subtitle"), + CODEC_LONG_NAME("ASS (Advanced SubStation Alpha) subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ASS, .init = ass_decode_init, diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index b024b1b0ed..db6fd25dd7 100644 --- a/libavcodec/assenc.c +++ b/libavcodec/assenc.c @@ -71,7 +71,7 @@ static int ass_encode_frame(AVCodecContext *avctx, #if CONFIG_SSA_ENCODER const FFCodec ff_ssa_encoder = { .p.name = "ssa", - .p.long_name = NULL_IF_CONFIG_SMALL("ASS (Advanced SubStation Alpha) subtitle"), + CODEC_LONG_NAME("ASS (Advanced SubStation Alpha) subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ASS, .init = ass_encode_init, @@ -82,7 +82,7 @@ const FFCodec ff_ssa_encoder = { #if CONFIG_ASS_ENCODER const FFCodec ff_ass_encoder = { .p.name = "ass", - .p.long_name = NULL_IF_CONFIG_SMALL("ASS (Advanced SubStation Alpha) subtitle"), + CODEC_LONG_NAME("ASS (Advanced SubStation Alpha) subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ASS, .init = ass_encode_init, diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index 2105d55e33..c8c50cc8d4 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -330,7 +330,7 @@ static av_cold int decode_end(AVCodecContext *avctx) #if CONFIG_ASV1_DECODER const FFCodec ff_asv1_decoder = { .p.name = "asv1", - .p.long_name = NULL_IF_CONFIG_SMALL("ASUS V1"), + CODEC_LONG_NAME("ASUS V1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV1, .priv_data_size = sizeof(ASV1Context), @@ -344,7 +344,7 @@ const FFCodec ff_asv1_decoder = { #if CONFIG_ASV2_DECODER const FFCodec ff_asv2_decoder = { .p.name = "asv2", - .p.long_name = NULL_IF_CONFIG_SMALL("ASUS V2"), + CODEC_LONG_NAME("ASUS V2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV2, .priv_data_size = sizeof(ASV1Context), diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index 4f14cbdb64..25ea96e64e 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -345,7 +345,7 @@ static av_cold int encode_init(AVCodecContext *avctx) #if CONFIG_ASV1_ENCODER const FFCodec ff_asv1_encoder = { .p.name = "asv1", - .p.long_name = NULL_IF_CONFIG_SMALL("ASUS V1"), + CODEC_LONG_NAME("ASUS V1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV1, .p.capabilities = AV_CODEC_CAP_DR1, @@ -360,7 +360,7 @@ const FFCodec ff_asv1_encoder = { #if CONFIG_ASV2_ENCODER const FFCodec ff_asv2_encoder = { .p.name = "asv2", - .p.long_name = NULL_IF_CONFIG_SMALL("ASUS V2"), + CODEC_LONG_NAME("ASUS V2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ASV2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index 3b60cee259..fb83449c16 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -384,7 +384,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx) const FFCodec ff_atrac1_decoder = { .p.name = "atrac1", - .p.long_name = NULL_IF_CONFIG_SMALL("ATRAC1 (Adaptive TRansform Acoustic Coding)"), + CODEC_LONG_NAME("ATRAC1 (Adaptive TRansform Acoustic Coding)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ATRAC1, .priv_data_size = sizeof(AT1Ctx), diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 79260c8760..12ba55d34d 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -1016,7 +1016,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) const FFCodec ff_atrac3_decoder = { .p.name = "atrac3", - .p.long_name = NULL_IF_CONFIG_SMALL("ATRAC3 (Adaptive TRansform Acoustic Coding 3)"), + CODEC_LONG_NAME("ATRAC3 (Adaptive TRansform Acoustic Coding 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ATRAC3, .priv_data_size = sizeof(ATRAC3Context), @@ -1031,7 +1031,7 @@ const FFCodec ff_atrac3_decoder = { const FFCodec ff_atrac3al_decoder = { .p.name = "atrac3al", - .p.long_name = NULL_IF_CONFIG_SMALL("ATRAC3 AL (Adaptive TRansform Acoustic Coding 3 Advanced Lossless)"), + CODEC_LONG_NAME("ATRAC3 AL (Adaptive TRansform Acoustic Coding 3 Advanced Lossless)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ATRAC3AL, .priv_data_size = sizeof(ATRAC3Context), diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c index 771c213bad..ee71645a3c 100644 --- a/libavcodec/atrac3plusdec.c +++ b/libavcodec/atrac3plusdec.c @@ -392,7 +392,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_atrac3p_decoder = { .p.name = "atrac3plus", - .p.long_name = NULL_IF_CONFIG_SMALL("ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)"), + CODEC_LONG_NAME("ATRAC3+ (Adaptive TRansform Acoustic Coding 3+)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ATRAC3P, .p.capabilities = AV_CODEC_CAP_DR1, @@ -405,7 +405,7 @@ const FFCodec ff_atrac3p_decoder = { const FFCodec ff_atrac3pal_decoder = { .p.name = "atrac3plusal", - .p.long_name = NULL_IF_CONFIG_SMALL("ATRAC3+ AL (Adaptive TRansform Acoustic Coding 3+ Advanced Lossless)"), + CODEC_LONG_NAME("ATRAC3+ AL (Adaptive TRansform Acoustic Coding 3+ Advanced Lossless)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ATRAC3PAL, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index 71ff6e0151..d3a5d05799 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -989,7 +989,7 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx) const FFCodec ff_atrac9_decoder = { .p.name = "atrac9", - .p.long_name = NULL_IF_CONFIG_SMALL("ATRAC9 (Adaptive TRansform Acoustic Coding 9)"), + CODEC_LONG_NAME("ATRAC9 (Adaptive TRansform Acoustic Coding 9)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ATRAC9, .priv_data_size = sizeof(ATRAC9Context), diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 220101e9eb..82babe3d31 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -591,7 +591,7 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx) FFAT_DEC_CLASS(NAME) \ const FFCodec ff_##NAME##_at_decoder = { \ .p.name = #NAME "_at", \ - .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " (AudioToolbox)"), \ + CODEC_LONG_NAME(#NAME " (AudioToolbox)"), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = ID, \ .priv_data_size = sizeof(ATDecodeContext), \ diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index 7cb7ab6e7e..02a863bf03 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -616,7 +616,7 @@ static const AVOption options[] = { FFAT_ENC_CLASS(NAME) \ const FFCodec ff_##NAME##_at_encoder = { \ .p.name = #NAME "_at", \ - .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " (AudioToolbox)"), \ + CODEC_LONG_NAME(#NAME " (AudioToolbox)"), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = ID, \ .priv_data_size = sizeof(ATDecodeContext), \ diff --git a/libavcodec/aura.c b/libavcodec/aura.c index 938706629d..78914fe9f2 100644 --- a/libavcodec/aura.c +++ b/libavcodec/aura.c @@ -98,7 +98,7 @@ static int aura_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_aura2_decoder = { .p.name = "aura2", - .p.long_name = NULL_IF_CONFIG_SMALL("Auravision Aura 2"), + CODEC_LONG_NAME("Auravision Aura 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AURA2, .init = aura_decode_init, diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 401462701f..0c24eac842 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -1247,7 +1247,7 @@ static const AVClass av1_class = { const FFCodec ff_av1_decoder = { .p.name = "av1", - .p.long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media AV1"), + CODEC_LONG_NAME("Alliance for Open Media AV1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AV1, .priv_data_size = sizeof(AV1DecContext), diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index f0257cd860..ef194058fc 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -91,7 +91,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_avrn_decoder = { .p.name = "avrn", - .p.long_name = NULL_IF_CONFIG_SMALL("Avid AVI Codec"), + CODEC_LONG_NAME("Avid AVI Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVRN, .priv_data_size = sizeof(AVRnContext), diff --git a/libavcodec/avs.c b/libavcodec/avs.c index ca2b2d4701..a1c9d3c436 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -177,7 +177,7 @@ static av_cold int avs_decode_end(AVCodecContext *avctx) const FFCodec ff_avs_decoder = { .p.name = "avs", - .p.long_name = NULL_IF_CONFIG_SMALL("AVS (Audio Video Standard) video"), + CODEC_LONG_NAME("AVS (Audio Video Standard) video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVS, .priv_data_size = sizeof(AvsContext), diff --git a/libavcodec/avuidec.c b/libavcodec/avuidec.c index 9e698b02ec..ba157e167c 100644 --- a/libavcodec/avuidec.c +++ b/libavcodec/avuidec.c @@ -121,7 +121,7 @@ static int avui_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_avui_decoder = { .p.name = "avui", - .p.long_name = NULL_IF_CONFIG_SMALL("Avid Meridien Uncompressed"), + CODEC_LONG_NAME("Avid Meridien Uncompressed"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVUI, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c index 0357e682a9..0b82848cb3 100644 --- a/libavcodec/avuienc.c +++ b/libavcodec/avuienc.c @@ -93,7 +93,7 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_avui_encoder = { .p.name = "avui", - .p.long_name = NULL_IF_CONFIG_SMALL("Avid Meridien Uncompressed"), + CODEC_LONG_NAME("Avid Meridien Uncompressed"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVUI, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c index 4562053829..e095d04fa5 100644 --- a/libavcodec/bethsoftvideo.c +++ b/libavcodec/bethsoftvideo.c @@ -165,7 +165,7 @@ static av_cold int bethsoftvid_decode_end(AVCodecContext *avctx) const FFCodec ff_bethsoftvid_decoder = { .p.name = "bethsoftvid", - .p.long_name = NULL_IF_CONFIG_SMALL("Bethesda VID video"), + CODEC_LONG_NAME("Bethesda VID video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BETHSOFTVID, .priv_data_size = sizeof(BethsoftvidContext), diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index 9df5bcdf5e..2b647419c7 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -177,7 +177,7 @@ static av_cold int bfi_decode_close(AVCodecContext *avctx) const FFCodec ff_bfi_decoder = { .p.name = "bfi", - .p.long_name = NULL_IF_CONFIG_SMALL("Brute Force & Ignorance"), + CODEC_LONG_NAME("Brute Force & Ignorance"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BFI, .priv_data_size = sizeof(BFIContext), diff --git a/libavcodec/bink.c b/libavcodec/bink.c index c1960484d6..e43ff1f4fa 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1420,7 +1420,7 @@ static void flush(AVCodecContext *avctx) const FFCodec ff_bink_decoder = { .p.name = "binkvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Bink video"), + CODEC_LONG_NAME("Bink video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BINKVIDEO, .priv_data_size = sizeof(BinkContext), diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index 372c439691..43dca1f565 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -367,7 +367,7 @@ static void decode_flush(AVCodecContext *avctx) const FFCodec ff_binkaudio_rdft_decoder = { .p.name = "binkaudio_rdft", - .p.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)"), + CODEC_LONG_NAME("Bink Audio (RDFT)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_BINKAUDIO_RDFT, .priv_data_size = sizeof(BinkAudioContext), @@ -381,7 +381,7 @@ const FFCodec ff_binkaudio_rdft_decoder = { const FFCodec ff_binkaudio_dct_decoder = { .p.name = "binkaudio_dct", - .p.long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)"), + CODEC_LONG_NAME("Bink Audio (DCT)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_BINKAUDIO_DCT, .priv_data_size = sizeof(BinkAudioContext), diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c index c3cf14f6dd..ce814f7693 100644 --- a/libavcodec/bintext.c +++ b/libavcodec/bintext.c @@ -219,7 +219,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, #if CONFIG_BINTEXT_DECODER const FFCodec ff_bintext_decoder = { .p.name = "bintext", - .p.long_name = NULL_IF_CONFIG_SMALL("Binary text"), + CODEC_LONG_NAME("Binary text"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BINTEXT, .priv_data_size = sizeof(XbinContext), @@ -231,7 +231,7 @@ const FFCodec ff_bintext_decoder = { #if CONFIG_XBIN_DECODER const FFCodec ff_xbin_decoder = { .p.name = "xbin", - .p.long_name = NULL_IF_CONFIG_SMALL("eXtended BINary text"), + CODEC_LONG_NAME("eXtended BINary text"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XBIN, .priv_data_size = sizeof(XbinContext), @@ -243,7 +243,7 @@ const FFCodec ff_xbin_decoder = { #if CONFIG_IDF_DECODER const FFCodec ff_idf_decoder = { .p.name = "idf", - .p.long_name = NULL_IF_CONFIG_SMALL("iCEDraw text"), + CODEC_LONG_NAME("iCEDraw text"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_IDF, .priv_data_size = sizeof(XbinContext), diff --git a/libavcodec/bitpacked_dec.c b/libavcodec/bitpacked_dec.c index 8a375fe08b..a1ffef185c 100644 --- a/libavcodec/bitpacked_dec.c +++ b/libavcodec/bitpacked_dec.c @@ -143,7 +143,7 @@ static int bitpacked_decode(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_bitpacked_decoder = { .p.name = "bitpacked", - .p.long_name = NULL_IF_CONFIG_SMALL("Bitpacked"), + CODEC_LONG_NAME("Bitpacked"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BITPACKED, .p.capabilities = AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/bitpacked_enc.c b/libavcodec/bitpacked_enc.c index f3ddbb2a88..ca4d5c887d 100644 --- a/libavcodec/bitpacked_enc.c +++ b/libavcodec/bitpacked_enc.c @@ -106,7 +106,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_bitpacked_encoder = { .p.name = "bitpacked", - .p.long_name = NULL_IF_CONFIG_SMALL("Bitpacked"), + CODEC_LONG_NAME("Bitpacked"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BITPACKED, .priv_data_size = sizeof(struct BitpackedContext), diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index d381eb2eee..d7e01f0725 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -366,7 +366,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_bmp_decoder = { .p.name = "bmp", - .p.long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), + CODEC_LONG_NAME("BMP (Windows and OS/2 bitmap)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BMP, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index 964f7cc2ad..abf644bd99 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -158,7 +158,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_bmp_encoder = { .p.name = "bmp", - .p.long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), + CODEC_LONG_NAME("BMP (Windows and OS/2 bitmap)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BMP, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/bmvaudio.c b/libavcodec/bmvaudio.c index d772f72d71..fc211732bb 100644 --- a/libavcodec/bmvaudio.c +++ b/libavcodec/bmvaudio.c @@ -80,7 +80,7 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_bmv_audio_decoder = { .p.name = "bmv_audio", - .p.long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV audio"), + CODEC_LONG_NAME("Discworld II BMV audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_BMV_AUDIO, .init = bmv_aud_decode_init, diff --git a/libavcodec/bmvvideo.c b/libavcodec/bmvvideo.c index 6a55d49494..92ce41c836 100644 --- a/libavcodec/bmvvideo.c +++ b/libavcodec/bmvvideo.c @@ -287,7 +287,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_bmv_video_decoder = { .p.name = "bmv_video", - .p.long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV video"), + CODEC_LONG_NAME("Discworld II BMV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BMV_VIDEO, .priv_data_size = sizeof(BMVDecContext), diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c index 170acc39a3..e95ab3d4af 100644 --- a/libavcodec/brenderpix.c +++ b/libavcodec/brenderpix.c @@ -286,7 +286,7 @@ static int pix_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_brender_pix_decoder = { .p.name = "brender_pix", - .p.long_name = NULL_IF_CONFIG_SMALL("BRender PIX image"), + CODEC_LONG_NAME("BRender PIX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_BRENDER_PIX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 03381f1e88..66b551a5d6 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -260,7 +260,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_c93_decoder = { .p.name = "c93", - .p.long_name = NULL_IF_CONFIG_SMALL("Interplay C93"), + CODEC_LONG_NAME("Interplay C93"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_C93, .priv_data_size = sizeof(C93DecoderContext), diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 3d4e306c93..3e8be65968 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -1317,7 +1317,7 @@ static int cavs_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_cavs_decoder = { .p.name = "cavs", - .p.long_name = NULL_IF_CONFIG_SMALL("Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)"), + CODEC_LONG_NAME("Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CAVS, .priv_data_size = sizeof(AVSContext), diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index 13648ff306..61eda9ff56 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -946,7 +946,7 @@ static const AVClass ccaption_dec_class = { const FFCodec ff_ccaption_decoder = { .p.name = "cc_dec", - .p.long_name = NULL_IF_CONFIG_SMALL("Closed Caption (EIA-608 / CEA-708)"), + CODEC_LONG_NAME("Closed Caption (EIA-608 / CEA-708)"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_EIA_608, .p.priv_class = &ccaption_dec_class, diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 19366bdcfe..51363b6be2 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -389,7 +389,7 @@ static av_cold int cdg_decode_end(AVCodecContext *avctx) const FFCodec ff_cdgraphics_decoder = { .p.name = "cdgraphics", - .p.long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"), + CODEC_LONG_NAME("CD Graphics video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CDGRAPHICS, .priv_data_size = sizeof(CDGraphicsContext), diff --git a/libavcodec/cdtoons.c b/libavcodec/cdtoons.c index 00fbe58c26..3ebed2267c 100644 --- a/libavcodec/cdtoons.c +++ b/libavcodec/cdtoons.c @@ -445,7 +445,7 @@ static av_cold int cdtoons_decode_end(AVCodecContext *avctx) const FFCodec ff_cdtoons_decoder = { .p.name = "cdtoons", - .p.long_name = NULL_IF_CONFIG_SMALL("CDToons video"), + CODEC_LONG_NAME("CDToons video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CDTOONS, .priv_data_size = sizeof(CDToonsContext), diff --git a/libavcodec/cdxl.c b/libavcodec/cdxl.c index 5821aaeb22..6b3b3e85e0 100644 --- a/libavcodec/cdxl.c +++ b/libavcodec/cdxl.c @@ -337,7 +337,7 @@ static av_cold int cdxl_decode_end(AVCodecContext *avctx) const FFCodec ff_cdxl_decoder = { .p.name = "cdxl", - .p.long_name = NULL_IF_CONFIG_SMALL("Commodore CDXL video"), + CODEC_LONG_NAME("Commodore CDXL video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CDXL, .priv_data_size = sizeof(CDXLVideoContext), diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index e72512707e..59f8c795a2 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -1457,7 +1457,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) const FFCodec ff_cfhd_decoder = { .p.name = "cfhd", - .p.long_name = NULL_IF_CONFIG_SMALL("GoPro CineForm HD"), + CODEC_LONG_NAME("GoPro CineForm HD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CFHD, .priv_data_size = sizeof(CFHDContext), diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c index 75858624b4..0fca46ef3a 100644 --- a/libavcodec/cfhdenc.c +++ b/libavcodec/cfhdenc.c @@ -848,7 +848,7 @@ static const AVClass cfhd_class = { const FFCodec ff_cfhd_encoder = { .p.name = "cfhd", - .p.long_name = NULL_IF_CONFIG_SMALL("GoPro CineForm HD"), + CODEC_LONG_NAME("GoPro CineForm HD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CFHD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 480afbc81d..282614fd1d 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -506,7 +506,7 @@ static av_cold int cinepak_decode_end(AVCodecContext *avctx) const FFCodec ff_cinepak_decoder = { .p.name = "cinepak", - .p.long_name = NULL_IF_CONFIG_SMALL("Cinepak"), + CODEC_LONG_NAME("Cinepak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CINEPAK, .priv_data_size = sizeof(CinepakContext), diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c index bff6833ceb..c05449e89c 100644 --- a/libavcodec/cinepakenc.c +++ b/libavcodec/cinepakenc.c @@ -1216,7 +1216,7 @@ static av_cold int cinepak_encode_end(AVCodecContext *avctx) const FFCodec ff_cinepak_encoder = { .p.name = "cinepak", - .p.long_name = NULL_IF_CONFIG_SMALL("Cinepak"), + CODEC_LONG_NAME("Cinepak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CINEPAK, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c index 8615bf2a51..4d6549560b 100644 --- a/libavcodec/clearvideo.c +++ b/libavcodec/clearvideo.c @@ -769,7 +769,7 @@ static av_cold int clv_decode_end(AVCodecContext *avctx) const FFCodec ff_clearvideo_decoder = { .p.name = "clearvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Iterated Systems ClearVideo"), + CODEC_LONG_NAME("Iterated Systems ClearVideo"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CLEARVIDEO, .priv_data_size = sizeof(CLVContext), diff --git a/libavcodec/cljrdec.c b/libavcodec/cljrdec.c index 0550e1dc05..914f853c8f 100644 --- a/libavcodec/cljrdec.c +++ b/libavcodec/cljrdec.c @@ -83,7 +83,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_cljr_decoder = { .p.name = "cljr", - .p.long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), + CODEC_LONG_NAME("Cirrus Logic AccuPak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CLJR, .init = decode_init, diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c index f84191b427..c1f8810a5a 100644 --- a/libavcodec/cljrenc.c +++ b/libavcodec/cljrenc.c @@ -110,7 +110,7 @@ static const AVClass cljr_class = { const FFCodec ff_cljr_encoder = { .p.name = "cljr", - .p.long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), + CODEC_LONG_NAME("Cirrus Logic AccuPak"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CLJR, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/cllc.c b/libavcodec/cllc.c index 1b9fdb80f0..911717b68d 100644 --- a/libavcodec/cllc.c +++ b/libavcodec/cllc.c @@ -493,7 +493,7 @@ static av_cold int cllc_decode_init(AVCodecContext *avctx) const FFCodec ff_cllc_decoder = { .p.name = "cllc", - .p.long_name = NULL_IF_CONFIG_SMALL("Canopus Lossless Codec"), + CODEC_LONG_NAME("Canopus Lossless Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CLLC, .priv_data_size = sizeof(CLLCContext), diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c index e698d142dd..5cf5dc9bcf 100644 --- a/libavcodec/cngdec.c +++ b/libavcodec/cngdec.c @@ -165,7 +165,7 @@ static int cng_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_comfortnoise_decoder = { .p.name = "comfortnoise", - .p.long_name = NULL_IF_CONFIG_SMALL("RFC 3389 comfort noise generator"), + CODEC_LONG_NAME("RFC 3389 comfort noise generator"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_COMFORT_NOISE, .priv_data_size = sizeof(CNGContext), diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index 7bb4bee857..ff40017f0d 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -98,7 +98,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_comfortnoise_encoder = { .p.name = "comfortnoise", - .p.long_name = NULL_IF_CONFIG_SMALL("RFC 3389 comfort noise generator"), + CODEC_LONG_NAME("RFC 3389 comfort noise generator"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_COMFORT_NOISE, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 62ea91cf4d..310e243d84 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -23,6 +23,7 @@ #include "libavutil/attributes.h" #include "codec.h" +#include "config.h" /** * The codec is not known to be init-threadsafe (i.e. it might be unsafe @@ -257,6 +258,12 @@ typedef struct FFCodec { const uint32_t *codec_tags; } FFCodec; +#if CONFIG_SMALL +#define CODEC_LONG_NAME(str) .p.long_name = NULL +#else +#define CODEC_LONG_NAME(str) .p.long_name = str +#endif + #define FF_CODEC_DECODE_CB(func) \ .cb_type = FF_CODEC_CB_TYPE_DECODE, \ .cb.decode = (func) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 5ccabb03ed..7c666f5cfe 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1298,7 +1298,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) const FFCodec ff_cook_decoder = { .p.name = "cook", - .p.long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"), + CODEC_LONG_NAME("Cook / Cooker / Gecko (RealAudio G2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_COOK, .priv_data_size = sizeof(COOKContext), diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c index c798038161..99362e73f0 100644 --- a/libavcodec/cpia.c +++ b/libavcodec/cpia.c @@ -224,7 +224,7 @@ static av_cold int cpia_decode_end(AVCodecContext *avctx) const FFCodec ff_cpia_decoder = { .p.name = "cpia", - .p.long_name = NULL_IF_CONFIG_SMALL("CPiA video format"), + CODEC_LONG_NAME("CPiA video format"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CPIA, .priv_data_size = sizeof(CpiaContext), diff --git a/libavcodec/cri.c b/libavcodec/cri.c index 65eb53d22e..ec5c88f897 100644 --- a/libavcodec/cri.c +++ b/libavcodec/cri.c @@ -433,5 +433,5 @@ const FFCodec ff_cri_decoder = { .close = cri_decode_close, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, - .p.long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"), + CODEC_LONG_NAME("Cintel RAW"), }; diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c index bdc2ecc116..8673a491d4 100644 --- a/libavcodec/crystalhd.c +++ b/libavcodec/crystalhd.c @@ -776,7 +776,7 @@ static int crystalhd_receive_frame(AVCodecContext *avctx, AVFrame *frame) }; \ const FFCodec ff_##x##_crystalhd_decoder = { \ .p.name = #x "_crystalhd", \ - .p.long_name = NULL_IF_CONFIG_SMALL("CrystalHD " #X " decoder"), \ + CODEC_LONG_NAME("CrystalHD " #X " decoder"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = AV_CODEC_ID_##X, \ .priv_data_size = sizeof(CHDContext), \ diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c index 51756b6d12..b4ed3332a9 100644 --- a/libavcodec/cscd.c +++ b/libavcodec/cscd.c @@ -167,7 +167,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_cscd_decoder = { .p.name = "camstudio", - .p.long_name = NULL_IF_CONFIG_SMALL("CamStudio"), + CODEC_LONG_NAME("CamStudio"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CSCD, .priv_data_size = sizeof(CamStudioContext), diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 82c40fc64e..4ba7918b64 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -1118,7 +1118,7 @@ static const AVCodecHWConfigInternal *const cuvid_hw_configs[] = { }; \ const FFCodec ff_##x##_cuvid_decoder = { \ .p.name = #x "_cuvid", \ - .p.long_name = NULL_IF_CONFIG_SMALL("Nvidia CUVID " #X " decoder"), \ + CODEC_LONG_NAME("Nvidia CUVID " #X " decoder"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = AV_CODEC_ID_##X, \ .priv_data_size = sizeof(CuvidContext), \ diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c index 8a7cef6b74..f233b362dc 100644 --- a/libavcodec/cyuv.c +++ b/libavcodec/cyuv.c @@ -177,7 +177,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, AVFrame *frame, #if CONFIG_AURA_DECODER const FFCodec ff_aura_decoder = { .p.name = "aura", - .p.long_name = NULL_IF_CONFIG_SMALL("Auravision AURA"), + CODEC_LONG_NAME("Auravision AURA"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AURA, .priv_data_size = sizeof(CyuvDecodeContext), @@ -190,7 +190,7 @@ const FFCodec ff_aura_decoder = { #if CONFIG_CYUV_DECODER const FFCodec ff_cyuv_decoder = { .p.name = "cyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("Creative YUV (CYUV)"), + CODEC_LONG_NAME("Creative YUV (CYUV)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CYUV, .priv_data_size = sizeof(CyuvDecodeContext), diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 46d3650b25..3e3e3053bb 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -412,7 +412,7 @@ static const AVClass dcadec_class = { const FFCodec ff_dca_decoder = { .p.name = "dca", - .p.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), + CODEC_LONG_NAME("DCA (DTS Coherent Acoustics)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DTS, .priv_data_size = sizeof(DCAContext), diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 6901e67860..d02602761b 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -1238,7 +1238,7 @@ static const FFCodecDefault defaults[] = { const FFCodec ff_dca_encoder = { .p.name = "dca", - .p.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), + CODEC_LONG_NAME("DCA (DTS Coherent Acoustics)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DTS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 6904191310..4bb425dbb3 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -710,7 +710,7 @@ static int dds_decode(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_dds_decoder = { .p.name = "dds", - .p.long_name = NULL_IF_CONFIG_SMALL("DirectDraw Surface image decoder"), + CODEC_LONG_NAME("DirectDraw Surface image decoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DDS, FF_CODEC_DECODE_CB(dds_decode), diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c index dadb64d87e..114c803f32 100644 --- a/libavcodec/dfa.c +++ b/libavcodec/dfa.c @@ -423,7 +423,7 @@ static av_cold int dfa_decode_end(AVCodecContext *avctx) const FFCodec ff_dfa_decoder = { .p.name = "dfa", - .p.long_name = NULL_IF_CONFIG_SMALL("Chronomaster DFA"), + CODEC_LONG_NAME("Chronomaster DFA"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DFA, .priv_data_size = sizeof(DfaContext), diff --git a/libavcodec/dfpwmdec.c b/libavcodec/dfpwmdec.c index 975afba4cc..532a955b4c 100644 --- a/libavcodec/dfpwmdec.c +++ b/libavcodec/dfpwmdec.c @@ -127,7 +127,7 @@ static int dfpwm_dec_frame(struct AVCodecContext *ctx, AVFrame *frame, const FFCodec ff_dfpwm_decoder = { .p.name = "dfpwm", - .p.long_name = NULL_IF_CONFIG_SMALL("DFPWM1a audio"), + CODEC_LONG_NAME("DFPWM1a audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DFPWM, .priv_data_size = sizeof(DFPWMState), diff --git a/libavcodec/dfpwmenc.c b/libavcodec/dfpwmenc.c index 41ad645315..7f465a446e 100644 --- a/libavcodec/dfpwmenc.c +++ b/libavcodec/dfpwmenc.c @@ -109,7 +109,7 @@ static int dfpwm_enc_frame(struct AVCodecContext *ctx, struct AVPacket *packet, const FFCodec ff_dfpwm_encoder = { .p.name = "dfpwm", - .p.long_name = NULL_IF_CONFIG_SMALL("DFPWM1a audio"), + CODEC_LONG_NAME("DFPWM1a audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DFPWM, .priv_data_size = sizeof(DFPWMState), diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index ef00c29150..a5cad29597 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -2357,7 +2357,7 @@ static int dirac_decode_frame(AVCodecContext *avctx, AVFrame *picture, const FFCodec ff_dirac_decoder = { .p.name = "dirac", - .p.long_name = NULL_IF_CONFIG_SMALL("BBC Dirac VC-2"), + CODEC_LONG_NAME("BBC Dirac VC-2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DIRAC, .priv_data_size = sizeof(DiracContext), diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 1c749d026c..17b7179927 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -726,7 +726,7 @@ static av_cold int dnxhd_decode_close(AVCodecContext *avctx) const FFCodec ff_dnxhd_decoder = { .p.name = "dnxhd", - .p.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), + CODEC_LONG_NAME("VC3/DNxHD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DNXHD, .priv_data_size = sizeof(DNXHDContext), diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 5029e510ef..e1008ec776 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -1355,7 +1355,7 @@ static const FFCodecDefault dnxhd_defaults[] = { const FFCodec ff_dnxhd_encoder = { .p.name = "dnxhd", - .p.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), + CODEC_LONG_NAME("VC3/DNxHD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DNXHD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index de852ecc0a..06f4fdd44f 100644 --- a/libavcodec/dolby_e.c +++ b/libavcodec/dolby_e.c @@ -1299,7 +1299,7 @@ static const AVClass dolby_e_decoder_class = { const FFCodec ff_dolby_e_decoder = { .p.name = "dolby_e", - .p.long_name = NULL_IF_CONFIG_SMALL("Dolby E"), + CODEC_LONG_NAME("Dolby E"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DOLBY_E, .priv_data_size = sizeof(DBEDecodeContext), diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index 34f3799b80..2425f84eb9 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -411,7 +411,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, #define DPCM_DECODER(id_, name_, long_name_) \ const FFCodec ff_ ## name_ ## _decoder = { \ .p.name = #name_, \ - .p.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = id_, \ .p.capabilities = AV_CODEC_CAP_DR1, \ diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index afd9f17b04..4f50608461 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -761,7 +761,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_dpx_decoder = { .p.name = "dpx", - .p.long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"), + CODEC_LONG_NAME("DPX (Digital Picture Exchange) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DPX, FF_CODEC_DECODE_CB(decode_frame), diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index c261d05fe2..e136cc1b9e 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -276,7 +276,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_dpx_encoder = { .p.name = "dpx", - .p.long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"), + CODEC_LONG_NAME("DPX (Digital Picture Exchange) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DPX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c index 0fdc2af565..3962075773 100644 --- a/libavcodec/dsddec.c +++ b/libavcodec/dsddec.c @@ -118,7 +118,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, #define DSD_DECODER(id_, name_, long_name_) \ const FFCodec ff_ ## name_ ## _decoder = { \ .p.name = #name_, \ - .p.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = AV_CODEC_ID_##id_, \ .init = decode_init, \ diff --git a/libavcodec/dsicinaudio.c b/libavcodec/dsicinaudio.c index ea37e68ea2..aa14966c7b 100644 --- a/libavcodec/dsicinaudio.c +++ b/libavcodec/dsicinaudio.c @@ -123,7 +123,7 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_dsicinaudio_decoder = { .p.name = "dsicinaudio", - .p.long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"), + CODEC_LONG_NAME("Delphine Software International CIN audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DSICINAUDIO, .priv_data_size = sizeof(CinAudioContext), diff --git a/libavcodec/dsicinvideo.c b/libavcodec/dsicinvideo.c index 32efefade1..222044d125 100644 --- a/libavcodec/dsicinvideo.c +++ b/libavcodec/dsicinvideo.c @@ -323,7 +323,7 @@ static av_cold int cinvideo_decode_end(AVCodecContext *avctx) const FFCodec ff_dsicinvideo_decoder = { .p.name = "dsicinvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN video"), + CODEC_LONG_NAME("Delphine Software International CIN video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DSICINVIDEO, .priv_data_size = sizeof(CinVideoContext), diff --git a/libavcodec/dss_sp.c b/libavcodec/dss_sp.c index 74419514d4..9337371bce 100644 --- a/libavcodec/dss_sp.c +++ b/libavcodec/dss_sp.c @@ -773,7 +773,7 @@ static int dss_sp_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_dss_sp_decoder = { .p.name = "dss_sp", - .p.long_name = NULL_IF_CONFIG_SMALL("Digital Speech Standard - Standard Play mode (DSS SP)"), + CODEC_LONG_NAME("Digital Speech Standard - Standard Play mode (DSS SP)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DSS_SP, .priv_data_size = sizeof(DssSpContext), diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c index 59f8e900d8..6bdd6c885c 100644 --- a/libavcodec/dstdec.c +++ b/libavcodec/dstdec.c @@ -380,7 +380,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_dst_decoder = { .p.name = "dst", - .p.long_name = NULL_IF_CONFIG_SMALL("DST (Digital Stream Transfer)"), + CODEC_LONG_NAME("DST (Digital Stream Transfer)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DST, .priv_data_size = sizeof(DSTContext), diff --git a/libavcodec/dvaudiodec.c b/libavcodec/dvaudiodec.c index 96bcadeb57..1c8344095a 100644 --- a/libavcodec/dvaudiodec.c +++ b/libavcodec/dvaudiodec.c @@ -120,7 +120,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_dvaudio_decoder = { .p.name = "dvaudio", - .p.long_name = NULL_IF_CONFIG_SMALL("Ulead DV Audio"), + CODEC_LONG_NAME("Ulead DV Audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_DVAUDIO, .init = decode_init, diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 63d4a13bcb..bcc607d1d7 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1571,7 +1571,7 @@ static const AVClass dvbsubdec_class = { const FFCodec ff_dvbsub_decoder = { .p.name = "dvbsub", - .p.long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), + CODEC_LONG_NAME("DVB subtitles"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_DVB_SUBTITLE, .priv_data_size = sizeof(DVBSubContext), diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c index 06087b058d..822e3a5309 100644 --- a/libavcodec/dvbsubenc.c +++ b/libavcodec/dvbsubenc.c @@ -508,7 +508,7 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t *outbuf, int buf_size, const FFCodec ff_dvbsub_encoder = { .p.name = "dvbsub", - .p.long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), + CODEC_LONG_NAME("DVB subtitles"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_DVB_SUBTITLE, .priv_data_size = sizeof(DVBSubtitleContext), diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 12e837c9ff..3af3e82eab 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -681,7 +681,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_dvvideo_decoder = { .p.name = "dvvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), + CODEC_LONG_NAME("DV (Digital Video)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DVVIDEO, .priv_data_size = sizeof(DVVideoContext), diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index e1ae441880..a5da0d7b08 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -708,7 +708,7 @@ static const AVClass dvdsub_class = { const FFCodec ff_dvdsub_decoder = { .p.name = "dvdsub", - .p.long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"), + CODEC_LONG_NAME("DVD subtitles"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_DVD_SUBTITLE, .priv_data_size = sizeof(DVDSubContext), diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index 37d6efdd5d..0874aaa02d 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -502,7 +502,7 @@ static const AVClass dvdsubenc_class = { const FFCodec ff_dvdsub_encoder = { .p.name = "dvdsub", - .p.long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"), + CODEC_LONG_NAME("DVD subtitles"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_DVD_SUBTITLE, .init = dvdsub_init, diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 5ba4de3213..78328f544c 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -1207,7 +1207,7 @@ static const AVClass dvvideo_encode_class = { const FFCodec ff_dvvideo_encoder = { .p.name = "dvvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), + CODEC_LONG_NAME("DV (Digital Video)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DVVIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | diff --git a/libavcodec/dxa.c b/libavcodec/dxa.c index a557501104..8d2d2d771b 100644 --- a/libavcodec/dxa.c +++ b/libavcodec/dxa.c @@ -360,7 +360,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_dxa_decoder = { .p.name = "dxa", - .p.long_name = NULL_IF_CONFIG_SMALL("Feeble Files/ScummVM DXA"), + CODEC_LONG_NAME("Feeble Files/ScummVM DXA"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DXA, .priv_data_size = sizeof(DxaDecContext), diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c index b7dfff4755..e13d274862 100644 --- a/libavcodec/dxtory.c +++ b/libavcodec/dxtory.c @@ -872,7 +872,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_dxtory_decoder = { .p.name = "dxtory", - .p.long_name = NULL_IF_CONFIG_SMALL("Dxtory"), + CODEC_LONG_NAME("Dxtory"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DXTORY, FF_CODEC_DECODE_CB(decode_frame), diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c index 13c028d8ba..7c84874229 100644 --- a/libavcodec/dxv.c +++ b/libavcodec/dxv.c @@ -1262,7 +1262,7 @@ static int dxv_close(AVCodecContext *avctx) const FFCodec ff_dxv_decoder = { .p.name = "dxv", - .p.long_name = NULL_IF_CONFIG_SMALL("Resolume DXV"), + CODEC_LONG_NAME("Resolume DXV"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DXV, .init = dxv_init, diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 9f8704450a..648c93dcaa 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -252,7 +252,7 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_eac3_encoder = { .p.name = "eac3", - .p.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"), + CODEC_LONG_NAME("ATSC A/52 E-AC-3"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_EAC3, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/eacmv.c b/libavcodec/eacmv.c index e8d757ed37..18f27dfdf0 100644 --- a/libavcodec/eacmv.c +++ b/libavcodec/eacmv.c @@ -231,7 +231,7 @@ static av_cold int cmv_decode_end(AVCodecContext *avctx){ const FFCodec ff_eacmv_decoder = { .p.name = "eacmv", - .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts CMV video"), + CODEC_LONG_NAME("Electronic Arts CMV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CMV, .priv_data_size = sizeof(CmvContext), diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 4904730c65..7ce2ce36c8 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -342,7 +342,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_eamad_decoder = { .p.name = "eamad", - .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts Madcow Video"), + CODEC_LONG_NAME("Electronic Arts Madcow Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MAD, .priv_data_size = sizeof(MadContext), diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index bdf70292fd..a6c3e72f85 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -248,7 +248,7 @@ static int tgq_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_eatgq_decoder = { .p.name = "eatgq", - .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGQ video"), + CODEC_LONG_NAME("Electronic Arts TGQ video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TGQ, .priv_data_size = sizeof(TgqContext), diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index 02a547b2da..29f7ee12f5 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -359,7 +359,7 @@ static av_cold int tgv_decode_end(AVCodecContext *avctx) const FFCodec ff_eatgv_decoder = { .p.name = "eatgv", - .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGV video"), + CODEC_LONG_NAME("Electronic Arts TGV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TGV, .priv_data_size = sizeof(TgvContext), diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 1aafd9af0c..4799f75886 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -183,7 +183,7 @@ static av_cold int tqi_decode_end(AVCodecContext *avctx) const FFCodec ff_eatqi_decoder = { .p.name = "eatqi", - .p.long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TQI Video"), + CODEC_LONG_NAME("Electronic Arts TQI Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TQI, .priv_data_size = sizeof(TqiContext), diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 6906992305..eeeb9bb0f7 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -377,7 +377,7 @@ static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_escape124_decoder = { .p.name = "escape124", - .p.long_name = NULL_IF_CONFIG_SMALL("Escape 124"), + CODEC_LONG_NAME("Escape 124"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ESCAPE124, .priv_data_size = sizeof(Escape124Context), diff --git a/libavcodec/escape130.c b/libavcodec/escape130.c index 5bf1a5d745..3b0460fd79 100644 --- a/libavcodec/escape130.c +++ b/libavcodec/escape130.c @@ -347,7 +347,7 @@ static int escape130_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_escape130_decoder = { .p.name = "escape130", - .p.long_name = NULL_IF_CONFIG_SMALL("Escape 130"), + CODEC_LONG_NAME("Escape 130"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ESCAPE130, .priv_data_size = sizeof(Escape130Context), diff --git a/libavcodec/evrcdec.c b/libavcodec/evrcdec.c index 2ac98b8e76..c4b0ad2957 100644 --- a/libavcodec/evrcdec.c +++ b/libavcodec/evrcdec.c @@ -931,7 +931,7 @@ static const AVClass evrcdec_class = { const FFCodec ff_evrc_decoder = { .p.name = "evrc", - .p.long_name = NULL_IF_CONFIG_SMALL("EVRC (Enhanced Variable Rate Codec)"), + CODEC_LONG_NAME("EVRC (Enhanced Variable Rate Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_EVRC, .init = evrc_decode_init, diff --git a/libavcodec/exr.c b/libavcodec/exr.c index f6eab048f4..235f6fa6cd 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -2335,7 +2335,7 @@ static const AVClass exr_class = { const FFCodec ff_exr_decoder = { .p.name = "exr", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"), + CODEC_LONG_NAME("OpenEXR image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_EXR, .priv_data_size = sizeof(EXRContext), diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c index 3dad107d62..10ed876888 100644 --- a/libavcodec/exrenc.c +++ b/libavcodec/exrenc.c @@ -542,7 +542,7 @@ static const AVClass exr_class = { const FFCodec ff_exr_encoder = { .p.name = "exr", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenEXR image"), + CODEC_LONG_NAME("OpenEXR image"), .priv_data_size = sizeof(EXRContext), .p.priv_class = &exr_class, .p.type = AVMEDIA_TYPE_VIDEO, diff --git a/libavcodec/fastaudio.c b/libavcodec/fastaudio.c index 262e2bea7c..f5569f5206 100644 --- a/libavcodec/fastaudio.c +++ b/libavcodec/fastaudio.c @@ -186,7 +186,7 @@ static av_cold int fastaudio_close(AVCodecContext *avctx) const FFCodec ff_fastaudio_decoder = { .p.name = "fastaudio", - .p.long_name = NULL_IF_CONFIG_SMALL("MobiClip FastAudio"), + CODEC_LONG_NAME("MobiClip FastAudio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_FASTAUDIO, .priv_data_size = sizeof(FastAudioContext), diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index fd549c7913..2fc8941362 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1070,7 +1070,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) const FFCodec ff_ffv1_decoder = { .p.name = "ffv1", - .p.long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), + CODEC_LONG_NAME("FFmpeg video codec #1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFV1, .priv_data_size = sizeof(FFV1Context), diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 422bc1d231..0237ac48eb 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1268,7 +1268,7 @@ static const AVClass ffv1_class = { const FFCodec ff_ffv1_encoder = { .p.name = "ffv1", - .p.long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), + CODEC_LONG_NAME("FFmpeg video codec #1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFV1, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index 728650b057..b932326fd0 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -461,7 +461,7 @@ static av_cold int wavesynth_close(AVCodecContext *avc) const FFCodec ff_ffwavesynth_decoder = { .p.name = "wavesynth", - .p.long_name = NULL_IF_CONFIG_SMALL("Wave synthesis pseudo-codec"), + CODEC_LONG_NAME("Wave synthesis pseudo-codec"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_FFWAVESYNTH, .priv_data_size = sizeof(struct wavesynth_context), diff --git a/libavcodec/fic.c b/libavcodec/fic.c index cb536cf36e..94cf42887f 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -486,7 +486,7 @@ static const AVClass fic_decoder_class = { const FFCodec ff_fic_decoder = { .p.name = "fic", - .p.long_name = NULL_IF_CONFIG_SMALL("Mirillis FIC"), + CODEC_LONG_NAME("Mirillis FIC"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FIC, .priv_data_size = sizeof(FICContext), diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c index 7e45f2a65f..b9c51e70c3 100644 --- a/libavcodec/fitsdec.c +++ b/libavcodec/fitsdec.c @@ -326,7 +326,7 @@ const FFCodec ff_fits_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FITS, .p.capabilities = AV_CODEC_CAP_DR1, - .p.long_name = NULL_IF_CONFIG_SMALL("Flexible Image Transport System"), + CODEC_LONG_NAME("Flexible Image Transport System"), .p.priv_class = &fits_decoder_class, .priv_data_size = sizeof(FITSContext), FF_CODEC_DECODE_CB(fits_decode_frame), diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c index 30395b0a43..ac910499e5 100644 --- a/libavcodec/fitsenc.c +++ b/libavcodec/fitsenc.c @@ -111,7 +111,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_fits_encoder = { .p.name = "fits", - .p.long_name = NULL_IF_CONFIG_SMALL("Flexible Image Transport System"), + CODEC_LONG_NAME("Flexible Image Transport System"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FITS, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index c5d9e95168..075d76bc8a 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -653,7 +653,7 @@ static const AVClass flac_decoder_class = { const FFCodec ff_flac_decoder = { .p.name = "flac", - .p.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), + CODEC_LONG_NAME("FLAC (Free Lossless Audio Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_FLAC, .priv_data_size = sizeof(FLACContext), diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 0170e02ae8..5d8c3f82be 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -1486,7 +1486,7 @@ static const AVClass flac_encoder_class = { const FFCodec ff_flac_encoder = { .p.name = "flac", - .p.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), + CODEC_LONG_NAME("FLAC (Free Lossless Audio Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_FLAC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 76459df4cb..8a01e3a4b6 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -502,7 +502,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, AVFrame *rframe, #if CONFIG_FLASHSV_DECODER const FFCodec ff_flashsv_decoder = { .p.name = "flashsv", - .p.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v1"), + CODEC_LONG_NAME("Flash Screen Video v1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV, .priv_data_size = sizeof(FlashSVContext), @@ -570,7 +570,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext *avctx) const FFCodec ff_flashsv2_decoder = { .p.name = "flashsv2", - .p.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v2"), + CODEC_LONG_NAME("Flash Screen Video v2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV2, .priv_data_size = sizeof(FlashSVContext), diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index a924092c52..668ca6a85f 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -912,7 +912,7 @@ static av_cold int flashsv2_encode_end(AVCodecContext * avctx) const FFCodec ff_flashsv2_encoder = { .p.name = "flashsv2", - .p.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video Version 2"), + CODEC_LONG_NAME("Flash Screen Video Version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index e6c9f640ae..35793400fa 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -258,7 +258,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_flashsv_encoder = { .p.name = "flashsv", - .p.long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video"), + CODEC_LONG_NAME("Flash Screen Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLASHSV, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index e141d90a37..228f652775 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -1104,7 +1104,7 @@ static av_cold int flic_decode_end(AVCodecContext *avctx) const FFCodec ff_flic_decoder = { .p.name = "flic", - .p.long_name = NULL_IF_CONFIG_SMALL("Autodesk Animator Flic video"), + CODEC_LONG_NAME("Autodesk Animator Flic video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLIC, .priv_data_size = sizeof(FlicDecodeContext), diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index a9910482a9..87c5e923ea 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -115,7 +115,7 @@ int ff_flv_decode_picture_header(MpegEncContext *s) const FFCodec ff_flv_decoder = { .p.name = "flv", - .p.long_name = NULL_IF_CONFIG_SMALL("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"), + CODEC_LONG_NAME("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLV1, .priv_data_size = sizeof(MpegEncContext), diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 453182b109..b49ca2e0d5 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -94,7 +94,7 @@ void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, const FFCodec ff_flv_encoder = { .p.name = "flv", - .p.long_name = NULL_IF_CONFIG_SMALL("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"), + CODEC_LONG_NAME("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FLV1, .p.priv_class = &ff_mpv_enc_class, diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c index b3a4e7184c..863c65c351 100644 --- a/libavcodec/fmvc.c +++ b/libavcodec/fmvc.c @@ -627,7 +627,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_fmvc_decoder = { .p.name = "fmvc", - .p.long_name = NULL_IF_CONFIG_SMALL("FM Screen Capture Codec"), + CODEC_LONG_NAME("FM Screen Capture Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FMVC, .priv_data_size = sizeof(FMVCContext), diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 92a1963d12..9c8cbf7323 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -341,7 +341,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_fraps_decoder = { .p.name = "fraps", - .p.long_name = NULL_IF_CONFIG_SMALL("Fraps"), + CODEC_LONG_NAME("Fraps"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FRAPS, .priv_data_size = sizeof(FrapsContext), diff --git a/libavcodec/frwu.c b/libavcodec/frwu.c index 225667b4c4..cf183f8410 100644 --- a/libavcodec/frwu.c +++ b/libavcodec/frwu.c @@ -117,7 +117,7 @@ static const AVClass frwu_class = { const FFCodec ff_frwu_decoder = { .p.name = "frwu", - .p.long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"), + CODEC_LONG_NAME("Forward Uncompressed"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FRWU, .priv_data_size = sizeof(FRWUContext), diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index 154ff10aad..080544de8b 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -1622,7 +1622,7 @@ static av_cold int g2m_decode_end(AVCodecContext *avctx) const FFCodec ff_g2m_decoder = { .p.name = "g2m", - .p.long_name = NULL_IF_CONFIG_SMALL("Go2Meeting"), + CODEC_LONG_NAME("Go2Meeting"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_G2M, .priv_data_size = sizeof(G2MContext), diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c index 23598cb71f..231f1d32eb 100644 --- a/libavcodec/g722dec.c +++ b/libavcodec/g722dec.c @@ -141,7 +141,7 @@ static int g722_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_adpcm_g722_decoder = { .p.name = "g722", - .p.long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), + CODEC_LONG_NAME("G.722 ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G722, .priv_data_size = sizeof(G722Context), diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index 7ba283df61..dc044c320d 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -372,7 +372,7 @@ static int g722_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_adpcm_g722_encoder = { .p.name = "g722", - .p.long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), + CODEC_LONG_NAME("G.722 ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G722, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/g723_1dec.c b/libavcodec/g723_1dec.c index 3904840eba..55e20de5b5 100644 --- a/libavcodec/g723_1dec.c +++ b/libavcodec/g723_1dec.c @@ -1112,7 +1112,7 @@ static const AVClass g723_1dec_class = { const FFCodec ff_g723_1_decoder = { .p.name = "g723_1", - .p.long_name = NULL_IF_CONFIG_SMALL("G.723.1"), + CODEC_LONG_NAME("G.723.1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_G723_1, .priv_data_size = sizeof(G723_1_Context), diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index 4dc5dcd13a..f3baf7b4ec 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -1240,7 +1240,7 @@ static const FFCodecDefault defaults[] = { const FFCodec ff_g723_1_encoder = { .p.name = "g723_1", - .p.long_name = NULL_IF_CONFIG_SMALL("G.723.1"), + CODEC_LONG_NAME("G.723.1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_G723_1, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 320bc55d15..7bbb7f900c 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -402,7 +402,7 @@ static const FFCodecDefault defaults[] = { #if CONFIG_ADPCM_G726_ENCODER const FFCodec ff_adpcm_g726_encoder = { .p.name = "g726", - .p.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), + CODEC_LONG_NAME("G.726 ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G726, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, @@ -419,7 +419,7 @@ const FFCodec ff_adpcm_g726_encoder = { #if CONFIG_ADPCM_G726LE_ENCODER const FFCodec ff_adpcm_g726le_encoder = { .p.name = "g726le", - .p.long_name = NULL_IF_CONFIG_SMALL("G.726 little endian ADPCM (\"right-justified\")"), + CODEC_LONG_NAME("G.726 little endian ADPCM (\"right-justified\")"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G726LE, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, @@ -502,7 +502,7 @@ static void g726_decode_flush(AVCodecContext *avctx) #if CONFIG_ADPCM_G726_DECODER const FFCodec ff_adpcm_g726_decoder = { .p.name = "g726", - .p.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), + CODEC_LONG_NAME("G.726 ADPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_G726, .priv_data_size = sizeof(G726Context), @@ -523,6 +523,6 @@ const FFCodec ff_adpcm_g726le_decoder = { FF_CODEC_DECODE_CB(g726_decode_frame), .flush = g726_decode_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, - .p.long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM little-endian"), + CODEC_LONG_NAME("G.726 ADPCM little-endian"), }; #endif diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index bcaee44d9d..f783812cc7 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -753,7 +753,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_g729_decoder = { .p.name = "g729", - .p.long_name = NULL_IF_CONFIG_SMALL("G.729"), + CODEC_LONG_NAME("G.729"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_G729, .priv_data_size = sizeof(G729Context), @@ -765,7 +765,7 @@ const FFCodec ff_g729_decoder = { const FFCodec ff_acelp_kelvin_decoder = { .p.name = "acelp.kelvin", - .p.long_name = NULL_IF_CONFIG_SMALL("Sipro ACELP.KELVIN"), + CODEC_LONG_NAME("Sipro ACELP.KELVIN"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ACELP_KELVIN, .priv_data_size = sizeof(G729Context), diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c index 19b4d4bdbb..e114f3e80f 100644 --- a/libavcodec/gdv.c +++ b/libavcodec/gdv.c @@ -561,7 +561,7 @@ static av_cold int gdv_decode_close(AVCodecContext *avctx) const FFCodec ff_gdv_decoder = { .p.name = "gdv", - .p.long_name = NULL_IF_CONFIG_SMALL("Gremlin Digital Video"), + CODEC_LONG_NAME("Gremlin Digital Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_GDV, .priv_data_size = sizeof(GDVContext), diff --git a/libavcodec/gemdec.c b/libavcodec/gemdec.c index 5533f981dc..c8fd8dcdcd 100644 --- a/libavcodec/gemdec.c +++ b/libavcodec/gemdec.c @@ -352,7 +352,7 @@ static av_cold int gem_close(AVCodecContext *avctx) const FFCodec ff_gem_decoder = { .p.name = "gem", - .p.long_name = NULL_IF_CONFIG_SMALL("GEM Raster image"), + CODEC_LONG_NAME("GEM Raster image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_GEM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 6adbf880ae..7e717d8220 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -550,7 +550,7 @@ static const AVClass gif_class = { const FFCodec ff_gif_encoder = { .p.name = "gif", - .p.long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), + CODEC_LONG_NAME("GIF (Graphics Interchange Format)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_GIF, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c index d8638a37be..f47390c3bd 100644 --- a/libavcodec/gifdec.c +++ b/libavcodec/gifdec.c @@ -557,7 +557,7 @@ static const AVClass decoder_class = { const FFCodec ff_gif_decoder = { .p.name = "gif", - .p.long_name = NULL_IF_CONFIG_SMALL("GIF (Graphics Interchange Format)"), + CODEC_LONG_NAME("GIF (Graphics Interchange Format)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_GIF, .priv_data_size = sizeof(GifState), diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c index c44c9d992f..14e2364345 100644 --- a/libavcodec/gsmdec.c +++ b/libavcodec/gsmdec.c @@ -115,7 +115,7 @@ static void gsm_flush(AVCodecContext *avctx) #if CONFIG_GSM_DECODER const FFCodec ff_gsm_decoder = { .p.name = "gsm", - .p.long_name = NULL_IF_CONFIG_SMALL("GSM"), + CODEC_LONG_NAME("GSM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM, .priv_data_size = sizeof(GSMContext), @@ -128,7 +128,7 @@ const FFCodec ff_gsm_decoder = { #if CONFIG_GSM_MS_DECODER const FFCodec ff_gsm_ms_decoder = { .p.name = "gsm_ms", - .p.long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"), + CODEC_LONG_NAME("GSM Microsoft variant"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM_MS, .priv_data_size = sizeof(GSMContext), diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 70a26f443d..5e4f298291 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -682,7 +682,7 @@ static av_cold int h261_decode_end(AVCodecContext *avctx) const FFCodec ff_h261_decoder = { .p.name = "h261", - .p.long_name = NULL_IF_CONFIG_SMALL("H.261"), + CODEC_LONG_NAME("H.261"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H261, .priv_data_size = sizeof(H261DecContext), diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index a1fba968a4..b868827160 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -402,7 +402,7 @@ av_cold void ff_h261_encode_init(MpegEncContext *s) const FFCodec ff_h261_encoder = { .p.name = "h261", - .p.long_name = NULL_IF_CONFIG_SMALL("H.261"), + CODEC_LONG_NAME("H.261"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H261, .p.priv_class = &ff_mpv_enc_class, diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index a08329a121..90dd32bd3a 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -749,7 +749,7 @@ static const AVCodecHWConfigInternal *const h263_hw_config_list[] = { const FFCodec ff_h263_decoder = { .p.name = "h263", - .p.long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), + CODEC_LONG_NAME("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263, .priv_data_size = sizeof(MpegEncContext), @@ -770,7 +770,7 @@ const FFCodec ff_h263_decoder = { const FFCodec ff_h263p_decoder = { .p.name = "h263p", - .p.long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), + CODEC_LONG_NAME("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263P, .priv_data_size = sizeof(MpegEncContext), diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index fc7b2c7f78..3cef3f39f5 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1068,7 +1068,7 @@ static const AVClass h264_class = { const FFCodec ff_h264_decoder = { .p.name = "h264", - .p.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + CODEC_LONG_NAME("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .priv_data_size = sizeof(H264Context), diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index beb068830d..3df69e6335 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -414,7 +414,7 @@ static av_cold int hap_close(AVCodecContext *avctx) const FFCodec ff_hap_decoder = { .p.name = "hap", - .p.long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap"), + CODEC_LONG_NAME("Vidvox Hap"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HAP, .init = hap_init, diff --git a/libavcodec/hapenc.c b/libavcodec/hapenc.c index fc533164c4..a890dc6492 100644 --- a/libavcodec/hapenc.c +++ b/libavcodec/hapenc.c @@ -348,7 +348,7 @@ static const AVClass hapenc_class = { const FFCodec ff_hap_encoder = { .p.name = "hap", - .p.long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap"), + CODEC_LONG_NAME("Vidvox Hap"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HAP, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, diff --git a/libavcodec/hcadec.c b/libavcodec/hcadec.c index 82276589fc..2f019a8214 100644 --- a/libavcodec/hcadec.c +++ b/libavcodec/hcadec.c @@ -441,7 +441,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_hca_decoder = { .p.name = "hca", - .p.long_name = NULL_IF_CONFIG_SMALL("CRI HCA"), + CODEC_LONG_NAME("CRI HCA"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_HCA, .priv_data_size = sizeof(HCAContext), diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c index 301b1e02d6..9284cd11c9 100644 --- a/libavcodec/hcom.c +++ b/libavcodec/hcom.c @@ -136,7 +136,7 @@ static av_cold int hcom_close(AVCodecContext *avctx) const FFCodec ff_hcom_decoder = { .p.name = "hcom", - .p.long_name = NULL_IF_CONFIG_SMALL("HCOM Audio"), + CODEC_LONG_NAME("HCOM Audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_HCOM, .priv_data_size = sizeof(HCOMContext), diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c index 9079e4a843..9b262f2ef2 100644 --- a/libavcodec/hdrdec.c +++ b/libavcodec/hdrdec.c @@ -211,7 +211,7 @@ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_hdr_decoder = { .p.name = "hdr", - .p.long_name = NULL_IF_CONFIG_SMALL("HDR (Radiance RGBE format) image"), + CODEC_LONG_NAME("HDR (Radiance RGBE format) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RADIANCE_HDR, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/hdrenc.c b/libavcodec/hdrenc.c index 0da89c092d..d8c3111c93 100644 --- a/libavcodec/hdrenc.c +++ b/libavcodec/hdrenc.c @@ -173,7 +173,7 @@ static int hdr_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_hdr_encoder = { .p.name = "hdr", - .p.long_name = NULL_IF_CONFIG_SMALL("HDR (Radiance RGBE format) image"), + CODEC_LONG_NAME("HDR (Radiance RGBE format) image"), .priv_data_size = sizeof(HDREncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RADIANCE_HDR, diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index ed6cef6bfb..91bafa2114 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3845,7 +3845,7 @@ static const AVClass hevc_decoder_class = { const FFCodec ff_hevc_decoder = { .p.name = "hevc", - .p.long_name = NULL_IF_CONFIG_SMALL("HEVC (High Efficiency Video Coding)"), + CODEC_LONG_NAME("HEVC (High Efficiency Video Coding)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .priv_data_size = sizeof(HEVCContext), diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index f68badf195..f223bb82fc 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -499,7 +499,7 @@ static av_cold int hnm_decode_end(AVCodecContext *avctx) const FFCodec ff_hnm4_video_decoder = { .p.name = "hnm4video", - .p.long_name = NULL_IF_CONFIG_SMALL("HNM 4 video"), + CODEC_LONG_NAME("HNM 4 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HNM4_VIDEO, .priv_data_size = sizeof(Hnm4VideoContext), diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index 075c74d105..6ce73b7ae4 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -384,7 +384,7 @@ static av_cold int hq_hqa_decode_close(AVCodecContext *avctx) const FFCodec ff_hq_hqa_decoder = { .p.name = "hq_hqa", - .p.long_name = NULL_IF_CONFIG_SMALL("Canopus HQ/HQA"), + CODEC_LONG_NAME("Canopus HQ/HQA"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HQ_HQA, .priv_data_size = sizeof(HQContext), diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c index c7ba6afc83..6083946550 100644 --- a/libavcodec/hqx.c +++ b/libavcodec/hqx.c @@ -536,7 +536,7 @@ static av_cold int hqx_decode_init(AVCodecContext *avctx) const FFCodec ff_hqx_decoder = { .p.name = "hqx", - .p.long_name = NULL_IF_CONFIG_SMALL("Canopus HQX"), + CODEC_LONG_NAME("Canopus HQX"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HQX, .priv_data_size = sizeof(HQXContext), diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index a9d63acb15..fce7497386 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -1264,7 +1264,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_huffyuv_decoder = { .p.name = "huffyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), + CODEC_LONG_NAME("Huffyuv / HuffYUV"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HUFFYUV, .priv_data_size = sizeof(HYuvContext), @@ -1279,7 +1279,7 @@ const FFCodec ff_huffyuv_decoder = { #if CONFIG_FFVHUFF_DECODER const FFCodec ff_ffvhuff_decoder = { .p.name = "ffvhuff", - .p.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), + CODEC_LONG_NAME("Huffyuv FFmpeg variant"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFVHUFF, .priv_data_size = sizeof(HYuvContext), @@ -1295,7 +1295,7 @@ const FFCodec ff_ffvhuff_decoder = { #if CONFIG_HYMT_DECODER const FFCodec ff_hymt_decoder = { .p.name = "hymt", - .p.long_name = NULL_IF_CONFIG_SMALL("HuffYUV MT"), + CODEC_LONG_NAME("HuffYUV MT"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HYMT, .priv_data_size = sizeof(HYuvContext), diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 9e4a1ddfba..2d63b12abc 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -1051,7 +1051,7 @@ static const AVClass ff_class = { const FFCodec ff_huffyuv_encoder = { .p.name = "huffyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"), + CODEC_LONG_NAME("Huffyuv / HuffYUV"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HUFFYUV, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, @@ -1070,7 +1070,7 @@ const FFCodec ff_huffyuv_encoder = { #if CONFIG_FFVHUFF_ENCODER const FFCodec ff_ffvhuff_encoder = { .p.name = "ffvhuff", - .p.long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"), + CODEC_LONG_NAME("Huffyuv FFmpeg variant"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_FFVHUFF, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c index 4d3bcd3e86..f6b8b3cd69 100644 --- a/libavcodec/idcinvideo.c +++ b/libavcodec/idcinvideo.c @@ -241,7 +241,7 @@ static const FFCodecDefault idcin_defaults[] = { const FFCodec ff_idcin_decoder = { .p.name = "idcinvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("id Quake II CIN video"), + CODEC_LONG_NAME("id Quake II CIN video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_IDCIN, .priv_data_size = sizeof(IdcinContext), diff --git a/libavcodec/iff.c b/libavcodec/iff.c index e31dc4cbd0..6c0f031238 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -1907,7 +1907,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_iff_ilbm_decoder = { .p.name = "iff", - .p.long_name = NULL_IF_CONFIG_SMALL("IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN"), + CODEC_LONG_NAME("IFF ACBM/ANIM/DEEP/ILBM/PBM/RGB8/RGBN"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_IFF_ILBM, .priv_data_size = sizeof(IffContext), diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c index 1ee59ef5c9..4ecdff4183 100644 --- a/libavcodec/ilbcdec.c +++ b/libavcodec/ilbcdec.c @@ -1480,7 +1480,7 @@ static av_cold int ilbc_decode_init(AVCodecContext *avctx) const FFCodec ff_ilbc_decoder = { .p.name = "ilbc", - .p.long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"), + CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ILBC, .init = ilbc_decode_init, diff --git a/libavcodec/imc.c b/libavcodec/imc.c index e751c1da8d..92f9980ded 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -1083,7 +1083,7 @@ static av_cold void flush(AVCodecContext *avctx) #if CONFIG_IMC_DECODER const FFCodec ff_imc_decoder = { .p.name = "imc", - .p.long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"), + CODEC_LONG_NAME("IMC (Intel Music Coder)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_IMC, .priv_data_size = sizeof(IMCContext), @@ -1099,7 +1099,7 @@ const FFCodec ff_imc_decoder = { #if CONFIG_IAC_DECODER const FFCodec ff_iac_decoder = { .p.name = "iac", - .p.long_name = NULL_IF_CONFIG_SMALL("IAC (Indeo Audio Coder)"), + CODEC_LONG_NAME("IAC (Indeo Audio Coder)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_IAC, .priv_data_size = sizeof(IMCContext), diff --git a/libavcodec/imm4.c b/libavcodec/imm4.c index 96a395a100..e2aa20813a 100644 --- a/libavcodec/imm4.c +++ b/libavcodec/imm4.c @@ -533,7 +533,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_imm4_decoder = { .p.name = "imm4", - .p.long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"), + CODEC_LONG_NAME("Infinity IMM4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_IMM4, .priv_data_size = sizeof(IMM4Context), diff --git a/libavcodec/imm5.c b/libavcodec/imm5.c index 2c85bcc54a..2535e7726c 100644 --- a/libavcodec/imm5.c +++ b/libavcodec/imm5.c @@ -179,7 +179,7 @@ static av_cold int imm5_close(AVCodecContext *avctx) const FFCodec ff_imm5_decoder = { .p.name = "imm5", - .p.long_name = NULL_IF_CONFIG_SMALL("Infinity IMM5"), + CODEC_LONG_NAME("Infinity IMM5"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_IMM5, .init = imm5_init, diff --git a/libavcodec/imx.c b/libavcodec/imx.c index 68fdbc4ae9..44bab23c27 100644 --- a/libavcodec/imx.c +++ b/libavcodec/imx.c @@ -181,7 +181,7 @@ static int imx_decode_close(AVCodecContext *avctx) const FFCodec ff_simbiosis_imx_decoder = { .p.name = "simbiosis_imx", - .p.long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"), + CODEC_LONG_NAME("Simbiosis Interactive IMX Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SIMBIOSIS_IMX, .priv_data_size = sizeof(SimbiosisIMXContext), diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 8a4b1a584a..dd88ebf7c5 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -260,7 +260,7 @@ static av_cold int ir2_decode_end(AVCodecContext *avctx) const FFCodec ff_indeo2_decoder = { .p.name = "indeo2", - .p.long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 2"), + CODEC_LONG_NAME("Intel Indeo 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_INDEO2, .priv_data_size = sizeof(Ir2Context), diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index a41608bb7e..5f1014f0d4 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -1135,7 +1135,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_indeo3_decoder = { .p.name = "indeo3", - .p.long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"), + CODEC_LONG_NAME("Intel Indeo 3"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_INDEO3, .priv_data_size = sizeof(Indeo3DecodeContext), diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c index b612c88ccf..64dfc7cce1 100644 --- a/libavcodec/indeo4.c +++ b/libavcodec/indeo4.c @@ -705,7 +705,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_indeo4_decoder = { .p.name = "indeo4", - .p.long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 4"), + CODEC_LONG_NAME("Intel Indeo Video Interactive 4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_INDEO4, .priv_data_size = sizeof(IVI45DecContext), diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index 1f799fdbc0..df95064e3f 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -685,7 +685,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_indeo5_decoder = { .p.name = "indeo5", - .p.long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"), + CODEC_LONG_NAME("Intel Indeo Video Interactive 5"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_INDEO5, .priv_data_size = sizeof(IVI45DecContext), diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 9fb1155691..453b93f16c 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -132,7 +132,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s) const FFCodec ff_h263i_decoder = { .p.name = "h263i", - .p.long_name = NULL_IF_CONFIG_SMALL("Intel H.263"), + CODEC_LONG_NAME("Intel H.263"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263I, .priv_data_size = sizeof(MpegEncContext), diff --git a/libavcodec/interplayacm.c b/libavcodec/interplayacm.c index 069b1ca704..a0b9655e7a 100644 --- a/libavcodec/interplayacm.c +++ b/libavcodec/interplayacm.c @@ -634,7 +634,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_interplay_acm_decoder = { .p.name = "interplayacm", - .p.long_name = NULL_IF_CONFIG_SMALL("Interplay ACM"), + CODEC_LONG_NAME("Interplay ACM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_INTERPLAY_ACM, .init = decode_init, diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index 21ceb75210..655326a7f1 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -1356,7 +1356,7 @@ static av_cold int ipvideo_decode_end(AVCodecContext *avctx) const FFCodec ff_interplay_video_decoder = { .p.name = "interplayvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Interplay MVE video"), + CODEC_LONG_NAME("Interplay MVE video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_INTERPLAY_VIDEO, .priv_data_size = sizeof(IpvideoContext), diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index e43cb33ea2..22e5a8368d 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -898,7 +898,7 @@ static const AVClass h263_class = { const FFCodec ff_h263_encoder = { .p.name = "h263", - .p.long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"), + CODEC_LONG_NAME("H.263 / H.263-1996"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263, .p.pix_fmts = (const enum AVPixelFormat[]){AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}, @@ -928,7 +928,7 @@ static const AVClass h263p_class = { const FFCodec ff_h263p_encoder = { .p.name = "h263p", - .p.long_name = NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"), + CODEC_LONG_NAME("H.263+ / H.263-1998 / H.263 version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H263P, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 5e6872080c..e883d5deb7 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -1832,7 +1832,7 @@ static const AVClass j2k_class = { const FFCodec ff_jpeg2000_encoder = { .p.name = "jpeg2000", - .p.long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"), + CODEC_LONG_NAME("JPEG 2000"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEG2000, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/jacosubdec.c b/libavcodec/jacosubdec.c index 8dcc38e651..08349a9ec8 100644 --- a/libavcodec/jacosubdec.c +++ b/libavcodec/jacosubdec.c @@ -195,7 +195,7 @@ static int jacosub_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, const FFCodec ff_jacosub_decoder = { .p.name = "jacosub", - .p.long_name = NULL_IF_CONFIG_SMALL("JACOsub subtitle"), + CODEC_LONG_NAME("JACOsub subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_JACOSUB, .init = ff_ass_subtitle_header_default, diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 2c1191035c..7d9661f29f 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2576,7 +2576,7 @@ static const AVClass jpeg2000_class = { const FFCodec ff_jpeg2000_decoder = { .p.name = "jpeg2000", - .p.long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"), + CODEC_LONG_NAME("JPEG 2000"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEG2000, .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_DR1, diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 984cc3b414..2e6d018ea6 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -552,7 +552,7 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, const FFCodec ff_jpegls_decoder = { .p.name = "jpegls", - .p.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), + CODEC_LONG_NAME("JPEG-LS"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEGLS, .priv_data_size = sizeof(MJpegDecodeContext), diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 8f3197e687..5ee39ac2d6 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -473,7 +473,7 @@ static const AVClass jpegls_class = { const FFCodec ff_jpegls_encoder = { .p.name = "jpegls", - .p.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), + CODEC_LONG_NAME("JPEG-LS"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEGLS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index 9bca18e32c..dd7e4a93ef 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -236,7 +236,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_jv_decoder = { .p.name = "jv", - .p.long_name = NULL_IF_CONFIG_SMALL("Bitmap Brothers JV video"), + CODEC_LONG_NAME("Bitmap Brothers JV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JV, .priv_data_size = sizeof(JvContext), diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 11dfc1b84f..139ec9b05e 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -178,7 +178,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_kgv1_decoder = { .p.name = "kgv1", - .p.long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"), + CODEC_LONG_NAME("Kega Game Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_KGV1, .priv_data_size = sizeof(KgvContext), diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index 1e37c233f4..153cea03b9 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -404,7 +404,7 @@ static av_cold int decode_init(AVCodecContext * avctx) const FFCodec ff_kmvc_decoder = { .p.name = "kmvc", - .p.long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"), + CODEC_LONG_NAME("Karl Morton's video codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_KMVC, .priv_data_size = sizeof(KmvcContext), diff --git a/libavcodec/lagarith.c b/libavcodec/lagarith.c index 68ffbc9821..78ccbc15b9 100644 --- a/libavcodec/lagarith.c +++ b/libavcodec/lagarith.c @@ -730,7 +730,7 @@ static av_cold int lag_decode_init(AVCodecContext *avctx) const FFCodec ff_lagarith_decoder = { .p.name = "lagarith", - .p.long_name = NULL_IF_CONFIG_SMALL("Lagarith lossless"), + CODEC_LONG_NAME("Lagarith lossless"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_LAGARITH, .priv_data_size = sizeof(LagarithContext), diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 6de55450df..5cc0a29bcd 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -632,7 +632,7 @@ static av_cold int decode_end(AVCodecContext *avctx) #if CONFIG_MSZH_DECODER const FFCodec ff_mszh_decoder = { .p.name = "mszh", - .p.long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"), + CODEC_LONG_NAME("LCL (LossLess Codec Library) MSZH"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSZH, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, @@ -647,7 +647,7 @@ const FFCodec ff_mszh_decoder = { #if CONFIG_ZLIB_DECODER const FFCodec ff_zlib_decoder = { .p.name = "zlib", - .p.long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"), + CODEC_LONG_NAME("LCL (LossLess Codec Library) ZLIB"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZLIB, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c index cbe336155e..2c9add5215 100644 --- a/libavcodec/lclenc.c +++ b/libavcodec/lclenc.c @@ -153,7 +153,7 @@ static av_cold int encode_end(AVCodecContext *avctx) const FFCodec ff_zlib_encoder = { .p.name = "zlib", - .p.long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"), + CODEC_LONG_NAME("LCL (LossLess Codec Library) ZLIB"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZLIB, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c index 5ed219b43d..378d638a89 100644 --- a/libavcodec/libaomdec.c +++ b/libavcodec/libaomdec.c @@ -227,7 +227,7 @@ static av_cold int av1_init(AVCodecContext *avctx) const FFCodec ff_libaom_av1_decoder = { .p.name = "libaom-av1", - .p.long_name = NULL_IF_CONFIG_SMALL("libaom AV1"), + CODEC_LONG_NAME("libaom AV1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AV1, .priv_data_size = sizeof(AV1DecodeContext), diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 1e89b7e3a8..bd576fdd3a 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1532,7 +1532,7 @@ static const AVClass class_aom = { FFCodec ff_libaom_av1_encoder = { .p.name = "libaom-av1", - .p.long_name = NULL_IF_CONFIG_SMALL("libaom AV1"), + CODEC_LONG_NAME("libaom AV1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AV1, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libaribb24.c b/libavcodec/libaribb24.c index e89e49a771..f40517e22e 100644 --- a/libavcodec/libaribb24.c +++ b/libavcodec/libaribb24.c @@ -383,7 +383,7 @@ static const AVClass aribb24_class = { const FFCodec ff_libaribb24_decoder = { .p.name = "libaribb24", - .p.long_name = NULL_IF_CONFIG_SMALL("libaribb24 ARIB STD-B24 caption decoder"), + CODEC_LONG_NAME("libaribb24 ARIB STD-B24 caption decoder"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ARIB_CAPTION, .p.priv_class = &aribb24_class, diff --git a/libavcodec/libcelt_dec.c b/libavcodec/libcelt_dec.c index 0c41a660bc..fcd4fc7736 100644 --- a/libavcodec/libcelt_dec.c +++ b/libavcodec/libcelt_dec.c @@ -129,7 +129,7 @@ static int libcelt_dec_decode(AVCodecContext *c, AVFrame *frame, const FFCodec ff_libcelt_decoder = { .p.name = "libcelt", - .p.long_name = NULL_IF_CONFIG_SMALL("Xiph CELT decoder using libcelt"), + CODEC_LONG_NAME("Xiph CELT decoder using libcelt"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_CELT, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 11e9d14d3a..be9677ddeb 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -178,7 +178,7 @@ static int libcodec2_encode(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_libcodec2_decoder = { .p.name = "libcodec2", - .p.long_name = NULL_IF_CONFIG_SMALL("codec2 decoder using libcodec2"), + CODEC_LONG_NAME("codec2 decoder using libcodec2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_CODEC2, .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF, @@ -197,7 +197,7 @@ const FFCodec ff_libcodec2_decoder = { const FFCodec ff_libcodec2_encoder = { .p.name = "libcodec2", - .p.long_name = NULL_IF_CONFIG_SMALL("codec2 encoder using libcodec2"), + CODEC_LONG_NAME("codec2 encoder using libcodec2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_CODEC2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index b120d55190..e76f33d7e2 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -576,7 +576,7 @@ static const AVClass libdav1d_class = { const FFCodec ff_libdav1d_decoder = { .p.name = "libdav1d", - .p.long_name = NULL_IF_CONFIG_SMALL("dav1d AV1 decoder by VideoLAN"), + CODEC_LONG_NAME("dav1d AV1 decoder by VideoLAN"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AV1, .priv_data_size = sizeof(Libdav1dContext), diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c index ce4c6a34f0..179d2f4e4b 100644 --- a/libavcodec/libdavs2.c +++ b/libavcodec/libdavs2.c @@ -223,7 +223,7 @@ static int davs2_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_libdavs2_decoder = { .p.name = "libdavs2", - .p.long_name = NULL_IF_CONFIG_SMALL("libdavs2 AVS2-P2/IEEE1857.4"), + CODEC_LONG_NAME("libdavs2 AVS2-P2/IEEE1857.4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVS2, .priv_data_size = sizeof(DAVS2Context), diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c index c148d46208..8c1586e25e 100644 --- a/libavcodec/libfdk-aacdec.c +++ b/libavcodec/libfdk-aacdec.c @@ -478,7 +478,7 @@ static av_cold void fdk_aac_decode_flush(AVCodecContext *avctx) const FFCodec ff_libfdk_aac_decoder = { .p.name = "libfdk_aac", - .p.long_name = NULL_IF_CONFIG_SMALL("Fraunhofer FDK AAC"), + CODEC_LONG_NAME("Fraunhofer FDK AAC"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, .priv_data_size = sizeof(FDKAACDecContext), diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index f53f5e97a9..fc2e71c51f 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -477,7 +477,7 @@ static const int aac_sample_rates[] = { const FFCodec ff_libfdk_aac_encoder = { .p.name = "libfdk_aac", - .p.long_name = NULL_IF_CONFIG_SMALL("Fraunhofer FDK AAC"), + CODEC_LONG_NAME("Fraunhofer FDK AAC"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AAC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libgsmdec.c b/libavcodec/libgsmdec.c index ad0b3c2f2a..a86e9deac0 100644 --- a/libavcodec/libgsmdec.c +++ b/libavcodec/libgsmdec.c @@ -127,7 +127,7 @@ static void libgsm_flush(AVCodecContext *avctx) { #if CONFIG_LIBGSM_DECODER const FFCodec ff_libgsm_decoder = { .p.name = "libgsm", - .p.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), + CODEC_LONG_NAME("libgsm GSM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, @@ -143,7 +143,7 @@ const FFCodec ff_libgsm_decoder = { #if CONFIG_LIBGSM_MS_DECODER const FFCodec ff_libgsm_ms_decoder = { .p.name = "libgsm_ms", - .p.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), + CODEC_LONG_NAME("libgsm GSM Microsoft variant"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM_MS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c index f83389dd60..9ad430bf62 100644 --- a/libavcodec/libgsmenc.c +++ b/libavcodec/libgsmenc.c @@ -119,7 +119,7 @@ static const FFCodecDefault libgsm_defaults[] = { #if CONFIG_LIBGSM_ENCODER const FFCodec ff_libgsm_encoder = { .p.name = "libgsm", - .p.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), + CODEC_LONG_NAME("libgsm GSM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -140,7 +140,7 @@ const FFCodec ff_libgsm_encoder = { #if CONFIG_LIBGSM_MS_ENCODER const FFCodec ff_libgsm_ms_encoder = { .p.name = "libgsm_ms", - .p.long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), + CODEC_LONG_NAME("libgsm GSM Microsoft variant"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_GSM_MS, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libilbc.c b/libavcodec/libilbc.c index 485762f66c..9ef6e16bc5 100644 --- a/libavcodec/libilbc.c +++ b/libavcodec/libilbc.c @@ -119,7 +119,7 @@ static int ilbc_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_libilbc_decoder = { .p.name = "libilbc", - .p.long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"), + CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ILBC, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, @@ -202,7 +202,7 @@ static const FFCodecDefault ilbc_encode_defaults[] = { const FFCodec ff_libilbc_encoder = { .p.name = "libilbc", - .p.long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"), + CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ILBC, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index 0d59160d27..de48bea4b2 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -447,7 +447,7 @@ static av_cold int libjxl_decode_close(AVCodecContext *avctx) const FFCodec ff_libjxl_decoder = { .p.name = "libjxl", - .p.long_name = NULL_IF_CONFIG_SMALL("libjxl JPEG XL"), + CODEC_LONG_NAME("libjxl JPEG XL"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEGXL, .priv_data_size = sizeof(LibJxlDecodeContext), diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c index 7e97237cd1..0793ed251b 100644 --- a/libavcodec/libjxlenc.c +++ b/libavcodec/libjxlenc.c @@ -460,7 +460,7 @@ static const AVClass libjxl_encode_class = { const FFCodec ff_libjxl_encoder = { .p.name = "libjxl", - .p.long_name = NULL_IF_CONFIG_SMALL("libjxl JPEG XL"), + CODEC_LONG_NAME("libjxl JPEG XL"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEGXL, .priv_data_size = sizeof(LibJxlEncodeContext), diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c index 3a3648f23c..168486f4ec 100644 --- a/libavcodec/libkvazaar.c +++ b/libavcodec/libkvazaar.c @@ -320,7 +320,7 @@ static const FFCodecDefault defaults[] = { const FFCodec ff_libkvazaar_encoder = { .p.name = "libkvazaar", - .p.long_name = NULL_IF_CONFIG_SMALL("libkvazaar H.265 / HEVC"), + CODEC_LONG_NAME("libkvazaar H.265 / HEVC"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 2cd51692a2..c8a6eb8c33 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -330,7 +330,7 @@ static const int libmp3lame_sample_rates[] = { const FFCodec ff_libmp3lame_encoder = { .p.name = "libmp3lame", - .p.long_name = NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"), + CODEC_LONG_NAME("libmp3lame MP3 (MPEG audio layer 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index 0d398ff02b..fd9e6e6343 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -135,7 +135,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_libopencore_amrnb_decoder = { .p.name = "libopencore_amrnb", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenCORE AMR-NB (Adaptive Multi-Rate Narrow-Band)"), + CODEC_LONG_NAME("OpenCORE AMR-NB (Adaptive Multi-Rate Narrow-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_NB, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, @@ -291,7 +291,7 @@ static int amr_nb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_libopencore_amrnb_encoder = { .p.name = "libopencore_amrnb", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenCORE AMR-NB (Adaptive Multi-Rate Narrow-Band)"), + CODEC_LONG_NAME("OpenCORE AMR-NB (Adaptive Multi-Rate Narrow-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_NB, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | @@ -377,7 +377,7 @@ static int amr_wb_decode_close(AVCodecContext *avctx) const FFCodec ff_libopencore_amrwb_decoder = { .p.name = "libopencore_amrwb", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenCORE AMR-WB (Adaptive Multi-Rate Wide-Band)"), + CODEC_LONG_NAME("OpenCORE AMR-WB (Adaptive Multi-Rate Wide-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_WB, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c index 3a8be36bf6..af53219b41 100644 --- a/libavcodec/libopenh264dec.c +++ b/libavcodec/libopenh264dec.c @@ -158,7 +158,7 @@ static int svc_decode_frame(AVCodecContext *avctx, AVFrame *avframe, const FFCodec ff_libopenh264_decoder = { .p.name = "libopenh264", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + CODEC_LONG_NAME("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .priv_data_size = sizeof(SVCContext), diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 54dff6833d..bbd6969568 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -453,7 +453,7 @@ static const FFCodecDefault svc_enc_defaults[] = { const FFCodec ff_libopenh264_encoder = { .p.name = "libopenh264", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + CODEC_LONG_NAME("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS, diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c index be2337d9b2..206db07ec7 100644 --- a/libavcodec/libopenjpegdec.c +++ b/libavcodec/libopenjpegdec.c @@ -502,7 +502,7 @@ static const AVClass openjpeg_class = { const FFCodec ff_libopenjpeg_decoder = { .p.name = "libopenjpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"), + CODEC_LONG_NAME("OpenJPEG JPEG 2000"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEG2000, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c index 750fce3d8d..6f77780391 100644 --- a/libavcodec/libopenjpegenc.c +++ b/libavcodec/libopenjpegenc.c @@ -756,7 +756,7 @@ static const AVClass openjpeg_class = { const FFCodec ff_libopenjpeg_encoder = { .p.name = "libopenjpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"), + CODEC_LONG_NAME("OpenJPEG JPEG 2000"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_JPEG2000, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c index fa7aba9d8a..31a04dfbeb 100644 --- a/libavcodec/libopusdec.c +++ b/libavcodec/libopusdec.c @@ -233,7 +233,7 @@ static const AVClass libopusdec_class = { const FFCodec ff_libopus_decoder = { .p.name = "libopus", - .p.long_name = NULL_IF_CONFIG_SMALL("libopus Opus"), + CODEC_LONG_NAME("libopus Opus"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_OPUS, .priv_data_size = sizeof(struct libopus_context), diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c index dd4c5f3e8d..81e765403f 100644 --- a/libavcodec/libopusenc.c +++ b/libavcodec/libopusenc.c @@ -585,7 +585,7 @@ static const int libopus_sample_rates[] = { const FFCodec ff_libopus_encoder = { .p.name = "libopus", - .p.long_name = NULL_IF_CONFIG_SMALL("libopus Opus"), + CODEC_LONG_NAME("libopus Opus"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_OPUS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c index 67b301b802..0601efed2c 100644 --- a/libavcodec/librav1e.c +++ b/libavcodec/librav1e.c @@ -616,7 +616,7 @@ static const AVClass class = { const FFCodec ff_librav1e_encoder = { .p.name = "librav1e", - .p.long_name = NULL_IF_CONFIG_SMALL("librav1e AV1"), + CODEC_LONG_NAME("librav1e AV1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AV1, .init = librav1e_encode_init, diff --git a/libavcodec/librsvgdec.c b/libavcodec/librsvgdec.c index cfafae2652..9c8aa2dedc 100644 --- a/libavcodec/librsvgdec.c +++ b/libavcodec/librsvgdec.c @@ -120,7 +120,7 @@ static const AVClass librsvg_decoder_class = { const FFCodec ff_librsvg_decoder = { .p.name = "librsvg", - .p.long_name = NULL_IF_CONFIG_SMALL("Librsvg rasterizer"), + CODEC_LONG_NAME("Librsvg rasterizer"), .p.priv_class = &librsvg_decoder_class, .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SVG, diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c index 123b1a0847..621c57816a 100644 --- a/libavcodec/libshine.c +++ b/libavcodec/libshine.c @@ -133,7 +133,7 @@ static const int libshine_sample_rates[] = { const FFCodec ff_libshine_encoder = { .p.name = "libshine", - .p.long_name = NULL_IF_CONFIG_SMALL("libshine MP3 (MPEG audio layer 3)"), + CODEC_LONG_NAME("libshine MP3 (MPEG audio layer 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index b1512549d6..47fc5d6a4b 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -192,7 +192,7 @@ static av_cold void libspeex_decode_flush(AVCodecContext *avctx) const FFCodec ff_libspeex_decoder = { .p.name = "libspeex", - .p.long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), + CODEC_LONG_NAME("libspeex Speex"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SPEEX, .p.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 411d9f0290..8d2c6347fa 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -350,7 +350,7 @@ static const FFCodecDefault defaults[] = { const FFCodec ff_libspeex_encoder = { .p.name = "libspeex", - .p.long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), + CODEC_LONG_NAME("libspeex Speex"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SPEEX, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 4c403a98d4..2f5634cee0 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -655,7 +655,7 @@ static const FFCodecDefault eb_enc_defaults[] = { const FFCodec ff_libsvtav1_encoder = { .p.name = "libsvtav1", - .p.long_name = NULL_IF_CONFIG_SMALL("SVT-AV1(Scalable Video Technology for AV1) encoder"), + CODEC_LONG_NAME("SVT-AV1(Scalable Video Technology for AV1) encoder"), .priv_data_size = sizeof(SvtContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AV1, diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index 22835553d6..b453e74c81 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -369,7 +369,7 @@ static av_cold int encode_close(AVCodecContext* avc_context) /** AVCodec struct exposed to libavcodec */ const FFCodec ff_libtheora_encoder = { .p.name = "libtheora", - .p.long_name = NULL_IF_CONFIG_SMALL("libtheora Theora"), + CODEC_LONG_NAME("libtheora Theora"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_THEORA, .p.capabilities = AV_CODEC_CAP_DR1 | diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c index 3da57bb779..2168b3cdf6 100644 --- a/libavcodec/libtwolame.c +++ b/libavcodec/libtwolame.c @@ -210,7 +210,7 @@ static const int twolame_samplerates[] = { const FFCodec ff_libtwolame_encoder = { .p.name = "libtwolame", - .p.long_name = NULL_IF_CONFIG_SMALL("libtwolame MP2 (MPEG audio layer 2)"), + CODEC_LONG_NAME("libtwolame MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c index 95616fcacb..f5a6e59496 100644 --- a/libavcodec/libuavs3d.c +++ b/libavcodec/libuavs3d.c @@ -248,7 +248,7 @@ static int libuavs3d_decode_frame(AVCodecContext *avctx, AVFrame *frm, const FFCodec ff_libuavs3d_decoder = { .p.name = "libuavs3d", - .p.long_name = NULL_IF_CONFIG_SMALL("libuavs3d AVS3-P2/IEEE1857.10"), + CODEC_LONG_NAME("libuavs3d AVS3-P2/IEEE1857.10"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVS3, .priv_data_size = sizeof(uavs3d_context), diff --git a/libavcodec/libvo-amrwbenc.c b/libavcodec/libvo-amrwbenc.c index a2d7f33ef7..76a6b69994 100644 --- a/libavcodec/libvo-amrwbenc.c +++ b/libavcodec/libvo-amrwbenc.c @@ -141,8 +141,7 @@ static int amr_wb_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_libvo_amrwbenc_encoder = { .p.name = "libvo_amrwbenc", - .p.long_name = NULL_IF_CONFIG_SMALL("Android VisualOn AMR-WB " - "(Adaptive Multi-Rate Wide-Band)"), + CODEC_LONG_NAME("Android VisualOn AMR-WB (Adaptive Multi-Rate Wide-Band)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_AMR_WB, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libvorbisdec.c b/libavcodec/libvorbisdec.c index f0f16f27cf..a5e7a691d6 100644 --- a/libavcodec/libvorbisdec.c +++ b/libavcodec/libvorbisdec.c @@ -212,7 +212,7 @@ static int oggvorbis_decode_close(AVCodecContext *avccontext) { const FFCodec ff_libvorbis_decoder = { .p.name = "libvorbis", - .p.long_name = NULL_IF_CONFIG_SMALL("libvorbis"), + CODEC_LONG_NAME("libvorbis"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_VORBIS, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_CHANNEL_CONF, diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c index 718e9d1912..f78a88bbcd 100644 --- a/libavcodec/libvorbisenc.c +++ b/libavcodec/libvorbisenc.c @@ -376,7 +376,7 @@ static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_libvorbis_encoder = { .p.name = "libvorbis", - .p.long_name = NULL_IF_CONFIG_SMALL("libvorbis"), + CODEC_LONG_NAME("libvorbis"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_VORBIS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index c7cb744312..9cd2c56caf 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -356,7 +356,7 @@ static av_cold int vp8_init(AVCodecContext *avctx) const FFCodec ff_libvpx_vp8_decoder = { .p.name = "libvpx", - .p.long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), + CODEC_LONG_NAME("libvpx VP8"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP8, .p.capabilities = AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_DR1, @@ -379,7 +379,7 @@ static av_cold int vp9_init(AVCodecContext *avctx) FFCodec ff_libvpx_vp9_decoder = { .p.name = "libvpx-vp9", - .p.long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), + CODEC_LONG_NAME("libvpx VP9"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP9, .p.capabilities = AV_CODEC_CAP_OTHER_THREADS, diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index bbbe56c0dc..09b56aae2a 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1944,7 +1944,7 @@ static const AVClass class_vp8 = { const FFCodec ff_libvpx_vp8_encoder = { .p.name = "libvpx", - .p.long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), + CODEC_LONG_NAME("libvpx VP8"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP8, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | @@ -1977,7 +1977,7 @@ static const AVClass class_vp9 = { FFCodec ff_libvpx_vp9_encoder = { .p.name = "libvpx-vp9", - .p.long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), + CODEC_LONG_NAME("libvpx VP9"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP9, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c index be7bfa3963..ee5795f041 100644 --- a/libavcodec/libwebpenc.c +++ b/libavcodec/libwebpenc.c @@ -89,7 +89,7 @@ static int libwebp_encode_close(AVCodecContext *avctx) const FFCodec ff_libwebp_encoder = { .p.name = "libwebp", - .p.long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"), + CODEC_LONG_NAME("libwebp WebP image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WEBP, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c index 43116c63c0..0f2c190c8c 100644 --- a/libavcodec/libwebpenc_animencoder.c +++ b/libavcodec/libwebpenc_animencoder.c @@ -131,7 +131,7 @@ static int libwebp_anim_encode_close(AVCodecContext *avctx) const FFCodec ff_libwebp_anim_encoder = { .p.name = "libwebp_anim", - .p.long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"), + CODEC_LONG_NAME("libwebp WebP image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WEBP, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 6afa3cdadb..ca0b5a145b 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -1270,7 +1270,7 @@ const #endif FFCodec ff_libx264_encoder = { .p.name = "libx264", - .p.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + CODEC_LONG_NAME("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | @@ -1307,7 +1307,7 @@ static const AVClass rgbclass = { const FFCodec ff_libx264rgb_encoder = { .p.name = "libx264rgb", - .p.long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"), + CODEC_LONG_NAME("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | @@ -1339,7 +1339,7 @@ static const AVClass X262_class = { const FFCodec ff_libx262_encoder = { .p.name = "libx262", - .p.long_name = NULL_IF_CONFIG_SMALL("libx262 MPEG2VIDEO"), + CODEC_LONG_NAME("libx262 MPEG2VIDEO"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 6d2590dd7f..4aa96e1f2d 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -743,7 +743,7 @@ static const FFCodecDefault x265_defaults[] = { FFCodec ff_libx265_encoder = { .p.name = "libx265", - .p.long_name = NULL_IF_CONFIG_SMALL("libx265 H.265 / HEVC"), + CODEC_LONG_NAME("libx265 H.265 / HEVC"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index 2c7577535f..9ed73d1042 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -423,7 +423,7 @@ static const FFCodecDefault xavs_defaults[] = { const FFCodec ff_libxavs_encoder = { .p.name = "libxavs", - .p.long_name = NULL_IF_CONFIG_SMALL("libxavs Chinese AVS (Audio Video Standard)"), + CODEC_LONG_NAME("libxavs Chinese AVS (Audio Video Standard)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_CAVS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index d4a1bf5bfc..1672edfc07 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -288,7 +288,7 @@ static const FFCodecDefault xavs2_defaults[] = { const FFCodec ff_libxavs2_encoder = { .p.name = "libxavs2", - .p.long_name = NULL_IF_CONFIG_SMALL("libxavs2 AVS2-P2/IEEE1857.4"), + CODEC_LONG_NAME("libxavs2 AVS2-P2/IEEE1857.4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVS2, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index 3845905555..4e04b3c098 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -899,7 +899,7 @@ static const AVClass xvid_class = { const FFCodec ff_libxvid_encoder = { .p.name = "libxvid", - .p.long_name = NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), + CODEC_LONG_NAME("libxvidcore MPEG-4 part 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG4, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c index c88ede05b5..45e30eb01c 100644 --- a/libavcodec/libzvbi-teletextdec.c +++ b/libavcodec/libzvbi-teletextdec.c @@ -813,7 +813,7 @@ static const AVClass teletext_class = { const FFCodec ff_libzvbi_teletext_decoder = { .p.name = "libzvbi_teletextdec", - .p.long_name = NULL_IF_CONFIG_SMALL("Libzvbi DVB teletext decoder"), + CODEC_LONG_NAME("Libzvbi DVB teletext decoder"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_DVB_TELETEXT, .p.capabilities = AV_CODEC_CAP_DELAY, diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 7aab915d01..a708d71220 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -325,7 +325,7 @@ static const AVClass ljpeg_class = { const FFCodec ff_ljpeg_encoder = { .p.name = "ljpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"), + CODEC_LONG_NAME("Lossless JPEG"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_LJPEG, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/loco.c b/libavcodec/loco.c index a31bbf38c1..d57a67317a 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -338,7 +338,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_loco_decoder = { .p.name = "loco", - .p.long_name = NULL_IF_CONFIG_SMALL("LOCO"), + CODEC_LONG_NAME("LOCO"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_LOCO, .priv_data_size = sizeof(LOCOContext), diff --git a/libavcodec/lscrdec.c b/libavcodec/lscrdec.c index cd7dc8b2b7..76a46751f0 100644 --- a/libavcodec/lscrdec.c +++ b/libavcodec/lscrdec.c @@ -246,7 +246,7 @@ static void lscr_decode_flush(AVCodecContext *avctx) const FFCodec ff_lscr_decoder = { .p.name = "lscr", - .p.long_name = NULL_IF_CONFIG_SMALL("LEAD Screen Capture"), + CODEC_LONG_NAME("LEAD Screen Capture"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_LSCR, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/m101.c b/libavcodec/m101.c index 5a06f02c37..3def577b74 100644 --- a/libavcodec/m101.c +++ b/libavcodec/m101.c @@ -106,7 +106,7 @@ static int m101_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_m101_decoder = { .p.name = "m101", - .p.long_name = NULL_IF_CONFIG_SMALL("Matrox Uncompressed SD"), + CODEC_LONG_NAME("Matrox Uncompressed SD"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_M101, .init = m101_decode_init, diff --git a/libavcodec/mace.c b/libavcodec/mace.c index bf45b36a20..a35291330e 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -286,7 +286,7 @@ static int mace_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_mace3_decoder = { .p.name = "mace3", - .p.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"), + CODEC_LONG_NAME("MACE (Macintosh Audio Compression/Expansion) 3:1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MACE3, .priv_data_size = sizeof(MACEContext), @@ -299,7 +299,7 @@ const FFCodec ff_mace3_decoder = { const FFCodec ff_mace6_decoder = { .p.name = "mace6", - .p.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"), + CODEC_LONG_NAME("MACE (Macintosh Audio Compression/Expansion) 6:1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MACE6, .priv_data_size = sizeof(MACEContext), diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 8b30ce08ac..62263409b1 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -694,7 +694,7 @@ static av_cold int magy_decode_end(AVCodecContext *avctx) const FFCodec ff_magicyuv_decoder = { .p.name = "magicyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"), + CODEC_LONG_NAME("MagicYUV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MAGICYUV, .priv_data_size = sizeof(MagicYUVContext), diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c index b2846948e6..7f9ff72834 100644 --- a/libavcodec/magicyuvenc.c +++ b/libavcodec/magicyuvenc.c @@ -566,7 +566,7 @@ static const AVClass magicyuv_class = { const FFCodec ff_magicyuv_encoder = { .p.name = "magicyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"), + CODEC_LONG_NAME("MagicYUV video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MAGICYUV, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 59bf86b0d7..c8994f68ee 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -251,7 +251,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_mdec_decoder = { .p.name = "mdec", - .p.long_name = NULL_IF_CONFIG_SMALL("Sony PlayStation MDEC (Motion DECoder)"), + CODEC_LONG_NAME("Sony PlayStation MDEC (Motion DECoder)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MDEC, .priv_data_size = sizeof(MDECContext), diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 0bf2a0595d..322b448d27 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -534,7 +534,7 @@ static const AVClass ff_##short_name##_mediacodec_dec_class = { \ DECLARE_MEDIACODEC_VCLASS(short_name) \ const FFCodec ff_ ## short_name ## _mediacodec_decoder = { \ .p.name = #short_name "_mediacodec", \ - .p.long_name = NULL_IF_CONFIG_SMALL(full_name " Android MediaCodec decoder"), \ + CODEC_LONG_NAME(full_name " Android MediaCodec decoder"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = codec_id, \ .p.priv_class = &ff_##short_name##_mediacodec_dec_class, \ diff --git a/libavcodec/metasound.c b/libavcodec/metasound.c index 6597563c67..d5bf2d22ad 100644 --- a/libavcodec/metasound.c +++ b/libavcodec/metasound.c @@ -375,7 +375,7 @@ static av_cold int metasound_decode_init(AVCodecContext *avctx) const FFCodec ff_metasound_decoder = { .p.name = "metasound", - .p.long_name = NULL_IF_CONFIG_SMALL("Voxware MetaSound"), + CODEC_LONG_NAME("Voxware MetaSound"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_METASOUND, .priv_data_size = sizeof(TwinVQContext), diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c index d5c241d169..36a6d8482d 100644 --- a/libavcodec/mfenc.c +++ b/libavcodec/mfenc.c @@ -1230,7 +1230,7 @@ static int mf_init(AVCodecContext *avctx) const FFCodec ff_ ## NAME ## _mf_encoder = { \ .p.priv_class = &ff_ ## NAME ## _mf_encoder_class, \ .p.name = #NAME "_mf", \ - .p.long_name = NULL_IF_CONFIG_SMALL(#ID " via MediaFoundation"), \ + CODEC_LONG_NAME(#ID " via MediaFoundation"), \ .p.type = AVMEDIA_TYPE_ ## MEDIATYPE, \ .p.id = AV_CODEC_ID_ ## ID, \ .priv_data_size = sizeof(MFContext), \ diff --git a/libavcodec/microdvddec.c b/libavcodec/microdvddec.c index b675fc0ea7..786a3845fd 100644 --- a/libavcodec/microdvddec.c +++ b/libavcodec/microdvddec.c @@ -370,7 +370,7 @@ static int microdvd_init(AVCodecContext *avctx) const FFCodec ff_microdvd_decoder = { .p.name = "microdvd", - .p.long_name = NULL_IF_CONFIG_SMALL("MicroDVD subtitle"), + CODEC_LONG_NAME("MicroDVD subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_MICRODVD, .init = microdvd_init, diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c index eaf138e87e..599d5c8f8f 100644 --- a/libavcodec/midivid.c +++ b/libavcodec/midivid.c @@ -274,7 +274,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_mvdv_decoder = { .p.name = "mvdv", - .p.long_name = NULL_IF_CONFIG_SMALL("MidiVid VQ"), + CODEC_LONG_NAME("MidiVid VQ"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MVDV, .priv_data_size = sizeof(MidiVidContext), diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index f5164e82e7..c506a42322 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -438,7 +438,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_mimic_decoder = { .p.name = "mimic", - .p.long_name = NULL_IF_CONFIG_SMALL("Mimic"), + CODEC_LONG_NAME("Mimic"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MIMIC, .priv_data_size = sizeof(MimicContext), diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index 2778332e2e..e74addb24b 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -158,7 +158,7 @@ static int mjpegb_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_mjpegb_decoder = { .p.name = "mjpegb", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"), + CODEC_LONG_NAME("Apple MJPEG-B"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MJPEGB, .priv_data_size = sizeof(MJpegDecodeContext), diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 65c3c402a2..65337360b0 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -3020,7 +3020,7 @@ static const AVClass mjpegdec_class = { const FFCodec ff_mjpeg_decoder = { .p.name = "mjpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"), + CODEC_LONG_NAME("MJPEG (Motion JPEG)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MJPEG, .priv_data_size = sizeof(MJpegDecodeContext), @@ -3050,7 +3050,7 @@ const FFCodec ff_mjpeg_decoder = { #if CONFIG_THP_DECODER const FFCodec ff_thp_decoder = { .p.name = "thp", - .p.long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"), + CODEC_LONG_NAME("Nintendo Gamecube THP video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_THP, .priv_data_size = sizeof(MJpegDecodeContext), @@ -3068,7 +3068,7 @@ const FFCodec ff_thp_decoder = { #if CONFIG_SMVJPEG_DECODER const FFCodec ff_smvjpeg_decoder = { .p.name = "smvjpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("SMV JPEG"), + CODEC_LONG_NAME("SMV JPEG"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SMVJPEG, .priv_data_size = sizeof(MJpegDecodeContext), diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 3df0b51bb4..e56a466b36 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -644,7 +644,7 @@ static const AVClass mjpeg_class = { const FFCodec ff_mjpeg_encoder = { .p.name = "mjpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"), + CODEC_LONG_NAME("MJPEG (Motion JPEG)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MJPEG, .priv_data_size = sizeof(MJPEGEncContext), @@ -673,7 +673,7 @@ static const AVClass amv_class = { const FFCodec ff_amv_encoder = { .p.name = "amv", - .p.long_name = NULL_IF_CONFIG_SMALL("AMV Video"), + CODEC_LONG_NAME("AMV Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AMV, .priv_data_size = sizeof(MJPEGEncContext), diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index bfd0091323..0a97fae26c 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -1416,7 +1416,7 @@ static const AVClass truehd_decoder_class = { #if CONFIG_MLP_DECODER const FFCodec ff_mlp_decoder = { .p.name = "mlp", - .p.long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), + CODEC_LONG_NAME("MLP (Meridian Lossless Packing)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MLP, .priv_data_size = sizeof(MLPDecodeContext), @@ -1430,7 +1430,7 @@ const FFCodec ff_mlp_decoder = { #if CONFIG_TRUEHD_DECODER const FFCodec ff_truehd_decoder = { .p.name = "truehd", - .p.long_name = NULL_IF_CONFIG_SMALL("TrueHD"), + CODEC_LONG_NAME("TrueHD"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TRUEHD, .priv_data_size = sizeof(MLPDecodeContext), diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index c986a0395f..80dc03a0ca 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -2210,7 +2210,7 @@ static av_cold int mlp_encode_close(AVCodecContext *avctx) #if CONFIG_MLP_ENCODER const FFCodec ff_mlp_encoder = { .p.name ="mlp", - .p.long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), + CODEC_LONG_NAME("MLP (Meridian Lossless Packing)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MLP, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | @@ -2231,7 +2231,7 @@ const FFCodec ff_mlp_encoder = { #if CONFIG_TRUEHD_ENCODER const FFCodec ff_truehd_encoder = { .p.name ="truehd", - .p.long_name = NULL_IF_CONFIG_SMALL("TrueHD"), + CODEC_LONG_NAME("TrueHD"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TRUEHD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c index c9b7b16b69..3092f58510 100644 --- a/libavcodec/mmaldec.c +++ b/libavcodec/mmaldec.c @@ -831,7 +831,7 @@ static const AVClass ffmmal_dec_class = { #define FFMMAL_DEC(NAME, ID) \ const FFCodec ff_##NAME##_mmal_decoder = { \ .p.name = #NAME "_mmal", \ - .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " (mmal)"), \ + CODEC_LONG_NAME(#NAME " (mmal)"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = ID, \ .priv_data_size = sizeof(MMALDecodeContext), \ diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index 97e55119e4..3038d9ea92 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -240,7 +240,7 @@ static av_cold int mm_decode_end(AVCodecContext *avctx) const FFCodec ff_mmvideo_decoder = { .p.name = "mmvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("American Laser Games MM Video"), + CODEC_LONG_NAME("American Laser Games MM Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MMVIDEO, .priv_data_size = sizeof(MmContext), diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index b99b070c56..5348f3bd6c 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -1342,7 +1342,7 @@ static av_cold int mobiclip_close(AVCodecContext *avctx) const FFCodec ff_mobiclip_decoder = { .p.name = "mobiclip", - .p.long_name = NULL_IF_CONFIG_SMALL("MobiClip Video"), + CODEC_LONG_NAME("MobiClip Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MOBICLIP, .priv_data_size = sizeof(MobiClipContext), diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 51e22c04c8..4141c5a495 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -347,7 +347,7 @@ static int mp_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_motionpixels_decoder = { .p.name = "motionpixels", - .p.long_name = NULL_IF_CONFIG_SMALL("Motion Pixels video"), + CODEC_LONG_NAME("Motion Pixels video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MOTIONPIXELS, .priv_data_size = sizeof(MotionPixelsContext), diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 42a964951d..f799252bf2 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -593,7 +593,7 @@ static const AVClass mov_text_decoder_class = { const FFCodec ff_movtext_decoder = { .p.name = "mov_text", - .p.long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"), + CODEC_LONG_NAME("3GPP Timed Text subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_MOV_TEXT, .priv_data_size = sizeof(MovTextContext), diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 9c17ca855a..7aa74d7c9d 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -701,7 +701,7 @@ static const AVClass mov_text_encoder_class = { const FFCodec ff_movtext_encoder = { .p.name = "mov_text", - .p.long_name = NULL_IF_CONFIG_SMALL("3GPP Timed Text subtitle"), + CODEC_LONG_NAME("3GPP Timed Text subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_MOV_TEXT, .priv_data_size = sizeof(MovTextContext), diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 0f203033ef..d2745366c2 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -311,7 +311,7 @@ static av_cold int mpc7_decode_close(AVCodecContext *avctx) const FFCodec ff_mpc7_decoder = { .p.name = "mpc7", - .p.long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"), + CODEC_LONG_NAME("Musepack SV7"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MUSEPACK7, .priv_data_size = sizeof(MPCContext), diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index 4ffdb32483..c1b787c33f 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -385,7 +385,7 @@ static av_cold void mpc8_decode_flush(AVCodecContext *avctx) const FFCodec ff_mpc8_decoder = { .p.name = "mpc8", - .p.long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"), + CODEC_LONG_NAME("Musepack SV8"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MUSEPACK8, .priv_data_size = sizeof(MPCContext), diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 34e9ed3505..2aa5bc776d 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2865,7 +2865,7 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx) const FFCodec ff_mpeg1video_decoder = { .p.name = "mpeg1video", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"), + CODEC_LONG_NAME("MPEG-1 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG1VIDEO, .priv_data_size = sizeof(Mpeg1Context), @@ -2897,7 +2897,7 @@ const FFCodec ff_mpeg1video_decoder = { const FFCodec ff_mpeg2video_decoder = { .p.name = "mpeg2video", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"), + CODEC_LONG_NAME("MPEG-2 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, .priv_data_size = sizeof(Mpeg1Context), @@ -2942,7 +2942,7 @@ const FFCodec ff_mpeg2video_decoder = { //legacy decoder const FFCodec ff_mpegvideo_decoder = { .p.name = "mpegvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"), + CODEC_LONG_NAME("MPEG-1 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, .priv_data_size = sizeof(Mpeg1Context), @@ -3106,7 +3106,7 @@ static av_cold int ipu_decode_end(AVCodecContext *avctx) const FFCodec ff_ipu_decoder = { .p.name = "ipu", - .p.long_name = NULL_IF_CONFIG_SMALL("IPU Video"), + CODEC_LONG_NAME("IPU Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_IPU, .priv_data_size = sizeof(IPUContext), diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index a7e7aef010..e1f09b7ede 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -1220,7 +1220,7 @@ mpeg12_class(2) const FFCodec ff_mpeg1video_encoder = { .p.name = "mpeg1video", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"), + CODEC_LONG_NAME("MPEG-1 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG1VIDEO, .priv_data_size = sizeof(MPEG12EncContext), @@ -1237,7 +1237,7 @@ const FFCodec ff_mpeg1video_encoder = { const FFCodec ff_mpeg2video_encoder = { .p.name = "mpeg2video", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"), + CODEC_LONG_NAME("MPEG-2 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, .priv_data_size = sizeof(MPEG12EncContext), diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 65f3c89c47..8eb81688ef 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3668,7 +3668,7 @@ static const AVClass mpeg4_class = { const FFCodec ff_mpeg4_decoder = { .p.name = "mpeg4", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), + CODEC_LONG_NAME("MPEG-4 part 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG4, .priv_data_size = sizeof(Mpeg4DecContext), diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 96c48b2eb2..8e6e35b927 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1394,7 +1394,7 @@ static const AVClass mpeg4enc_class = { const FFCodec ff_mpeg4_encoder = { .p.name = "mpeg4", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), + CODEC_LONG_NAME("MPEG-4 part 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG4, .priv_data_size = sizeof(MpegEncContext), diff --git a/libavcodec/mpegaudiodec_fixed.c b/libavcodec/mpegaudiodec_fixed.c index 59e1072ffd..b5b6822a19 100644 --- a/libavcodec/mpegaudiodec_fixed.c +++ b/libavcodec/mpegaudiodec_fixed.c @@ -63,7 +63,7 @@ static const int32_t csa_table[8][4] = { #if CONFIG_MP1_DECODER const FFCodec ff_mp1_decoder = { .p.name = "mp1", - .p.long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), + CODEC_LONG_NAME("MP1 (MPEG audio layer 1)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), @@ -80,7 +80,7 @@ const FFCodec ff_mp1_decoder = { #if CONFIG_MP2_DECODER const FFCodec ff_mp2_decoder = { .p.name = "mp2", - .p.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), + CODEC_LONG_NAME("MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, .priv_data_size = sizeof(MPADecodeContext), @@ -97,7 +97,7 @@ const FFCodec ff_mp2_decoder = { #if CONFIG_MP3_DECODER const FFCodec ff_mp3_decoder = { .p.name = "mp3", - .p.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), + CODEC_LONG_NAME("MP3 (MPEG audio layer 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), @@ -114,7 +114,7 @@ const FFCodec ff_mp3_decoder = { #if CONFIG_MP3ADU_DECODER const FFCodec ff_mp3adu_decoder = { .p.name = "mp3adu", - .p.long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), + CODEC_LONG_NAME("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), @@ -131,7 +131,7 @@ const FFCodec ff_mp3adu_decoder = { #if CONFIG_MP3ON4_DECODER const FFCodec ff_mp3on4_decoder = { .p.name = "mp3on4", - .p.long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), + CODEC_LONG_NAME("MP3onMP4"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3ON4, .priv_data_size = sizeof(MP3On4DecodeContext), diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index 1a83f40c19..ba8c49a3b4 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -76,7 +76,7 @@ static const float csa_table[8][4] = { #if CONFIG_MP1FLOAT_DECODER const FFCodec ff_mp1float_decoder = { .p.name = "mp1float", - .p.long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), + CODEC_LONG_NAME("MP1 (MPEG audio layer 1)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), @@ -93,7 +93,7 @@ const FFCodec ff_mp1float_decoder = { #if CONFIG_MP2FLOAT_DECODER const FFCodec ff_mp2float_decoder = { .p.name = "mp2float", - .p.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), + CODEC_LONG_NAME("MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, .priv_data_size = sizeof(MPADecodeContext), @@ -110,7 +110,7 @@ const FFCodec ff_mp2float_decoder = { #if CONFIG_MP3FLOAT_DECODER const FFCodec ff_mp3float_decoder = { .p.name = "mp3float", - .p.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), + CODEC_LONG_NAME("MP3 (MPEG audio layer 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), @@ -127,7 +127,7 @@ const FFCodec ff_mp3float_decoder = { #if CONFIG_MP3ADUFLOAT_DECODER const FFCodec ff_mp3adufloat_decoder = { .p.name = "mp3adufloat", - .p.long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), + CODEC_LONG_NAME("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), @@ -144,7 +144,7 @@ const FFCodec ff_mp3adufloat_decoder = { #if CONFIG_MP3ON4FLOAT_DECODER const FFCodec ff_mp3on4float_decoder = { .p.name = "mp3on4float", - .p.long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), + CODEC_LONG_NAME("MP3onMP4"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP3ON4, .priv_data_size = sizeof(MP3On4DecodeContext), diff --git a/libavcodec/mpegaudioenc_fixed.c b/libavcodec/mpegaudioenc_fixed.c index 1191bbc752..3b2bcb3594 100644 --- a/libavcodec/mpegaudioenc_fixed.c +++ b/libavcodec/mpegaudioenc_fixed.c @@ -25,7 +25,7 @@ const FFCodec ff_mp2fixed_encoder = { .p.name = "mp2fixed", - .p.long_name = NULL_IF_CONFIG_SMALL("MP2 fixed point (MPEG audio layer 2)"), + CODEC_LONG_NAME("MP2 fixed point (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/mpegaudioenc_float.c b/libavcodec/mpegaudioenc_float.c index 6a5bc59bf3..64b5bbda6e 100644 --- a/libavcodec/mpegaudioenc_float.c +++ b/libavcodec/mpegaudioenc_float.c @@ -26,7 +26,7 @@ const FFCodec ff_mp2_encoder = { .p.name = "mp2", - .p.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), + CODEC_LONG_NAME("MP2 (MPEG audio layer 2)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MP2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/mpl2dec.c b/libavcodec/mpl2dec.c index 3645a3a0f6..8639acf0b0 100644 --- a/libavcodec/mpl2dec.c +++ b/libavcodec/mpl2dec.c @@ -83,7 +83,7 @@ static int mpl2_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, const FFCodec ff_mpl2_decoder = { .p.name = "mpl2", - .p.long_name = NULL_IF_CONFIG_SMALL("MPL2 subtitle"), + CODEC_LONG_NAME("MPL2 subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_MPL2, FF_CODEC_DECODE_SUB_CB(mpl2_decode_frame), diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c index 574a3b1526..e8406aa268 100644 --- a/libavcodec/mscc.c +++ b/libavcodec/mscc.c @@ -252,7 +252,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_mscc_decoder = { .p.name = "mscc", - .p.long_name = NULL_IF_CONFIG_SMALL("Mandsoft Screen Capture Codec"), + CODEC_LONG_NAME("Mandsoft Screen Capture Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSCC, .priv_data_size = sizeof(MSCCContext), @@ -265,7 +265,7 @@ const FFCodec ff_mscc_decoder = { const FFCodec ff_srgc_decoder = { .p.name = "srgc", - .p.long_name = NULL_IF_CONFIG_SMALL("Screen Recorder Gold Codec"), + CODEC_LONG_NAME("Screen Recorder Gold Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SRGC, .priv_data_size = sizeof(MSCCContext), diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index a2b1ab1c9f..05a7ed4db6 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -866,7 +866,7 @@ void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr) const FFCodec ff_msmpeg4v1_decoder = { .p.name = "msmpeg4v1", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"), + CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V1, .priv_data_size = sizeof(MpegEncContext), @@ -884,7 +884,7 @@ const FFCodec ff_msmpeg4v1_decoder = { const FFCodec ff_msmpeg4v2_decoder = { .p.name = "msmpeg4v2", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"), + CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V2, .priv_data_size = sizeof(MpegEncContext), @@ -902,7 +902,7 @@ const FFCodec ff_msmpeg4v2_decoder = { const FFCodec ff_msmpeg4v3_decoder = { .p.name = "msmpeg4", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"), + CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 3"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V3, .priv_data_size = sizeof(MpegEncContext), @@ -920,7 +920,7 @@ const FFCodec ff_msmpeg4v3_decoder = { const FFCodec ff_wmv1_decoder = { .p.name = "wmv1", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"), + CODEC_LONG_NAME("Windows Media Video 7"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV1, .priv_data_size = sizeof(MpegEncContext), diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 3bd37d8380..e40acdf3fc 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -678,7 +678,7 @@ void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n) const FFCodec ff_msmpeg4v2_encoder = { .p.name = "msmpeg4v2", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"), + CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V2, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, @@ -692,7 +692,7 @@ const FFCodec ff_msmpeg4v2_encoder = { const FFCodec ff_msmpeg4v3_encoder = { .p.name = "msmpeg4", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"), + CODEC_LONG_NAME("MPEG-4 part 2 Microsoft variant version 3"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSMPEG4V3, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, @@ -706,7 +706,7 @@ const FFCodec ff_msmpeg4v3_encoder = { const FFCodec ff_wmv1_encoder = { .p.name = "wmv1", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"), + CODEC_LONG_NAME("Windows Media Video 7"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV1, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, diff --git a/libavcodec/msp2dec.c b/libavcodec/msp2dec.c index f51075e961..9c51c35c61 100644 --- a/libavcodec/msp2dec.c +++ b/libavcodec/msp2dec.c @@ -94,7 +94,7 @@ static int msp2_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_msp2_decoder = { .p.name = "msp2", - .p.long_name = NULL_IF_CONFIG_SMALL("Microsoft Paint (MSP) version 2"), + CODEC_LONG_NAME("Microsoft Paint (MSP) version 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSP2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index 447d18002c..b6fa7f7abb 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -158,7 +158,7 @@ static av_cold int msrle_decode_end(AVCodecContext *avctx) const FFCodec ff_msrle_decoder = { .p.name = "msrle", - .p.long_name = NULL_IF_CONFIG_SMALL("Microsoft RLE"), + CODEC_LONG_NAME("Microsoft RLE"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSRLE, .priv_data_size = sizeof(MsrleContext), diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c index 8a5f00674a..775852102a 100644 --- a/libavcodec/mss1.c +++ b/libavcodec/mss1.c @@ -221,7 +221,7 @@ static av_cold int mss1_decode_end(AVCodecContext *avctx) const FFCodec ff_mss1_decoder = { .p.name = "mss1", - .p.long_name = NULL_IF_CONFIG_SMALL("MS Screen 1"), + CODEC_LONG_NAME("MS Screen 1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSS1, .priv_data_size = sizeof(MSS1Context), diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 7dfb626014..d8a30019f7 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -846,7 +846,7 @@ static av_cold int mss2_decode_init(AVCodecContext *avctx) const FFCodec ff_mss2_decoder = { .p.name = "mss2", - .p.long_name = NULL_IF_CONFIG_SMALL("MS Windows Media Video V9 Screen"), + CODEC_LONG_NAME("MS Windows Media Video V9 Screen"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSS2, .priv_data_size = sizeof(MSS2Context), diff --git a/libavcodec/mss3.c b/libavcodec/mss3.c index 0464bd12a6..023f110ec8 100644 --- a/libavcodec/mss3.c +++ b/libavcodec/mss3.c @@ -862,7 +862,7 @@ static av_cold int mss3_decode_init(AVCodecContext *avctx) const FFCodec ff_msa1_decoder = { .p.name = "msa1", - .p.long_name = NULL_IF_CONFIG_SMALL("MS ATC Screen"), + CODEC_LONG_NAME("MS ATC Screen"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSA1, .priv_data_size = sizeof(MSS3Context), diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c index 21e0536319..dceb42da25 100644 --- a/libavcodec/mss4.c +++ b/libavcodec/mss4.c @@ -611,7 +611,7 @@ static av_cold int mss4_decode_init(AVCodecContext *avctx) const FFCodec ff_mts2_decoder = { .p.name = "mts2", - .p.long_name = NULL_IF_CONFIG_SMALL("MS Expression Encoder Screen"), + CODEC_LONG_NAME("MS Expression Encoder Screen"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MTS2, .priv_data_size = sizeof(MSS4Context), diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index aeb3027b5f..9903ff36a7 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -340,7 +340,7 @@ static av_cold int msvideo1_decode_end(AVCodecContext *avctx) const FFCodec ff_msvideo1_decoder = { .p.name = "msvideo1", - .p.long_name = NULL_IF_CONFIG_SMALL("Microsoft Video 1"), + CODEC_LONG_NAME("Microsoft Video 1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSVIDEO1, .priv_data_size = sizeof(Msvideo1Context), diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c index 4e1e94e9ab..a349b42ca0 100644 --- a/libavcodec/msvideo1enc.c +++ b/libavcodec/msvideo1enc.c @@ -304,7 +304,7 @@ static av_cold int encode_end(AVCodecContext *avctx) const FFCodec ff_msvideo1_encoder = { .p.name = "msvideo1", - .p.long_name = NULL_IF_CONFIG_SMALL("Microsoft Video-1"), + CODEC_LONG_NAME("Microsoft Video-1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MSVIDEO1, .priv_data_size = sizeof(Msvideo1EncContext), diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c index 4633fb86bc..03be4ddd9d 100644 --- a/libavcodec/mv30.c +++ b/libavcodec/mv30.c @@ -703,7 +703,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_mv30_decoder = { .p.name = "mv30", - .p.long_name = NULL_IF_CONFIG_SMALL("MidiVid 3.0"), + CODEC_LONG_NAME("MidiVid 3.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MV30, .priv_data_size = sizeof(MV30Context), diff --git a/libavcodec/mvcdec.c b/libavcodec/mvcdec.c index 0040ff0853..1e99f44a7d 100644 --- a/libavcodec/mvcdec.c +++ b/libavcodec/mvcdec.c @@ -257,7 +257,7 @@ static int mvc_decode_frame(AVCodecContext *avctx, AVFrame *frame, #if CONFIG_MVC1_DECODER const FFCodec ff_mvc1_decoder = { .p.name = "mvc1", - .p.long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics Motion Video Compressor 1"), + CODEC_LONG_NAME("Silicon Graphics Motion Video Compressor 1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MVC1, .priv_data_size = sizeof(MvcContext), @@ -270,7 +270,7 @@ const FFCodec ff_mvc1_decoder = { #if CONFIG_MVC2_DECODER const FFCodec ff_mvc2_decoder = { .p.name = "mvc2", - .p.long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics Motion Video Compressor 2"), + CODEC_LONG_NAME("Silicon Graphics Motion Video Compressor 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MVC2, .priv_data_size = sizeof(MvcContext), diff --git a/libavcodec/mvha.c b/libavcodec/mvha.c index c58fd239a7..b1661c1c3b 100644 --- a/libavcodec/mvha.c +++ b/libavcodec/mvha.c @@ -295,7 +295,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_mvha_decoder = { .p.name = "mvha", - .p.long_name = NULL_IF_CONFIG_SMALL("MidiVid Archive Codec"), + CODEC_LONG_NAME("MidiVid Archive Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MVHA, .priv_data_size = sizeof(MVHAContext), diff --git a/libavcodec/mwsc.c b/libavcodec/mwsc.c index 8d971fa331..f57648bb15 100644 --- a/libavcodec/mwsc.c +++ b/libavcodec/mwsc.c @@ -168,7 +168,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_mwsc_decoder = { .p.name = "mwsc", - .p.long_name = NULL_IF_CONFIG_SMALL("MatchWare Screen Capture Codec"), + CODEC_LONG_NAME("MatchWare Screen Capture Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MWSC, .priv_data_size = sizeof(MWSCContext), diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c index b3862c7791..760b12f0cc 100644 --- a/libavcodec/mxpegdec.c +++ b/libavcodec/mxpegdec.c @@ -344,7 +344,7 @@ static int mxpeg_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_mxpeg_decoder = { .p.name = "mxpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("Mobotix MxPEG video"), + CODEC_LONG_NAME("Mobotix MxPEG video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MXPEG, .priv_data_size = sizeof(MXpegDecodeContext), diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 3f1d1e028c..e6b52f8592 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -187,7 +187,7 @@ static av_cold int decode_end(AVCodecContext * avctx) { const FFCodec ff_nellymoser_decoder = { .p.name = "nellymoser", - .p.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), + CODEC_LONG_NAME("Nellymoser Asao"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_NELLYMOSER, .priv_data_size = sizeof(NellyMoserDecodeContext), diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 5a50ee6a22..1831d36462 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -415,7 +415,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_nellymoser_encoder = { .p.name = "nellymoser", - .p.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), + CODEC_LONG_NAME("Nellymoser Asao"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_NELLYMOSER, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c index fce11e97f2..90704e1aeb 100644 --- a/libavcodec/notchlc.c +++ b/libavcodec/notchlc.c @@ -535,7 +535,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_notchlc_decoder = { .p.name = "notchlc", - .p.long_name = NULL_IF_CONFIG_SMALL("NotchLC"), + CODEC_LONG_NAME("NotchLC"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_NOTCHLC, .priv_data_size = sizeof(NotchLCContext), diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c index 8dbfa7f726..ccd47586b5 100644 --- a/libavcodec/nuv.c +++ b/libavcodec/nuv.c @@ -361,7 +361,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_nuv_decoder = { .p.name = "nuv", - .p.long_name = NULL_IF_CONFIG_SMALL("NuppelVideo/RTJPEG"), + CODEC_LONG_NAME("NuppelVideo/RTJPEG"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_NUV, .priv_data_size = sizeof(NuvContext), diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index 7fa6c23190..a178827291 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -221,7 +221,7 @@ static const AVClass h264_nvenc_class = { const FFCodec ff_h264_nvenc_encoder = { .p.name = "h264_nvenc", - .p.long_name = NULL_IF_CONFIG_SMALL("NVIDIA NVENC H.264 encoder"), + CODEC_LONG_NAME("NVIDIA NVENC H.264 encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .init = ff_nvenc_encode_init, diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index 290bb1eb77..ae4d73e497 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -202,7 +202,7 @@ static const AVClass hevc_nvenc_class = { const FFCodec ff_hevc_nvenc_encoder = { .p.name = "hevc_nvenc", - .p.long_name = NULL_IF_CONFIG_SMALL("NVIDIA NVENC hevc encoder"), + CODEC_LONG_NAME("NVIDIA NVENC hevc encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .init = ff_nvenc_encode_init, diff --git a/libavcodec/omx.c b/libavcodec/omx.c index 97a2cc0ff1..6e667971ea 100644 --- a/libavcodec/omx.c +++ b/libavcodec/omx.c @@ -938,7 +938,7 @@ static const AVClass omx_mpeg4enc_class = { }; const FFCodec ff_mpeg4_omx_encoder = { .p.name = "mpeg4_omx", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenMAX IL MPEG-4 video encoder"), + CODEC_LONG_NAME("OpenMAX IL MPEG-4 video encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG4, .priv_data_size = sizeof(OMXCodecContext), @@ -959,7 +959,7 @@ static const AVClass omx_h264enc_class = { }; const FFCodec ff_h264_omx_encoder = { .p.name = "h264_omx", - .p.long_name = NULL_IF_CONFIG_SMALL("OpenMAX IL H.264 video encoder"), + CODEC_LONG_NAME("OpenMAX IL H.264 video encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .priv_data_size = sizeof(OMXCodecContext), diff --git a/libavcodec/on2avc.c b/libavcodec/on2avc.c index 3aadac4baf..411414ee26 100644 --- a/libavcodec/on2avc.c +++ b/libavcodec/on2avc.c @@ -1006,7 +1006,7 @@ static av_cold int on2avc_decode_close(AVCodecContext *avctx) const FFCodec ff_on2avc_decoder = { .p.name = "on2avc", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 Audio for Video Codec"), + CODEC_LONG_NAME("On2 Audio for Video Codec"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ON2AVC, .priv_data_size = sizeof(On2AVCContext), diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c index 792eeb1507..c04aa598b8 100644 --- a/libavcodec/opusdec.c +++ b/libavcodec/opusdec.c @@ -704,7 +704,7 @@ static const AVClass opus_class = { const FFCodec ff_opus_decoder = { .p.name = "opus", - .p.long_name = NULL_IF_CONFIG_SMALL("Opus"), + CODEC_LONG_NAME("Opus"), .p.priv_class = &opus_class, .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_OPUS, diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index 7380051a7d..a7a9d3a5f5 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -727,7 +727,7 @@ static const FFCodecDefault opusenc_defaults[] = { const FFCodec ff_opus_encoder = { .p.name = "opus", - .p.long_name = NULL_IF_CONFIG_SMALL("Opus"), + CODEC_LONG_NAME("Opus"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_OPUS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/pafaudio.c b/libavcodec/pafaudio.c index 16f440dd87..52566e86fb 100644 --- a/libavcodec/pafaudio.c +++ b/libavcodec/pafaudio.c @@ -75,7 +75,7 @@ static int paf_audio_decode(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_paf_audio_decoder = { .p.name = "paf_audio", - .p.long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Audio"), + CODEC_LONG_NAME("Amazing Studio Packed Animation File Audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_PAF_AUDIO, .init = paf_audio_init, diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c index cb57b2a5a6..458fe9ff47 100644 --- a/libavcodec/pafvideo.c +++ b/libavcodec/pafvideo.c @@ -410,7 +410,7 @@ static int paf_video_decode(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_paf_video_decoder = { .p.name = "paf_video", - .p.long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Video"), + CODEC_LONG_NAME("Amazing Studio Packed Animation File Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PAF_VIDEO, .priv_data_size = sizeof(PAFVideoDecContext), diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c index 6e934ba7a1..7d01e89f74 100644 --- a/libavcodec/pamenc.c +++ b/libavcodec/pamenc.c @@ -130,7 +130,7 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_pam_encoder = { .p.name = "pam", - .p.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), + CODEC_LONG_NAME("PAM (Portable AnyMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PAM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c index 365b69b599..f65609514a 100644 --- a/libavcodec/pcm-bluray.c +++ b/libavcodec/pcm-bluray.c @@ -301,7 +301,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_pcm_bluray_decoder = { .p.name = "pcm_bluray", - .p.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"), + CODEC_LONG_NAME("PCM signed 16|20|24-bit big-endian for Blu-ray media"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_PCM_BLURAY, FF_CODEC_DECODE_CB(pcm_bluray_decode_frame), diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c index 6543bc2213..1f1a3a27d8 100644 --- a/libavcodec/pcm-blurayenc.c +++ b/libavcodec/pcm-blurayenc.c @@ -272,7 +272,7 @@ static int pcm_bluray_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_pcm_bluray_encoder = { .p.name = "pcm_bluray", - .p.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"), + CODEC_LONG_NAME("PCM signed 16|20|24-bit big-endian for Blu-ray media"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_PCM_BLURAY, .priv_data_size = sizeof(BlurayPCMEncContext), diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c index 358c9d5b0f..419b2a138f 100644 --- a/libavcodec/pcm-dvd.c +++ b/libavcodec/pcm-dvd.c @@ -297,7 +297,7 @@ static int pcm_dvd_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_pcm_dvd_decoder = { .p.name = "pcm_dvd", - .p.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for DVD media"), + CODEC_LONG_NAME("PCM signed 16|20|24-bit big-endian for DVD media"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_PCM_DVD, .priv_data_size = sizeof(PCMDVDContext), diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index 4bc635ab1f..e9349680e8 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -173,7 +173,7 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_pcm_dvd_encoder = { .p.name = "pcm_dvd", - .p.long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for DVD media"), + CODEC_LONG_NAME("PCM signed 16|20|24-bit big-endian for DVD media"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_PCM_DVD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 8e87679329..fcb8ae1c2c 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -555,7 +555,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, AVFrame *frame, #define PCM_ENCODER_1(id_, sample_fmt_, name_, long_name_) \ const FFCodec ff_ ## name_ ## _encoder = { \ .p.name = #name_, \ - .p.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = AV_CODEC_ID_ ## id_, \ .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \ @@ -576,7 +576,7 @@ const FFCodec ff_ ## name_ ## _encoder = { \ #define PCM_DECODER_1(id_, sample_fmt_, name_, long_name_) \ const FFCodec ff_ ## name_ ## _decoder = { \ .p.name = #name_, \ - .p.long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + CODEC_LONG_NAME(long_name_), \ .p.type = AVMEDIA_TYPE_AUDIO, \ .p.id = AV_CODEC_ID_ ## id_, \ .priv_data_size = sizeof(PCMDecode), \ diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 3b82e5ba3e..4cca497298 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -250,7 +250,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_pcx_decoder = { .p.name = "pcx", - .p.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"), + CODEC_LONG_NAME("PC Paintbrush PCX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PCX, FF_CODEC_DECODE_CB(pcx_decode_frame), diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index 1d344994de..509158ba0f 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -194,7 +194,7 @@ static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_pcx_encoder = { .p.name = "pcx", - .p.long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"), + CODEC_LONG_NAME("PC Paintbrush PCX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PCX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index 69aabfe2b0..5f76f12615 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -691,7 +691,7 @@ static const AVClass pgsdec_class = { const FFCodec ff_pgssub_decoder = { .p.name = "pgssub", - .p.long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"), + CODEC_LONG_NAME("HDMV Presentation Graphic Stream subtitles"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_HDMV_PGS_SUBTITLE, .priv_data_size = sizeof(PGSSubContext), diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c index 177ad66468..e5d1df784e 100644 --- a/libavcodec/pgxdec.c +++ b/libavcodec/pgxdec.c @@ -152,7 +152,7 @@ static int pgx_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_pgx_decoder = { .p.name = "pgx", - .p.long_name = NULL_IF_CONFIG_SMALL("PGX (JPEG2000 Test Format)"), + CODEC_LONG_NAME("PGX (JPEG2000 Test Format)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c index b31666d78a..f0e1ef7796 100644 --- a/libavcodec/photocd.c +++ b/libavcodec/photocd.c @@ -466,5 +466,5 @@ const FFCodec ff_photocd_decoder = { .close = photocd_decode_close, FF_CODEC_DECODE_CB(photocd_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .p.long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"), + CODEC_LONG_NAME("Kodak Photo CD"), }; diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c index fcd9e8a9ed..71bad40a0a 100644 --- a/libavcodec/pictordec.c +++ b/libavcodec/pictordec.c @@ -281,7 +281,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_pictor_decoder = { .p.name = "pictor", - .p.long_name = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"), + CODEC_LONG_NAME("Pictor/PC Paint"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PICTOR, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c index d7c40052a5..b349d397f4 100644 --- a/libavcodec/pixlet.c +++ b/libavcodec/pixlet.c @@ -692,7 +692,7 @@ static int pixlet_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_pixlet_decoder = { .p.name = "pixlet", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple Pixlet"), + CODEC_LONG_NAME("Apple Pixlet"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PIXLET, .init = pixlet_init, diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 7cb3d98bd6..9e7d9b589f 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1715,7 +1715,7 @@ static av_cold int png_dec_end(AVCodecContext *avctx) #if CONFIG_APNG_DECODER const FFCodec ff_apng_decoder = { .p.name = "apng", - .p.long_name = NULL_IF_CONFIG_SMALL("APNG (Animated Portable Network Graphics) image"), + CODEC_LONG_NAME("APNG (Animated Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_APNG, .priv_data_size = sizeof(PNGDecContext), @@ -1733,7 +1733,7 @@ const FFCodec ff_apng_decoder = { #if CONFIG_PNG_DECODER const FFCodec ff_png_decoder = { .p.name = "png", - .p.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"), + CODEC_LONG_NAME("PNG (Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PNG, .priv_data_size = sizeof(PNGDecContext), diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 7c1cc55c34..ca1a186ca8 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -1193,7 +1193,7 @@ static const AVClass pngenc_class = { const FFCodec ff_png_encoder = { .p.name = "png", - .p.long_name = NULL_IF_CONFIG_SMALL("PNG (Portable Network Graphics) image"), + CODEC_LONG_NAME("PNG (Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PNG, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, @@ -1215,7 +1215,7 @@ const FFCodec ff_png_encoder = { const FFCodec ff_apng_encoder = { .p.name = "apng", - .p.long_name = NULL_IF_CONFIG_SMALL("APNG (Animated Portable Network Graphics) image"), + CODEC_LONG_NAME("APNG (Animated Portable Network Graphics) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_APNG, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index 6e807a7ac1..6ba54ddccd 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -403,7 +403,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, #if CONFIG_PGM_DECODER const FFCodec ff_pgm_decoder = { .p.name = "pgm", - .p.long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), + CODEC_LONG_NAME("PGM (Portable GrayMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -415,7 +415,7 @@ const FFCodec ff_pgm_decoder = { #if CONFIG_PGMYUV_DECODER const FFCodec ff_pgmyuv_decoder = { .p.name = "pgmyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), + CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGMYUV, .p.capabilities = AV_CODEC_CAP_DR1, @@ -427,7 +427,7 @@ const FFCodec ff_pgmyuv_decoder = { #if CONFIG_PPM_DECODER const FFCodec ff_ppm_decoder = { .p.name = "ppm", - .p.long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), + CODEC_LONG_NAME("PPM (Portable PixelMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PPM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -439,7 +439,7 @@ const FFCodec ff_ppm_decoder = { #if CONFIG_PBM_DECODER const FFCodec ff_pbm_decoder = { .p.name = "pbm", - .p.long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), + CODEC_LONG_NAME("PBM (Portable BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PBM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -451,7 +451,7 @@ const FFCodec ff_pbm_decoder = { #if CONFIG_PAM_DECODER const FFCodec ff_pam_decoder = { .p.name = "pam", - .p.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), + CODEC_LONG_NAME("PAM (Portable AnyMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PAM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -463,7 +463,7 @@ const FFCodec ff_pam_decoder = { #if CONFIG_PFM_DECODER const FFCodec ff_pfm_decoder = { .p.name = "pfm", - .p.long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"), + CODEC_LONG_NAME("PFM (Portable FloatMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PFM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -484,7 +484,7 @@ static av_cold int phm_dec_init(AVCodecContext *avctx) const FFCodec ff_phm_decoder = { .p.name = "phm", - .p.long_name = NULL_IF_CONFIG_SMALL("PHM (Portable HalfFloatMap) image"), + CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PHM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c index b052c03b21..9eb663306d 100644 --- a/libavcodec/pnmenc.c +++ b/libavcodec/pnmenc.c @@ -221,7 +221,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, #if CONFIG_PGM_ENCODER const FFCodec ff_pgm_encoder = { .p.name = "pgm", - .p.long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"), + CODEC_LONG_NAME("PGM (Portable GrayMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -235,7 +235,7 @@ const FFCodec ff_pgm_encoder = { #if CONFIG_PGMYUV_ENCODER const FFCodec ff_pgmyuv_encoder = { .p.name = "pgmyuv", - .p.long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"), + CODEC_LONG_NAME("PGMYUV (Portable GrayMap YUV) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PGMYUV, .p.capabilities = AV_CODEC_CAP_DR1, @@ -249,7 +249,7 @@ const FFCodec ff_pgmyuv_encoder = { #if CONFIG_PPM_ENCODER const FFCodec ff_ppm_encoder = { .p.name = "ppm", - .p.long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"), + CODEC_LONG_NAME("PPM (Portable PixelMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PPM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -263,7 +263,7 @@ const FFCodec ff_ppm_encoder = { #if CONFIG_PBM_ENCODER const FFCodec ff_pbm_encoder = { .p.name = "pbm", - .p.long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"), + CODEC_LONG_NAME("PBM (Portable BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PBM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -276,7 +276,7 @@ const FFCodec ff_pbm_encoder = { #if CONFIG_PFM_ENCODER const FFCodec ff_pfm_encoder = { .p.name = "pfm", - .p.long_name = NULL_IF_CONFIG_SMALL("PFM (Portable FloatMap) image"), + CODEC_LONG_NAME("PFM (Portable FloatMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PFM, .p.capabilities = AV_CODEC_CAP_DR1, @@ -301,7 +301,7 @@ static av_cold int phm_enc_init(AVCodecContext *avctx) const FFCodec ff_phm_encoder = { .p.name = "phm", - .p.long_name = NULL_IF_CONFIG_SMALL("PHM (Portable HalfFloatMap) image"), + CODEC_LONG_NAME("PHM (Portable HalfFloatMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PHM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index df864c77ec..68b29deadb 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -871,7 +871,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) const FFCodec ff_prores_decoder = { .p.name = "prores", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"), + CODEC_LONG_NAME("Apple ProRes (iCodec Pro)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, .priv_data_size = sizeof(ProresContext), diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c index 482f09415d..5fa5f1fd69 100644 --- a/libavcodec/proresenc_anatoliy.c +++ b/libavcodec/proresenc_anatoliy.c @@ -942,7 +942,7 @@ static const enum AVPixelFormat pix_fmts[] = { const FFCodec ff_prores_aw_encoder = { .p.name = "prores_aw", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"), + CODEC_LONG_NAME("Apple ProRes"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, @@ -958,7 +958,7 @@ const FFCodec ff_prores_aw_encoder = { const FFCodec ff_prores_encoder = { .p.name = "prores", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"), + CODEC_LONG_NAME("Apple ProRes"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c index 60bb2286f8..5b38437d0a 100644 --- a/libavcodec/proresenc_kostya.c +++ b/libavcodec/proresenc_kostya.c @@ -1421,7 +1421,7 @@ static const AVClass proresenc_class = { const FFCodec ff_prores_ks_encoder = { .p.name = "prores_ks", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"), + CODEC_LONG_NAME("Apple ProRes (iCodec Pro)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, .priv_data_size = sizeof(ProresContext), diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c index 974b1657c3..e199d1aaa9 100644 --- a/libavcodec/prosumer.c +++ b/libavcodec/prosumer.c @@ -366,7 +366,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_prosumer_decoder = { .p.name = "prosumer", - .p.long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), + CODEC_LONG_NAME("Brooktree ProSumer Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PROSUMER, .priv_data_size = sizeof(ProSumerContext), diff --git a/libavcodec/psd.c b/libavcodec/psd.c index 3ac3f46dd5..ee96bd1237 100644 --- a/libavcodec/psd.c +++ b/libavcodec/psd.c @@ -546,7 +546,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, const FFCodec ff_psd_decoder = { .p.name = "psd", - .p.long_name = NULL_IF_CONFIG_SMALL("Photoshop PSD file"), + CODEC_LONG_NAME("Photoshop PSD file"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PSD, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index 84fe1872d2..ef0b6a306d 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -87,7 +87,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_ptx_decoder = { .p.name = "ptx", - .p.long_name = NULL_IF_CONFIG_SMALL("V.Flash PTX image"), + CODEC_LONG_NAME("V.Flash PTX image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PTX, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index f9da514834..277c55100a 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -790,7 +790,7 @@ static int qcelp_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_qcelp_decoder = { .p.name = "qcelp", - .p.long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"), + CODEC_LONG_NAME("QCELP / PureVoice"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_QCELP, .init = qcelp_decode_init, diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 51ca1fb516..bdf7310b42 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1870,7 +1870,7 @@ static int qdm2_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_qdm2_decoder = { .p.name = "qdm2", - .p.long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"), + CODEC_LONG_NAME("QDesign Music Codec 2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_QDM2, .priv_data_size = sizeof(QDM2Context), diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c index 77bb8d1742..4b582dc349 100644 --- a/libavcodec/qdmc.c +++ b/libavcodec/qdmc.c @@ -729,7 +729,7 @@ static int qdmc_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_qdmc_decoder = { .p.name = "qdmc", - .p.long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 1"), + CODEC_LONG_NAME("QDesign Music Codec 1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_QDMC, .priv_data_size = sizeof(QDMCContext), diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c index 4405ff2b4e..e41451e9a7 100644 --- a/libavcodec/qdrw.c +++ b/libavcodec/qdrw.c @@ -515,7 +515,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_qdraw_decoder = { .p.name = "qdraw", - .p.long_name = NULL_IF_CONFIG_SMALL("Apple QuickDraw"), + CODEC_LONG_NAME("Apple QuickDraw"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QDRAW, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/qoidec.c b/libavcodec/qoidec.c index 1053d784a2..d218d649de 100644 --- a/libavcodec/qoidec.c +++ b/libavcodec/qoidec.c @@ -114,7 +114,7 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_qoi_decoder = { .p.name = "qoi", - .p.long_name = NULL_IF_CONFIG_SMALL("QOI (Quite OK Image format) image"), + CODEC_LONG_NAME("QOI (Quite OK Image format) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QOI, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/qoienc.c b/libavcodec/qoienc.c index 9a18c2a357..6d574e0da9 100644 --- a/libavcodec/qoienc.c +++ b/libavcodec/qoienc.c @@ -128,7 +128,7 @@ static int qoi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_qoi_encoder = { .p.name = "qoi", - .p.long_name = NULL_IF_CONFIG_SMALL("QOI (Quite OK Image format) image"), + CODEC_LONG_NAME("QOI (Quite OK Image format) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QOI, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index ea11e10b1a..5bca338acf 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -352,7 +352,7 @@ static av_cold int decode_init(AVCodecContext *avctx){ const FFCodec ff_qpeg_decoder = { .p.name = "qpeg", - .p.long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"), + CODEC_LONG_NAME("Q-team QPEG"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QPEG, .priv_data_size = sizeof(QpegContext), diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 89ec5dcee8..0f0d719e23 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -1026,7 +1026,7 @@ static const AVClass x##_qsv_class = { \ }; \ const FFCodec ff_##x##_qsv_decoder = { \ .p.name = #x "_qsv", \ - .p.long_name = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync Video acceleration)"), \ + CODEC_LONG_NAME(#X " video (Intel Quick Sync Video acceleration)"), \ .priv_data_size = sizeof(QSVDecContext), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = AV_CODEC_ID_##X, \ diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index a0dc31e24a..1bbdc45203 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -186,7 +186,7 @@ static const FFCodecDefault qsv_enc_defaults[] = { const FFCodec ff_h264_qsv_encoder = { .p.name = "h264_qsv", - .p.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"), + CODEC_LONG_NAME("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)"), .priv_data_size = sizeof(QSVH264EncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index e59747fda3..5986c3f1a6 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -299,7 +299,7 @@ static const FFCodecDefault qsv_enc_defaults[] = { const FFCodec ff_hevc_qsv_encoder = { .p.name = "hevc_qsv", - .p.long_name = NULL_IF_CONFIG_SMALL("HEVC (Intel Quick Sync Video acceleration)"), + CODEC_LONG_NAME("HEVC (Intel Quick Sync Video acceleration)"), .priv_data_size = sizeof(QSVHEVCEncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c index 6d17d896eb..2469ef7c9f 100644 --- a/libavcodec/qsvenc_jpeg.c +++ b/libavcodec/qsvenc_jpeg.c @@ -80,7 +80,7 @@ static const FFCodecDefault qsv_enc_defaults[] = { const FFCodec ff_mjpeg_qsv_encoder = { .p.name = "mjpeg_qsv", - .p.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Intel Quick Sync Video acceleration)"), + CODEC_LONG_NAME("MJPEG (Intel Quick Sync Video acceleration)"), .priv_data_size = sizeof(QSVMJPEGEncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MJPEG, diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c index 5666b3e6e2..22f1ff7c0d 100644 --- a/libavcodec/qsvenc_mpeg2.c +++ b/libavcodec/qsvenc_mpeg2.c @@ -94,7 +94,7 @@ static const FFCodecDefault qsv_enc_defaults[] = { const FFCodec ff_mpeg2_qsv_encoder = { .p.name = "mpeg2_qsv", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync Video acceleration)"), + CODEC_LONG_NAME("MPEG-2 video (Intel Quick Sync Video acceleration)"), .priv_data_size = sizeof(QSVMpeg2EncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index c738da3904..61d50156d3 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -103,7 +103,7 @@ static const FFCodecDefault qsv_enc_defaults[] = { const FFCodec ff_vp9_qsv_encoder = { .p.name = "vp9_qsv", - .p.long_name = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync Video acceleration)"), + CODEC_LONG_NAME("VP9 video (Intel Quick Sync Video acceleration)"), .priv_data_size = sizeof(QSVVP9EncContext), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP9, diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c index 569c68359b..5cb18c86c2 100644 --- a/libavcodec/qtrle.c +++ b/libavcodec/qtrle.c @@ -580,7 +580,7 @@ static av_cold int qtrle_decode_end(AVCodecContext *avctx) const FFCodec ff_qtrle_decoder = { .p.name = "qtrle", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"), + CODEC_LONG_NAME("QuickTime Animation (RLE) video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QTRLE, .priv_data_size = sizeof(QtrleContext), diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 3962c08356..855494d3df 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -401,7 +401,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_qtrle_encoder = { .p.name = "qtrle", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"), + CODEC_LONG_NAME("QuickTime Animation (RLE) video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QTRLE, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/r210dec.c b/libavcodec/r210dec.c index 163e203c73..ae80f46eb6 100644 --- a/libavcodec/r210dec.c +++ b/libavcodec/r210dec.c @@ -105,7 +105,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, #if CONFIG_R210_DECODER const FFCodec ff_r210_decoder = { .p.name = "r210", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), + CODEC_LONG_NAME("Uncompressed RGB 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_R210, .init = decode_init, @@ -116,7 +116,7 @@ const FFCodec ff_r210_decoder = { #if CONFIG_R10K_DECODER const FFCodec ff_r10k_decoder = { .p.name = "r10k", - .p.long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"), + CODEC_LONG_NAME("AJA Kona 10-bit RGB Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_R10K, .init = decode_init, @@ -127,7 +127,7 @@ const FFCodec ff_r10k_decoder = { #if CONFIG_AVRP_DECODER const FFCodec ff_avrp_decoder = { .p.name = "avrp", - .p.long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"), + CODEC_LONG_NAME("Avid 1:1 10-bit RGB Packer"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVRP, .init = decode_init, diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index 139e5b75eb..d87f42ce4a 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -93,7 +93,7 @@ static const enum AVPixelFormat pix_fmt[] = { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE #if CONFIG_R210_ENCODER const FFCodec ff_r210_encoder = { .p.name = "r210", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), + CODEC_LONG_NAME("Uncompressed RGB 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_R210, .p.capabilities = AV_CODEC_CAP_DR1, @@ -105,7 +105,7 @@ const FFCodec ff_r210_encoder = { #if CONFIG_R10K_ENCODER const FFCodec ff_r10k_encoder = { .p.name = "r10k", - .p.long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"), + CODEC_LONG_NAME("AJA Kona 10-bit RGB Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_R10K, .p.capabilities = AV_CODEC_CAP_DR1, @@ -117,7 +117,7 @@ const FFCodec ff_r10k_encoder = { #if CONFIG_AVRP_ENCODER const FFCodec ff_avrp_encoder = { .p.name = "avrp", - .p.long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"), + CODEC_LONG_NAME("Avid 1:1 10-bit RGB Packer"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AVRP, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/ra144dec.c b/libavcodec/ra144dec.c index f9c0900de0..943e84e1f8 100644 --- a/libavcodec/ra144dec.c +++ b/libavcodec/ra144dec.c @@ -128,7 +128,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, AVFrame *frame, const FFCodec ff_ra_144_decoder = { .p.name = "real_144", - .p.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), + CODEC_LONG_NAME("RealAudio 1.0 (14.4K)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_RA_144, .priv_data_size = sizeof(RA144Context), diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 1608b9463e..d9448e88c8 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -537,7 +537,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_ra_144_encoder = { .p.name = "real_144", - .p.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), + CODEC_LONG_NAME("RealAudio 1.0 (14.4K)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_RA_144, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 73242669d3..c8c20e4884 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -239,7 +239,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, AVFrame *frame, const FFCodec ff_ra_288_decoder = { .p.name = "real_288", - .p.long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"), + CODEC_LONG_NAME("RealAudio 2.0 (28.8K)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_RA_288, .priv_data_size = sizeof(RA288Context), diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 5efa919e09..20c5f060d0 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -515,7 +515,7 @@ static void decode_flush(AVCodecContext *avctx) const FFCodec ff_ralf_decoder = { .p.name = "ralf", - .p.long_name = NULL_IF_CONFIG_SMALL("RealAudio Lossless"), + CODEC_LONG_NAME("RealAudio Lossless"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_RALF, .priv_data_size = sizeof(RALFContext), diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c index a04dff6d90..cfa3d6b079 100644 --- a/libavcodec/rasc.c +++ b/libavcodec/rasc.c @@ -797,7 +797,7 @@ static const AVClass rasc_decoder_class = { const FFCodec ff_rasc_decoder = { .p.name = "rasc", - .p.long_name = NULL_IF_CONFIG_SMALL("RemotelyAnywhere Screen Capture"), + CODEC_LONG_NAME("RemotelyAnywhere Screen Capture"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RASC, .priv_data_size = sizeof(RASCContext), diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index e1bb542d51..72cdd13916 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -482,7 +482,7 @@ static av_cold int raw_close_decoder(AVCodecContext *avctx) const FFCodec ff_rawvideo_decoder = { .p.name = "rawvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("raw video"), + CODEC_LONG_NAME("raw video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RAWVIDEO, .priv_data_size = sizeof(RawVideoContext), diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c index 826102efaf..c2643e6d80 100644 --- a/libavcodec/rawenc.c +++ b/libavcodec/rawenc.c @@ -83,7 +83,7 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_rawvideo_encoder = { .p.name = "rawvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("raw video"), + CODEC_LONG_NAME("raw video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RAWVIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/realtextdec.c b/libavcodec/realtextdec.c index f78c8229fe..b09ff78ea4 100644 --- a/libavcodec/realtextdec.c +++ b/libavcodec/realtextdec.c @@ -76,7 +76,7 @@ static int realtext_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, const FFCodec ff_realtext_decoder = { .p.name = "realtext", - .p.long_name = NULL_IF_CONFIG_SMALL("RealText subtitle"), + CODEC_LONG_NAME("RealText subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_REALTEXT, FF_CODEC_DECODE_SUB_CB(realtext_decode_frame), diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c index 77d09739a5..8bf7c6ed16 100644 --- a/libavcodec/rkmppdec.c +++ b/libavcodec/rkmppdec.c @@ -563,7 +563,7 @@ static const AVCodecHWConfigInternal *const rkmpp_hw_configs[] = { RKMPP_DEC_CLASS(NAME) \ const FFCodec ff_##NAME##_rkmpp_decoder = { \ .p.name = #NAME "_rkmpp", \ - .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " (rkmpp)"), \ + CODEC_LONG_NAME(#NAME " (rkmpp)"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = ID, \ .priv_data_size = sizeof(RKMPPDecodeContext), \ diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c index 2e6f555b8c..5dedb96266 100644 --- a/libavcodec/rl2.c +++ b/libavcodec/rl2.c @@ -217,7 +217,7 @@ static av_cold int rl2_decode_end(AVCodecContext *avctx) const FFCodec ff_rl2_decoder = { .p.name = "rl2", - .p.long_name = NULL_IF_CONFIG_SMALL("RL2 video"), + CODEC_LONG_NAME("RL2 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RL2, .priv_data_size = sizeof(Rl2Context), diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index e5bc902133..f0254adc70 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -189,7 +189,7 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_roq_dpcm_encoder = { .p.name = "roq_dpcm", - .p.long_name = NULL_IF_CONFIG_SMALL("id RoQ DPCM"), + CODEC_LONG_NAME("id RoQ DPCM"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ROQ_DPCM, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c index 2f7f91d41f..6f2e48d2f3 100644 --- a/libavcodec/roqvideodec.c +++ b/libavcodec/roqvideodec.c @@ -234,7 +234,7 @@ static av_cold int roq_decode_end(AVCodecContext *avctx) const FFCodec ff_roq_decoder = { .p.name = "roqvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("id RoQ video"), + CODEC_LONG_NAME("id RoQ video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ROQ, .priv_data_size = sizeof(RoqContext), diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 9f03107d81..273686a147 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1119,7 +1119,7 @@ static const AVClass roq_class = { const FFCodec ff_roq_encoder = { .p.name = "roqvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("id RoQ video"), + CODEC_LONG_NAME("id RoQ video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ROQ, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c index f9ab3a7647..cad2eaad73 100644 --- a/libavcodec/rpza.c +++ b/libavcodec/rpza.c @@ -285,7 +285,7 @@ static av_cold int rpza_decode_end(AVCodecContext *avctx) const FFCodec ff_rpza_decoder = { .p.name = "rpza", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime video (RPZA)"), + CODEC_LONG_NAME("QuickTime video (RPZA)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RPZA, .priv_data_size = sizeof(RpzaContext), diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c index e9f035c510..0084a271c6 100644 --- a/libavcodec/rpzaenc.c +++ b/libavcodec/rpzaenc.c @@ -846,7 +846,7 @@ static const AVClass rpza_class = { const FFCodec ff_rpza_encoder = { .p.name = "rpza", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime video (RPZA)"), + CODEC_LONG_NAME("QuickTime video (RPZA)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RPZA, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c index e74f2defe7..61a25df382 100644 --- a/libavcodec/rscc.c +++ b/libavcodec/rscc.c @@ -363,7 +363,7 @@ static int rscc_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_rscc_decoder = { .p.name = "rscc", - .p.long_name = NULL_IF_CONFIG_SMALL("innoHeim/Rsupport Screen Capture Codec"), + CODEC_LONG_NAME("innoHeim/Rsupport Screen Capture Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RSCC, .init = rscc_init, diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index d8b8900795..a45683228e 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -683,7 +683,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict, const FFCodec ff_rv10_decoder = { .p.name = "rv10", - .p.long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"), + CODEC_LONG_NAME("RealVideo 1.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV10, .priv_data_size = sizeof(RVDecContext), @@ -700,7 +700,7 @@ const FFCodec ff_rv10_decoder = { const FFCodec ff_rv20_decoder = { .p.name = "rv20", - .p.long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"), + CODEC_LONG_NAME("RealVideo 2.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV20, .priv_data_size = sizeof(RVDecContext), diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 71cbb8d249..d0704c5a4b 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -67,7 +67,7 @@ int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number) const FFCodec ff_rv10_encoder = { .p.name = "rv10", - .p.long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"), + CODEC_LONG_NAME("RealVideo 1.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV10, .p.priv_class = &ff_mpv_enc_class, diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 8978f3f8e5..a6bacacb48 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -64,7 +64,7 @@ void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number){ const FFCodec ff_rv20_encoder = { .p.name = "rv20", - .p.long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"), + CODEC_LONG_NAME("RealVideo 2.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV20, .p.priv_class = &ff_mpv_enc_class, diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index a06e928a64..0361e75580 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -293,7 +293,7 @@ static av_cold int rv30_decode_init(AVCodecContext *avctx) const FFCodec ff_rv30_decoder = { .p.name = "rv30", - .p.long_name = NULL_IF_CONFIG_SMALL("RealVideo 3.0"), + CODEC_LONG_NAME("RealVideo 3.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV30, .priv_data_size = sizeof(RV34DecContext), diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 1ddc04ebb3..728a04062a 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -576,7 +576,7 @@ static av_cold int rv40_decode_init(AVCodecContext *avctx) const FFCodec ff_rv40_decoder = { .p.name = "rv40", - .p.long_name = NULL_IF_CONFIG_SMALL("RealVideo 4.0"), + CODEC_LONG_NAME("RealVideo 4.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RV40, .priv_data_size = sizeof(RV34DecContext), diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index 07d036e932..f1b41608f3 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -228,7 +228,7 @@ static const AVClass s302m_class = { const FFCodec ff_s302m_decoder = { .p.name = "s302m", - .p.long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"), + CODEC_LONG_NAME("SMPTE 302M"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_S302M, .p.priv_class = &s302m_class, diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c index 123ce1302c..ad59325ec4 100644 --- a/libavcodec/s302menc.c +++ b/libavcodec/s302menc.c @@ -172,7 +172,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, const FFCodec ff_s302m_encoder = { .p.name = "s302m", - .p.long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"), + CODEC_LONG_NAME("SMPTE 302M"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_S302M, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c index d3d77cb548..e84c4bc6b8 100644 --- a/libavcodec/samidec.c +++ b/libavcodec/samidec.c @@ -182,7 +182,7 @@ static void sami_flush(AVCodecContext *avctx) const FFCodec ff_sami_decoder = { .p.name = "sami", - .p.long_name = NULL_IF_CONFIG_SMALL("SAMI subtitle"), + CODEC_LONG_NAME("SAMI subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SAMI, .priv_data_size = sizeof(SAMIContext), diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index aceddaf835..bec3c770ec 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -1516,7 +1516,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_sanm_decoder = { .p.name = "sanm", - .p.long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/Smush video"), + CODEC_LONG_NAME("LucasArts SANM/Smush video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SANM, .priv_data_size = sizeof(SANMVideoContext), diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c index 3c955d5b96..51411eb16b 100644 --- a/libavcodec/sbcdec.c +++ b/libavcodec/sbcdec.c @@ -367,7 +367,7 @@ static int sbc_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_sbc_decoder = { .p.name = "sbc", - .p.long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), + CODEC_LONG_NAME("SBC (low-complexity subband codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SBC, .priv_data_size = sizeof(SBCDecContext), diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c index 863899c524..d7e9fb4198 100644 --- a/libavcodec/sbcenc.c +++ b/libavcodec/sbcenc.c @@ -345,7 +345,7 @@ static const AVClass sbc_class = { const FFCodec ff_sbc_encoder = { .p.name = "sbc", - .p.long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), + CODEC_LONG_NAME("SBC (low-complexity subband codec)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SBC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/scpr.c b/libavcodec/scpr.c index 3abde1c17a..5abe157a7d 100644 --- a/libavcodec/scpr.c +++ b/libavcodec/scpr.c @@ -667,7 +667,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_scpr_decoder = { .p.name = "scpr", - .p.long_name = NULL_IF_CONFIG_SMALL("ScreenPressor"), + CODEC_LONG_NAME("ScreenPressor"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SCPR, .priv_data_size = sizeof(SCPRContext), diff --git a/libavcodec/screenpresso.c b/libavcodec/screenpresso.c index a5ca32765f..0d9e485043 100644 --- a/libavcodec/screenpresso.c +++ b/libavcodec/screenpresso.c @@ -184,7 +184,7 @@ static int screenpresso_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_screenpresso_decoder = { .p.name = "screenpresso", - .p.long_name = NULL_IF_CONFIG_SMALL("Screenpresso"), + CODEC_LONG_NAME("Screenpresso"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SCREENPRESSO, .init = screenpresso_init, diff --git a/libavcodec/sga.c b/libavcodec/sga.c index 296ab5dd5d..d3f4924298 100644 --- a/libavcodec/sga.c +++ b/libavcodec/sga.c @@ -521,7 +521,7 @@ static av_cold int sga_decode_end(AVCodecContext *avctx) const FFCodec ff_sga_decoder = { .p.name = "sga", - .p.long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"), + CODEC_LONG_NAME("Digital Pictures SGA Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SGA_VIDEO, .priv_data_size = sizeof(SGAVideoContext), diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index e33a739ecd..dd3dc46b48 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -287,7 +287,7 @@ static av_cold int sgi_decode_init(AVCodecContext *avctx) const FFCodec ff_sgi_decoder = { .p.name = "sgi", - .p.long_name = NULL_IF_CONFIG_SMALL("SGI image"), + CODEC_LONG_NAME("SGI image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SGI, .priv_data_size = sizeof(SgiState), diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c index 109dbdc1fc..901e0a74f9 100644 --- a/libavcodec/sgienc.c +++ b/libavcodec/sgienc.c @@ -272,7 +272,7 @@ static const AVClass sgi_class = { const FFCodec ff_sgi_encoder = { .p.name = "sgi", - .p.long_name = NULL_IF_CONFIG_SMALL("SGI image"), + CODEC_LONG_NAME("SGI image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SGI, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/sgirledec.c b/libavcodec/sgirledec.c index c1d1da25c4..9e3a220ad4 100644 --- a/libavcodec/sgirledec.c +++ b/libavcodec/sgirledec.c @@ -133,7 +133,7 @@ static int sgirle_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_sgirle_decoder = { .p.name = "sgirle", - .p.long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics RLE 8-bit video"), + CODEC_LONG_NAME("Silicon Graphics RLE 8-bit video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SGIRLE, .init = sgirle_decode_init, diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c index 327bf85eda..eee6014742 100644 --- a/libavcodec/sheervideo.c +++ b/libavcodec/sheervideo.c @@ -2000,7 +2000,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_sheervideo_decoder = { .p.name = "sheervideo", - .p.long_name = NULL_IF_CONFIG_SMALL("BitJazz SheerVideo"), + CODEC_LONG_NAME("BitJazz SheerVideo"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SHEERVIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 02864d06ae..1b2abd76b1 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -805,7 +805,7 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx) const FFCodec ff_shorten_decoder = { .p.name = "shorten", - .p.long_name = NULL_IF_CONFIG_SMALL("Shorten"), + CODEC_LONG_NAME("Shorten"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SHORTEN, .priv_data_size = sizeof(ShortenContext), diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c index d28bc760ca..692b59b3e8 100644 --- a/libavcodec/sipr.c +++ b/libavcodec/sipr.c @@ -564,7 +564,7 @@ static int sipr_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_sipr_decoder = { .p.name = "sipr", - .p.long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"), + CODEC_LONG_NAME("RealAudio SIPR / ACELP.NET"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SIPR, .priv_data_size = sizeof(SiprContext), diff --git a/libavcodec/siren.c b/libavcodec/siren.c index 8a22825615..b3627754da 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -842,7 +842,7 @@ static av_cold int siren_close(AVCodecContext *avctx) const FFCodec ff_siren_decoder = { .p.name = "siren", - .p.long_name = NULL_IF_CONFIG_SMALL("Siren"), + CODEC_LONG_NAME("Siren"), .priv_data_size = sizeof(SirenContext), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SIREN, @@ -857,7 +857,7 @@ const FFCodec ff_siren_decoder = { const FFCodec ff_msnsiren_decoder = { .p.name = "msnsiren", - .p.long_name = NULL_IF_CONFIG_SMALL("MSN Siren"), + CODEC_LONG_NAME("MSN Siren"), .priv_data_size = sizeof(SirenContext), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_MSNSIREN, diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index 2b1c4aebb5..ecc27e9b67 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -742,7 +742,7 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_smacker_decoder = { .p.name = "smackvid", - .p.long_name = NULL_IF_CONFIG_SMALL("Smacker video"), + CODEC_LONG_NAME("Smacker video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SMACKVIDEO, .priv_data_size = sizeof(SmackVContext), @@ -755,7 +755,7 @@ const FFCodec ff_smacker_decoder = { const FFCodec ff_smackaud_decoder = { .p.name = "smackaud", - .p.long_name = NULL_IF_CONFIG_SMALL("Smacker audio"), + CODEC_LONG_NAME("Smacker audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SMACKAUDIO, .init = smka_decode_init, diff --git a/libavcodec/smc.c b/libavcodec/smc.c index c4364cfe8c..e6d01791c2 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -466,7 +466,7 @@ static av_cold int smc_decode_end(AVCodecContext *avctx) const FFCodec ff_smc_decoder = { .p.name = "smc", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"), + CODEC_LONG_NAME("QuickTime Graphics (SMC)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SMC, .priv_data_size = sizeof(SmcContext), diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c index f97e06c07c..f3d26a4e8d 100644 --- a/libavcodec/smcenc.c +++ b/libavcodec/smcenc.c @@ -550,7 +550,7 @@ static int smc_encode_end(AVCodecContext *avctx) const FFCodec ff_smc_encoder = { .p.name = "smc", - .p.long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"), + CODEC_LONG_NAME("QuickTime Graphics (SMC)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SMC, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 3a7fda09eb..5c95ffde11 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -655,7 +655,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_snow_decoder = { .p.name = "snow", - .p.long_name = NULL_IF_CONFIG_SMALL("Snow"), + CODEC_LONG_NAME("Snow"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SNOW, .priv_data_size = sizeof(SnowContext), diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index 351ee0abc4..b647fc9016 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1930,7 +1930,7 @@ static const AVClass snowenc_class = { const FFCodec ff_snow_encoder = { .p.name = "snow", - .p.long_name = NULL_IF_CONFIG_SMALL("Snow"), + CODEC_LONG_NAME("Snow"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SNOW, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 50fd171231..77bdb418a7 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -1078,7 +1078,7 @@ static int sonic_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_sonic_decoder = { .p.name = "sonic", - .p.long_name = NULL_IF_CONFIG_SMALL("Sonic"), + CODEC_LONG_NAME("Sonic"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC, .priv_data_size = sizeof(SonicContext), @@ -1093,7 +1093,7 @@ const FFCodec ff_sonic_decoder = { #if CONFIG_SONIC_ENCODER const FFCodec ff_sonic_encoder = { .p.name = "sonic", - .p.long_name = NULL_IF_CONFIG_SMALL("Sonic"), + CODEC_LONG_NAME("Sonic"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, @@ -1109,7 +1109,7 @@ const FFCodec ff_sonic_encoder = { #if CONFIG_SONIC_LS_ENCODER const FFCodec ff_sonic_ls_encoder = { .p.name = "sonicls", - .p.long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"), + CODEC_LONG_NAME("Sonic lossless"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SONIC_LS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 1d8316f64c..394448c5a9 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -94,7 +94,7 @@ int ff_sp5x_process_packet(AVCodecContext *avctx, AVPacket *avpkt) #if CONFIG_SP5X_DECODER const FFCodec ff_sp5x_decoder = { .p.name = "sp5x", - .p.long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"), + CODEC_LONG_NAME("Sunplus JPEG (SP5X)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SP5X, .priv_data_size = sizeof(MJpegDecodeContext), @@ -110,7 +110,7 @@ const FFCodec ff_sp5x_decoder = { #if CONFIG_AMV_DECODER const FFCodec ff_amv_decoder = { .p.name = "amv", - .p.long_name = NULL_IF_CONFIG_SMALL("AMV Video"), + CODEC_LONG_NAME("AMV Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AMV, .priv_data_size = sizeof(MJpegDecodeContext), diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index b3b3f091d6..1661b66ae7 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -725,7 +725,7 @@ static av_cold int speedhq_decode_init(AVCodecContext *avctx) const FFCodec ff_speedhq_decoder = { .p.name = "speedhq", - .p.long_name = NULL_IF_CONFIG_SMALL("NewTek SpeedHQ"), + CODEC_LONG_NAME("NewTek SpeedHQ"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SPEEDHQ, .priv_data_size = sizeof(SHQContext), diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 73c70c269a..747ed679bd 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -279,7 +279,7 @@ int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_sli #if CONFIG_SPEEDHQ_ENCODER const FFCodec ff_speedhq_encoder = { .p.name = "speedhq", - .p.long_name = NULL_IF_CONFIG_SMALL("NewTek SpeedHQ"), + CODEC_LONG_NAME("NewTek SpeedHQ"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SPEEDHQ, .p.priv_class = &ff_mpv_enc_class, diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c index d16317ddec..83981fc454 100644 --- a/libavcodec/speexdec.c +++ b/libavcodec/speexdec.c @@ -1578,7 +1578,7 @@ static av_cold int speex_decode_close(AVCodecContext *avctx) const FFCodec ff_speex_decoder = { .p.name = "speex", - .p.long_name = NULL_IF_CONFIG_SMALL("Speex"), + CODEC_LONG_NAME("Speex"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_SPEEX, .init = speex_decode_init, diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c index 3a1ddfc88b..8697f5b149 100644 --- a/libavcodec/srtdec.c +++ b/libavcodec/srtdec.c @@ -92,7 +92,7 @@ static int srt_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, /* deprecated decoder */ const FFCodec ff_srt_decoder = { .p.name = "srt", - .p.long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + CODEC_LONG_NAME("SubRip subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBRIP, .init = ff_ass_subtitle_header_default, @@ -105,7 +105,7 @@ const FFCodec ff_srt_decoder = { #if CONFIG_SUBRIP_DECODER const FFCodec ff_subrip_decoder = { .p.name = "subrip", - .p.long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + CODEC_LONG_NAME("SubRip subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBRIP, .init = ff_ass_subtitle_header_default, diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index f6b2f16048..7e36a2200c 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -295,7 +295,7 @@ static int srt_encode_close(AVCodecContext *avctx) /* deprecated encoder */ const FFCodec ff_srt_encoder = { .p.name = "srt", - .p.long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + CODEC_LONG_NAME("SubRip subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBRIP, .priv_data_size = sizeof(SRTContext), @@ -308,7 +308,7 @@ const FFCodec ff_srt_encoder = { #if CONFIG_SUBRIP_ENCODER const FFCodec ff_subrip_encoder = { .p.name = "subrip", - .p.long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"), + CODEC_LONG_NAME("SubRip subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBRIP, .priv_data_size = sizeof(SRTContext), @@ -321,7 +321,7 @@ const FFCodec ff_subrip_encoder = { #if CONFIG_TEXT_ENCODER const FFCodec ff_text_encoder = { .p.name = "text", - .p.long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"), + CODEC_LONG_NAME("Raw text subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_TEXT, .priv_data_size = sizeof(SRTContext), diff --git a/libavcodec/subviewerdec.c b/libavcodec/subviewerdec.c index 3a293b0a34..209f69505f 100644 --- a/libavcodec/subviewerdec.c +++ b/libavcodec/subviewerdec.c @@ -67,7 +67,7 @@ static int subviewer_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, const FFCodec ff_subviewer_decoder = { .p.name = "subviewer", - .p.long_name = NULL_IF_CONFIG_SMALL("SubViewer subtitle"), + CODEC_LONG_NAME("SubViewer subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBVIEWER, FF_CODEC_DECODE_SUB_CB(subviewer_decode_frame), diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index ee648ba95d..77feef06e1 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -206,7 +206,7 @@ static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_sunrast_decoder = { .p.name = "sunrast", - .p.long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"), + CODEC_LONG_NAME("Sun Rasterfile image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SUNRAST, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c index 2f0c033b46..9b82f9921a 100644 --- a/libavcodec/sunrastenc.c +++ b/libavcodec/sunrastenc.c @@ -210,7 +210,7 @@ static const AVClass sunrast_class = { const FFCodec ff_sunrast_encoder = { .p.name = "sunrast", - .p.long_name = NULL_IF_CONFIG_SMALL("Sun Rasterfile image"), + CODEC_LONG_NAME("Sun Rasterfile image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SUNRAST, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index c96f65249a..828b38b93d 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -845,7 +845,7 @@ static void svq1_flush(AVCodecContext *avctx) const FFCodec ff_svq1_decoder = { .p.name = "svq1", - .p.long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), + CODEC_LONG_NAME("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SVQ1, .priv_data_size = sizeof(SVQ1Context), diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index f92ede867c..ef6655c2f7 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -679,7 +679,7 @@ static const AVClass svq1enc_class = { const FFCodec ff_svq1_encoder = { .p.name = "svq1", - .p.long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), + CODEC_LONG_NAME("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SVQ1, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index ea9842f9b4..7e8f16cc72 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -1588,7 +1588,7 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx) const FFCodec ff_svq3_decoder = { .p.name = "svq3", - .p.long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"), + CODEC_LONG_NAME("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_SVQ3, .priv_data_size = sizeof(SVQ3Context), diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 6f4cc92e88..f7fb34617d 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -939,7 +939,7 @@ static av_cold int tak_decode_close(AVCodecContext *avctx) const FFCodec ff_tak_decoder = { .p.name = "tak", - .p.long_name = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor)"), + CODEC_LONG_NAME("TAK (Tom's lossless Audio Kompressor)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TAK, .priv_data_size = sizeof(TAKDecContext), diff --git a/libavcodec/targa.c b/libavcodec/targa.c index daade89e28..07005f2be6 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -304,7 +304,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_targa_decoder = { .p.name = "targa", - .p.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), + CODEC_LONG_NAME("Truevision Targa image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TARGA, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/targa_y216dec.c b/libavcodec/targa_y216dec.c index ab98597492..d5234c16ae 100644 --- a/libavcodec/targa_y216dec.c +++ b/libavcodec/targa_y216dec.c @@ -75,7 +75,7 @@ static int y216_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_targa_y216_decoder = { .p.name = "targa_y216", - .p.long_name = NULL_IF_CONFIG_SMALL("Pinnacle TARGA CineWave YUV16"), + CODEC_LONG_NAME("Pinnacle TARGA CineWave YUV16"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TARGA_Y216, .init = y216_decode_init, diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index d93a698e24..bb3cb93187 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -204,7 +204,7 @@ static const AVClass targa_class = { const FFCodec ff_targa_encoder = { .p.name = "targa", - .p.long_name = NULL_IF_CONFIG_SMALL("Truevision Targa image"), + CODEC_LONG_NAME("Truevision Targa image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TARGA, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/tdsc.c b/libavcodec/tdsc.c index aeb1ea363e..b5ab2e171b 100644 --- a/libavcodec/tdsc.c +++ b/libavcodec/tdsc.c @@ -623,7 +623,7 @@ static int tdsc_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_tdsc_decoder = { .p.name = "tdsc", - .p.long_name = NULL_IF_CONFIG_SMALL("TDSC"), + CODEC_LONG_NAME("TDSC"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TDSC, .init = tdsc_init, diff --git a/libavcodec/textdec.c b/libavcodec/textdec.c index 4856ecdde3..b9aebff002 100644 --- a/libavcodec/textdec.c +++ b/libavcodec/textdec.c @@ -82,7 +82,7 @@ static const AVClass textsub_decoder_class = { #if CONFIG_TEXT_DECODER const FFCodec ff_text_decoder = { .p.name = "text", - .p.long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"), + CODEC_LONG_NAME("Raw text subtitle"), .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_TEXT, @@ -105,7 +105,7 @@ static int linebreak_init(AVCodecContext *avctx) #if CONFIG_VPLAYER_DECODER const FFCodec ff_vplayer_decoder = { .p.name = "vplayer", - .p.long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitle"), + CODEC_LONG_NAME("VPlayer subtitle"), .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_VPLAYER, @@ -119,7 +119,7 @@ const FFCodec ff_vplayer_decoder = { #if CONFIG_STL_DECODER const FFCodec ff_stl_decoder = { .p.name = "stl", - .p.long_name = NULL_IF_CONFIG_SMALL("Spruce subtitle format"), + CODEC_LONG_NAME("Spruce subtitle format"), .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_STL, @@ -133,7 +133,7 @@ const FFCodec ff_stl_decoder = { #if CONFIG_PJS_DECODER const FFCodec ff_pjs_decoder = { .p.name = "pjs", - .p.long_name = NULL_IF_CONFIG_SMALL("PJS subtitle"), + CODEC_LONG_NAME("PJS subtitle"), .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_PJS, @@ -147,7 +147,7 @@ const FFCodec ff_pjs_decoder = { #if CONFIG_SUBVIEWER1_DECODER const FFCodec ff_subviewer1_decoder = { .p.name = "subviewer1", - .p.long_name = NULL_IF_CONFIG_SMALL("SubViewer1 subtitle"), + CODEC_LONG_NAME("SubViewer1 subtitle"), .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBVIEWER1, diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 785ccfbdcf..19c0671bf6 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -263,7 +263,7 @@ static av_cold int seqvideo_decode_end(AVCodecContext *avctx) const FFCodec ff_tiertexseqvideo_decoder = { .p.name = "tiertexseqvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"), + CODEC_LONG_NAME("Tiertex Limited SEQ video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TIERTEXSEQVIDEO, .priv_data_size = sizeof(SeqVideoContext), diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 109392ad44..beb427e007 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -2182,7 +2182,7 @@ static const AVClass tiff_decoder_class = { const FFCodec ff_tiff_decoder = { .p.name = "tiff", - .p.long_name = NULL_IF_CONFIG_SMALL("TIFF image"), + CODEC_LONG_NAME("TIFF image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TIFF, .priv_data_size = sizeof(TiffContext), diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index 2dc31345d4..6dfbdaeb40 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -571,7 +571,7 @@ static const AVClass tiffenc_class = { const FFCodec ff_tiff_encoder = { .p.name = "tiff", - .p.long_name = NULL_IF_CONFIG_SMALL("TIFF image"), + CODEC_LONG_NAME("TIFF image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TIFF, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c index fff3806e04..cdb83452e5 100644 --- a/libavcodec/tmv.c +++ b/libavcodec/tmv.c @@ -88,7 +88,7 @@ static av_cold int tmv_decode_init(AVCodecContext *avctx) const FFCodec ff_tmv_decoder = { .p.name = "tmv", - .p.long_name = NULL_IF_CONFIG_SMALL("8088flex TMV"), + CODEC_LONG_NAME("8088flex TMV"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TMV, .init = tmv_decode_init, diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index ab632e99dc..6b0ee22569 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -912,7 +912,7 @@ static av_cold int truemotion1_decode_end(AVCodecContext *avctx) const FFCodec ff_truemotion1_decoder = { .p.name = "truemotion1", - .p.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 1.0"), + CODEC_LONG_NAME("Duck TrueMotion 1.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TRUEMOTION1, .priv_data_size = sizeof(TrueMotion1Context), diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index 3784733bee..b168b9cda1 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -1010,7 +1010,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_truemotion2_decoder = { .p.name = "truemotion2", - .p.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0"), + CODEC_LONG_NAME("Duck TrueMotion 2.0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TRUEMOTION2, .priv_data_size = sizeof(TM2Context), diff --git a/libavcodec/truemotion2rt.c b/libavcodec/truemotion2rt.c index a0bf4749f3..c6015b278a 100644 --- a/libavcodec/truemotion2rt.c +++ b/libavcodec/truemotion2rt.c @@ -216,7 +216,7 @@ static av_cold int truemotion2rt_decode_init(AVCodecContext *avctx) const FFCodec ff_truemotion2rt_decoder = { .p.name = "truemotion2rt", - .p.long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0 Real Time"), + CODEC_LONG_NAME("Duck TrueMotion 2.0 Real Time"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TRUEMOTION2RT, .priv_data_size = sizeof(TrueMotion2RTContext), diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index 2493a944cf..454121cc75 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -357,7 +357,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_truespeech_decoder = { .p.name = "truespeech", - .p.long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"), + CODEC_LONG_NAME("DSP Group TrueSpeech"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TRUESPEECH, .priv_data_size = sizeof(TSContext), diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index 89c4413647..0ebe641ab1 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -168,7 +168,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_tscc_decoder = { .p.name = "camtasia", - .p.long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"), + CODEC_LONG_NAME("TechSmith Screen Capture Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TSCC, .priv_data_size = sizeof(CamtasiaContext), diff --git a/libavcodec/tscc2.c b/libavcodec/tscc2.c index ba84a07da7..6e4fe503c1 100644 --- a/libavcodec/tscc2.c +++ b/libavcodec/tscc2.c @@ -358,7 +358,7 @@ static av_cold int tscc2_decode_init(AVCodecContext *avctx) const FFCodec ff_tscc2_decoder = { .p.name = "tscc2", - .p.long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Codec 2"), + CODEC_LONG_NAME("TechSmith Screen Codec 2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TSCC2, .priv_data_size = sizeof(TSCC2Context), diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 4bc6016977..6fb8d7a74f 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -422,7 +422,7 @@ static const AVClass tta_decoder_class = { const FFCodec ff_tta_decoder = { .p.name = "tta", - .p.long_name = NULL_IF_CONFIG_SMALL("TTA (True Audio)"), + CODEC_LONG_NAME("TTA (True Audio)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TTA, .priv_data_size = sizeof(TTAContext), diff --git a/libavcodec/ttaenc.c b/libavcodec/ttaenc.c index 20a711ede6..d41d2e6fa5 100644 --- a/libavcodec/ttaenc.c +++ b/libavcodec/ttaenc.c @@ -201,7 +201,7 @@ static av_cold int tta_encode_close(AVCodecContext *avctx) const FFCodec ff_tta_encoder = { .p.name = "tta", - .p.long_name = NULL_IF_CONFIG_SMALL("TTA (True Audio)"), + CODEC_LONG_NAME("TTA (True Audio)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TTA, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index 7a09c8fb5e..fb05c38968 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -385,7 +385,7 @@ static av_cold int ttml_encode_init(AVCodecContext *avctx) const FFCodec ff_ttml_encoder = { .p.name = "ttml", - .p.long_name = NULL_IF_CONFIG_SMALL("TTML subtitle"), + CODEC_LONG_NAME("TTML subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_TTML, .priv_data_size = sizeof(TTMLContext), diff --git a/libavcodec/twinvqdec.c b/libavcodec/twinvqdec.c index 7732957850..9e4587f2bc 100644 --- a/libavcodec/twinvqdec.c +++ b/libavcodec/twinvqdec.c @@ -416,7 +416,7 @@ static av_cold int twinvq_decode_init(AVCodecContext *avctx) const FFCodec ff_twinvq_decoder = { .p.name = "twinvq", - .p.long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"), + CODEC_LONG_NAME("VQF TwinVQ"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_TWINVQ, .priv_data_size = sizeof(TwinVQContext), diff --git a/libavcodec/txd.c b/libavcodec/txd.c index 7e8b33646b..d71e788e7d 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -164,7 +164,7 @@ static int txd_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_txd_decoder = { .p.name = "txd", - .p.long_name = NULL_IF_CONFIG_SMALL("Renderware TXD (TeXture Dictionary) image"), + CODEC_LONG_NAME("Renderware TXD (TeXture Dictionary) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_TXD, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c index a3abec3d5a..c5652c6889 100644 --- a/libavcodec/ulti.c +++ b/libavcodec/ulti.c @@ -416,7 +416,7 @@ static int ulti_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_ulti_decoder = { .p.name = "ultimotion", - .p.long_name = NULL_IF_CONFIG_SMALL("IBM UltiMotion"), + CODEC_LONG_NAME("IBM UltiMotion"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ULTI, .priv_data_size = sizeof(UltimotionDecodeContext), diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c index fd16c3f59b..83120d1b22 100644 --- a/libavcodec/utvideodec.c +++ b/libavcodec/utvideodec.c @@ -1052,7 +1052,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_utvideo_decoder = { .p.name = "utvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Ut Video"), + CODEC_LONG_NAME("Ut Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_UTVIDEO, .priv_data_size = sizeof(UtvideoContext), diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c index 191d271ca2..d4388da8ba 100644 --- a/libavcodec/utvideoenc.c +++ b/libavcodec/utvideoenc.c @@ -645,7 +645,7 @@ static const AVClass utvideo_class = { const FFCodec ff_utvideo_encoder = { .p.name = "utvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Ut Video"), + CODEC_LONG_NAME("Ut Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_UTVIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index f5463799c4..43b92f6ec9 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -233,7 +233,7 @@ static const AVClass v210dec_class = { const FFCodec ff_v210_decoder = { .p.name = "v210", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), + CODEC_LONG_NAME("Uncompressed 4:2:2 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V210, .priv_data_size = sizeof(V210DecContext), diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index f466df8c60..abbbf4ff9d 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -109,7 +109,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_v210_encoder = { .p.name = "v210", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), + CODEC_LONG_NAME("Uncompressed 4:2:2 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V210, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/v210x.c b/libavcodec/v210x.c index dc188eb8a3..96594e2a43 100644 --- a/libavcodec/v210x.c +++ b/libavcodec/v210x.c @@ -121,7 +121,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_v210x_decoder = { .p.name = "v210x", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), + CODEC_LONG_NAME("Uncompressed 4:2:2 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V210X, .init = decode_init, diff --git a/libavcodec/v308dec.c b/libavcodec/v308dec.c index ee9d723dd6..a81771fc5f 100644 --- a/libavcodec/v308dec.c +++ b/libavcodec/v308dec.c @@ -74,7 +74,7 @@ static int v308_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_v308_decoder = { .p.name = "v308", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"), + CODEC_LONG_NAME("Uncompressed packed 4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V308, .init = v308_decode_init, diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c index c6a270a883..78e33c0a8a 100644 --- a/libavcodec/v308enc.c +++ b/libavcodec/v308enc.c @@ -72,7 +72,7 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_v308_encoder = { .p.name = "v308", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"), + CODEC_LONG_NAME("Uncompressed packed 4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V308, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/v408dec.c b/libavcodec/v408dec.c index 0c1d0244d0..edc9976d94 100644 --- a/libavcodec/v408dec.c +++ b/libavcodec/v408dec.c @@ -92,7 +92,7 @@ static int v408_decode_frame(AVCodecContext *avctx, AVFrame *pic, #if CONFIG_AYUV_DECODER const FFCodec ff_ayuv_decoder = { .p.name = "ayuv", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed MS 4:4:4:4"), + CODEC_LONG_NAME("Uncompressed packed MS 4:4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AYUV, .init = v408_decode_init, @@ -104,7 +104,7 @@ const FFCodec ff_ayuv_decoder = { #if CONFIG_V408_DECODER const FFCodec ff_v408_decoder = { .p.name = "v408", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed QT 4:4:4:4"), + CODEC_LONG_NAME("Uncompressed packed QT 4:4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V408, .init = v408_decode_init, diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c index 7ab59792e6..514f41be4e 100644 --- a/libavcodec/v408enc.c +++ b/libavcodec/v408enc.c @@ -91,7 +91,7 @@ static const enum AVPixelFormat pix_fmt[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NO #if CONFIG_AYUV_ENCODER const FFCodec ff_ayuv_encoder = { .p.name = "ayuv", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed MS 4:4:4:4"), + CODEC_LONG_NAME("Uncompressed packed MS 4:4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_AYUV, .p.capabilities = AV_CODEC_CAP_DR1, @@ -104,7 +104,7 @@ const FFCodec ff_ayuv_encoder = { #if CONFIG_V408_ENCODER const FFCodec ff_v408_encoder = { .p.name = "v408", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed QT 4:4:4:4"), + CODEC_LONG_NAME("Uncompressed packed QT 4:4:4:4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V408, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/v410dec.c b/libavcodec/v410dec.c index 4844e123d9..fb859e8cca 100644 --- a/libavcodec/v410dec.c +++ b/libavcodec/v410dec.c @@ -116,7 +116,7 @@ static int v410_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_v410_decoder = { .p.name = "v410", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"), + CODEC_LONG_NAME("Uncompressed 4:4:4 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V410, .init = v410_decode_init, diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index f08ccb2147..bad13c371a 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -76,7 +76,7 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_v410_encoder = { .p.name = "v410", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"), + CODEC_LONG_NAME("Uncompressed 4:4:4 10-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_V410, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index 81729e256c..53a57eaeb8 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -242,7 +242,7 @@ static const AVOption options[] = { M2MDEC_CLASS(NAME) \ const FFCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ .p.name = #NAME "_v4l2m2m" , \ - .p.long_name = NULL_IF_CONFIG_SMALL("V4L2 mem2mem " LONGNAME " decoder wrapper"), \ + CODEC_LONG_NAME("V4L2 mem2mem " LONGNAME " decoder wrapper"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = CODEC , \ .priv_data_size = sizeof(V4L2m2mPriv), \ diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index 03425673ea..9a0837ecf3 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -423,7 +423,7 @@ static const FFCodecDefault v4l2_m2m_defaults[] = { M2MENC_CLASS(NAME, OPTIONS_NAME) \ const FFCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ .p.name = #NAME "_v4l2m2m" , \ - .p.long_name = NULL_IF_CONFIG_SMALL("V4L2 mem2mem " LONGNAME " encoder wrapper"), \ + CODEC_LONG_NAME("V4L2 mem2mem " LONGNAME " encoder wrapper"), \ .p.type = AVMEDIA_TYPE_VIDEO, \ .p.id = CODEC , \ .priv_data_size = sizeof(V4L2m2mPriv), \ diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index f1f6694f3b..b1b503b2a6 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -1327,7 +1327,7 @@ static const AVClass vaapi_encode_h264_class = { const FFCodec ff_h264_vaapi_encoder = { .p.name = "h264_vaapi", - .p.long_name = NULL_IF_CONFIG_SMALL("H.264/AVC (VAAPI)"), + CODEC_LONG_NAME("H.264/AVC (VAAPI)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .priv_data_size = sizeof(VAAPIEncodeH264Context), diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 967d71e998..875c18343e 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1447,7 +1447,7 @@ static const AVClass vaapi_encode_h265_class = { const FFCodec ff_hevc_vaapi_encoder = { .p.name = "hevc_vaapi", - .p.long_name = NULL_IF_CONFIG_SMALL("H.265/HEVC (VAAPI)"), + CODEC_LONG_NAME("H.265/HEVC (VAAPI)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .priv_data_size = sizeof(VAAPIEncodeH265Context), diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index cf1497a440..5ef93cd102 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -566,7 +566,7 @@ static const AVClass vaapi_encode_mjpeg_class = { const FFCodec ff_mjpeg_vaapi_encoder = { .p.name = "mjpeg_vaapi", - .p.long_name = NULL_IF_CONFIG_SMALL("MJPEG (VAAPI)"), + CODEC_LONG_NAME("MJPEG (VAAPI)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MJPEG, .priv_data_size = sizeof(VAAPIEncodeMJPEGContext), diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index f592043f37..38e1d83f68 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -689,7 +689,7 @@ static const AVClass vaapi_encode_mpeg2_class = { const FFCodec ff_mpeg2_vaapi_encoder = { .p.name = "mpeg2_vaapi", - .p.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 (VAAPI)"), + CODEC_LONG_NAME("MPEG-2 (VAAPI)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, .priv_data_size = sizeof(VAAPIEncodeMPEG2Context), diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index 1cb2446c88..93e543d798 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -244,7 +244,7 @@ static const AVClass vaapi_encode_vp8_class = { const FFCodec ff_vp8_vaapi_encoder = { .p.name = "vp8_vaapi", - .p.long_name = NULL_IF_CONFIG_SMALL("VP8 (VAAPI)"), + CODEC_LONG_NAME("VP8 (VAAPI)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP8, .priv_data_size = sizeof(VAAPIEncodeVP8Context), diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 9530b2f462..ea824a31d1 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -298,7 +298,7 @@ static const AVClass vaapi_encode_vp9_class = { const FFCodec ff_vp9_vaapi_encoder = { .p.name = "vp9_vaapi", - .p.long_name = NULL_IF_CONFIG_SMALL("VP9 (VAAPI)"), + CODEC_LONG_NAME("VP9 (VAAPI)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP9, .priv_data_size = sizeof(VAAPIEncodeVP9Context), diff --git a/libavcodec/vb.c b/libavcodec/vb.c index 9024f0947c..8b0e216473 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -277,7 +277,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_vb_decoder = { .p.name = "vb", - .p.long_name = NULL_IF_CONFIG_SMALL("Beam Software VB"), + CODEC_LONG_NAME("Beam Software VB"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VB, .priv_data_size = sizeof(VBDecContext), diff --git a/libavcodec/vble.c b/libavcodec/vble.c index 48a0c1371b..9307b0d165 100644 --- a/libavcodec/vble.c +++ b/libavcodec/vble.c @@ -203,7 +203,7 @@ static av_cold int vble_decode_init(AVCodecContext *avctx) const FFCodec ff_vble_decoder = { .p.name = "vble", - .p.long_name = NULL_IF_CONFIG_SMALL("VBLE Lossless Codec"), + CODEC_LONG_NAME("VBLE Lossless Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VBLE, .priv_data_size = sizeof(VBLEContext), diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c index d8a3c61c8c..d92dcd46b9 100644 --- a/libavcodec/vbndec.c +++ b/libavcodec/vbndec.c @@ -175,7 +175,7 @@ static int vbn_decode_frame(AVCodecContext *avctx, const FFCodec ff_vbn_decoder = { .p.name = "vbn", - .p.long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), + CODEC_LONG_NAME("Vizrt Binary Image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VBN, .init = vbn_init, diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c index c93b4e37be..45101382a3 100644 --- a/libavcodec/vbnenc.c +++ b/libavcodec/vbnenc.c @@ -150,7 +150,7 @@ static const AVClass vbnenc_class = { const FFCodec ff_vbn_encoder = { .p.name = "vbn", - .p.long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), + CODEC_LONG_NAME("Vizrt Binary Image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VBN, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 60e86acfd9..9f32e82f9e 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -1203,7 +1203,7 @@ static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = { const FFCodec ff_vc1_decoder = { .p.name = "vc1", - .p.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), + CODEC_LONG_NAME("SMPTE VC-1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VC1, .priv_data_size = sizeof(VC1Context), @@ -1240,7 +1240,7 @@ const FFCodec ff_vc1_decoder = { #if CONFIG_WMV3_DECODER const FFCodec ff_wmv3_decoder = { .p.name = "wmv3", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), + CODEC_LONG_NAME("Windows Media Video 9"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV3, .priv_data_size = sizeof(VC1Context), @@ -1278,7 +1278,7 @@ const FFCodec ff_wmv3_decoder = { #if CONFIG_WMV3IMAGE_DECODER const FFCodec ff_wmv3image_decoder = { .p.name = "wmv3image", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image"), + CODEC_LONG_NAME("Windows Media Video 9 Image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV3IMAGE, .priv_data_size = sizeof(VC1Context), @@ -1297,7 +1297,7 @@ const FFCodec ff_wmv3image_decoder = { #if CONFIG_VC1IMAGE_DECODER const FFCodec ff_vc1image_decoder = { .p.name = "vc1image", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image v2"), + CODEC_LONG_NAME("Windows Media Video 9 Image v2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VC1IMAGE, .priv_data_size = sizeof(VC1Context), diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index e1fd5fa608..5cb6e0d198 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -1226,7 +1226,7 @@ static const enum AVPixelFormat allowed_pix_fmts[] = { const FFCodec ff_vc2_encoder = { .p.name = "vc2", - .p.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-2"), + CODEC_LONG_NAME("SMPTE VC-2"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DIRAC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index a97412fe7d..853d4459a8 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -123,7 +123,7 @@ static int vcr1_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_vcr1_decoder = { .p.name = "vcr1", - .p.long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"), + CODEC_LONG_NAME("ATI VCR1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VCR1, .priv_data_size = sizeof(VCR1Context), diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 9de86cc4d9..bb3065d1d5 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -2759,7 +2759,7 @@ static const AVClass h264_videotoolbox_class = { const FFCodec ff_h264_videotoolbox_encoder = { .p.name = "h264_videotoolbox", - .p.long_name = NULL_IF_CONFIG_SMALL("VideoToolbox H.264 Encoder"), + CODEC_LONG_NAME("VideoToolbox H.264 Encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_H264, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, @@ -2794,7 +2794,7 @@ static const AVClass hevc_videotoolbox_class = { const FFCodec ff_hevc_videotoolbox_encoder = { .p.name = "hevc_videotoolbox", - .p.long_name = NULL_IF_CONFIG_SMALL("VideoToolbox H.265 Encoder"), + CODEC_LONG_NAME("VideoToolbox H.265 Encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_HEVC, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | @@ -2832,7 +2832,7 @@ static const AVClass prores_videotoolbox_class = { const FFCodec ff_prores_videotoolbox_encoder = { .p.name = "prores_videotoolbox", - .p.long_name = NULL_IF_CONFIG_SMALL("VideoToolbox ProRes Encoder"), + CODEC_LONG_NAME("VideoToolbox ProRes Encoder"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_PRORES, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/vima.c b/libavcodec/vima.c index 0ccf2dd877..56cc1b7a85 100644 --- a/libavcodec/vima.c +++ b/libavcodec/vima.c @@ -209,7 +209,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_adpcm_vima_decoder = { .p.name = "adpcm_vima", - .p.long_name = NULL_IF_CONFIG_SMALL("LucasArts VIMA audio"), + CODEC_LONG_NAME("LucasArts VIMA audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_ADPCM_VIMA, .init = decode_init, diff --git a/libavcodec/vmdaudio.c b/libavcodec/vmdaudio.c index 158b02f6d9..7e4477ef75 100644 --- a/libavcodec/vmdaudio.c +++ b/libavcodec/vmdaudio.c @@ -230,7 +230,7 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_vmdaudio_decoder = { .p.name = "vmdaudio", - .p.long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"), + CODEC_LONG_NAME("Sierra VMD audio"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_VMDAUDIO, .priv_data_size = sizeof(VmdAudioContext), diff --git a/libavcodec/vmdvideo.c b/libavcodec/vmdvideo.c index 3e530e6ee5..226ae0d316 100644 --- a/libavcodec/vmdvideo.c +++ b/libavcodec/vmdvideo.c @@ -466,7 +466,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_vmdvideo_decoder = { .p.name = "vmdvideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Sierra VMD video"), + CODEC_LONG_NAME("Sierra VMD video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VMDVIDEO, .priv_data_size = sizeof(VmdVideoContext), diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c index 2d47f8ec0f..8daaf08c5d 100644 --- a/libavcodec/vmnc.c +++ b/libavcodec/vmnc.c @@ -571,7 +571,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_vmnc_decoder = { .p.name = "vmnc", - .p.long_name = NULL_IF_CONFIG_SMALL("VMware Screen Codec / VMware Video"), + CODEC_LONG_NAME("VMware Screen Codec / VMware Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VMNC, .priv_data_size = sizeof(VmncContext), diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 8addc07dcf..4d03947c49 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1886,7 +1886,7 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx) const FFCodec ff_vorbis_decoder = { .p.name = "vorbis", - .p.long_name = NULL_IF_CONFIG_SMALL("Vorbis"), + CODEC_LONG_NAME("Vorbis"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_VORBIS, .priv_data_size = sizeof(vorbis_context), diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c index 20abb2a670..b33d758e44 100644 --- a/libavcodec/vorbisenc.c +++ b/libavcodec/vorbisenc.c @@ -1297,7 +1297,7 @@ static av_cold int vorbis_encode_init(AVCodecContext *avctx) const FFCodec ff_vorbis_encoder = { .p.name = "vorbis", - .p.long_name = NULL_IF_CONFIG_SMALL("Vorbis"), + CODEC_LONG_NAME("Vorbis"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_VORBIS, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 4734025244..58dd81cd61 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -3169,7 +3169,7 @@ static av_cold int theora_decode_init(AVCodecContext *avctx) const FFCodec ff_theora_decoder = { .p.name = "theora", - .p.long_name = NULL_IF_CONFIG_SMALL("Theora"), + CODEC_LONG_NAME("Theora"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_THEORA, .priv_data_size = sizeof(Vp3DecodeContext), @@ -3187,7 +3187,7 @@ const FFCodec ff_theora_decoder = { const FFCodec ff_vp3_decoder = { .p.name = "vp3", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), + CODEC_LONG_NAME("On2 VP3"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP3, .priv_data_size = sizeof(Vp3DecodeContext), @@ -3205,7 +3205,7 @@ const FFCodec ff_vp3_decoder = { #if CONFIG_VP4_DECODER const FFCodec ff_vp4_decoder = { .p.name = "vp4", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP4"), + CODEC_LONG_NAME("On2 VP4"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP4, .priv_data_size = sizeof(Vp3DecodeContext), diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 9ddc6fa70d..579333506a 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -305,7 +305,7 @@ static av_cold int vp56_free(AVCodecContext *avctx) const FFCodec ff_vp5_decoder = { .p.name = "vp5", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP5"), + CODEC_LONG_NAME("On2 VP5"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP5, .priv_data_size = sizeof(VP56Context), diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index f7815d7398..9bbfa0eb5d 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -715,7 +715,7 @@ static av_cold void vp6_decode_free_context(VP56Context *s) const FFCodec ff_vp6_decoder = { .p.name = "vp6", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP6"), + CODEC_LONG_NAME("On2 VP6"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP6, .priv_data_size = sizeof(VP56Context), @@ -729,7 +729,7 @@ const FFCodec ff_vp6_decoder = { /* flash version, not flipped upside-down */ const FFCodec ff_vp6f_decoder = { .p.name = "vp6f", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"), + CODEC_LONG_NAME("On2 VP6 (Flash version)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP6F, .priv_data_size = sizeof(VP56Context), @@ -743,7 +743,7 @@ const FFCodec ff_vp6f_decoder = { /* flash version, not flipped upside-down, with alpha channel */ const FFCodec ff_vp6a_decoder = { .p.name = "vp6a", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"), + CODEC_LONG_NAME("On2 VP6 (Flash version, with alpha channel)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP6A, .priv_data_size = 2 /* Main context + alpha context */ * sizeof(VP56Context), diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index ab38c76735..6545002fd7 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -2977,7 +2977,7 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, #if CONFIG_VP7_DECODER const FFCodec ff_vp7_decoder = { .p.name = "vp7", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP7"), + CODEC_LONG_NAME("On2 VP7"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP7, .priv_data_size = sizeof(VP8Context), @@ -2992,7 +2992,7 @@ const FFCodec ff_vp7_decoder = { #if CONFIG_VP8_DECODER const FFCodec ff_vp8_decoder = { .p.name = "vp8", - .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), + CODEC_LONG_NAME("On2 VP8"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP8, .priv_data_size = sizeof(VP8Context), diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index fe85c17133..acbbce5624 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1870,7 +1870,7 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo const FFCodec ff_vp9_decoder = { .p.name = "vp9", - .p.long_name = NULL_IF_CONFIG_SMALL("Google VP9"), + CODEC_LONG_NAME("Google VP9"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VP9, .priv_data_size = sizeof(VP9Context), diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 4006b1433c..0573696d94 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -846,7 +846,7 @@ static const FFCodecDefault vqa_defaults[] = { const FFCodec ff_vqa_decoder = { .p.name = "vqavideo", - .p.long_name = NULL_IF_CONFIG_SMALL("Westwood Studios VQA (Vector Quantized Animation) video"), + CODEC_LONG_NAME("Westwood Studios VQA (Vector Quantized Animation) video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WS_VQA, .priv_data_size = sizeof(VqaContext), diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index a09ce00fe2..a326b06e94 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1699,7 +1699,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_wavpack_decoder = { .p.name = "wavpack", - .p.long_name = NULL_IF_CONFIG_SMALL("WavPack"), + CODEC_LONG_NAME("WavPack"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WAVPACK, .priv_data_size = sizeof(WavpackContext), diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c index d813d7a63f..bdb536382f 100644 --- a/libavcodec/wavpackenc.c +++ b/libavcodec/wavpackenc.c @@ -2960,7 +2960,7 @@ static const AVClass wavpack_encoder_class = { const FFCodec ff_wavpack_encoder = { .p.name = "wavpack", - .p.long_name = NULL_IF_CONFIG_SMALL("WavPack"), + CODEC_LONG_NAME("WavPack"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WAVPACK, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, diff --git a/libavcodec/wbmpdec.c b/libavcodec/wbmpdec.c index c289b08bcc..9638b55b94 100644 --- a/libavcodec/wbmpdec.c +++ b/libavcodec/wbmpdec.c @@ -84,7 +84,7 @@ static int wbmp_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_wbmp_decoder = { .p.name = "wbmp", - .p.long_name = NULL_IF_CONFIG_SMALL("WBMP (Wireless Application Protocol Bitmap) image"), + CODEC_LONG_NAME("WBMP (Wireless Application Protocol Bitmap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WBMP, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/wbmpenc.c b/libavcodec/wbmpenc.c index c2dd5f5ca9..25fac746fc 100644 --- a/libavcodec/wbmpenc.c +++ b/libavcodec/wbmpenc.c @@ -77,7 +77,7 @@ static int wbmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_wbmp_encoder = { .p.name = "wbmp", - .p.long_name = NULL_IF_CONFIG_SMALL("WBMP (Wireless Application Protocol Bitmap) image"), + CODEC_LONG_NAME("WBMP (Wireless Application Protocol Bitmap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WBMP, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, diff --git a/libavcodec/wcmv.c b/libavcodec/wcmv.c index 8bc900f304..2f1d22bc24 100644 --- a/libavcodec/wcmv.c +++ b/libavcodec/wcmv.c @@ -240,7 +240,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_wcmv_decoder = { .p.name = "wcmv", - .p.long_name = NULL_IF_CONFIG_SMALL("WinCAM Motion Video"), + CODEC_LONG_NAME("WinCAM Motion Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WCMV, .priv_data_size = sizeof(WCMVContext), diff --git a/libavcodec/webp.c b/libavcodec/webp.c index dca5e451f2..b4357f95d5 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1557,7 +1557,7 @@ static av_cold int webp_decode_close(AVCodecContext *avctx) const FFCodec ff_webp_decoder = { .p.name = "webp", - .p.long_name = NULL_IF_CONFIG_SMALL("WebP image"), + CODEC_LONG_NAME("WebP image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WEBP, .priv_data_size = sizeof(WebPContext), diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c index e245e83ad3..690f00dc47 100644 --- a/libavcodec/webvttdec.c +++ b/libavcodec/webvttdec.c @@ -100,7 +100,7 @@ static int webvtt_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, const FFCodec ff_webvtt_decoder = { .p.name = "webvtt", - .p.long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"), + CODEC_LONG_NAME("WebVTT subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_WEBVTT, FF_CODEC_DECODE_SUB_CB(webvtt_decode_frame), diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c index f47a5c51d4..4369aacb74 100644 --- a/libavcodec/webvttenc.c +++ b/libavcodec/webvttenc.c @@ -213,7 +213,7 @@ static av_cold int webvtt_encode_init(AVCodecContext *avctx) const FFCodec ff_webvtt_encoder = { .p.name = "webvtt", - .p.long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"), + CODEC_LONG_NAME("WebVTT subtitle"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_WEBVTT, .priv_data_size = sizeof(WebVTTContext), diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index c3badcd5f9..4bc6a28daf 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -1002,7 +1002,7 @@ static av_cold void flush(AVCodecContext *avctx) #if CONFIG_WMAV1_DECODER const FFCodec ff_wmav1_decoder = { .p.name = "wmav1", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), + CODEC_LONG_NAME("Windows Media Audio 1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV1, .priv_data_size = sizeof(WMACodecContext), @@ -1019,7 +1019,7 @@ const FFCodec ff_wmav1_decoder = { #if CONFIG_WMAV2_DECODER const FFCodec ff_wmav2_decoder = { .p.name = "wmav2", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), + CODEC_LONG_NAME("Windows Media Audio 2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV2, .priv_data_size = sizeof(WMACodecContext), diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 95b992859a..90bb6949cb 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -434,7 +434,7 @@ static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt, #if CONFIG_WMAV1_ENCODER const FFCodec ff_wmav1_encoder = { .p.name = "wmav1", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), + CODEC_LONG_NAME("Windows Media Audio 1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV1, .p.capabilities = AV_CODEC_CAP_DR1, @@ -450,7 +450,7 @@ const FFCodec ff_wmav1_encoder = { #if CONFIG_WMAV2_ENCODER const FFCodec ff_wmav2_encoder = { .p.name = "wmav2", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), + CODEC_LONG_NAME("Windows Media Audio 2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAV2, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index fa4230c1b5..5112b763fa 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1327,7 +1327,7 @@ static av_cold int decode_close(AVCodecContext *avctx) const FFCodec ff_wmalossless_decoder = { .p.name = "wmalossless", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"), + CODEC_LONG_NAME("Windows Media Audio Lossless"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMALOSSLESS, .priv_data_size = sizeof(WmallDecodeCtx), diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index b90fd581f0..7cfd0c04be 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -2083,7 +2083,7 @@ static void xma_flush(AVCodecContext *avctx) */ const FFCodec ff_wmapro_decoder = { .p.name = "wmapro", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), + CODEC_LONG_NAME("Windows Media Audio 9 Professional"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAPRO, .priv_data_size = sizeof(WMAProDecodeCtx), @@ -2099,7 +2099,7 @@ const FFCodec ff_wmapro_decoder = { const FFCodec ff_xma1_decoder = { .p.name = "xma1", - .p.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 1"), + CODEC_LONG_NAME("Xbox Media Audio 1"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_XMA1, .priv_data_size = sizeof(XMADecodeCtx), @@ -2114,7 +2114,7 @@ const FFCodec ff_xma1_decoder = { const FFCodec ff_xma2_decoder = { .p.name = "xma2", - .p.long_name = NULL_IF_CONFIG_SMALL("Xbox Media Audio 2"), + CODEC_LONG_NAME("Xbox Media Audio 2"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_XMA2, .priv_data_size = sizeof(XMADecodeCtx), diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 6b7e9d5a31..8fa9db63ee 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -2000,7 +2000,7 @@ static av_cold int wmavoice_decode_end(AVCodecContext *ctx) const FFCodec ff_wmavoice_decoder = { .p.name = "wmavoice", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"), + CODEC_LONG_NAME("Windows Media Audio Voice"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WMAVOICE, .priv_data_size = sizeof(WMAVoiceContext), diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 22eb012f56..f638b31cec 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -597,7 +597,7 @@ static av_cold int wmv2_decode_end(AVCodecContext *avctx) const FFCodec ff_wmv2_decoder = { .p.name = "wmv2", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), + CODEC_LONG_NAME("Windows Media Video 8"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV2, .priv_data_size = sizeof(WMV2DecContext), diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index 2f6c688b2a..8a6d897468 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -235,7 +235,7 @@ void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64], const FFCodec ff_wmv2_encoder = { .p.name = "wmv2", - .p.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), + CODEC_LONG_NAME("Windows Media Video 8"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WMV2, .p.priv_class = &ff_mpv_enc_class, diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index ff5238eed0..88532ee426 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -137,7 +137,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_wnv1_decoder = { .p.name = "wnv1", - .p.long_name = NULL_IF_CONFIG_SMALL("Winnov WNV1"), + CODEC_LONG_NAME("Winnov WNV1"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WNV1, .init = decode_init, diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c index def29a9060..c9579848e6 100644 --- a/libavcodec/wrapped_avframe.c +++ b/libavcodec/wrapped_avframe.c @@ -106,7 +106,7 @@ static int wrapped_avframe_decode(AVCodecContext *avctx, AVFrame *out, const FFCodec ff_wrapped_avframe_encoder = { .p.name = "wrapped_avframe", - .p.long_name = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket passthrough"), + CODEC_LONG_NAME("AVFrame to AVPacket passthrough"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WRAPPED_AVFRAME, FF_CODEC_ENCODE_CB(wrapped_avframe_encode), @@ -114,7 +114,7 @@ const FFCodec ff_wrapped_avframe_encoder = { const FFCodec ff_wrapped_avframe_decoder = { .p.name = "wrapped_avframe", - .p.long_name = NULL_IF_CONFIG_SMALL("AVPacket to AVFrame passthrough"), + CODEC_LONG_NAME("AVPacket to AVFrame passthrough"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_WRAPPED_AVFRAME, FF_CODEC_DECODE_CB(wrapped_avframe_decode), diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c index 6dcb8d2a24..0e97ef2165 100644 --- a/libavcodec/ws-snd1.c +++ b/libavcodec/ws-snd1.c @@ -172,7 +172,7 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_ws_snd1_decoder = { .p.name = "ws_snd1", - .p.long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"), + CODEC_LONG_NAME("Westwood Audio (SND1)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_WESTWOOD_SND1, .init = ws_snd_decode_init, diff --git a/libavcodec/xan.c b/libavcodec/xan.c index d9df569a04..14fc2443c5 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -634,7 +634,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_xan_wc3_decoder = { .p.name = "xan_wc3", - .p.long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"), + CODEC_LONG_NAME("Wing Commander III / Xan"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XAN_WC3, .priv_data_size = sizeof(XanContext), diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index f38f9dd1e8..6a31215329 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -137,7 +137,7 @@ static int xbm_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_xbm_decoder = { .p.name = "xbm", - .p.long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"), + CODEC_LONG_NAME("XBM (X BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XBM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c index d4b8a542d9..664c6599bf 100644 --- a/libavcodec/xbmenc.c +++ b/libavcodec/xbmenc.c @@ -79,7 +79,7 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_xbm_encoder = { .p.name = "xbm", - .p.long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"), + CODEC_LONG_NAME("XBM (X BitMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XBM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xfacedec.c b/libavcodec/xfacedec.c index eb16bb6727..378d6aea0e 100644 --- a/libavcodec/xfacedec.c +++ b/libavcodec/xfacedec.c @@ -175,7 +175,7 @@ static int xface_decode_frame(AVCodecContext *avctx, AVFrame *frame, const FFCodec ff_xface_decoder = { .p.name = "xface", - .p.long_name = NULL_IF_CONFIG_SMALL("X-face image"), + CODEC_LONG_NAME("X-face image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XFACE, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xfaceenc.c b/libavcodec/xfaceenc.c index a46b7133e7..7125f1f085 100644 --- a/libavcodec/xfaceenc.c +++ b/libavcodec/xfaceenc.c @@ -213,7 +213,7 @@ static int xface_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_xface_encoder = { .p.name = "xface", - .p.long_name = NULL_IF_CONFIG_SMALL("X-face image"), + CODEC_LONG_NAME("X-face image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XFACE, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xl.c b/libavcodec/xl.c index ada0959346..283cd39aa7 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -128,7 +128,7 @@ static av_cold int decode_init(AVCodecContext *avctx) const FFCodec ff_xl_decoder = { .p.name = "xl", - .p.long_name = NULL_IF_CONFIG_SMALL("Miro VideoXL"), + CODEC_LONG_NAME("Miro VideoXL"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_VIXL, .init = decode_init, diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index c005dc1e3a..d0e5d696e7 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -437,7 +437,7 @@ static av_cold int xpm_decode_close(AVCodecContext *avctx) const FFCodec ff_xpm_decoder = { .p.name = "xpm", - .p.long_name = NULL_IF_CONFIG_SMALL("XPM (X PixMap) image"), + CODEC_LONG_NAME("XPM (X PixMap) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XPM, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 49c8e8e7ff..f86b7c58e7 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -156,7 +156,7 @@ static int decode_frame(AVCodecContext *avctx, AVSubtitle *sub, const FFCodec ff_xsub_decoder = { .p.name = "xsub", - .p.long_name = NULL_IF_CONFIG_SMALL("XSUB"), + CODEC_LONG_NAME("XSUB"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_XSUB, .init = decode_init, diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index cc0fc094ef..6f417c5958 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -213,7 +213,7 @@ static av_cold int xsub_encoder_init(AVCodecContext *avctx) const FFCodec ff_xsub_encoder = { .p.name = "xsub", - .p.long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"), + CODEC_LONG_NAME("DivX subtitles (XSUB)"), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_XSUB, .init = xsub_encoder_init, diff --git a/libavcodec/xwddec.c b/libavcodec/xwddec.c index f3703292ca..cee230a363 100644 --- a/libavcodec/xwddec.c +++ b/libavcodec/xwddec.c @@ -249,7 +249,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, const FFCodec ff_xwd_decoder = { .p.name = "xwd", - .p.long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"), + CODEC_LONG_NAME("XWD (X Window Dump) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XWD, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index 01c43c1d81..6c588f3acc 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -213,7 +213,7 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_xwd_encoder = { .p.name = "xwd", - .p.long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"), + CODEC_LONG_NAME("XWD (X Window Dump) image"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XWD, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c index 555925e5b5..cb6a97c668 100644 --- a/libavcodec/xxan.c +++ b/libavcodec/xxan.c @@ -435,7 +435,7 @@ static int xan_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_xan_wc4_decoder = { .p.name = "xan_wc4", - .p.long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"), + CODEC_LONG_NAME("Wing Commander IV / Xxan"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XAN_WC4, .priv_data_size = sizeof(XanContext), diff --git a/libavcodec/y41pdec.c b/libavcodec/y41pdec.c index 7d63228937..b461f349ad 100644 --- a/libavcodec/y41pdec.c +++ b/libavcodec/y41pdec.c @@ -83,7 +83,7 @@ static int y41p_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_y41p_decoder = { .p.name = "y41p", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed YUV 4:1:1 12-bit"), + CODEC_LONG_NAME("Uncompressed YUV 4:1:1 12-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_Y41P, .init = y41p_decode_init, diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c index f7ac58c30e..d3ef88c2ce 100644 --- a/libavcodec/y41penc.c +++ b/libavcodec/y41penc.c @@ -79,7 +79,7 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_y41p_encoder = { .p.name = "y41p", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed YUV 4:1:1 12-bit"), + CODEC_LONG_NAME("Uncompressed YUV 4:1:1 12-bit"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_Y41P, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c index 4f629bd6cd..3ea6749ffe 100644 --- a/libavcodec/ylc.c +++ b/libavcodec/ylc.c @@ -451,7 +451,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_ylc_decoder = { .p.name = "ylc", - .p.long_name = NULL_IF_CONFIG_SMALL("YUY2 Lossless Codec"), + CODEC_LONG_NAME("YUY2 Lossless Codec"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_YLC, .priv_data_size = sizeof(YLCContext), diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 33d8c8b815..816fe8bdc8 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -267,7 +267,7 @@ static int yop_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const FFCodec ff_yop_decoder = { .p.name = "yop", - .p.long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Video"), + CODEC_LONG_NAME("Psygnosis YOP Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_YOP, .priv_data_size = sizeof(YopDecContext), diff --git a/libavcodec/yuv4dec.c b/libavcodec/yuv4dec.c index 274b8b7b2d..15424b1940 100644 --- a/libavcodec/yuv4dec.c +++ b/libavcodec/yuv4dec.c @@ -75,7 +75,7 @@ static int yuv4_decode_frame(AVCodecContext *avctx, AVFrame *pic, const FFCodec ff_yuv4_decoder = { .p.name = "yuv4", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:2:0"), + CODEC_LONG_NAME("Uncompressed packed 4:2:0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_YUV4, .init = yuv4_decode_init, diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c index 94e9b5dc1b..27e786dd54 100644 --- a/libavcodec/yuv4enc.c +++ b/libavcodec/yuv4enc.c @@ -61,7 +61,7 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const FFCodec ff_yuv4_encoder = { .p.name = "yuv4", - .p.long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:2:0"), + CODEC_LONG_NAME("Uncompressed packed 4:2:0"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_YUV4, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c index c369ff8e3c..93fc2834e4 100644 --- a/libavcodec/zerocodec.c +++ b/libavcodec/zerocodec.c @@ -136,7 +136,7 @@ static void zerocodec_decode_flush(AVCodecContext *avctx) const FFCodec ff_zerocodec_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.name = "zerocodec", - .p.long_name = NULL_IF_CONFIG_SMALL("ZeroCodec Lossless Video"), + CODEC_LONG_NAME("ZeroCodec Lossless Video"), .p.id = AV_CODEC_ID_ZEROCODEC, .priv_data_size = sizeof(ZeroCodecContext), .init = zerocodec_decode_init, diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index edbd88eb73..0b44851811 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -646,7 +646,7 @@ static av_cold int decode_end(AVCodecContext *avctx) const FFCodec ff_zmbv_decoder = { .p.name = "zmbv", - .p.long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), + CODEC_LONG_NAME("Zip Motion Blocks Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZMBV, .priv_data_size = sizeof(ZmbvContext), diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index cc8578afea..c12f783d5a 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -413,7 +413,7 @@ static av_cold int encode_init(AVCodecContext *avctx) const FFCodec ff_zmbv_encoder = { .p.name = "zmbv", - .p.long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), + CODEC_LONG_NAME("Zip Motion Blocks Video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_ZMBV, .p.capabilities = AV_CODEC_CAP_DR1, diff --git a/libavutil/internal.h b/libavutil/internal.h index 14f3acec58..40072d4e30 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -107,8 +107,7 @@ /** * Return NULL if CONFIG_SMALL is true, otherwise the argument - * without modification. Used to disable the definition of strings - * (for example AVCodec long_names). + * without modification. Used to disable the definition of strings. */ #if CONFIG_SMALL # define NULL_IF_CONFIG_SMALL(x) NULL From 73fada029c527fda6c248785a948c61249fd4b2d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 29 Aug 2022 15:03:21 +0200 Subject: [PATCH 112/590] avcodec/codec_internal: Add macros for update_thread_context(_for_user) It reduces typing: Before this patch, there were 11 callbacks that exceeded the 80 char line length limit; now there are zero. It also allows to remove ONLY_IF_THREADS_ENABLED() in libavutil/internal.h. Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhd.c | 2 +- libavcodec/codec_internal.h | 12 ++++++++++++ libavcodec/ffv1dec.c | 2 +- libavcodec/h264dec.c | 4 ++-- libavcodec/hevcdec.c | 2 +- libavcodec/mimic.c | 2 +- libavcodec/mpeg12dec.c | 2 +- libavcodec/mpeg4videodec.c | 4 ++-- libavcodec/pngdec.c | 4 ++-- libavcodec/proresdec2.c | 2 +- libavcodec/rv30.c | 2 +- libavcodec/rv40.c | 2 +- libavcodec/takdec.c | 2 +- libavcodec/vp3.c | 6 +++--- libavcodec/vp8.c | 2 +- libavcodec/vp9.c | 2 +- libavcodec/wavpack.c | 2 +- libavutil/internal.h | 11 ----------- 18 files changed, 33 insertions(+), 32 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 59f8c795a2..7afbbac59e 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -1464,7 +1464,7 @@ const FFCodec ff_cfhd_decoder = { .init = cfhd_init, .close = cfhd_close, FF_CODEC_DECODE_CB(cfhd_decode), - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 310e243d84..2d9b4f6460 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -264,6 +264,18 @@ typedef struct FFCodec { #define CODEC_LONG_NAME(str) .p.long_name = str #endif +#if HAVE_THREADS +#define UPDATE_THREAD_CONTEXT(func) \ + .update_thread_context = (func) +#define UPDATE_THREAD_CONTEXT_FOR_USER(func) \ + .update_thread_context_for_user = (func) +#else +#define UPDATE_THREAD_CONTEXT(func) \ + .update_thread_context = NULL +#define UPDATE_THREAD_CONTEXT_FOR_USER(func) \ + .update_thread_context_for_user = NULL +#endif + #define FF_CODEC_DECODE_CB(func) \ .cb_type = FF_CODEC_CB_TYPE_DECODE, \ .cb.decode = (func) diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 2fc8941362..794c58cc40 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -1077,7 +1077,7 @@ const FFCodec ff_ffv1_decoder = { .init = decode_init, .close = ff_ffv1_close, FF_CODEC_DECODE_CB(decode_frame), - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 3cef3f39f5..8f56f3ff92 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1105,8 +1105,8 @@ const FFCodec ff_h264_decoder = { .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP, .flush = h264_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context), - .update_thread_context_for_user = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context_for_user), + UPDATE_THREAD_CONTEXT(ff_h264_update_thread_context), + UPDATE_THREAD_CONTEXT_FOR_USER(ff_h264_update_thread_context_for_user), .p.profiles = NULL_IF_CONFIG_SMALL(ff_h264_profiles), .p.priv_class = &h264_class, }; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 91bafa2114..90961f87be 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3854,7 +3854,7 @@ const FFCodec ff_hevc_decoder = { .close = hevc_decode_free, FF_CODEC_DECODE_CB(hevc_decode_frame), .flush = hevc_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(hevc_update_thread_context), + UPDATE_THREAD_CONTEXT(hevc_update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index c506a42322..1d4f2b85c1 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -446,7 +446,7 @@ const FFCodec ff_mimic_decoder = { .close = mimic_decode_end, FF_CODEC_DECODE_CB(mimic_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .update_thread_context = ONLY_IF_THREADS_ENABLED(mimic_decode_update_thread_context), + UPDATE_THREAD_CONTEXT(mimic_decode_update_thread_context), .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 2aa5bc776d..7133696f3c 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2880,7 +2880,7 @@ const FFCodec ff_mpeg1video_decoder = { .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .flush = flush, .p.max_lowres = 3, - .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context), + UPDATE_THREAD_CONTEXT(mpeg_decode_update_thread_context), .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_MPEG1_NVDEC_HWACCEL HWACCEL_NVDEC(mpeg1), diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 8eb81688ef..4dbf37afe5 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3686,8 +3686,8 @@ const FFCodec ff_mpeg4_decoder = { .p.max_lowres = 3, .p.pix_fmts = ff_h263_hwaccel_pixfmt_list_420, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg4_video_profiles), - .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg4_update_thread_context), - .update_thread_context_for_user = ONLY_IF_THREADS_ENABLED(mpeg4_update_thread_context_for_user), + UPDATE_THREAD_CONTEXT(mpeg4_update_thread_context), + UPDATE_THREAD_CONTEXT_FOR_USER(mpeg4_update_thread_context_for_user), .p.priv_class = &mpeg4_class, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_MPEG4_NVDEC_HWACCEL diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 9e7d9b589f..582953d17b 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1722,7 +1722,7 @@ const FFCodec ff_apng_decoder = { .init = png_dec_init, .close = png_dec_end, FF_CODEC_DECODE_CB(decode_frame_apng), - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ALLOCATE_PROGRESS | @@ -1740,7 +1740,7 @@ const FFCodec ff_png_decoder = { .init = png_dec_init, .close = png_dec_end, FF_CODEC_DECODE_CB(decode_frame_png), - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/, .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_ALLOCATE_PROGRESS | FF_CODEC_CAP_INIT_CLEANUP | diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 68b29deadb..5ec579b994 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -878,7 +878,7 @@ const FFCodec ff_prores_decoder = { .init = decode_init, .close = decode_close, FF_CODEC_DECODE_CB(decode_frame), - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .p.profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), .hw_configs = (const AVCodecHWConfigInternal *const []) { diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 0361e75580..be62577f99 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -307,6 +307,6 @@ const FFCodec ff_rv30_decoder = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context), + UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context), .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, }; diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 728a04062a..75849b173e 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -590,6 +590,6 @@ const FFCodec ff_rv40_decoder = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_rv34_decode_update_thread_context), + UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context), .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, }; diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index f7fb34617d..68ad1e9ed7 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -946,7 +946,7 @@ const FFCodec ff_tak_decoder = { .init = tak_decode_init, .close = tak_decode_close, FF_CODEC_DECODE_CB(tak_decode_frame), - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_CHANNEL_CONF, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 58dd81cd61..31775455a4 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -3179,7 +3179,7 @@ const FFCodec ff_theora_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), + UPDATE_THREAD_CONTEXT(vp3_update_thread_context), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_ALLOCATE_PROGRESS, }; @@ -3197,7 +3197,7 @@ const FFCodec ff_vp3_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), + UPDATE_THREAD_CONTEXT(vp3_update_thread_context), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ALLOCATE_PROGRESS, }; @@ -3215,7 +3215,7 @@ const FFCodec ff_vp4_decoder = { .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), + UPDATE_THREAD_CONTEXT(vp3_update_thread_context), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ALLOCATE_PROGRESS, }; diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 6545002fd7..0e16e75faa 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -3003,7 +3003,7 @@ const FFCodec ff_vp8_decoder = { AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, .flush = vp8_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context), + UPDATE_THREAD_CONTEXT(vp8_decode_update_thread_context), .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_VP8_VAAPI_HWACCEL HWACCEL_VAAPI(vp8), diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index acbbce5624..029e9156c5 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1882,7 +1882,7 @@ const FFCodec ff_vp9_decoder = { FF_CODEC_CAP_SLICE_THREAD_HAS_MF | FF_CODEC_CAP_ALLOCATE_PROGRESS, .flush = vp9_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context), + UPDATE_THREAD_CONTEXT(vp9_decode_update_thread_context), .p.profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .bsfs = "vp9_superframe_split", .hw_configs = (const AVCodecHWConfigInternal *const []) { diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index a326b06e94..7aa1f65e17 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1707,7 +1707,7 @@ const FFCodec ff_wavpack_decoder = { .close = wavpack_decode_end, FF_CODEC_DECODE_CB(wavpack_decode_frame), .flush = wavpack_decode_flush, - .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), + UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_CHANNEL_CONF, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | diff --git a/libavutil/internal.h b/libavutil/internal.h index 40072d4e30..c9e30bc5e9 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -115,17 +115,6 @@ # define NULL_IF_CONFIG_SMALL(x) x #endif -/** - * Return NULL if a threading library has not been enabled. - * Used to disable threading functions in AVCodec definitions - * when not needed. - */ -#if HAVE_THREADS -# define ONLY_IF_THREADS_ENABLED(x) x -#else -# define ONLY_IF_THREADS_ENABLED(x) NULL -#endif - /** * Log a generic warning message about a missing feature. * From 416923346a6d31563801784963d2893a8d1da1c8 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Sat, 3 Sep 2022 19:49:53 +0200 Subject: [PATCH 113/590] compat/cuda: switch from powf to __powf intrinsic The powf builtin causes crashes on older clang, so manually implement the (faster) intrinsic. The code it spawns is identical to that of nvcc. --- compat/cuda/cuda_runtime.h | 2 +- libavfilter/vf_bilateral_cuda.cu | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compat/cuda/cuda_runtime.h b/compat/cuda/cuda_runtime.h index 082e4a8ba3..699c4b6c75 100644 --- a/compat/cuda/cuda_runtime.h +++ b/compat/cuda/cuda_runtime.h @@ -182,11 +182,11 @@ static inline __device__ float fabsf(float a) { return __builtin_fabsf(a); } static inline __device__ float fabs(float a) { return __builtin_fabsf(a); } static inline __device__ double fabs(double a) { return __builtin_fabs(a); } static inline __device__ float sqrtf(float a) { return __builtin_sqrtf(a); } -static inline __device__ float powf(float a, float y) { return __builtin_powf(a,y); } static inline __device__ float __saturatef(float a) { return __nvvm_saturate_f(a); } static inline __device__ float __sinf(float a) { return __nvvm_sin_approx_f(a); } static inline __device__ float __cosf(float a) { return __nvvm_cos_approx_f(a); } static inline __device__ float __expf(float a) { return __nvvm_ex2_approx_f(a * (float)__builtin_log2(__builtin_exp(1))); } +static inline __device__ float __powf(float a, float b) { return __nvvm_ex2_approx_f(__nvvm_lg2_approx_f(a) * b); } #endif /* COMPAT_CUDA_CUDA_RUNTIME_H */ diff --git a/libavfilter/vf_bilateral_cuda.cu b/libavfilter/vf_bilateral_cuda.cu index 8aba3a079f..bbcfc81db5 100644 --- a/libavfilter/vf_bilateral_cuda.cu +++ b/libavfilter/vf_bilateral_cuda.cu @@ -34,9 +34,9 @@ extern "C" __device__ static inline float norm_squared(float4 first_yuv, float4 second_yuv) { float ans = 0; - ans += powf(first_yuv.x - second_yuv.x, 2); - ans += powf(first_yuv.y - second_yuv.y, 2); - ans += powf(first_yuv.z - second_yuv.z, 2); + ans += __powf(first_yuv.x - second_yuv.x, 2); + ans += __powf(first_yuv.y - second_yuv.y, 2); + ans += __powf(first_yuv.z - second_yuv.z, 2); return ans; } @@ -52,7 +52,7 @@ __device__ static inline float calculate_w(int x, int y, int r, int c, float sigma_space, float sigma_color) { float first_term, second_term; - first_term = (powf(x - r, 2) + powf(y - c, 2)) / (2 * sigma_space * sigma_space); + first_term = (__powf(x - r, 2) + __powf(y - c, 2)) / (2 * sigma_space * sigma_space); second_term = norm_squared(pixel_value, neighbor_value) / (2 * sigma_color * sigma_color); return __expf(-first_term - second_term); } From 6512dd6cb528a261369284f2634c0856fdaffaf9 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Sat, 3 Sep 2022 20:02:03 +0200 Subject: [PATCH 114/590] avfilter/vf_bilateral_cuda: refactor use of pow to simple multiplication --- libavfilter/vf_bilateral_cuda.cu | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_bilateral_cuda.cu b/libavfilter/vf_bilateral_cuda.cu index bbcfc81db5..7d6cc14c0a 100644 --- a/libavfilter/vf_bilateral_cuda.cu +++ b/libavfilter/vf_bilateral_cuda.cu @@ -33,11 +33,10 @@ extern "C" */ __device__ static inline float norm_squared(float4 first_yuv, float4 second_yuv) { - float ans = 0; - ans += __powf(first_yuv.x - second_yuv.x, 2); - ans += __powf(first_yuv.y - second_yuv.y, 2); - ans += __powf(first_yuv.z - second_yuv.z, 2); - return ans; + float x = first_yuv.x - second_yuv.x; + float y = first_yuv.y - second_yuv.y; + float z = first_yuv.z - second_yuv.z; + return (x*x) + (y*y) + (z*z); } /** @@ -52,7 +51,7 @@ __device__ static inline float calculate_w(int x, int y, int r, int c, float sigma_space, float sigma_color) { float first_term, second_term; - first_term = (__powf(x - r, 2) + __powf(y - c, 2)) / (2 * sigma_space * sigma_space); + first_term = (((x - r) * (x - r)) + ((y - c) * (y - c))) / (2 * sigma_space * sigma_space); second_term = norm_squared(pixel_value, neighbor_value) / (2 * sigma_color * sigma_color); return __expf(-first_term - second_term); } From 0b95a6a1d0b3d9c06aedd5fc929804661addd263 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 2 Sep 2022 22:54:04 +0200 Subject: [PATCH 115/590] avcodec/mathops: Set hidden visibility where advantageous MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is advantageous for ff_crop_tab, as the base pointer used to access this table is not the first element of it. But the real base pointer is still at a constant offset from the code/the GOT and can therefore be accessed relative to the instruction pointer (if supported by the arch) or relative to the GOT; without this, one has to first load address of ff_crop_tab (potentially via the GOT) and then offset manually (which is what the earlier code did). Reviewed-by: Martin Storsjö Signed-off-by: Andreas Rheinhardt --- libavcodec/mathops.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index f81d21f9c4..c89054d6ed 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -24,6 +24,7 @@ #include +#include "libavutil/attributes_internal.h" #include "libavutil/common.h" #include "config.h" @@ -32,7 +33,7 @@ extern const uint32_t ff_inverse[257]; extern const uint8_t ff_log2_run[41]; extern const uint8_t ff_sqrt_tab[256]; -extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP]; +extern const uint8_t attribute_visibility_hidden ff_crop_tab[256 + 2 * MAX_NEG_CROP]; extern const uint8_t ff_zigzag_direct[64]; extern const uint8_t ff_zigzag_scan[16+1]; From 164021423a25f02c6253bb8d73ae9a443a129381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 3 Sep 2022 18:05:17 +0300 Subject: [PATCH 116/590] aarch64: relax byte-swap assembler constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are no particular reasons to force the compiler to use the same register as output and input operand. This forces an extra MOV instruction if the input value needs to be reused after the swap. In most cases, this makes no differences, as the compiler will seleect the same register for both operands either way. Signed-off-by: Martin Storsjö --- libavutil/aarch64/bswap.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavutil/aarch64/bswap.h b/libavutil/aarch64/bswap.h index 1e735c52cf..7abca657ba 100644 --- a/libavutil/aarch64/bswap.h +++ b/libavutil/aarch64/bswap.h @@ -28,22 +28,28 @@ #define av_bswap16 av_bswap16 static av_always_inline av_const unsigned av_bswap16(unsigned x) { - __asm__("rev16 %w0, %w0" : "+r"(x)); - return x; + unsigned y; + + __asm__("rev16 %w0, %w1" : "=r"(y) : "r"(x)); + return y; } #define av_bswap32 av_bswap32 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { - __asm__("rev %w0, %w0" : "+r"(x)); - return x; + uint32_t y; + + __asm__("rev %w0, %w1" : "=r"(y) : "r"(x)); + return y; } #define av_bswap64 av_bswap64 static av_always_inline av_const uint64_t av_bswap64(uint64_t x) { - __asm__("rev %0, %0" : "+r"(x)); - return x; + uint64_t y; + + __asm__("rev %0, %1" : "=r"(y) : "r"(x)); + return y; } #endif /* HAVE_INLINE_ASM */ From 620e6e14878de7392f9b5fd109cc8f5ed90dd835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 3 Sep 2022 18:05:18 +0300 Subject: [PATCH 117/590] arm: relax byte-swap assembler constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are no particular reasons to force the compiler to use the same register as output and input operand. This forces an extra MOV instruction if the input value needs to be reused after the swap. In most cases, this makes no differences, as the compiler will seleect the same register for both operands either way. Signed-off-by: Martin Storsjö --- libavutil/arm/bswap.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavutil/arm/bswap.h b/libavutil/arm/bswap.h index 611ff0ad5b..c3460e035d 100644 --- a/libavutil/arm/bswap.h +++ b/libavutil/arm/bswap.h @@ -39,8 +39,10 @@ static av_always_inline av_const uint32_t av_bswap32(uint32_t x) #define av_bswap16 av_bswap16 static av_always_inline av_const unsigned av_bswap16(unsigned x) { - __asm__("rev16 %0, %0" : "+r"(x)); - return x; + unsigned y; + + __asm__("rev16 %0, %1" : "=r"(y) : "r"(x)); + return y; } #endif @@ -48,17 +50,18 @@ static av_always_inline av_const unsigned av_bswap16(unsigned x) #define av_bswap32 av_bswap32 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { + uint32_t y; #if HAVE_ARMV6_INLINE - __asm__("rev %0, %0" : "+r"(x)); + __asm__("rev %0, %1" : "=r"(y) : "r"(x)); #else uint32_t t; - __asm__ ("eor %1, %0, %0, ror #16 \n\t" + __asm__ ("eor %1, %2, %2, ror #16 \n\t" "bic %1, %1, #0xFF0000 \n\t" - "mov %0, %0, ror #8 \n\t" + "mov %0, %2, ror #8 \n\t" "eor %0, %0, %1, lsr #8 \n\t" - : "+r"(x), "=&r"(t)); + : "=r"(y), "=&r"(t) : "r"(x)); #endif /* HAVE_ARMV6_INLINE */ - return x; + return y; } #endif /* AV_GCC_VERSION_AT_MOST(4,4) */ From d75c4693fef51e8f0a1b88798530f4c5147ea906 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sat, 13 Aug 2022 13:50:07 -0700 Subject: [PATCH 118/590] lavu/pixfmt: Add P012, Y212, XV30, and XV36 formats These are the formats we want/need to use when dealing with the Intel VAAPI decoder for 12bit 4:2:0, 12bit 4:2:2, 10bit 4:4:4 and 12bit 4:4:4 respectively. As with the already supported Y210 and YUVX (XVUY) formats, they are based on formats Microsoft picked as their preferred 4:2:2 and 4:4:4 video formats, and Intel ran with it. P12 and Y212 are simply an extension of 10 bit formats to say 12 bits will be used, with 4 unused bits instead of 6. XV30, and XV36, as exotic as they sound, are variants of Y410 and Y412 where the alpha channel is left formally undefined. We prefer these over the alpha versions because the hardware cannot actually do anything with the alpha channel and respecting it is just overhead. Y412/XV46 is a normal looking packed 4 channel format where each channel is 16bits wide but only the 12msb are used (like P012). Y410/XV30 packs three 10bit channels in 32bits with 2bits of alpha, like A/X2RGB10 style formats. This annoying layout forced me to define the BE version as a bitstream format. It seems like our pixdesc infrastructure can handle the LE version being byte-defined, but not when it's reversed. If there's a better way to handle this, please let me know. Our existing X2 formats all have the 2 bits at the MSB end, but this format places them at the LSB end and that seems to be the root of the problem. --- doc/APIchanges | 3 + libavutil/pixdesc.c | 95 +++++++++++++++++++++++++++++++- libavutil/pixfmt.h | 16 ++++++ libavutil/version.h | 2 +- tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 38 +++++++++++++ 6 files changed, 160 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b0d0757b13..729f56be7b 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-03 - xxxxxxxxxx - lavu 57.36.100 - pixfmt.h + Add AV_PIX_FMT_P012, AV_PIX_FMT_Y212, AV_PIX_FMT_XV30, AV_PIX_FMT_XV36 + 2022-09-03 - xxxxxxxxxx - lavu 57.35.100 - file.h Deprecate av_tempfile() without replacement. diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 79ebfd3f16..d7c6ebfdc4 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2147,6 +2147,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_P012LE] = { + .name = "p012le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, + .comp = { + { 0, 2, 0, 4, 12 }, /* Y */ + { 1, 4, 0, 4, 12 }, /* U */ + { 1, 4, 2, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P012BE] = { + .name = "p012be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, + .comp = { + { 0, 2, 0, 4, 12 }, /* Y */ + { 1, 4, 0, 4, 12 }, /* U */ + { 1, 4, 2, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, [AV_PIX_FMT_P016LE] = { .name = "p016le", .nb_components = 3, @@ -2543,6 +2567,75 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_FLOAT, }, + [AV_PIX_FMT_Y212LE] = { + .name = "y212le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 0, 4, 12 }, /* Y */ + { 0, 8, 2, 4, 12 }, /* U */ + { 0, 8, 6, 4, 12 }, /* V */ + }, + }, + [AV_PIX_FMT_Y212BE] = { + .name = "y212be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 0, 4, 12 }, /* Y */ + { 0, 8, 2, 4, 12 }, /* U */ + { 0, 8, 6, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_XV30LE] = { + .name = "xv30le", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 4, 1, 2, 10 }, /* Y */ + { 0, 4, 0, 0, 10 }, /* U */ + { 0, 4, 2, 4, 10 }, /* V */ + }, + }, + [AV_PIX_FMT_XV30BE] = { + .name = "xv30be", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 32, 10, 0, 10 }, /* Y */ + { 0, 32, 0, 0, 10 }, /* U */ + { 0, 32, 20, 0, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_BITSTREAM, + }, + [AV_PIX_FMT_XV36LE] = { + .name = "xv36le", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 8, 2, 4, 12 }, /* Y */ + { 0, 8, 0, 4, 12 }, /* U */ + { 0, 8, 4, 4, 12 }, /* V */ + }, + }, + [AV_PIX_FMT_XV36BE] = { + .name = "xv36be", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 8, 2, 4, 12 }, /* Y */ + { 0, 8, 0, 4, 12 }, /* U */ + { 0, 8, 4, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE, + }, }; static const char * const color_range_names[] = { @@ -2778,7 +2871,7 @@ void ff_check_pixfmt_descriptors(void){ if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags) continue; -// av_log(NULL, AV_LOG_DEBUG, "Checking: %s\n", d->name); + av_log(NULL, AV_LOG_INFO, "Checking: %s\n", d->name); av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 7d45561395..a1c4c9fb75 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -374,6 +374,18 @@ enum AVPixelFormat { AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined + AV_PIX_FMT_P012LE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, little-endian + AV_PIX_FMT_P012BE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, big-endian + + AV_PIX_FMT_Y212BE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, big-endian + AV_PIX_FMT_Y212LE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, little-endian + + AV_PIX_FMT_XV30BE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), big-endian, variant of Y410 where alpha channel is left undefined + AV_PIX_FMT_XV30LE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), little-endian, variant of Y410 where alpha channel is left undefined + + AV_PIX_FMT_XV36BE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian, variant of Y412 where alpha channel is left undefined + AV_PIX_FMT_XV36LE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian, variant of Y412 where alpha channel is left undefined + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -460,9 +472,13 @@ enum AVPixelFormat { #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) #define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE) #define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE) +#define AV_PIX_FMT_P012 AV_PIX_FMT_NE(P012BE, P012LE) #define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE) #define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE) +#define AV_PIX_FMT_Y212 AV_PIX_FMT_NE(Y212BE, Y212LE) +#define AV_PIX_FMT_XV30 AV_PIX_FMT_NE(XV30BE, XV30LE) +#define AV_PIX_FMT_XV36 AV_PIX_FMT_NE(XV36BE, XV36LE) #define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE) #define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE) diff --git a/libavutil/version.h b/libavutil/version.h index f33b3d1b49..c6e5b9f145 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 35 +#define LIBAVUTIL_VERSION_MINOR 36 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 47b73b1b64..de73513e7c 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -250,3 +250,11 @@ vuya planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 rgbaf16be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 rgbaf16le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 vuyx planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +p012le planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 3072 0 0, plane_offsets: 6144 0 0, total_size: 9216 +p012be planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 3072 0 0, plane_offsets: 6144 0 0, total_size: 9216 +y212be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +y212le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +xv30be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +xv30le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +xv36be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 +xv36le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index f54372d364..20fc596ce9 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -63,6 +63,8 @@ isNBPS: nv20le p010be p010le + p012be + p012le p210be p210le p410be @@ -71,10 +73,16 @@ isNBPS: x2bgr10le x2rgb10be x2rgb10le + xv30be + xv30le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le yuv420p10be yuv420p10le yuv420p12be @@ -149,6 +157,7 @@ isBE: grayf32be nv20be p010be + p012be p016be p210be p216be @@ -162,8 +171,11 @@ isBE: rgbaf16be x2bgr10be x2rgb10be + xv30be + xv36be xyz12be y210be + y212be ya16be yuv420p10be yuv420p12be @@ -206,6 +218,8 @@ isYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -220,10 +234,16 @@ isYUV: uyyvyy411 vuya vuyx + xv30be + xv30le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le ya16be ya16le ya8 @@ -310,6 +330,8 @@ isPlanarYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -401,6 +423,8 @@ isSemiPlanarYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -759,10 +783,16 @@ Packed: x2bgr10le x2rgb10be x2rgb10le + xv30be + xv30le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le ya16be ya16le ya8 @@ -801,6 +831,8 @@ Planar: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -973,14 +1005,20 @@ usePal: DataInHighBits: p010be p010le + p012be + p012le p210be p210le p410be p410le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le SwappedChroma: nv21 From b982dd0d8366b2cb9cc6288b821a536c8e2b50ed Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Fri, 19 Aug 2022 17:01:07 -0700 Subject: [PATCH 119/590] lavc/vaapi: Add support for remaining 10/12bit profiles With the necessary pixel formats defined, we can now expose support for the remaining 10/12bit combinations that VAAPI can handle. Specifically, we are adding support for: * HEVC ** 12bit 420 ** 10bit 422 ** 12bit 422 ** 10bit 444 ** 12bit 444 * VP9 ** 10bit 444 ** 12bit 444 These obviously require actual hardware support to be usable, but where that exists, it is now enabled. Note that unlike YUVA/YUVX, the Intel driver does not formally expose support for the alphaless formats XV30 and XV360, and so we are implicitly discarding the alpha from the decoder and passing undefined values for the alpha to the encoder. If a future encoder iteration was to actually do something with the alpha bits, we would need to use a formal alpha capable format or the encoder would need to explicitly accept the alphaless format. --- Changelog | 2 +- libavcodec/hevcdec.c | 8 ++++++++ libavcodec/vaapi_decode.c | 13 +++++++++++++ libavcodec/vaapi_encode.c | 4 ++++ libavcodec/vaapi_encode_h265.c | 4 ++++ libavcodec/vaapi_encode_vp9.c | 1 + libavcodec/vaapi_hevc.c | 11 ++++++++++- libavcodec/version.h | 2 +- libavcodec/vp9.c | 2 ++ libavutil/hwcontext_vaapi.c | 25 +++++++++++++++++++++++++ 10 files changed, 69 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 70c12df8dc..f34e8e5d42 100644 --- a/Changelog +++ b/Changelog @@ -8,7 +8,7 @@ version : - ffmpeg now requires threading to be built - ffmpeg now runs every muxer in a separate thread - Add new mode to cropdetect filter to detect crop-area based on motion vectors and edges -- VAAPI decoding and encoding for 8bit 444 HEVC and VP9 +- VAAPI decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9 - WBMP (Wireless Application Protocol Bitmap) image format - a3dscope filter diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 90961f87be..fb44d8d3f2 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -482,11 +482,19 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV444P12: +#if CONFIG_HEVC_VAAPI_HWACCEL + *fmt++ = AV_PIX_FMT_VAAPI; +#endif #if CONFIG_HEVC_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; +#endif + break; + case AV_PIX_FMT_YUV422P12: +#if CONFIG_HEVC_VAAPI_HWACCEL + *fmt++ = AV_PIX_FMT_VAAPI; #endif break; } diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 8c13a4f098..134f10eca5 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -262,6 +262,9 @@ static const struct { MAP(YUY2, YUYV422), #ifdef VA_FOURCC_Y210 MAP(Y210, Y210), +#endif +#ifdef VA_FOURCC_Y212 + MAP(Y212, Y212), #endif // 4:4:0 MAP(422V, YUV440P), @@ -269,11 +272,20 @@ static const struct { MAP(444P, YUV444P), #ifdef VA_FOURCC_XYUV MAP(XYUV, VUYX), +#endif +#ifdef VA_FOURCC_Y410 + MAP(Y410, XV30), +#endif +#ifdef VA_FOURCC_Y412 + MAP(Y412, XV36), #endif // 4:2:0 10-bit #ifdef VA_FOURCC_P010 MAP(P010, P010), #endif +#ifdef VA_FOURCC_P012 + MAP(P012, P012), +#endif #ifdef VA_FOURCC_I010 MAP(I010, YUV420P10), #endif @@ -417,6 +429,7 @@ static const struct { #if VA_CHECK_VERSION(0, 39, 0) MAP(VP9, VP9_1, VP9Profile1 ), MAP(VP9, VP9_2, VP9Profile2 ), + MAP(VP9, VP9_3, VP9Profile3 ), #endif #if VA_CHECK_VERSION(1, 8, 0) MAP(AV1, AV1_MAIN, AV1Profile0), diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2dc5c96f7b..9a58661b51 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1305,7 +1305,11 @@ static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[] = { { "YUV420", VA_RT_FORMAT_YUV420, 8, 3, 1, 1 }, { "YUV422", VA_RT_FORMAT_YUV422, 8, 3, 1, 0 }, #if VA_CHECK_VERSION(1, 2, 0) + { "YUV420_12", VA_RT_FORMAT_YUV420_12, 12, 3, 1, 1 }, { "YUV422_10", VA_RT_FORMAT_YUV422_10, 10, 3, 1, 0 }, + { "YUV422_12", VA_RT_FORMAT_YUV422_12, 12, 3, 1, 0 }, + { "YUV444_10", VA_RT_FORMAT_YUV444_10, 10, 3, 0, 0 }, + { "YUV444_12", VA_RT_FORMAT_YUV444_12, 12, 3, 0, 0 }, #endif { "YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, { "XYUV", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 875c18343e..94b56c6578 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1276,9 +1276,13 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { { FF_PROFILE_HEVC_REXT, 10, 3, 1, 1, VAProfileHEVCMain10 }, #endif #if VA_CHECK_VERSION(1, 2, 0) + { FF_PROFILE_HEVC_REXT, 12, 3, 1, 1, VAProfileHEVCMain12 }, { FF_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 }, { FF_PROFILE_HEVC_REXT, 10, 3, 1, 0, VAProfileHEVCMain422_10 }, + { FF_PROFILE_HEVC_REXT, 12, 3, 1, 0, VAProfileHEVCMain422_12 }, { FF_PROFILE_HEVC_REXT, 8, 3, 0, 0, VAProfileHEVCMain444 }, + { FF_PROFILE_HEVC_REXT, 10, 3, 0, 0, VAProfileHEVCMain444_10 }, + { FF_PROFILE_HEVC_REXT, 12, 3, 0, 0, VAProfileHEVCMain444_12 }, #endif { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index ea824a31d1..b4c5588730 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -230,6 +230,7 @@ static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[] = { { FF_PROFILE_VP9_0, 8, 3, 1, 1, VAProfileVP9Profile0 }, { FF_PROFILE_VP9_1, 8, 3, 0, 0, VAProfileVP9Profile1 }, { FF_PROFILE_VP9_2, 10, 3, 1, 1, VAProfileVP9Profile2 }, + { FF_PROFILE_VP9_3, 10, 3, 0, 0, VAProfileVP9Profile3 }, { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index d82975979a..20fb36adfa 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -567,15 +567,24 @@ VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx) } #if VA_CHECK_VERSION(1, 2, 0) - if (!strcmp(profile->name, "Main 4:2:2 10") || + if (!strcmp(profile->name, "Main 12") || + !strcmp(profile->name, "Main 12 Intra")) + return VAProfileHEVCMain12; + else if (!strcmp(profile->name, "Main 4:2:2 10") || !strcmp(profile->name, "Main 4:2:2 10 Intra")) return VAProfileHEVCMain422_10; + else if (!strcmp(profile->name, "Main 4:2:2 12") || + !strcmp(profile->name, "Main 4:2:2 12 Intra")) + return VAProfileHEVCMain422_12; else if (!strcmp(profile->name, "Main 4:4:4") || !strcmp(profile->name, "Main 4:4:4 Intra")) return VAProfileHEVCMain444; else if (!strcmp(profile->name, "Main 4:4:4 10") || !strcmp(profile->name, "Main 4:4:4 10 Intra")) return VAProfileHEVCMain444_10; + else if (!strcmp(profile->name, "Main 4:4:4 12") || + !strcmp(profile->name, "Main 4:4:4 12 Intra")) + return VAProfileHEVCMain444_12; #else av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is " "not supported with this VA version.\n", profile->name); diff --git a/libavcodec/version.h b/libavcodec/version.h index d7d5fca6b2..d251ae2eff 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 42 -#define LIBAVCODEC_VERSION_MICRO 103 +#define LIBAVCODEC_VERSION_MICRO 104 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 029e9156c5..7c0a246446 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -235,6 +235,8 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif break; case AV_PIX_FMT_YUV444P: + case AV_PIX_FMT_YUV444P10: + case AV_PIX_FMT_YUV444P12: #if CONFIG_VP9_VAAPI_HWACCEL *fmtp++ = AV_PIX_FMT_VAAPI; #endif diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 78205425ee..9ba5225ad2 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -121,6 +121,9 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { MAP(YUY2, YUV422, YUYV422, 0), #ifdef VA_FOURCC_Y210 MAP(Y210, YUV422_10, Y210, 0), +#endif +#ifdef VA_FOURCC_Y212 + MAP(Y212, YUV422_12, Y212, 0), #endif MAP(411P, YUV411, YUV411P, 0), MAP(422V, YUV422, YUV440P, 0), @@ -131,6 +134,9 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { MAP(Y800, YUV400, GRAY8, 0), #ifdef VA_FOURCC_P010 MAP(P010, YUV420_10BPP, P010, 0), +#endif +#ifdef VA_FOURCC_P012 + MAP(P012, YUV420_12, P012, 0), #endif MAP(BGRA, RGB32, BGRA, 0), MAP(BGRX, RGB32, BGR0, 0), @@ -145,6 +151,16 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { #ifdef VA_FOURCC_X2R10G10B10 MAP(X2R10G10B10, RGB32_10, X2RGB10, 0), #endif +#ifdef VA_FOURCC_Y410 + // libva doesn't include a fourcc for XV30 and the driver only declares + // support for Y410, so we must fudge the mapping here. + MAP(Y410, YUV444_10, XV30, 0), +#endif +#ifdef VA_FOURCC_Y412 + // libva doesn't include a fourcc for XV36 and the driver only declares + // support for Y412, so we must fudge the mapping here. + MAP(Y412, YUV444_12, XV36, 0), +#endif }; #undef MAP @@ -1000,6 +1016,9 @@ static const struct { DRM_MAP(NV12, 1, DRM_FORMAT_NV12), #if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16) DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616), +#endif +#if defined(VA_FOURCC_P012) && defined(DRM_FORMAT_R16) + DRM_MAP(P012, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616), #endif DRM_MAP(BGRA, 1, DRM_FORMAT_ARGB8888), DRM_MAP(BGRX, 1, DRM_FORMAT_XRGB8888), @@ -1014,6 +1033,12 @@ static const struct { #if defined(VA_FOURCC_XYUV) && defined(DRM_FORMAT_XYUV8888) DRM_MAP(XYUV, 1, DRM_FORMAT_XYUV8888), #endif +#if defined(VA_FOURCC_Y412) && defined(DRM_FORMAT_XVYU2101010) + DRM_MAP(Y410, 1, DRM_FORMAT_XVYU2101010), +#endif +#if defined(VA_FOURCC_Y412) && defined(DRM_FORMAT_XVYU12_16161616) + DRM_MAP(Y412, 1, DRM_FORMAT_XVYU12_16161616), +#endif }; #undef DRM_MAP From 2f9b8bbd1f415769e1da03571e09c74a78987a3d Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sat, 20 Aug 2022 09:47:27 -0700 Subject: [PATCH 120/590] lavu/hwcontext_vulkan: support mapping VUYX, P012, and XV36 If we want to be able to map between VAAPI and Vulkan (to do Vulkan filtering), we need to have matching formats on each side. The mappings here are not exact. In the same way that P010 is still mapped to full 16 bit formats, P012 has to be mapped that way as well. Similarly, VUYX has to be mapped to an alpha-equipped format, and XV36 has to be mapped to a fully 16bit alpha-equipped format. While Vulkan seems to fundamentally lack formats with an undefined, but physically present, alpha channel, it has have 10X6 and 12X4 formats that you could imagine using for P010, P012 and XV36, but these formats don't support the STORAGE usage flag. Today, hwcontext_vulkan requires all formats to be storable because it wants to be able to use them to create writable images. Until that changes, which might happen, we have to restrict the set of formats we use. Finally, when mapping a Vulkan image back to vaapi, I observed that the VK_FORMAT_R16G16B16A16_UNORM format we have to use for XV36 going to Vulkan is mapped to Y416 when going to vaapi (which makes sense as it's the exact matching format) so I had to add an entry for it even though we don't use it directly. --- libavutil/hwcontext_vulkan.c | 13 +++++++++++++ libavutil/version.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 237caa4bc0..f1db1c7291 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -173,6 +173,7 @@ static const struct { { AV_PIX_FMT_NV12, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } }, { AV_PIX_FMT_NV21, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } }, { AV_PIX_FMT_P010, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } }, + { AV_PIX_FMT_P012, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } }, { AV_PIX_FMT_P016, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } }, { AV_PIX_FMT_NV16, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } }, @@ -210,6 +211,9 @@ static const struct { { AV_PIX_FMT_YUVA444P12, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, { AV_PIX_FMT_YUVA444P16, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, + { AV_PIX_FMT_VUYX, { VK_FORMAT_R8G8B8A8_UNORM } }, + { AV_PIX_FMT_XV36, { VK_FORMAT_R16G16B16A16_UNORM } }, + { AV_PIX_FMT_BGRA, { VK_FORMAT_B8G8R8A8_UNORM } }, { AV_PIX_FMT_RGBA, { VK_FORMAT_R8G8B8A8_UNORM } }, { AV_PIX_FMT_RGB24, { VK_FORMAT_R8G8B8_UNORM } }, @@ -2629,6 +2633,15 @@ static const struct { { DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_UNORM }, { DRM_FORMAT_ABGR8888, VK_FORMAT_R8G8B8A8_UNORM }, { DRM_FORMAT_XBGR8888, VK_FORMAT_R8G8B8A8_UNORM }, + + // All these DRM_FORMATs were added in the same libdrm commit. +#ifdef DRM_FORMAT_XYUV8888 + { DRM_FORMAT_XYUV8888, VK_FORMAT_R8G8B8A8_UNORM }, + { DRM_FORMAT_XVYU12_16161616, VK_FORMAT_R16G16B16A16_UNORM} , + // As we had to map XV36 to a 16bit Vulkan format, reverse mapping will + // end up yielding Y416 as the DRM format, so we need to recognise it. + { DRM_FORMAT_Y416, VK_FORMAT_R16G16B16A16_UNORM }, +#endif }; static inline VkFormat drm_to_vulkan_fmt(uint32_t drm_fourcc) diff --git a/libavutil/version.h b/libavutil/version.h index c6e5b9f145..9b8462c705 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 57 #define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From b6e8fc1c201d58672639134a737137e1ba7b55fe Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 3 Sep 2022 18:17:23 +0200 Subject: [PATCH 121/590] avcodec/speexdec: improve support for speex in non-ogg --- libavcodec/speexdec.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libavcodec/speexdec.c b/libavcodec/speexdec.c index 83981fc454..9793d939fc 100644 --- a/libavcodec/speexdec.c +++ b/libavcodec/speexdec.c @@ -1462,7 +1462,7 @@ static av_cold int speex_decode_init(AVCodecContext *avctx) default: s->mode = 2; } - s->frames_per_packet = 1; + s->frames_per_packet = 64; s->frame_size = NB_FRAME_SIZE << s->mode; } @@ -1537,6 +1537,7 @@ static int speex_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { SpeexContext *s = avctx->priv_data; + int frames_per_packet = s->frames_per_packet; const float scale = 1.f / 32768.f; int buf_size = avpkt->size; float *dst; @@ -1547,26 +1548,31 @@ static int speex_decode_frame(AVCodecContext *avctx, AVFrame *frame, if ((ret = init_get_bits8(&s->gb, avpkt->data, buf_size)) < 0) return ret; - frame->nb_samples = FFALIGN(s->frame_size * s->frames_per_packet, 4); + frame->nb_samples = FFALIGN(s->frame_size * frames_per_packet, 4); if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; dst = (float *)frame->extended_data[0]; - for (int i = 0; i < s->frames_per_packet; i++) { + for (int i = 0; i < frames_per_packet; i++) { ret = speex_modes[s->mode].decode(avctx, &s->st[s->mode], &s->gb, dst + i * s->frame_size); if (ret < 0) return ret; if (avctx->ch_layout.nb_channels == 2) speex_decode_stereo(dst + i * s->frame_size, s->frame_size, &s->stereo); + if (get_bits_left(&s->gb) < 5 || + show_bits(&s->gb, 5) == 15) { + frames_per_packet = i + 1; + break; + } } dst = (float *)frame->extended_data[0]; s->fdsp->vector_fmul_scalar(dst, dst, scale, frame->nb_samples * frame->ch_layout.nb_channels); - frame->nb_samples = s->frame_size * s->frames_per_packet; + frame->nb_samples = s->frame_size * frames_per_packet; *got_frame_ptr = 1; - return buf_size; + return (get_bits_count(&s->gb) + 7) >> 3; } static av_cold int speex_decode_close(AVCodecContext *avctx) From 49a1de26ec6c358e5367ba1fb6e5828196626201 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 4 Sep 2022 16:38:00 +0200 Subject: [PATCH 122/590] avfilter/vf_gblur: handle cases when parameters become invalid --- libavfilter/vf_gblur.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c index 8bb851a774..bb4c342116 100644 --- a/libavfilter/vf_gblur.c +++ b/libavfilter/vf_gblur.c @@ -207,6 +207,12 @@ static void set_params(float sigma, int steps, float *postscale, float *boundary *postscale = pow(dnu / lambda, steps); *boundaryscale = 1.0 / (1.0 - dnu); *nu = (float)dnu; + if (!isnormal(*postscale)) + *postscale = 1.f; + if (!isnormal(*boundaryscale)) + *boundaryscale = 1.f; + if (!isnormal(*nu)) + *nu = 0.f; } static int filter_frame(AVFilterLink *inlink, AVFrame *in) From c49beead1926400dadf92e00de906300b41e3d21 Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Sun, 28 Aug 2022 14:08:55 -0400 Subject: [PATCH 123/590] avformat/avisynth: read _SARNum/_SARDen from frame properties Initialized to 1:1, but if the script sets these properties, it will be set to those instead (0:0 disables it, apparently). Signed-off-by: Stephen Hutchinson --- libavformat/avisynth.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 3d9fa2be50..d978e6ec40 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -251,6 +251,8 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) AVS_VideoFrame *frame; int error; int planar = 0; // 0: packed, 1: YUV, 2: Y8, 3: Planar RGB, 4: YUVA, 5: Planar RGBA + int sar_num = 1; + int sar_den = 1; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; @@ -728,6 +730,12 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED; } } + + /* Sample aspect ratio */ + sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error); + sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error); + st->sample_aspect_ratio = (AVRational){ sar_num, sar_den }; + avs_library.avs_release_video_frame(frame); } else { st->codecpar->field_order = AV_FIELD_UNKNOWN; From adead1ccd6a8b1d89a6f5298a5708c41cabddd67 Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Tue, 30 Aug 2022 18:34:57 -0400 Subject: [PATCH 124/590] avformat/avisynth: implement avisynth_flags option Signed-off-by: Stephen Hutchinson --- libavformat/avisynth.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index d978e6ec40..7bb2977383 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -21,6 +21,7 @@ #include "libavutil/attributes.h" #include "libavutil/internal.h" +#include "libavutil/opt.h" #include "libavcodec/internal.h" @@ -85,7 +86,18 @@ typedef struct AviSynthLibrary { #undef AVSC_DECLARE_FUNC } AviSynthLibrary; +typedef enum AviSynthFlags { + AVISYNTH_FRAMEPROP_FIELD_ORDER = (1 << 0), + AVISYNTH_FRAMEPROP_RANGE = (1 << 1), + AVISYNTH_FRAMEPROP_PRIMARIES = (1 << 2), + AVISYNTH_FRAMEPROP_TRANSFER = (1 << 3), + AVISYNTH_FRAMEPROP_MATRIX = (1 << 4), + AVISYNTH_FRAMEPROP_CHROMA_LOCATION = (1 << 5), + AVISYNTH_FRAMEPROP_SAR = (1 << 6), +} AviSynthFlags; + typedef struct AviSynthContext { + const AVClass *class; AVS_ScriptEnvironment *env; AVS_Clip *clip; const AVS_VideoInfo *vi; @@ -100,6 +112,8 @@ typedef struct AviSynthContext { int error; + uint32_t flags; + /* Linked list pointers. */ struct AviSynthContext *next; } AviSynthContext; @@ -518,6 +532,7 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) avsmap = avs_library.avs_get_frame_props_ro(avs->env, frame); /* Field order */ + if(avs->flags & AVISYNTH_FRAMEPROP_FIELD_ORDER) { if(avs_library.avs_prop_get_type(avs->env, avsmap, "_FieldBased") == AVS_PROPTYPE_UNSET) { st->codecpar->field_order = AV_FIELD_UNKNOWN; } else { @@ -535,8 +550,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->field_order = AV_FIELD_UNKNOWN; } } + } /* Color Range */ + if(avs->flags & AVISYNTH_FRAMEPROP_RANGE) { if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ColorRange") == AVS_PROPTYPE_UNSET) { st->codecpar->color_range = AVCOL_RANGE_UNSPECIFIED; } else { @@ -551,8 +568,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->color_range = AVCOL_RANGE_UNSPECIFIED; } } + } /* Color Primaries */ + if(avs->flags & AVISYNTH_FRAMEPROP_PRIMARIES) { switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Primaries", 0, &error)) { case 1: st->codecpar->color_primaries = AVCOL_PRI_BT709; @@ -593,8 +612,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) default: st->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED; } + } /* Color Transfer Characteristics */ + if(avs->flags & AVISYNTH_FRAMEPROP_TRANSFER) { switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Transfer", 0, &error)) { case 1: st->codecpar->color_trc = AVCOL_TRC_BT709; @@ -650,8 +671,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) default: st->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED; } + } /* Matrix coefficients */ + if(avs->flags & AVISYNTH_FRAMEPROP_MATRIX) { if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) { st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; } else { @@ -702,8 +725,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; } } + } /* Chroma Location */ + if(avs->flags & AVISYNTH_FRAMEPROP_CHROMA_LOCATION) { if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) { st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED; } else { @@ -730,11 +755,14 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED; } } + } /* Sample aspect ratio */ + if(avs->flags & AVISYNTH_FRAMEPROP_SAR) { sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error); sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error); st->sample_aspect_ratio = (AVRational){ sar_num, sar_den }; + } avs_library.avs_release_video_frame(frame); } else { @@ -1140,6 +1168,29 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, return 0; } +#define AVISYNTH_FRAMEPROP_DEFAULT AVISYNTH_FRAMEPROP_FIELD_ORDER | AVISYNTH_FRAMEPROP_RANGE | \ + AVISYNTH_FRAMEPROP_PRIMARIES | AVISYNTH_FRAMEPROP_TRANSFER | \ + AVISYNTH_FRAMEPROP_MATRIX | AVISYNTH_FRAMEPROP_CHROMA_LOCATION +#define OFFSET(x) offsetof(AviSynthContext, x) +static const AVOption avisynth_options[] = { + { "avisynth_flags", "set flags related to reading frame properties from script (AviSynth+ v3.7.1 or higher)", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVISYNTH_FRAMEPROP_DEFAULT}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "field_order", "read field order", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_FIELD_ORDER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "range", "read color range", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_RANGE}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "primaries", "read color primaries", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_PRIMARIES}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "transfer", "read color transfer characteristics", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_TRANSFER}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "matrix", "read matrix coefficients", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_MATRIX}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "chroma_location", "read chroma location", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_CHROMA_LOCATION}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { "sar", "read sample aspect ratio", 0, AV_OPT_TYPE_CONST, {.i64 = AVISYNTH_FRAMEPROP_SAR}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "flags" }, + { NULL }, +}; + +static const AVClass avisynth_demuxer_class = { + .class_name = "AviSynth demuxer", + .item_name = av_default_item_name, + .option = avisynth_options, + .version = LIBAVUTIL_VERSION_INT, +}; + const AVInputFormat ff_avisynth_demuxer = { .name = "avisynth", .long_name = NULL_IF_CONFIG_SMALL("AviSynth script"), @@ -1149,4 +1200,5 @@ const AVInputFormat ff_avisynth_demuxer = { .read_close = avisynth_read_close, .read_seek = avisynth_read_seek, .extensions = "avs", + .priv_class = &avisynth_demuxer_class, }; From 6195a0ee191728b4e638cf3b620e68acde8854b0 Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Tue, 30 Aug 2022 20:11:20 -0400 Subject: [PATCH 125/590] avformat/avisynth: reindent Signed-off-by: Stephen Hutchinson --- libavformat/avisynth.c | 348 ++++++++++++++++++++--------------------- 1 file changed, 174 insertions(+), 174 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 7bb2977383..b426ac343e 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -533,235 +533,235 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) /* Field order */ if(avs->flags & AVISYNTH_FRAMEPROP_FIELD_ORDER) { - if(avs_library.avs_prop_get_type(avs->env, avsmap, "_FieldBased") == AVS_PROPTYPE_UNSET) { - st->codecpar->field_order = AV_FIELD_UNKNOWN; - } else { - switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_FieldBased", 0, &error)) { - case 0: - st->codecpar->field_order = AV_FIELD_PROGRESSIVE; - break; - case 1: - st->codecpar->field_order = AV_FIELD_BB; - break; - case 2: - st->codecpar->field_order = AV_FIELD_TT; - break; - default: + if(avs_library.avs_prop_get_type(avs->env, avsmap, "_FieldBased") == AVS_PROPTYPE_UNSET) { st->codecpar->field_order = AV_FIELD_UNKNOWN; + } else { + switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_FieldBased", 0, &error)) { + case 0: + st->codecpar->field_order = AV_FIELD_PROGRESSIVE; + break; + case 1: + st->codecpar->field_order = AV_FIELD_BB; + break; + case 2: + st->codecpar->field_order = AV_FIELD_TT; + break; + default: + st->codecpar->field_order = AV_FIELD_UNKNOWN; + } } } - } /* Color Range */ if(avs->flags & AVISYNTH_FRAMEPROP_RANGE) { - if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ColorRange") == AVS_PROPTYPE_UNSET) { - st->codecpar->color_range = AVCOL_RANGE_UNSPECIFIED; - } else { - switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ColorRange", 0, &error)) { - case 0: - st->codecpar->color_range = AVCOL_RANGE_JPEG; - break; - case 1: - st->codecpar->color_range = AVCOL_RANGE_MPEG; - break; - default: + if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ColorRange") == AVS_PROPTYPE_UNSET) { st->codecpar->color_range = AVCOL_RANGE_UNSPECIFIED; + } else { + switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ColorRange", 0, &error)) { + case 0: + st->codecpar->color_range = AVCOL_RANGE_JPEG; + break; + case 1: + st->codecpar->color_range = AVCOL_RANGE_MPEG; + break; + default: + st->codecpar->color_range = AVCOL_RANGE_UNSPECIFIED; + } } } - } /* Color Primaries */ if(avs->flags & AVISYNTH_FRAMEPROP_PRIMARIES) { - switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Primaries", 0, &error)) { - case 1: - st->codecpar->color_primaries = AVCOL_PRI_BT709; - break; - case 2: - st->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED; - break; - case 4: - st->codecpar->color_primaries = AVCOL_PRI_BT470M; - break; - case 5: - st->codecpar->color_primaries = AVCOL_PRI_BT470BG; - break; - case 6: - st->codecpar->color_primaries = AVCOL_PRI_SMPTE170M; - break; - case 7: - st->codecpar->color_primaries = AVCOL_PRI_SMPTE240M; - break; - case 8: - st->codecpar->color_primaries = AVCOL_PRI_FILM; - break; - case 9: - st->codecpar->color_primaries = AVCOL_PRI_BT2020; - break; - case 10: - st->codecpar->color_primaries = AVCOL_PRI_SMPTE428; - break; - case 11: - st->codecpar->color_primaries = AVCOL_PRI_SMPTE431; - break; - case 12: - st->codecpar->color_primaries = AVCOL_PRI_SMPTE432; - break; - case 22: - st->codecpar->color_primaries = AVCOL_PRI_EBU3213; - break; - default: - st->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED; - } + switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Primaries", 0, &error)) { + case 1: + st->codecpar->color_primaries = AVCOL_PRI_BT709; + break; + case 2: + st->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED; + break; + case 4: + st->codecpar->color_primaries = AVCOL_PRI_BT470M; + break; + case 5: + st->codecpar->color_primaries = AVCOL_PRI_BT470BG; + break; + case 6: + st->codecpar->color_primaries = AVCOL_PRI_SMPTE170M; + break; + case 7: + st->codecpar->color_primaries = AVCOL_PRI_SMPTE240M; + break; + case 8: + st->codecpar->color_primaries = AVCOL_PRI_FILM; + break; + case 9: + st->codecpar->color_primaries = AVCOL_PRI_BT2020; + break; + case 10: + st->codecpar->color_primaries = AVCOL_PRI_SMPTE428; + break; + case 11: + st->codecpar->color_primaries = AVCOL_PRI_SMPTE431; + break; + case 12: + st->codecpar->color_primaries = AVCOL_PRI_SMPTE432; + break; + case 22: + st->codecpar->color_primaries = AVCOL_PRI_EBU3213; + break; + default: + st->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED; + } } /* Color Transfer Characteristics */ if(avs->flags & AVISYNTH_FRAMEPROP_TRANSFER) { - switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Transfer", 0, &error)) { - case 1: - st->codecpar->color_trc = AVCOL_TRC_BT709; - break; - case 2: - st->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED; - break; - case 4: - st->codecpar->color_trc = AVCOL_TRC_GAMMA22; - break; - case 5: - st->codecpar->color_trc = AVCOL_TRC_GAMMA28; - break; - case 6: - st->codecpar->color_trc = AVCOL_TRC_SMPTE170M; - break; - case 7: - st->codecpar->color_trc = AVCOL_TRC_SMPTE240M; - break; - case 8: - st->codecpar->color_trc = AVCOL_TRC_LINEAR; - break; - case 9: - st->codecpar->color_trc = AVCOL_TRC_LOG; - break; - case 10: - st->codecpar->color_trc = AVCOL_TRC_LOG_SQRT; - break; - case 11: - st->codecpar->color_trc = AVCOL_TRC_IEC61966_2_4; - break; - case 12: - st->codecpar->color_trc = AVCOL_TRC_BT1361_ECG; - break; - case 13: - st->codecpar->color_trc = AVCOL_TRC_IEC61966_2_1; - break; - case 14: - st->codecpar->color_trc = AVCOL_TRC_BT2020_10; - break; - case 15: - st->codecpar->color_trc = AVCOL_TRC_BT2020_12; - break; - case 16: - st->codecpar->color_trc = AVCOL_TRC_SMPTE2084; - break; - case 17: - st->codecpar->color_trc = AVCOL_TRC_SMPTE428; - break; - case 18: - st->codecpar->color_trc = AVCOL_TRC_ARIB_STD_B67; - break; - default: - st->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED; - } - } - - /* Matrix coefficients */ - if(avs->flags & AVISYNTH_FRAMEPROP_MATRIX) { - if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) { - st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; - } else { - switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) { - case 0: - st->codecpar->color_space = AVCOL_SPC_RGB; - break; + switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Transfer", 0, &error)) { case 1: - st->codecpar->color_space = AVCOL_SPC_BT709; + st->codecpar->color_trc = AVCOL_TRC_BT709; break; case 2: - st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; + st->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED; break; case 4: - st->codecpar->color_space = AVCOL_SPC_FCC; + st->codecpar->color_trc = AVCOL_TRC_GAMMA22; break; case 5: - st->codecpar->color_space = AVCOL_SPC_BT470BG; + st->codecpar->color_trc = AVCOL_TRC_GAMMA28; break; case 6: - st->codecpar->color_space = AVCOL_SPC_SMPTE170M; + st->codecpar->color_trc = AVCOL_TRC_SMPTE170M; break; case 7: - st->codecpar->color_space = AVCOL_SPC_SMPTE240M; + st->codecpar->color_trc = AVCOL_TRC_SMPTE240M; break; case 8: - st->codecpar->color_space = AVCOL_SPC_YCGCO; + st->codecpar->color_trc = AVCOL_TRC_LINEAR; break; case 9: - st->codecpar->color_space = AVCOL_SPC_BT2020_NCL; + st->codecpar->color_trc = AVCOL_TRC_LOG; break; case 10: - st->codecpar->color_space = AVCOL_SPC_BT2020_CL; + st->codecpar->color_trc = AVCOL_TRC_LOG_SQRT; break; case 11: - st->codecpar->color_space = AVCOL_SPC_SMPTE2085; + st->codecpar->color_trc = AVCOL_TRC_IEC61966_2_4; break; case 12: - st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_NCL; + st->codecpar->color_trc = AVCOL_TRC_BT1361_ECG; break; case 13: - st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_CL; + st->codecpar->color_trc = AVCOL_TRC_IEC61966_2_1; break; case 14: - st->codecpar->color_space = AVCOL_SPC_ICTCP; + st->codecpar->color_trc = AVCOL_TRC_BT2020_10; + break; + case 15: + st->codecpar->color_trc = AVCOL_TRC_BT2020_12; + break; + case 16: + st->codecpar->color_trc = AVCOL_TRC_SMPTE2084; + break; + case 17: + st->codecpar->color_trc = AVCOL_TRC_SMPTE428; + break; + case 18: + st->codecpar->color_trc = AVCOL_TRC_ARIB_STD_B67; break; default: - st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; + st->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED; } } + + /* Matrix coefficients */ + if(avs->flags & AVISYNTH_FRAMEPROP_MATRIX) { + if(avs_library.avs_prop_get_type(avs->env, avsmap, "_Matrix") == AVS_PROPTYPE_UNSET) { + st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; + } else { + switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_Matrix", 0, &error)) { + case 0: + st->codecpar->color_space = AVCOL_SPC_RGB; + break; + case 1: + st->codecpar->color_space = AVCOL_SPC_BT709; + break; + case 2: + st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; + break; + case 4: + st->codecpar->color_space = AVCOL_SPC_FCC; + break; + case 5: + st->codecpar->color_space = AVCOL_SPC_BT470BG; + break; + case 6: + st->codecpar->color_space = AVCOL_SPC_SMPTE170M; + break; + case 7: + st->codecpar->color_space = AVCOL_SPC_SMPTE240M; + break; + case 8: + st->codecpar->color_space = AVCOL_SPC_YCGCO; + break; + case 9: + st->codecpar->color_space = AVCOL_SPC_BT2020_NCL; + break; + case 10: + st->codecpar->color_space = AVCOL_SPC_BT2020_CL; + break; + case 11: + st->codecpar->color_space = AVCOL_SPC_SMPTE2085; + break; + case 12: + st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_NCL; + break; + case 13: + st->codecpar->color_space = AVCOL_SPC_CHROMA_DERIVED_CL; + break; + case 14: + st->codecpar->color_space = AVCOL_SPC_ICTCP; + break; + default: + st->codecpar->color_space = AVCOL_SPC_UNSPECIFIED; + } + } } /* Chroma Location */ if(avs->flags & AVISYNTH_FRAMEPROP_CHROMA_LOCATION) { - if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) { - st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED; - } else { - switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) { - case 0: - st->codecpar->chroma_location = AVCHROMA_LOC_LEFT; - break; - case 1: - st->codecpar->chroma_location = AVCHROMA_LOC_CENTER; - break; - case 2: - st->codecpar->chroma_location = AVCHROMA_LOC_TOPLEFT; - break; - case 3: - st->codecpar->chroma_location = AVCHROMA_LOC_TOP; - break; - case 4: - st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOMLEFT; - break; - case 5: - st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOM; - break; - default: + if(avs_library.avs_prop_get_type(avs->env, avsmap, "_ChromaLocation") == AVS_PROPTYPE_UNSET) { st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED; + } else { + switch (avs_library.avs_prop_get_int(avs->env, avsmap, "_ChromaLocation", 0, &error)) { + case 0: + st->codecpar->chroma_location = AVCHROMA_LOC_LEFT; + break; + case 1: + st->codecpar->chroma_location = AVCHROMA_LOC_CENTER; + break; + case 2: + st->codecpar->chroma_location = AVCHROMA_LOC_TOPLEFT; + break; + case 3: + st->codecpar->chroma_location = AVCHROMA_LOC_TOP; + break; + case 4: + st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOMLEFT; + break; + case 5: + st->codecpar->chroma_location = AVCHROMA_LOC_BOTTOM; + break; + default: + st->codecpar->chroma_location = AVCHROMA_LOC_UNSPECIFIED; + } } } - } /* Sample aspect ratio */ if(avs->flags & AVISYNTH_FRAMEPROP_SAR) { - sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error); - sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error); - st->sample_aspect_ratio = (AVRational){ sar_num, sar_den }; + sar_num = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARNum", 0, &error); + sar_den = avs_library.avs_prop_get_int(avs->env, avsmap, "_SARDen", 0, &error); + st->sample_aspect_ratio = (AVRational){ sar_num, sar_den }; } avs_library.avs_release_video_frame(frame); From f0395f9ef6051315973f1fdded1804f81458566d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 18 Aug 2022 23:41:57 +0200 Subject: [PATCH 126/590] avcodec/speedhq: Check width Fixes: out of array access Fixes: 50014/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-4748914632294400 Alternatively the buffer size can be increased Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/speedhq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 1661b66ae7..4f0e417a82 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -498,7 +498,7 @@ static int speedhq_decode_frame(AVCodecContext *avctx, AVFrame *frame, uint32_t second_field_offset; int ret; - if (buf_size < 4 || avctx->width < 8) + if (buf_size < 4 || avctx->width < 8 || avctx->width % 8 != 0) return AVERROR_INVALIDDATA; quality = buf[0]; From f89949afed7a538db603f32d463fe9547bc439a7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 01:35:19 +0200 Subject: [PATCH 127/590] avutil/tests/.gitignore: Add channel_layout testtool Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt --- libavutil/tests/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore index 919010e4fc..87895912f5 100644 --- a/libavutil/tests/.gitignore +++ b/libavutil/tests/.gitignore @@ -9,6 +9,7 @@ /bprint /camellia /cast5 +/channel_layout /color_utils /cpu /cpu_init From dcc4704a4e818a2f25766a62d780c021126ea8a5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 10:20:15 +0200 Subject: [PATCH 128/590] lavf/dv: remove DVMuxContext declaration from dv.h DVMuxContext is only used inside dvenc.c, there is no reason for it to be visible outside of that file. --- libavformat/dv.h | 4 +--- libavformat/dvenc.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavformat/dv.h b/libavformat/dv.h index 160c6ab873..efced6ccf0 100644 --- a/libavformat/dv.h +++ b/libavformat/dv.h @@ -1,5 +1,5 @@ /* - * General DV muxer/demuxer + * General DV demuxer * Copyright (c) 2003 Roman Shaposhnik * * Many thanks to Dan Dennedy for providing wealth @@ -36,6 +36,4 @@ int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *); int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset); -typedef struct DVMuxContext DVMuxContext; - #endif /* AVFORMAT_DV_H */ diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 7ef9692302..429ddcb96c 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -43,7 +43,7 @@ #define MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32-bit audio -struct DVMuxContext { +typedef struct DVMuxContext { AVClass *av_class; const AVDVProfile* sys; /* current DV profile, e.g.: 525/60, 625/50 */ int n_ast; /* number of stereo audio streams (up to 2) */ @@ -55,7 +55,7 @@ struct DVMuxContext { int has_video; /* frame under construction has video */ uint8_t frame_buf[DV_MAX_FRAME_SIZE]; /* frame under construction */ AVTimecode tc; /* timecode context */ -}; +} DVMuxContext; static const int dv_aaux_packs_dist[12][9] = { { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, From b6196cb2ef011f1a3278534070205b44c1e0e780 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 10:41:04 +0200 Subject: [PATCH 129/590] lavf/dv: always provide avpriv_dv_* symbols They are used from libavdevice. --- configure | 1 + libavformat/Makefile | 3 +-- libavformat/dv.c | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/configure b/configure index b9e1e403b1..9e51abd0d3 100755 --- a/configure +++ b/configure @@ -3532,6 +3532,7 @@ gdigrab_indev_deps="CreateDIBSection" gdigrab_indev_extralibs="-lgdi32" gdigrab_indev_select="bmp_decoder" iec61883_indev_deps="libiec61883" +iec61883_indev_select="dv_demuxer" jack_indev_deps="libjack" jack_indev_deps_any="sem_timedwait dispatch_dispatch_h" kmsgrab_indev_deps="libdrm" diff --git a/libavformat/Makefile b/libavformat/Makefile index f67a99f839..684bad0eb4 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -13,6 +13,7 @@ OBJS = allformats.o \ demux.o \ demux_utils.o \ dump.o \ + dv.o \ format.o \ id3v1.o \ id3v2.o \ @@ -184,7 +185,6 @@ OBJS-$(CONFIG_DSS_DEMUXER) += dss.o OBJS-$(CONFIG_DTSHD_DEMUXER) += dtshddec.o OBJS-$(CONFIG_DTS_DEMUXER) += dtsdec.o rawdec.o OBJS-$(CONFIG_DTS_MUXER) += rawenc.o -OBJS-$(CONFIG_DV_DEMUXER) += dv.o OBJS-$(CONFIG_DV_MUXER) += dvenc.o OBJS-$(CONFIG_DVBSUB_DEMUXER) += dvbsub.o rawdec.o OBJS-$(CONFIG_DVBTXT_DEMUXER) += dvbtxt.o rawdec.o @@ -711,7 +711,6 @@ SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o \ SHLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o # libavdevice dependencies -OBJS-$(CONFIG_IEC61883_INDEV) += dv.o # Windows resource file SHLIBOBJS-$(HAVE_GNU_WINDRES) += avformatres.o diff --git a/libavformat/dv.c b/libavformat/dv.c index 1dadaf6e62..24bacd5c53 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -28,6 +28,9 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include "config_components.h" + #include #include "avformat.h" #include "internal.h" @@ -40,6 +43,8 @@ #include "dv.h" #include "libavutil/avassert.h" +#if CONFIG_DV_DEMUXER + // Must be kept in sync with AVPacket struct DVPacket { int64_t pts; @@ -647,3 +652,21 @@ const AVInputFormat ff_dv_demuxer = { .read_seek = dv_read_seek, .extensions = "dv,dif", }; + +#else // CONFIG_DV_DEMUXER +DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s) +{ + return NULL; +} + +int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) +{ + return AVERROR(ENOSYS); +} + +int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, + uint8_t *buf, int buf_size, int64_t pos) +{ + return AVERROR(ENOSYS); +} +#endif // CONFIG_DV_DEMUXER From b62d41df07c627a677c69da139fd7e3710495a3a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:23:09 +0200 Subject: [PATCH 130/590] lavc/dvdec: drop the only use of DVVideoContext.avctx The function gets the codec context parameter directly. --- libavcodec/dvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 3af3e82eab..d5ed2ca2a8 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -391,7 +391,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]); LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */ - const int log2_blocksize = 3-s->avctx->lowres; + const int log2_blocksize = 3 - avctx->lowres; int is_field_mode[5]; int vs_bit_buffer_damaged = 0; int mb_bit_buffer_damaged[5] = {0}; From d1ba5d883ef95489fe59d035dd71105dc1184e84 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:06:32 +0200 Subject: [PATCH 131/590] lavc/dv: remove ff_dvvideo_init() The function contains only two assignments, setting DVVideoContext.avctx and AVCodecContext.chroma_sample_location. However, the decoder does not use the former, and the encoder should not be setting the latter. Therefore move the first assignment to dvenc and the second to dvdec. Make the encoder warn if the user-signalled chroma sample location does not match the supported one, and return an error on higher compliance levels. --- libavcodec/dv.c | 10 ---------- libavcodec/dv.h | 2 -- libavcodec/dvdec.c | 4 +++- libavcodec/dvenc.c | 12 +++++++++++- tests/ref/lavf/mxf_dv25 | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index e2550c4cc1..9e05aa8927 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -184,13 +184,3 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d) return 0; } - -av_cold int ff_dvvideo_init(AVCodecContext *avctx) -{ - DVVideoContext *s = avctx->priv_data; - - s->avctx = avctx; - avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; - - return 0; -} diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 331b8e846a..2b082d0140 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -97,8 +97,6 @@ enum dv_pack_type { int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d); -int ff_dvvideo_init(AVCodecContext *avctx); - static inline int dv_work_pool_size(const AVDVProfile *d) { int size = d->n_difchan * d->difseg_size * 27; diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index d5ed2ca2a8..87a321dd2e 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -238,6 +238,8 @@ static av_cold int dvvideo_decode_init(AVCodecContext *avctx) DVVideoContext *s = avctx->priv_data; int i; + avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; + ff_idctdsp_init(&s->idsp, avctx); for (i = 0; i < 64; i++) @@ -256,7 +258,7 @@ static av_cold int dvvideo_decode_init(AVCodecContext *avctx) ff_thread_once(&init_static_once, dv_init_static); - return ff_dvvideo_init(avctx); + return 0; } /* decode AC coefficients */ diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 78328f544c..7ae2c0c3d5 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -55,6 +55,16 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) PixblockDSPContext pdsp; int ret; + s->avctx = avctx; + + if (avctx->chroma_sample_location != AVCHROMA_LOC_TOPLEFT) { + const char *name = av_chroma_location_name(avctx->chroma_sample_location); + av_log(avctx, AV_LOG_WARNING, "Only top-left chroma location is supported " + "in DV, input value is: %s\n", name ? name : "unknown"); + if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL) + return AVERROR(EINVAL); + } + s->sys = av_dv_codec_profile2(avctx->width, avctx->height, avctx->pix_fmt, avctx->time_base); if (!s->sys) { av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. " @@ -91,7 +101,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) } #endif - return ff_dvvideo_init(avctx); + return 0; } /* bit budget for AC only in 5 MBs */ diff --git a/tests/ref/lavf/mxf_dv25 b/tests/ref/lavf/mxf_dv25 index 5022f1f62d..95a58906a0 100644 --- a/tests/ref/lavf/mxf_dv25 +++ b/tests/ref/lavf/mxf_dv25 @@ -1,3 +1,3 @@ -3339def72599c79ad5860c6860cc3123 *tests/data/lavf/lavf.mxf_dv25 +59d632e097e6f45c28445b2ab862ffe8 *tests/data/lavf/lavf.mxf_dv25 3834413 tests/data/lavf/lavf.mxf_dv25 tests/data/lavf/lavf.mxf_dv25 CRC=0xbdaf7f52 From 91c51dac6d00fec9dca0dc137230f1ab24ab7077 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:09:09 +0200 Subject: [PATCH 132/590] lavc/dv: do not pass DVVideoContext to ff_dv_init_dynamic_tables() It only needs work_chunks from it, so pass that directly. This is done in preparation to splitting DVVideoContext. --- libavcodec/dv.c | 6 +++--- libavcodec/dv.h | 2 +- libavcodec/dvdec.c | 2 +- libavcodec/dvenc.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 9e05aa8927..b5e54de5dd 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -162,7 +162,7 @@ static inline void dv_calc_mb_coordinates(const AVDVProfile *d, int chan, } } -int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d) +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d) { int j, i, c, s, p; @@ -174,8 +174,8 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d) p += !(j % 3); if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) && !(DV_PROFILE_IS_720p50(d) && s > 9)) { - dv_calc_mb_coordinates(d, c, s, j, &ctx->work_chunks[i].mb_coordinates[0]); - ctx->work_chunks[i++].buf_offset = p; + dv_calc_mb_coordinates(d, c, s, j, &work_chunks[i].mb_coordinates[0]); + work_chunks[i++].buf_offset = p; } p += 5; } diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 2b082d0140..286b267de2 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -95,7 +95,7 @@ enum dv_pack_type { */ #define DV_MAX_BPM 8 -int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d); +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); static inline int dv_work_pool_size(const AVDVProfile *d) { diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 87a321dd2e..63b1edd615 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -624,7 +624,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, } if (sys != s->sys) { - ret = ff_dv_init_dynamic_tables(s, sys); + ret = ff_dv_init_dynamic_tables(s->work_chunks, sys); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing the work tables.\n"); return ret; diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 7ae2c0c3d5..35a7f06f24 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -74,7 +74,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } - ret = ff_dv_init_dynamic_tables(s, s->sys); + ret = ff_dv_init_dynamic_tables(s->work_chunks, s->sys); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n"); return ret; From 69bad628ec37dc75813ae015df7ce4022d002d9a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:09:09 +0200 Subject: [PATCH 133/590] lavc/dv: do not pass DVVideoContext to dv_calculate_mb_xy() Pass the two variables needed from it directly. This is done in preparation to splitting DVVideoContext. --- libavcodec/dv.h | 5 +++-- libavcodec/dvdec.c | 2 +- libavcodec/dvenc.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 286b267de2..6430688795 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -107,7 +107,8 @@ static inline int dv_work_pool_size(const AVDVProfile *d) return size; } -static inline void dv_calculate_mb_xy(const DVVideoContext *s, +static inline void dv_calculate_mb_xy(const AVDVProfile *sys, + const uint8_t *buf, const DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y) { @@ -116,7 +117,7 @@ static inline void dv_calculate_mb_xy(const DVVideoContext *s, /* We work with 720p frames split in half. * The odd half-frame (chan == 2,3) is displaced :-( */ - if (s->sys->height == 720 && !(s->buf[1] & 0x0C)) + if (sys->height == 720 && !(buf[1] & 0x0C)) /* shifting the Y coordinate down by 72/2 macro blocks */ *mb_y -= (*mb_y > 17) ? 18 : -72; } diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 63b1edd615..06ce16d056 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -533,7 +533,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) block = &sblock[0][0]; mb = mb_data; for (mb_index = 0; mb_index < 5; mb_index++) { - dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y); + dv_calculate_mb_xy(s->sys, s->buf, work_chunk, mb_index, &mb_x, &mb_y); /* idct_put'ting luminance */ if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P) || diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 35a7f06f24..3560d3613f 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -873,7 +873,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) p = dif = &s->buf[work_chunk->buf_offset * 80]; enc_blk = &enc_blks[0]; for (mb_index = 0; mb_index < 5; mb_index++) { - dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y); + dv_calculate_mb_xy(s->sys, s->buf, work_chunk, mb_index, &mb_x, &mb_y); qnos[mb_index] = DV_PROFILE_IS_HD(s->sys) ? 1 : 15; From 4e73ed836641e85c5efbcb0d42a811645c74ac95 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:31:07 +0200 Subject: [PATCH 134/590] lavc/dvdec: stop using DVVideoContext The struct is quite small and the decoder and the encoder use different fields from it, so benefits from reusing it are small. This allows making the buf field const. --- libavcodec/dvdec.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 06ce16d056..2622a7e0c5 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -47,6 +47,7 @@ #include "dv_profile_internal.h" #include "dvdata.h" #include "get_bits.h" +#include "idctdsp.h" #include "put_bits.h" #include "simple_idct.h" #include "thread.h" @@ -61,6 +62,19 @@ typedef struct BlockInfo { int shift_offset; } BlockInfo; +typedef struct DVDecContext { + const AVDVProfile *sys; + const AVFrame *frame; + const uint8_t *buf; + + uint8_t dv_zigzag[2][64]; + DVwork_chunk work_chunks[4 * 12 * 27]; + uint32_t idct_factor[2 * 4 * 16 * 64]; + void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block); + + IDCTDSPContext idsp; +} DVDecContext; + static const int dv_iweight_bits = 14; static const uint16_t dv_iweight_88[64] = { @@ -186,7 +200,7 @@ static void dv_init_static(void) } } -static void dv_init_weight_tables(DVVideoContext *ctx, const AVDVProfile *d) +static void dv_init_weight_tables(DVDecContext *ctx, const AVDVProfile *d) { int j, i, c, s; uint32_t *factor1 = &ctx->idct_factor[0], @@ -235,7 +249,7 @@ static void dv_init_weight_tables(DVVideoContext *ctx, const AVDVProfile *d) static av_cold int dvvideo_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; - DVVideoContext *s = avctx->priv_data; + DVDecContext *s = avctx->priv_data; int i; avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; @@ -345,7 +359,7 @@ static av_always_inline void put_block_8x4(int16_t *block, uint8_t *av_restrict } } -static void dv100_idct_put_last_row_field_chroma(const DVVideoContext *s, uint8_t *data, +static void dv100_idct_put_last_row_field_chroma(const DVDecContext *s, uint8_t *data, int stride, int16_t *blocks) { s->idsp.idct(blocks + 0*64); @@ -357,7 +371,7 @@ static void dv100_idct_put_last_row_field_chroma(const DVVideoContext *s, uint8_ put_block_8x4(blocks+1*64 + 4*8, data + 8 + stride, stride<<1); } -static void dv100_idct_put_last_row_field_luma(const DVVideoContext *s, uint8_t *data, +static void dv100_idct_put_last_row_field_luma(const DVDecContext *s, uint8_t *data, int stride, int16_t *blocks) { s->idsp.idct(blocks + 0*64); @@ -378,7 +392,7 @@ static void dv100_idct_put_last_row_field_luma(const DVVideoContext *s, uint8_t /* mb_x and mb_y are in units of 8 pixels */ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) { - const DVVideoContext *s = avctx->priv_data; + const DVDecContext *s = avctx->priv_data; DVwork_chunk *work_chunk = arg; int quant, dc, dct_mode, class1, j; int mb_index, mb_x, mb_y, last_index; @@ -612,7 +626,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, { uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - DVVideoContext *s = avctx->priv_data; + DVDecContext *s = avctx->priv_data; const uint8_t *vsc_pack; int apt, is16_9, ret; const AVDVProfile *sys; @@ -686,7 +700,7 @@ const FFCodec ff_dvvideo_decoder = { CODEC_LONG_NAME("DV (Digital Video)"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_DVVIDEO, - .priv_data_size = sizeof(DVVideoContext), + .priv_data_size = sizeof(DVDecContext), .init = dvvideo_decode_init, FF_CODEC_DECODE_CB(dvvideo_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, From 828ec6ef4306d046749817fd6890e11f3289928b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:31:07 +0200 Subject: [PATCH 135/590] lavc/dvenc: stop using DVVideoContext Move the parts of it used by the encoder into a new DVEncContext and remove DVVideoContext. --- libavcodec/dv.h | 23 ----------------------- libavcodec/dvenc.c | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 6430688795..859a4e6545 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -27,36 +27,13 @@ #ifndef AVCODEC_DV_H #define AVCODEC_DV_H -#include "avcodec.h" #include "dv_profile.h" -#include "me_cmp.h" -#include "idctdsp.h" typedef struct DVwork_chunk { uint16_t buf_offset; uint16_t mb_coordinates[5]; } DVwork_chunk; -typedef struct DVVideoContext { - AVClass *avclass; - const AVDVProfile *sys; - const AVFrame *frame; - AVCodecContext *avctx; - uint8_t *buf; - - uint8_t dv_zigzag[2][64]; - - void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize); - void (*fdct[2])(int16_t *block); - void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block); - me_cmp_func ildct_cmp; - DVwork_chunk work_chunks[4 * 12 * 27]; - uint32_t idct_factor[2 * 4 * 16 * 64]; - IDCTDSPContext idsp; - - int quant_deadzone; -} DVVideoContext; - enum dv_section_type { dv_sect_header = 0x1f, dv_sect_subcode = 0x3f, diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 3560d3613f..a4d18ec0ef 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -47,9 +47,26 @@ #include "pixblockdsp.h" #include "put_bits.h" +typedef struct DVEncContext { + const AVClass *class; + const AVDVProfile *sys; + const AVFrame *frame; + AVCodecContext *avctx; + uint8_t *buf; + + void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize); + void (*fdct[2])(int16_t *block); + + me_cmp_func ildct_cmp; + DVwork_chunk work_chunks[4 * 12 * 27]; + + int quant_deadzone; +} DVEncContext; + + static av_cold int dvvideo_encode_init(AVCodecContext *avctx) { - DVVideoContext *s = avctx->priv_data; + DVEncContext *s = avctx->priv_data; FDCTDSPContext fdsp; MECmpContext mecc; PixblockDSPContext pdsp; @@ -227,7 +244,7 @@ static av_always_inline PutBitContext *dv_encode_ac(EncBlockInfo *bi, return pb; } -static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, const uint8_t *data, +static av_always_inline int dv_guess_dct_mode(DVEncContext *s, const uint8_t *data, ptrdiff_t linesize) { if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) { @@ -375,7 +392,7 @@ static const int dv_weight_720[2][64] = { 2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, } }; -static av_always_inline int dv_set_class_number_sd(DVVideoContext *s, +static av_always_inline int dv_set_class_number_sd(DVEncContext *s, int16_t *blk, EncBlockInfo *bi, const uint8_t *zigzag_scan, const int *weight, int bias) @@ -459,7 +476,7 @@ static av_always_inline int dv_set_class_number_sd(DVVideoContext *s, /* this function just copies the DCT coefficients and performs the initial (non-)quantization. */ -static inline void dv_set_class_number_hd(DVVideoContext *s, +static inline void dv_set_class_number_hd(DVEncContext *s, int16_t *blk, EncBlockInfo *bi, const uint8_t *zigzag_scan, const int *weight, int bias) @@ -517,7 +534,7 @@ static inline void dv_set_class_number_hd(DVVideoContext *s, } static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const uint8_t *data, int linesize, - DVVideoContext *s, int chroma) + DVEncContext *s, int chroma) { LOCAL_ALIGNED_16(int16_t, blk, [64]); @@ -854,7 +871,7 @@ static inline void dv_revise_cnos(uint8_t *dif, EncBlockInfo *blk, const AVDVPro static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) { - DVVideoContext *s = avctx->priv_data; + DVEncContext *s = avctx->priv_data; DVwork_chunk *work_chunk = arg; int mb_index, i, j; int mb_x, mb_y, c_offset; @@ -1002,7 +1019,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) return 0; } -static inline int dv_write_pack(enum dv_pack_type pack_id, DVVideoContext *c, +static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c, uint8_t *buf) { /* @@ -1122,7 +1139,7 @@ static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t *buf) return 3; } -static void dv_format_frame(DVVideoContext *c, uint8_t *buf) +static void dv_format_frame(DVEncContext *c, uint8_t *buf) { int chan, i, j, k; /* We work with 720p frames split in half. The odd half-frame is chan 2,3 */ @@ -1177,7 +1194,7 @@ static void dv_format_frame(DVVideoContext *c, uint8_t *buf) static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt, const AVFrame *frame, int *got_packet) { - DVVideoContext *s = c->priv_data; + DVEncContext *s = c->priv_data; int ret; if ((ret = ff_get_encode_buffer(c, pkt, s->sys->frame_size, 0)) < 0) @@ -1202,7 +1219,7 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt, } #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM -#define OFFSET(x) offsetof(DVVideoContext, x) +#define OFFSET(x) offsetof(DVEncContext, x) static const AVOption dv_options[] = { { "quant_deadzone", "Quantizer dead zone", OFFSET(quant_deadzone), AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024, VE }, { NULL }, @@ -1222,7 +1239,7 @@ const FFCodec ff_dvvideo_encoder = { .p.id = AV_CODEC_ID_DVVIDEO, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, - .priv_data_size = sizeof(DVVideoContext), + .priv_data_size = sizeof(DVEncContext), .init = dvvideo_encode_init, FF_CODEC_ENCODE_CB(dvvideo_encode_frame), .p.pix_fmts = (const enum AVPixelFormat[]) { From 7203bb6a59c55e853855b2e60e3fbc6d2f65dce1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 11:54:41 +0200 Subject: [PATCH 136/590] lavc/dv.h: move encoder/decoder-specific code to a new header dv.h is also used by libavformat, so avoid exposing encoder/decoder code to it. --- libavcodec/dv.c | 8 ++++-- libavcodec/dv.h | 34 ---------------------- libavcodec/dv_internal.h | 62 ++++++++++++++++++++++++++++++++++++++++ libavcodec/dvdec.c | 1 + libavcodec/dvenc.c | 1 + 5 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 libavcodec/dv_internal.h diff --git a/libavcodec/dv.c b/libavcodec/dv.c index b5e54de5dd..eb49978ad8 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -38,8 +38,12 @@ * DV codec. */ -#include "avcodec.h" -#include "dv.h" +#include + +#include "libavutil/pixfmt.h" + +#include "dv_internal.h" +#include "dv_profile.h" static inline void dv_calc_mb_coordinates(const AVDVProfile *d, int chan, int seq, int slot, uint16_t *tbl) diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 859a4e6545..535f01cf0b 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -27,13 +27,6 @@ #ifndef AVCODEC_DV_H #define AVCODEC_DV_H -#include "dv_profile.h" - -typedef struct DVwork_chunk { - uint16_t buf_offset; - uint16_t mb_coordinates[5]; -} DVwork_chunk; - enum dv_section_type { dv_sect_header = 0x1f, dv_sect_subcode = 0x3f, @@ -72,31 +65,4 @@ enum dv_pack_type { */ #define DV_MAX_BPM 8 -int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); - -static inline int dv_work_pool_size(const AVDVProfile *d) -{ - int size = d->n_difchan * d->difseg_size * 27; - if (DV_PROFILE_IS_1080i50(d)) - size -= 3 * 27; - if (DV_PROFILE_IS_720p50(d)) - size -= 4 * 27; - return size; -} - -static inline void dv_calculate_mb_xy(const AVDVProfile *sys, - const uint8_t *buf, - const DVwork_chunk *work_chunk, - int m, int *mb_x, int *mb_y) -{ - *mb_x = work_chunk->mb_coordinates[m] & 0xff; - *mb_y = work_chunk->mb_coordinates[m] >> 8; - - /* We work with 720p frames split in half. - * The odd half-frame (chan == 2,3) is displaced :-( */ - if (sys->height == 720 && !(buf[1] & 0x0C)) - /* shifting the Y coordinate down by 72/2 macro blocks */ - *mb_y -= (*mb_y > 17) ? 18 : -72; -} - #endif /* AVCODEC_DV_H */ diff --git a/libavcodec/dv_internal.h b/libavcodec/dv_internal.h new file mode 100644 index 0000000000..4b4151c88d --- /dev/null +++ b/libavcodec/dv_internal.h @@ -0,0 +1,62 @@ +/* + * DV encoder/decoder shared code + * Copyright (c) 2002 Fabrice Bellard + * + * 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_DV_INTERNAL_H +#define AVCODEC_DV_INTERNAL_H + +#include + +#include "dv.h" +#include "dv_profile.h" + +typedef struct DVwork_chunk { + uint16_t buf_offset; + uint16_t mb_coordinates[5]; +} DVwork_chunk; + +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); + +static inline int dv_work_pool_size(const AVDVProfile *d) +{ + int size = d->n_difchan * d->difseg_size * 27; + if (DV_PROFILE_IS_1080i50(d)) + size -= 3 * 27; + if (DV_PROFILE_IS_720p50(d)) + size -= 4 * 27; + return size; +} + +static inline void dv_calculate_mb_xy(const AVDVProfile *sys, + const uint8_t *buf, + const DVwork_chunk *work_chunk, + int m, int *mb_x, int *mb_y) +{ + *mb_x = work_chunk->mb_coordinates[m] & 0xff; + *mb_y = work_chunk->mb_coordinates[m] >> 8; + + /* We work with 720p frames split in half. + * The odd half-frame (chan == 2,3) is displaced :-( */ + if (sys->height == 720 && !(buf[1] & 0x0C)) + /* shifting the Y coordinate down by 72/2 macro blocks */ + *mb_y -= (*mb_y > 17) ? 18 : -72; +} + +#endif // AVCODEC_DV_INTERNAL_H diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 2622a7e0c5..994c53534e 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -44,6 +44,7 @@ #include "codec_internal.h" #include "decode.h" #include "dv.h" +#include "dv_internal.h" #include "dv_profile_internal.h" #include "dvdata.h" #include "get_bits.h" diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index a4d18ec0ef..c2f13e2d39 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -38,6 +38,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "dv.h" +#include "dv_internal.h" #include "dv_profile_internal.h" #include "dv_tablegen.h" #include "encode.h" From f7b3fc4afe6540506257c73a93a3f4272c250d44 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 12:04:58 +0200 Subject: [PATCH 137/590] lavc/dv: rename constants to follow our naming conventions CamelCase for enum tags, ALL_CAPS for enum values. --- libavcodec/dv.h | 38 +++++++++++++++++++------------------- libavcodec/dvdec.c | 4 ++-- libavcodec/dvenc.c | 32 ++++++++++++++++---------------- libavformat/dv.c | 18 +++++++++--------- libavformat/dvenc.c | 34 +++++++++++++++++----------------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 535f01cf0b..29f97b6089 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -27,27 +27,27 @@ #ifndef AVCODEC_DV_H #define AVCODEC_DV_H -enum dv_section_type { - dv_sect_header = 0x1f, - dv_sect_subcode = 0x3f, - dv_sect_vaux = 0x56, - dv_sect_audio = 0x76, - dv_sect_video = 0x96, +enum DVSectionType { + DV_SECT_HEADER = 0x1f, + DV_SECT_SUBCODE = 0x3f, + DV_SECT_VAUX = 0x56, + DV_SECT_AUDIO = 0x76, + DV_SECT_VIDEO = 0x96, }; -enum dv_pack_type { - dv_header525 = 0x3f, /* see dv_write_pack for important details on */ - dv_header625 = 0xbf, /* these two packs */ - dv_timecode = 0x13, - dv_audio_source = 0x50, - dv_audio_control = 0x51, - dv_audio_recdate = 0x52, - dv_audio_rectime = 0x53, - dv_video_source = 0x60, - dv_video_control = 0x61, - dv_video_recdate = 0x62, - dv_video_rectime = 0x63, - dv_unknown_pack = 0xff, +enum DVPackType { + DV_HEADER525 = 0x3f, /* see dv_write_pack for important details on */ + DV_HEADER625 = 0xbf, /* these two packs */ + DV_TIMECODE = 0x13, + DV_AUDIO_SOURCE = 0x50, + DV_AUDIO_CONTROL = 0x51, + DV_AUDIO_RECDATE = 0x52, + DV_AUDIO_RECTIME = 0x53, + DV_VIDEO_SOURCE = 0x60, + DV_VIDEO_CONTROL = 0x61, + DV_VIDEO_RECDATE = 0x62, + DV_VIDEO_RECTIME = 0x63, + DV_UNKNOWN_PACK = 0xff, }; #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 994c53534e..28dbe8c11a 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -660,7 +660,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, /* Determine the codec's sample_aspect ratio from the packet */ vsc_pack = buf + 80 * 5 + 48 + 5; - if (*vsc_pack == dv_video_control) { + if (*vsc_pack == DV_VIDEO_CONTROL) { apt = buf[4] & 0x07; is16_9 = (vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07); @@ -671,7 +671,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, AVFrame *frame, return ret; /* Determine the codec's field order from the packet */ - if ( *vsc_pack == dv_video_control ) { + if ( *vsc_pack == DV_VIDEO_CONTROL ) { if (avctx->height == 720) { frame->interlaced_frame = 0; frame->top_field_first = 0; diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index c2f13e2d39..4c747ef71f 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -1020,7 +1020,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg) return 0; } -static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c, +static inline int dv_write_pack(enum DVPackType pack_id, DVEncContext *c, uint8_t *buf) { /* @@ -1058,8 +1058,8 @@ static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c, buf[0] = (uint8_t) pack_id; switch (pack_id) { - case dv_header525: /* I can't imagine why these two weren't defined as real */ - case dv_header625: /* packs in SMPTE314M -- they definitely look like ones */ + case DV_HEADER525: /* I can't imagine why these two weren't defined as real */ + case DV_HEADER625: /* packs in SMPTE314M -- they definitely look like ones */ buf[1] = 0xf8 | /* reserved -- always 1 */ (apt & 0x07); /* APT: Track application ID */ buf[2] = (0 << 7) | /* TF1: audio data is 0 - valid; 1 - invalid */ @@ -1072,7 +1072,7 @@ static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c, (0x0f << 3) | /* reserved -- always 1 */ (apt & 0x07); /* AP3: Subcode application ID */ break; - case dv_video_source: + case DV_VIDEO_SOURCE: buf[1] = 0xff; /* reserved -- always 1 */ buf[2] = (1 << 7) | /* B/W: 0 - b/w, 1 - color */ (1 << 6) | /* following CLF is valid - 0, invalid - 1 */ @@ -1083,7 +1083,7 @@ static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c, c->sys->video_stype; /* signal type video compression */ buf[4] = 0xff; /* VISC: 0xff -- no information */ break; - case dv_video_control: + case DV_VIDEO_CONTROL: buf[1] = (0 << 6) | /* Copy generation management (CGMS) 0 -- free */ 0x3f; /* reserved -- always 1 */ buf[2] = 0xc8 | /* reserved -- always b11001xxx */ @@ -1104,7 +1104,7 @@ static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c, return 5; } -static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, +static inline int dv_write_dif_id(enum DVSectionType t, uint8_t chan_num, uint8_t seq_num, uint8_t dif_num, uint8_t *buf) { @@ -1151,14 +1151,14 @@ static void dv_format_frame(DVEncContext *c, uint8_t *buf) memset(buf, 0xff, 80 * 6); /* first 6 DIF blocks are for control data */ /* DV header: 1DIF */ - buf += dv_write_dif_id(dv_sect_header, chan+chan_offset, i, 0, buf); - buf += dv_write_pack((c->sys->dsf ? dv_header625 : dv_header525), + buf += dv_write_dif_id(DV_SECT_HEADER, chan+chan_offset, i, 0, buf); + buf += dv_write_pack((c->sys->dsf ? DV_HEADER625 : DV_HEADER525), c, buf); buf += 72; /* unused bytes */ /* DV subcode: 2DIFs */ for (j = 0; j < 2; j++) { - buf += dv_write_dif_id(dv_sect_subcode, chan+chan_offset, i, j, buf); + buf += dv_write_dif_id(DV_SECT_SUBCODE, chan+chan_offset, i, j, buf); for (k = 0; k < 6; k++) buf += dv_write_ssyb_id(k, (i < c->sys->difseg_size / 2), buf) + 5; buf += 29; /* unused bytes */ @@ -1166,12 +1166,12 @@ static void dv_format_frame(DVEncContext *c, uint8_t *buf) /* DV VAUX: 3DIFS */ for (j = 0; j < 3; j++) { - buf += dv_write_dif_id(dv_sect_vaux, chan+chan_offset, i, j, buf); - buf += dv_write_pack(dv_video_source, c, buf); - buf += dv_write_pack(dv_video_control, c, buf); + buf += dv_write_dif_id(DV_SECT_VAUX, chan+chan_offset, i, j, buf); + buf += dv_write_pack(DV_VIDEO_SOURCE, c, buf); + buf += dv_write_pack(DV_VIDEO_CONTROL, c, buf); buf += 7 * 5; - buf += dv_write_pack(dv_video_source, c, buf); - buf += dv_write_pack(dv_video_control, c, buf); + buf += dv_write_pack(DV_VIDEO_SOURCE, c, buf); + buf += dv_write_pack(DV_VIDEO_CONTROL, c, buf); buf += 4 * 5 + 2; /* unused bytes */ } @@ -1179,10 +1179,10 @@ static void dv_format_frame(DVEncContext *c, uint8_t *buf) for (j = 0; j < 135; j++) { if (j % 15 == 0) { memset(buf, 0xff, 80); - buf += dv_write_dif_id(dv_sect_audio, chan+chan_offset, i, j/15, buf); + buf += dv_write_dif_id(DV_SECT_AUDIO, chan+chan_offset, i, j/15, buf); buf += 77; /* audio control & shuffled PCM audio */ } - buf += dv_write_dif_id(dv_sect_video, chan+chan_offset, i, j, buf); + buf += dv_write_dif_id(DV_SECT_VIDEO, chan+chan_offset, i, j, buf); buf += 77; /* 1 video macroblock: 1 bytes control * 4 * 14 bytes Y 8x8 data * 10 bytes Cr 8x8 data diff --git a/libavformat/dv.c b/libavformat/dv.c index 24bacd5c53..303cecf9bb 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -87,26 +87,26 @@ static inline uint16_t dv_audio_12to16(uint16_t sample) return result; } -static const uint8_t *dv_extract_pack(const uint8_t *frame, enum dv_pack_type t) +static const uint8_t *dv_extract_pack(const uint8_t *frame, enum DVPackType t) { int offs; int c; for (c = 0; c < 10; c++) { switch (t) { - case dv_audio_source: + case DV_AUDIO_SOURCE: if (c&1) offs = (80 * 6 + 80 * 16 * 0 + 3 + c*12000); else offs = (80 * 6 + 80 * 16 * 3 + 3 + c*12000); break; - case dv_audio_control: + case DV_AUDIO_CONTROL: if (c&1) offs = (80 * 6 + 80 * 16 * 1 + 3 + c*12000); else offs = (80 * 6 + 80 * 16 * 4 + 3 + c*12000); break; - case dv_video_control: + case DV_VIDEO_CONTROL: if (c&1) offs = (80 * 3 + 8 + c*12000); else offs = (80 * 5 + 48 + 5 + c*12000); break; - case dv_timecode: + case DV_TIMECODE: offs = (80*1 + 3 + 3); break; default: @@ -139,7 +139,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t **ppcm, const uint8_t *as_pack; uint8_t *pcm, ipcm; - as_pack = dv_extract_pack(frame, dv_audio_source); + as_pack = dv_extract_pack(frame, DV_AUDIO_SOURCE); if (!as_pack) /* No audio ? */ return 0; @@ -239,7 +239,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) const uint8_t *as_pack; int freq, stype, smpls, quant, i, ach; - as_pack = dv_extract_pack(frame, dv_audio_source); + as_pack = dv_extract_pack(frame, DV_AUDIO_SOURCE); if (!as_pack || !c->sys) { /* No audio ? */ c->ach = 0; return 0; @@ -308,7 +308,7 @@ static int dv_extract_video_info(DVDemuxContext *c, const uint8_t *frame) c->vst->avg_frame_rate = av_inv_q(c->vst->time_base); /* finding out SAR is a little bit messy */ - vsc_pack = dv_extract_pack(frame, dv_video_control); + vsc_pack = dv_extract_pack(frame, DV_VIDEO_CONTROL); apt = frame[4] & 0x07; is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07))); @@ -328,7 +328,7 @@ static int dv_extract_timecode(DVDemuxContext* c, const uint8_t* frame, char *tc // is only relevant for NTSC systems. int prevent_df = c->sys->ltc_divisor == 25 || c->sys->ltc_divisor == 50; - tc_pack = dv_extract_pack(frame, dv_timecode); + tc_pack = dv_extract_pack(frame, DV_TIMECODE); if (!tc_pack) return 0; av_timecode_make_smpte_tc_string2(tc, av_inv_q(c->sys->time_base), AV_RB32(tc_pack + 1), prevent_df, 1); diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index 429ddcb96c..11947aa493 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -94,7 +94,7 @@ static int dv_audio_frame_size(const AVDVProfile* sys, int frame, int sample_rat sizeof(sys->audio_samples_dist[0]))]; } -static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* buf, int channel, int seq) +static int dv_write_pack(enum DVPackType pack_id, DVMuxContext *c, uint8_t* buf, int channel, int seq) { struct tm tc; time_t ct; @@ -103,12 +103,12 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu buf[0] = (uint8_t)pack_id; switch (pack_id) { - case dv_timecode: + case DV_TIMECODE: timecode = av_timecode_get_smpte_from_framenum(&c->tc, c->frames); timecode |= 1<<23 | 1<<15 | 1<<7 | 1<<6; // biphase and binary group flags AV_WB32(buf + 1, timecode); break; - case dv_audio_source: /* AAUX source pack */ + case DV_AUDIO_SOURCE: /* AAUX source pack */ if (c->ast[channel]->codecpar->sample_rate == 44100) { audio_type = 1; } else if (c->ast[channel]->codecpar->sample_rate == 32000) @@ -132,7 +132,7 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu 0; /* quantization: 0 -- 16-bit linear, 1 -- 12-bit nonlinear */ break; - case dv_audio_control: + case DV_AUDIO_CONTROL: buf[1] = (0 << 6) | /* copy protection: 0 -- unrestricted */ (1 << 4) | /* input source: 1 -- digital input */ (3 << 2) | /* compression: 3 -- no information */ @@ -147,8 +147,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu buf[4] = (1 << 7) | /* reserved -- always 1 */ 0x7f; /* genre category */ break; - case dv_audio_recdate: - case dv_video_recdate: /* VAUX recording date */ + case DV_AUDIO_RECDATE: + case DV_VIDEO_RECDATE: /* VAUX recording date */ ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num, c->sys->time_base.den, AV_ROUND_DOWN); brktimegm(ct, &tc); @@ -163,8 +163,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu buf[4] = (((tc.tm_year % 100) / 10) << 4) | /* Tens of year */ (tc.tm_year % 10); /* Units of year */ break; - case dv_audio_rectime: /* AAUX recording time */ - case dv_video_rectime: /* VAUX recording time */ + case DV_AUDIO_RECTIME: /* AAUX recording time */ + case DV_VIDEO_RECTIME: /* VAUX recording time */ ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num, c->sys->time_base.den, AV_ROUND_DOWN); brktimegm(ct, &tc); @@ -219,22 +219,22 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame) /* DV subcode: 2nd and 3d DIFs */ for (j = 80; j < 80 * 3; j += 80) { for (k = 6; k < 6 * 8; k += 8) - dv_write_pack(dv_timecode, c, &buf[j+k], 0, seq); + dv_write_pack(DV_TIMECODE, c, &buf[j+k], 0, seq); if (((long)(buf-frame)/(c->sys->frame_size/(c->sys->difseg_size*c->sys->n_difchan))%c->sys->difseg_size) > 5) { /* FIXME: is this really needed ? */ - dv_write_pack(dv_video_recdate, c, &buf[j+14], 0, seq); - dv_write_pack(dv_video_rectime, c, &buf[j+22], 0, seq); - dv_write_pack(dv_video_recdate, c, &buf[j+38], 0, seq); - dv_write_pack(dv_video_rectime, c, &buf[j+46], 0, seq); + dv_write_pack(DV_VIDEO_RECDATE, c, &buf[j+14], 0, seq); + dv_write_pack(DV_VIDEO_RECTIME, c, &buf[j+22], 0, seq); + dv_write_pack(DV_VIDEO_RECDATE, c, &buf[j+38], 0, seq); + dv_write_pack(DV_VIDEO_RECTIME, c, &buf[j+46], 0, seq); } } /* DV VAUX: 4th, 5th and 6th 3DIFs */ for (j = 80*3 + 3; j < 80*6; j += 80) { - dv_write_pack(dv_video_recdate, c, &buf[j+5* 2], 0, seq); - dv_write_pack(dv_video_rectime, c, &buf[j+5* 3], 0, seq); - dv_write_pack(dv_video_recdate, c, &buf[j+5*11], 0, seq); - dv_write_pack(dv_video_rectime, c, &buf[j+5*12], 0, seq); + dv_write_pack(DV_VIDEO_RECDATE, c, &buf[j+5* 2], 0, seq); + dv_write_pack(DV_VIDEO_RECTIME, c, &buf[j+5* 3], 0, seq); + dv_write_pack(DV_VIDEO_RECDATE, c, &buf[j+5*11], 0, seq); + dv_write_pack(DV_VIDEO_RECTIME, c, &buf[j+5*12], 0, seq); } } } From 090f12b15750bc3eb81b2d892cd980e9285cfe48 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 12:12:34 +0200 Subject: [PATCH 138/590] lavf/dv: make returning the video packet optional The mov demuxer only returns DV audio, video packets are discarded. It first reads the data to be parsed into a packet. Then both this packet and the pointer to its data are passed together to avpriv_dv_produce_packet(), which parses the data and partially overwrites the packet. This is confusing and potentially dangerous, so just pass NULL and avoid pointless packet modification. --- libavformat/dv.c | 19 +++++++++++-------- libavformat/mov.c | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index 303cecf9bb..f88fe62349 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -430,14 +430,17 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, } } - /* Now it's time to return video packet */ - size = dv_extract_video_info(c, buf); - pkt->data = buf; - pkt->pos = pos; - pkt->size = size; - pkt->flags |= AV_PKT_FLAG_KEY; - pkt->stream_index = c->vst->index; - pkt->pts = c->frames; + /* return the video packet, if the caller wants it */ + if (pkt) { + size = dv_extract_video_info(c, buf); + + pkt->data = buf; + pkt->pos = pos; + pkt->size = size; + pkt->flags |= AV_PKT_FLAG_KEY; + pkt->stream_index = c->vst->index; + pkt->pts = c->frames; + } c->frames++; diff --git a/libavformat/mov.c b/libavformat/mov.c index df45408060..b93facf7e0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8777,7 +8777,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { - ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); + ret = avpriv_dv_produce_packet(mov->dv_demux, NULL, pkt->data, pkt->size, pkt->pos); av_packet_unref(pkt); if (ret < 0) return ret; From f0283f278a6a5f587d6cd66128b29d49ef42fb36 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 13:49:36 +0200 Subject: [PATCH 139/590] lavf/dv: return a meaningful error code from avpriv_dv_produce_packet() --- libavformat/dv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index f88fe62349..c888111789 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -404,7 +404,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, if (buf_size < DV_PROFILE_BYTES || !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) || buf_size < c->sys->frame_size) { - return -1; /* Broken frame, or not enough data */ + return AVERROR_INVALIDDATA; } /* Queueing audio packet */ From b2e1d1443c12bb4cab54137154ae395b2d11c744 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 14:36:24 +0200 Subject: [PATCH 140/590] lavf/dv: forward errors from avformat_new_stream() --- libavformat/dv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index c888111789..24d6897da5 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -268,11 +268,13 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) ach = 2; /* Dynamic handling of the audio streams in DV */ + c->ach = 0; for (i = 0; i < ach; i++) { if (!c->ast[i]) { c->ast[i] = avformat_new_stream(c->fctx, NULL); if (!c->ast[i]) - break; + return AVERROR(ENOMEM); + avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, c->sys->time_base.den); c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; @@ -290,7 +292,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->start_time = 0; } - c->ach = i; + c->ach = ach; return (c->sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */ } @@ -410,6 +412,9 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, /* Queueing audio packet */ /* FIXME: in case of no audio/bad audio we have to do something */ size = dv_extract_audio_info(c, buf); + if (size < 0) + return size; + for (i = 0; i < c->ach; i++) { c->audio_pkt[i].pos = pos; c->audio_pkt[i].size = size; From 000b8d2acc53b23eaccf7a2d3e650f7e633bd3b6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 14:38:17 +0200 Subject: [PATCH 141/590] lavf/dv: set non-changing AVStream fields only once --- libavformat/dv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index 24d6897da5..f65c2d596f 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -278,6 +278,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, c->sys->time_base.den); c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; + c->ast[i]->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; + c->ast[i]->start_time = 0; c->audio_pkt[i].size = 0; c->audio_pkt[i].data = c->audio_buf[i]; @@ -288,9 +290,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->audio_pkt[i].pos = -1; } c->ast[i]->codecpar->sample_rate = dv_audio_frequency[freq]; - c->ast[i]->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; - c->ast[i]->start_time = 0; } c->ach = ach; From 6def44128afedcfbcad98ca00e209345875fac45 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 14:39:50 +0200 Subject: [PATCH 142/590] lavf/dv: set audio bitrate only at stream creation Demuxers are not supposed to update AVCodecParameters after the stream was seen by the caller. This value is not important enough to support dynamic updates for. --- libavformat/dv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index f65c2d596f..9c8b0a262c 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -280,6 +280,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; c->ast[i]->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; c->ast[i]->start_time = 0; + c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; c->audio_pkt[i].size = 0; c->audio_pkt[i].data = c->audio_buf[i]; @@ -290,7 +291,6 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->audio_pkt[i].pos = -1; } c->ast[i]->codecpar->sample_rate = dv_audio_frequency[freq]; - c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; } c->ach = ach; From 1ef4620290bcea29097a79c3f27be3d5cb366687 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Aug 2022 16:21:03 +0200 Subject: [PATCH 143/590] lavf/dv: do not update AVCodecParameters.sample_rate while demuxing Demuxers are not allowed to do this and few callers, if any, will handle this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data instead. --- libavformat/dv.c | 49 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/libavformat/dv.c b/libavformat/dv.c index 9c8b0a262c..ffed1a7a90 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -33,6 +33,7 @@ #include #include "avformat.h" +#include "demux.h" #include "internal.h" #include "libavcodec/dv_profile.h" #include "libavcodec/dv.h" @@ -46,7 +47,7 @@ #if CONFIG_DV_DEMUXER // Must be kept in sync with AVPacket -struct DVPacket { +typedef struct DVPacket { int64_t pts; uint8_t *data; int size; @@ -54,7 +55,10 @@ struct DVPacket { int flags; int64_t pos; int64_t duration; -}; + + int sample_rate; + int last_sample_rate; +} DVPacket; struct DVDemuxContext { const AVDVProfile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */ @@ -237,7 +241,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t **ppcm, static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) { const uint8_t *as_pack; - int freq, stype, smpls, quant, i, ach; + int freq, stype, smpls, quant, i, ach, sr; as_pack = dv_extract_pack(frame, DV_AUDIO_SOURCE); if (!as_pack || !c->sys) { /* No audio ? */ @@ -255,6 +259,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) "Unrecognized audio sample rate index (%d)\n", freq); return 0; } + sr = dv_audio_frequency[freq]; if (stype > 3) { av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype); @@ -280,7 +285,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; c->ast[i]->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; c->ast[i]->start_time = 0; - c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; + c->ast[i]->codecpar->bit_rate = 2 * sr * 16; + + c->ast[i]->codecpar->sample_rate = sr; + c->audio_pkt[i].last_sample_rate = sr; c->audio_pkt[i].size = 0; c->audio_pkt[i].data = c->audio_buf[i]; @@ -290,7 +298,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) c->audio_pkt[i].duration = 0; c->audio_pkt[i].pos = -1; } - c->ast[i]->codecpar->sample_rate = dv_audio_frequency[freq]; + + c->audio_pkt[i].sample_rate = sr; } c->ach = ach; @@ -380,16 +389,26 @@ int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) for (i = 0; i < c->ach; i++) { if (c->ast[i] && c->audio_pkt[i].size) { - pkt->size = c->audio_pkt[i].size; - pkt->data = c->audio_pkt[i].data; - pkt->stream_index = c->audio_pkt[i].stream_index; - pkt->flags = c->audio_pkt[i].flags; - pkt->pts = c->audio_pkt[i].pts; - pkt->duration = c->audio_pkt[i].duration; - pkt->pos = c->audio_pkt[i].pos; - - c->audio_pkt[i].size = 0; - size = pkt->size; + DVPacket *dpkt = &c->audio_pkt[i]; + + pkt->size = dpkt->size; + pkt->data = dpkt->data; + pkt->stream_index = dpkt->stream_index; + pkt->flags = dpkt->flags; + pkt->pts = dpkt->pts; + pkt->duration = dpkt->duration; + pkt->pos = dpkt->pos; + + dpkt->size = 0; + size = pkt->size; + + if (dpkt->last_sample_rate != dpkt->sample_rate) { + int ret = ff_add_param_change(pkt, 0, 0, dpkt->sample_rate, 0, 0); + if (ret < 0) + return ret; + dpkt->last_sample_rate = dpkt->sample_rate; + } + break; } } From 693c1e631c4957acd2fe9d9650d757fd8d3d1239 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 31 Aug 2022 04:43:22 +0200 Subject: [PATCH 144/590] lavf/mov: avoid leaks with multiple dv-audio streams --- libavformat/mov.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index b93facf7e0..a1bc627991 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2431,6 +2431,11 @@ static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, switch (st->codecpar->codec_id) { #if CONFIG_DV_DEMUXER case AV_CODEC_ID_DVAUDIO: + if (c->dv_fctx) { + avpriv_request_sample(c->fc, "multiple DV audio streams"); + return AVERROR(ENOSYS); + } + c->dv_fctx = avformat_alloc_context(); if (!c->dv_fctx) { av_log(c->fc, AV_LOG_ERROR, "dv demux context alloc error\n"); From c9b6fd27bfbd2c4c99c1af8e86b70eeb47991124 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 30 Jun 2022 16:20:09 +0200 Subject: [PATCH 145/590] lavu/fifo: add the header to its own doxy group Also, drop mentions of it being a circular buffer, as this is an internal implementation detail that should be invisible to the caller. --- libavutil/fifo.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavutil/fifo.h b/libavutil/fifo.h index 4eed364afc..6c6bd78842 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -18,7 +18,8 @@ /** * @file - * a very simple circular buffer FIFO implementation + * @ingroup lavu_fifo + * A generic FIFO API */ #ifndef AVUTIL_FIFO_H @@ -30,6 +31,14 @@ #include "attributes.h" #include "version.h" +/** + * @defgroup lavu_fifo AVFifo + * @ingroup lavu_data + * + * @{ + * A generic FIFO API + */ + typedef struct AVFifo AVFifo; /** @@ -423,4 +432,8 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) #endif #endif +/** + * @} + */ + #endif /* AVUTIL_FIFO_H */ From 8728808b3eadae96595cfc22424ae877d9276789 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 30 Jun 2022 16:23:46 +0200 Subject: [PATCH 146/590] lavu/fifo: clarify interaction of AV_FIFO_FLAG_AUTO_GROW with av_fifo_can_write() --- libavutil/fifo.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavutil/fifo.h b/libavutil/fifo.h index 6c6bd78842..89872d0972 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -97,7 +97,13 @@ void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems); size_t av_fifo_can_read(const AVFifo *f); /** - * @return number of elements that can be written into the given FIFO. + * @return Number of elements that can be written into the given FIFO without + * growing it. + * + * In other words, this number of elements or less is guaranteed to fit + * into the FIFO. More data may be written when the + * AV_FIFO_FLAG_AUTO_GROW flag was specified at FIFO creation, but this + * may involve memory allocation, which can fail. */ size_t av_fifo_can_write(const AVFifo *f); From ea5b375e0e95b05c88ec728d5953c916b4925bef Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 30 Jun 2022 16:23:46 +0200 Subject: [PATCH 147/590] lavu/fifo: clarify interaction of AV_FIFO_FLAG_AUTO_GROW with av_fifo_write() --- libavutil/fifo.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavutil/fifo.h b/libavutil/fifo.h index 89872d0972..70f9376d97 100644 --- a/libavutil/fifo.h +++ b/libavutil/fifo.h @@ -124,9 +124,12 @@ int av_fifo_grow2(AVFifo *f, size_t inc); /** * Write data into a FIFO. * - * In case nb_elems > av_fifo_can_write(f), nothing is written and an error + * In case nb_elems > av_fifo_can_write(f) and the AV_FIFO_FLAG_AUTO_GROW flag + * was not specified at FIFO creation, nothing is written and an error * is returned. * + * Calling function is guaranteed to succeed if nb_elems <= av_fifo_can_write(f). + * * @param f the FIFO buffer * @param buf Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be * read from buf on success. From 1e202d89c95d99d69412854f4ee9d5e569c3da69 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 3 Sep 2022 23:41:38 +0200 Subject: [PATCH 148/590] avcodec/x86/flacdsp: fix bug in decorrelation Fixes #9297 --- libavcodec/x86/flacdsp.asm | 23 +++++++++++++++----- libavcodec/x86/flacdsp_init.c | 41 ++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/libavcodec/x86/flacdsp.asm b/libavcodec/x86/flacdsp.asm index 7138611526..6d755f4972 100644 --- a/libavcodec/x86/flacdsp.asm +++ b/libavcodec/x86/flacdsp.asm @@ -23,6 +23,10 @@ %include "libavutil/x86/x86util.asm" +SECTION_RODATA + +vector: db 0,1,4,5,8,9,12,13,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,4,5,8,9,12,13, + SECTION .text %macro PMACSDQL 5 @@ -89,6 +93,9 @@ LPC_32 sse4 ;---------------------------------------------------------------------------------- %macro FLAC_DECORRELATE_16 3-4 cglobal flac_decorrelate_%1_16, 2, 4, 4, out, in0, in1, len +%ifidn %1, indep2 + VBROADCASTI128 m2, [vector] +%endif %if ARCH_X86_32 mov lend, lenm %endif @@ -112,11 +119,17 @@ align 16 %endif %ifnidn %1, indep2 p%4d m2, m0, m1 + packssdw m%2, m%2 + packssdw m%3, m%3 + punpcklwd m%2, m%3 + psllw m%2, m3 +%else + pslld m%2, m3 + pslld m%3, m3 + pshufb m%2, m%2, m2 + pshufb m%3, m%3, m2 + punpcklwd m%2, m%3 %endif - packssdw m%2, m%2 - packssdw m%3, m%3 - punpcklwd m%2, m%3 - psllw m%2, m3 mova [outq + lenq], m%2 add lenq, 16 jl .loop @@ -292,7 +305,7 @@ align 16 REP_RET %endmacro -INIT_XMM sse2 +INIT_XMM ssse3 FLAC_DECORRELATE_16 indep2, 0, 1 ; Reuse stereo 16bits macro FLAC_DECORRELATE_INDEP 32, 2, 3, d FLAC_DECORRELATE_INDEP 16, 4, 3, w diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c index 2deaf3117f..48e3e7c55c 100644 --- a/libavcodec/x86/flacdsp_init.c +++ b/libavcodec/x86/flacdsp_init.c @@ -34,7 +34,9 @@ void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int chann void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ int len, int shift); \ void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ - int len, int shift); \ + int len, int shift); + +#define DECORRELATE_IFUNCS(fmt, opt) \ void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ int len, int shift); \ void ff_flac_decorrelate_indep4_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ @@ -48,6 +50,10 @@ DECORRELATE_FUNCS(16, sse2); DECORRELATE_FUNCS(16, avx); DECORRELATE_FUNCS(32, sse2); DECORRELATE_FUNCS(32, avx); +DECORRELATE_IFUNCS(16, ssse3); +DECORRELATE_IFUNCS(16, avx); +DECORRELATE_IFUNCS(32, ssse3); +DECORRELATE_IFUNCS(32, avx); av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels) { @@ -55,30 +61,35 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_SSE2(cpu_flags)) { + if (fmt == AV_SAMPLE_FMT_S16) { + c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2; + c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2; + c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2; + } else if (fmt == AV_SAMPLE_FMT_S32) { + c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2; + c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2; + c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2; + } + } + if (EXTERNAL_SSSE3(cpu_flags)) { if (fmt == AV_SAMPLE_FMT_S16) { if (channels == 2) - c->decorrelate[0] = ff_flac_decorrelate_indep2_16_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3; else if (channels == 4) - c->decorrelate[0] = ff_flac_decorrelate_indep4_16_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3; else if (channels == 6) - c->decorrelate[0] = ff_flac_decorrelate_indep6_16_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3; else if (ARCH_X86_64 && channels == 8) - c->decorrelate[0] = ff_flac_decorrelate_indep8_16_sse2; - c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2; - c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2; - c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3; } else if (fmt == AV_SAMPLE_FMT_S32) { if (channels == 2) - c->decorrelate[0] = ff_flac_decorrelate_indep2_32_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3; else if (channels == 4) - c->decorrelate[0] = ff_flac_decorrelate_indep4_32_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3; else if (channels == 6) - c->decorrelate[0] = ff_flac_decorrelate_indep6_32_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3; else if (ARCH_X86_64 && channels == 8) - c->decorrelate[0] = ff_flac_decorrelate_indep8_32_sse2; - c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2; - c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2; - c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2; + c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3; } } if (EXTERNAL_SSE4(cpu_flags)) { From 2ed5925e26f77fc377cedcefb3864dc1a4712210 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 4 Sep 2022 20:50:16 +0200 Subject: [PATCH 149/590] avcodec/flac: smallest frame is 10 bytes Fixes #9270 --- libavcodec/flac.h | 2 +- libavcodec/flacdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/flac.h b/libavcodec/flac.h index f118dbbff3..00e631ed20 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -33,7 +33,7 @@ #define FLAC_MAX_CHANNELS 8 #define FLAC_MIN_BLOCKSIZE 16 #define FLAC_MAX_BLOCKSIZE 65535 -#define FLAC_MIN_FRAME_SIZE 11 +#define FLAC_MIN_FRAME_SIZE 10 enum { FLAC_CHMODE_INDEPENDENT = 0, diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 075d76bc8a..5b8547a98f 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -577,7 +577,7 @@ static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame, /* check that there is at least the smallest decodable amount of data. this amount corresponds to the smallest valid FLAC frame possible. - FF F8 69 02 00 00 9A 00 00 34 46 */ + FF F8 69 02 00 00 9A 00 00 34 */ if (buf_size < FLAC_MIN_FRAME_SIZE) return buf_size; From 6b1a7fc8bd473aa4e644a64335eb93044647f96d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 3 Sep 2022 16:39:46 +0200 Subject: [PATCH 150/590] avcodec/cfhd, cfhddata: Simplify check for escape cfhd.c checked for level being equal to a certain codebook- dependent constant and to run being two. The first check is actually redundant, as all codebooks contain only one (real) entry with run == 2 (as is usual with VLCs, this one real entry has several corresponding entries in the table). But given that no entry has a run of zero (except incomplete entries which just signal that one needs to do another round of parsing), one can actually use that as sentinel. This patch does so. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhd.c | 4 ++-- libavcodec/cfhddata.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 7afbbac59e..90b3d0a850 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -819,7 +819,7 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic, VLC_BITS, 3, 1); /* escape */ - if (level == 64 && run == 2) + if (!run) break; count += run; @@ -850,7 +850,7 @@ static int cfhd_decode(AVCodecContext *avctx, AVFrame *pic, VLC_BITS, 3, 1); /* escape */ - if (level == 255 && run == 2) + if (!run) break; count += run; diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 67bd8e66db..212dccadb9 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -72,7 +72,7 @@ static const uint16_t table_9_vlc_run[NB_VLC_TABLE_9] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, + 1, 0, }; static const uint8_t table_9_vlc_level[NB_VLC_TABLE_9] = { @@ -226,7 +226,7 @@ static const uint16_t table_18_vlc_run[NB_VLC_TABLE_18] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, + 1, 1, 1, 1, 1, 1, 1, 0, }; static const uint8_t table_18_vlc_level[NB_VLC_TABLE_18] = { From 764cacfdb60faba00cee057c347c2168ac006814 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 3 Sep 2022 04:39:16 +0200 Subject: [PATCH 151/590] avcodec/cfhddata: Avoid code tables cfhddata.c initializes a RL VLC table via code tables and corresponding tables for length, run and level. code and length tables are used to initialize a VLC, no symbol table is used. Afterwards the symbols of said VLC are just the indices of the corresponding entries in the code and length table that were used for initialization; they can therefore be used to get the matching level and run entry and they are not used for anything else. Therefore one can just permute these tables without changing the resulting RL VLC tables. This commit does just this. It permutes these tables so that the code tables are ordered from left to right in the resulting tree and then switches to ff_init_vlc_from_lengths(), which allows to remove the codes table altogether. Given that these tables are constructed on the stack, this also reduces stack usage, potentially fixing part of #9399. (The size of the tables on the stack decreases from 4752 to 2640.) Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhddata.c | 372 +++++++++++++----------------------------- 1 file changed, 111 insertions(+), 261 deletions(-) diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 212dccadb9..7c4b1454f3 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -27,248 +27,106 @@ #define NB_VLC_TABLE_9 (71 + 3) #define NB_VLC_TABLE_18 (263 + 1) -static const uint32_t table_9_vlc_bits[NB_VLC_TABLE_9] = { - 0, 0x2, 0xc, 0x1a, - 0x1d, 0x1e, 0x39, 0x3e, - 0x37, 0x7e, 0x6c, 0xe2, - 0xfe, 0xdb, 0xe0, 0x1c3, - 0x1c6, 0x1ff, 0x1fe, 0x1b5, - 0x369, 0x385, 0x71d, 0x6d0, - 0x708, 0x71f, 0xe3d, 0xe39, - 0xe13, 0xe12, 0x1c71, 0x1b45, - 0x1b47, 0x3689, 0x38f2, 0x38e1, - 0x38e0, 0x38f1, 0x3688, 0x6d1b, - 0x71e0, 0x6d19, 0x71e7, 0xe3cd, - 0xda35, 0xda30, 0xe3c3, 0x1b469, - 0x1b462, 0x1c798, 0x1b463, 0x1c799, - 0x38f08, 0x38f09, 0x38f0a, 0x6d1a0, - 0x6d1a3, 0x6d1a1, 0xda345, 0xda344, - 0xe3c2d, 0xe3c2f, 0xe3c2e, 0x38f0b2, - 0x71e160, 0x71e162, 0x71e166, 0x71e161, - 0xe3c2ce, 0xe3c2c6, 0xe3c2c7, 0x1C7859E, - 0x38F0B3F, 0x38F0B3E, +typedef struct CFHD_RL_ELEM { + uint16_t run; + uint8_t level; + uint8_t len; +} CFHD_RL_ELEM; + +static const CFHD_RL_ELEM table_9_vlc[NB_VLC_TABLE_9] = { + { 1, 0, 1 }, { 1, 1, 2 }, { 1, 2, 4 }, { 1, 3, 5 }, + { 1, 6, 7 }, { 1, 15, 11 }, { 1, 26, 14 }, { 1, 27, 14 }, + { 1, 23, 13 }, { 1, 36, 16 }, { 1, 40, 17 }, { 1, 41, 17 }, + { 1, 32, 15 }, { 1, 48, 19 }, { 1, 49, 19 }, { 1, 51, 20 }, + { 1, 52, 20 }, { 1, 50, 19 }, { 1, 42, 17 }, { 1, 37, 16 }, + { 1, 33, 15 }, { 1, 24, 13 }, { 1, 13, 10 }, { 1, 10, 9 }, + { 1, 8, 8 }, { 1, 5, 6 }, { 80, 0, 8 }, { 1, 16, 11 }, + { 1, 19, 12 }, { 1, 20, 12 }, { 1, 14, 10 }, { 120, 0, 9 }, + { 320, 0, 8 }, { 1, 11, 9 }, { 1, 28, 14 }, { 1, 29, 14 }, + { 1, 25, 13 }, { 1, 21, 12 }, { 1, 17, 11 }, { 1, 34, 15 }, + { 1, 45, 18 }, { 1, 46, 18 }, { 1, 47, 18 }, { 1, 57, 23 }, + { 1, 58, 23 }, { 1, 59, 23 }, { 1, 62, 24 }, { 1, 63, 24 }, + { 1, 56, 22 }, { 1, 60, 23 }, { 1, 61, 24 }, { 1, 64, 25 }, + { 0, 64, 26 }, { 1, 64, 26 }, { 1, 53, 20 }, { 1, 54, 20 }, + { 1, 55, 20 }, { 1, 38, 16 }, { 1, 30, 14 }, { 1, 31, 14 }, + { 1, 43, 17 }, { 1, 44, 17 }, { 1, 39, 16 }, { 1, 35, 15 }, + { 1, 22, 12 }, { 1, 18, 11 }, { 32, 0, 6 }, { 12, 0, 5 }, + { 1, 4, 5 }, { 160, 0, 6 }, { 1, 7, 7 }, { 1, 9, 8 }, + { 100, 0, 9 }, { 1, 12, 9 }, }; -static const uint8_t table_9_vlc_len[NB_VLC_TABLE_9] = { - 1, 2, 4, 5, 5, 5, 6, 6, - 6, 7, 7, 8, 8, 8, 8, 9, - 9, 9, 9, 9, 10, 10, 11, 11, - 11, 11, 12, 12, 12, 12, 13, 13, - 13, 14, 14, 14, 14, 14, 14, 15, - 15, 15, 15, 16, 16, 16, 16, 17, - 17, 17, 17, 17, 18, 18, 18, 19, - 19, 19, 20, 20, 20, 20, 20, 22, - 23, 23, 23, 23, 24, 24, 24, 25, - 26, 26, -}; - -static const uint16_t table_9_vlc_run[NB_VLC_TABLE_9] = { - 1, 1, 1, 1, 12, 1, 32, 160, - 1, 1, 1, 320, 1, 1, 80, 120, - 1, 1, 100, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, -}; - -static const uint8_t table_9_vlc_level[NB_VLC_TABLE_9] = { - 0, 1, 2, 3, 0, 4, 0, 0, - 5, 7, 6, 0, 9, 8, 0, 0, - 11, 12, 0, 10, 13, 14, 17, 15, - 16, 18, 22, 21, 20, 19, 25, 23, - 24, 27, 31, 29, 28, 30, 26, 33, - 34, 32, 35, 39, 37, 36, 38, 42, - 40, 43, 41, 44, 45, 46, 47, 48, - 50, 49, 52, 51, 53, 55, 54, 56, - 57, 59, 60, 58, 61, 62, 63, 64, - 64, 64, -}; - -static const uint32_t table_18_vlc_bits[NB_VLC_TABLE_18] = { - 0, 0x2, 0x7, 0x19, - 0x30, 0x36, 0x6f, 0x63, - 0x69, 0x6b, 0xd1, 0xd4, - 0xdc, 0x189, 0x18a, 0x1a0, - 0x1ab, 0x377, 0x310, 0x316, - 0x343, 0x354, 0x375, 0x623, - 0x684, 0x685, 0x6ab, 0x6ec, - 0xddb, 0xc5c, 0xc5e, 0xc44, - 0xd55, 0xdd1, 0xdd3, 0x1bb5, - 0x188b, 0x18bb, 0x18bf, 0x1aa8, - 0x1ba0, 0x1ba5, 0x1ba4, 0x3115, - 0x3175, 0x317d, 0x3553, 0x3768, - 0x6e87, 0x6ed3, 0x62e8, 0x62f8, - 0x6228, 0x6aa4, 0x6e85, 0xc453, - 0xc5d3, 0xc5f3, 0xdda4, 0xdd08, - 0xdd0c, 0x1bb4b, 0x1bb4a, 0x18ba5, - 0x18be5, 0x1aa95, 0x1aa97, 0x188a4, - 0x1ba13, 0x31748, 0x317c8, 0x35528, - 0x3552c, 0x37424, 0x37434, 0x37436, - 0x62294, 0x62e92, 0x62f92, 0x6aa52, - 0x6aa5a, 0x6e86a, 0x6e86e, 0x6e84a, - 0xc452a, 0xc5d27, 0xc5f26, 0xd54a6, - 0xd54b6, 0xdd096, 0xdd0d6, 0xdd0de, - 0x188a56, 0x18ba4d, 0x18be4e, 0x18be4f, - 0x1aa96e, 0x1ba12e, 0x1ba12f, 0x1ba1af, - 0x1ba1bf, 0x37435d, 0x37437d, 0x317498, - 0x35529c, 0x35529d, 0x3552de, 0x3552df, - 0x62e933, 0x62295d, 0x6aa53d, 0x6aa53f, - 0x6aa53e, 0x6e86b9, 0x6e86f8, 0xd54a79, - 0xc5d265, 0xc452b8, 0xdd0d71, 0xd54a78, - 0xdd0d70, 0xdd0df2, 0xdd0df3, 0x188a5f6, - 0x188a5f5, 0x188a5f4, 0x188a5f3, 0x188a5f2, - 0x188a5f1, 0x188a5f0, 0x188a5ef, 0x188a5ee, - 0x188a5ed, 0x188a5aa, 0x188a5e3, 0x188a5df, - 0x188a589, 0x188a5dd, 0x188a578, 0x188a5e0, - 0x188a588, 0x188a5d6, 0x188a5db, 0x188a5e1, - 0x188a587, 0x188a59a, 0x188a5c4, 0x188a5ec, - 0x188a586, 0x188a573, 0x188a59c, 0x188a5c8, - 0x188a5fb, 0x188a5a1, 0x188a5eb, 0x188a5a8, - 0x188a584, 0x188a5d2, 0x188a599, 0x188a598, - 0x188a583, 0x18ba4c9, 0x188a5d0, 0x188a594, - 0x188a582, 0x188a5cb, 0x188a5d8, 0x188a5e7, - 0x188a581, 0x188a5ea, 0x188a5a9, 0x188a5a6, - 0x188a580, 0x188a5a0, 0x188a59d, 0x188a5c3, - 0x188a57f, 0x188a5c0, 0x188a5de, 0x188a5d4, - 0x188a57e, 0x188a5c2, 0x188a592, 0x188a5cd, - 0x188a57d, 0x188a5a3, 0x188a5e8, 0x188a5a2, - 0x188a57c, 0x188a58e, 0x188a5b3, 0x188a5b2, - 0x188a5b1, 0x188a5b0, 0x188a5af, 0x188a5ae, - 0x188a5ad, 0x188a5ac, 0x188a5ab, 0x188a5da, - 0x188a5e4, 0x188a5e5, 0x188a5d9, 0x188a5b5, - 0x188a5bc, 0x188a5bd, 0x188a5e9, 0x188a5cc, - 0x188a585, 0x188a5d3, 0x188a5e2, 0x188a595, - 0x188a596, 0x188a5b8, 0x188a590, 0x188a5c9, - 0x188a5a4, 0x188a5e6, 0x188a5a5, 0x188a5ce, - 0x188a5bf, 0x188a572, 0x188a59b, 0x188a5be, - 0x188a5c7, 0x188a5ca, 0x188a5d5, 0x188a57b, - 0x188a58d, 0x188a58c, 0x188a58b, 0x188a58a, - 0x18ba4c8, 0x188a5c5, 0x188a5fa, 0x188a5bb, - 0x188a5c1, 0x188a5cf, 0x188a5b9, 0x188a5b6, - 0x188a597, 0x188a5fe, 0x188a5d7, 0x188a5ba, - 0x188a591, 0x188a5c6, 0x188a5dc, 0x188a57a, - 0x188a59f, 0x188a5f9, 0x188a5b4, 0x188a5a7, - 0x188a58f, 0x188a5fd, 0x188a5b7, 0x188a593, - 0x188a59e, 0x188a5f8, 0x188a5ff, 0x188a5fc, - 0x188a579, 0x188a5f7, 0x3114ba2, 0x3114ba3, -}; - -static const uint8_t table_18_vlc_len[NB_VLC_TABLE_18] = { - 1, 2, 3, 5, 6, 6, 7, 7, - 7, 7, 8, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 10, 10, 10, 11, - 11, 11, 11, 11, 12, 12, 12, 12, - 12, 12, 12, 13, 13, 13, 13, 13, - 13, 13, 13, 14, 14, 14, 14, 14, - 15, 15, 15, 15, 15, 15, 15, 16, - 16, 16, 16, 16, 16, 17, 17, 17, - 17, 17, 17, 17, 17, 18, 18, 18, - 18, 18, 18, 18, 19, 19, 19, 19, - 19, 19, 19, 19, 20, 20, 20, 20, - 20, 20, 20, 20, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 22, 22, 22, - 22, 22, 22, 22, 23, 23, 23, 23, - 23, 23, 23, 24, 24, 24, 24, 24, - 24, 24, 24, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 26, 26, -}; - -static const uint16_t table_18_vlc_run[NB_VLC_TABLE_18] = { - 1, 1, 1, 1, 1, 1, 1, 1, - 12, 1, 20, 1, 1, 1, 32, 1, - 1, 1, 1, 1, 60, 1, 1, 1, - 1, 100, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 180, 1, - 1, 320, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, -}; - -static const uint8_t table_18_vlc_level[NB_VLC_TABLE_18] = { - 0, 1, 2, 3, 4, 5, 8, 6, - 0, 7, 0, 9, 10, 11, 0, 12, - 13, 18, 14, 15, 0, 16, 17, 19, - 20, 0, 21, 22, 29, 24, 25, 23, - 26, 27, 28, 35, 30, 31, 0, 32, - 33, 0, 34, 36, 37, 38, 39, 40, - 46, 47, 42, 43, 41, 44, 45, 48, - 49, 50, 53, 51, 52, 61, 60, 55, - 56, 57, 58, 54, 59, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, - 73, 75, 76, 74, 77, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 99, 100, 94, - 95, 96, 97, 98, 102, 101, 103, 105, - 104, 106, 107, 111, 109, 108, 113, 110, - 112, 114, 115, 225, 189, 188, 203, 202, - 197, 207, 169, 223, 159, 235, 152, 192, - 179, 201, 172, 149, 178, 120, 219, 150, - 127, 211, 125, 158, 247, 238, 163, 228, - 183, 217, 168, 122, 128, 249, 187, 186, - 136, 181, 255, 230, 135, 233, 222, 145, - 134, 167, 248, 209, 243, 216, 164, 140, - 157, 239, 191, 251, 156, 139, 242, 133, - 162, 213, 165, 212, 227, 198, 236, 234, - 117, 215, 124, 123, 254, 253, 148, 218, - 146, 147, 224, 143, 184, 185, 166, 132, - 129, 250, 151, 119, 193, 176, 245, 229, - 206, 144, 208, 137, 241, 237, 190, 240, - 131, 232, 252, 171, 205, 204, 118, 214, - 180, 126, 182, 175, 141, 138, 177, 153, - 194, 160, 121, 174, 246, 130, 200, 170, - 221, 196, 142, 210, 199, 155, 154, 244, - 220, 195, 161, 231, 173, 226, 116, 255, +static const CFHD_RL_ELEM table_18_vlc[NB_VLC_TABLE_18] = { + { 1, 0, 1 }, { 1, 1, 2 }, { 1, 4, 6 }, { 1, 14, 10 }, + { 1, 23, 12 }, { 1, 41, 15 }, { 1, 54, 17 }, { 1, 69, 19 }, + { 1, 77, 20 }, { 1, 85, 21 }, { 1, 108, 24 }, { 1, 237, 25 }, + { 1, 238, 25 }, { 1, 101, 23 }, { 1, 172, 25 }, { 1, 173, 25 }, + { 1, 170, 25 }, { 1, 171, 25 }, { 1, 227, 25 }, { 1, 162, 25 }, + { 1, 156, 25 }, { 1, 157, 25 }, { 1, 243, 25 }, { 1, 134, 25 }, + { 1, 135, 25 }, { 1, 136, 25 }, { 1, 128, 25 }, { 1, 129, 25 }, + { 1, 247, 25 }, { 1, 127, 25 }, { 1, 178, 25 }, { 1, 179, 25 }, + { 1, 214, 25 }, { 1, 118, 25 }, { 1, 204, 25 }, { 1, 205, 25 }, + { 1, 198, 25 }, { 1, 199, 25 }, { 1, 245, 25 }, { 1, 246, 25 }, + { 1, 242, 25 }, { 1, 244, 25 }, { 1, 230, 25 }, { 1, 119, 25 }, + { 1, 193, 25 }, { 1, 194, 25 }, { 1, 186, 25 }, { 1, 187, 25 }, + { 1, 211, 25 }, { 1, 190, 25 }, { 1, 163, 25 }, { 1, 164, 25 }, + { 1, 220, 25 }, { 1, 221, 25 }, { 1, 216, 25 }, { 1, 217, 25 }, + { 1, 212, 25 }, { 1, 213, 25 }, { 1, 206, 25 }, { 1, 208, 25 }, + { 1, 209, 25 }, { 1, 210, 25 }, { 1, 122, 25 }, { 1, 248, 25 }, + { 1, 235, 25 }, { 1, 148, 25 }, { 1, 253, 25 }, { 1, 254, 25 }, + { 1, 123, 25 }, { 1, 124, 25 }, { 1, 215, 25 }, { 1, 117, 25 }, + { 1, 234, 25 }, { 1, 236, 25 }, { 1, 142, 25 }, { 1, 143, 25 }, + { 1, 153, 25 }, { 1, 154, 25 }, { 1, 176, 25 }, { 1, 177, 25 }, + { 1, 174, 25 }, { 1, 175, 25 }, { 1, 184, 25 }, { 1, 185, 25 }, + { 1, 240, 25 }, { 1, 241, 25 }, { 1, 239, 25 }, { 1, 141, 25 }, + { 1, 139, 25 }, { 1, 140, 25 }, { 1, 125, 25 }, { 1, 126, 25 }, + { 1, 130, 25 }, { 1, 131, 25 }, { 1, 228, 25 }, { 1, 229, 25 }, + { 1, 232, 25 }, { 1, 233, 25 }, { 1, 132, 25 }, { 1, 133, 25 }, + { 1, 137, 25 }, { 1, 138, 25 }, { 1, 255, 25 }, { 1, 116, 26 }, + { 0, 255, 26 }, { 1, 249, 25 }, { 1, 250, 25 }, { 1, 251, 25 }, + { 1, 252, 25 }, { 1, 120, 25 }, { 1, 121, 25 }, { 1, 222, 25 }, + { 1, 224, 25 }, { 1, 218, 25 }, { 1, 219, 25 }, { 1, 200, 25 }, + { 1, 201, 25 }, { 1, 191, 25 }, { 1, 192, 25 }, { 1, 149, 25 }, + { 1, 150, 25 }, { 1, 151, 25 }, { 1, 152, 25 }, { 1, 146, 25 }, + { 1, 147, 25 }, { 1, 144, 25 }, { 1, 145, 25 }, { 1, 165, 25 }, + { 1, 166, 25 }, { 1, 167, 25 }, { 1, 168, 25 }, { 1, 158, 25 }, + { 1, 159, 25 }, { 1, 223, 25 }, { 1, 169, 25 }, { 1, 207, 25 }, + { 1, 197, 25 }, { 1, 202, 25 }, { 1, 203, 25 }, { 1, 188, 25 }, + { 1, 189, 25 }, { 1, 225, 25 }, { 1, 226, 25 }, { 1, 195, 25 }, + { 1, 196, 25 }, { 1, 182, 25 }, { 1, 183, 25 }, { 1, 231, 25 }, + { 1, 155, 25 }, { 1, 160, 25 }, { 1, 161, 25 }, { 1, 48, 16 }, + { 1, 36, 14 }, { 1, 30, 13 }, { 1, 19, 11 }, { 1, 11, 9 }, + { 32, 0, 9 }, { 1, 15, 10 }, { 1, 24, 12 }, { 1, 42, 15 }, + { 1, 62, 18 }, { 1, 70, 19 }, { 1, 94, 22 }, { 1, 180, 25 }, + { 1, 181, 25 }, { 1, 109, 24 }, { 1, 102, 23 }, { 1, 86, 21 }, + { 1, 78, 20 }, { 1, 55, 17 }, { 1, 49, 16 }, { 1, 37, 14 }, + { 1, 31, 13 }, { 1, 25, 12 }, { 1, 43, 15 }, { 1, 63, 18 }, + { 1, 71, 19 }, { 1, 79, 20 }, { 1, 87, 21 }, { 1, 88, 21 }, + { 1, 56, 17 }, { 1, 50, 16 }, { 1, 38, 14 }, { 180, 0, 13 }, + { 1, 6, 7 }, { 1, 3, 5 }, { 1, 12, 9 }, { 1, 20, 11 }, + { 100, 0, 11 }, { 60, 0, 10 }, { 20, 0, 8 }, { 12, 0, 7 }, + { 1, 9, 8 }, { 1, 16, 10 }, { 1, 32, 13 }, { 1, 44, 15 }, + { 1, 64, 18 }, { 1, 72, 19 }, { 1, 80, 20 }, { 1, 95, 22 }, + { 1, 96, 22 }, { 1, 110, 24 }, { 1, 111, 24 }, { 1, 103, 23 }, + { 1, 104, 23 }, { 1, 105, 23 }, { 1, 57, 17 }, { 1, 65, 18 }, + { 1, 73, 19 }, { 1, 81, 20 }, { 1, 89, 21 }, { 1, 97, 22 }, + { 1, 98, 22 }, { 1, 58, 17 }, { 1, 39, 14 }, { 1, 26, 12 }, + { 1, 21, 11 }, { 1, 13, 9 }, { 1, 7, 7 }, { 1, 5, 6 }, + { 1, 10, 8 }, { 1, 33, 13 }, { 1, 51, 16 }, { 1, 66, 18 }, + { 1, 74, 19 }, { 1, 82, 20 }, { 1, 90, 21 }, { 1, 91, 21 }, + { 1, 59, 17 }, { 1, 45, 15 }, { 1, 52, 16 }, { 1, 67, 18 }, + { 1, 75, 19 }, { 1, 83, 20 }, { 1, 112, 24 }, { 1, 113, 24 }, + { 1, 106, 23 }, { 1, 99, 22 }, { 1, 92, 21 }, { 1, 68, 18 }, + { 1, 76, 19 }, { 1, 84, 20 }, { 1, 107, 23 }, { 1, 114, 24 }, + { 1, 115, 24 }, { 1, 100, 22 }, { 1, 93, 21 }, { 1, 46, 15 }, + { 1, 27, 12 }, { 1, 34, 13 }, { 320, 0, 13 }, { 1, 28, 12 }, + { 1, 17, 10 }, { 1, 22, 11 }, { 1, 40, 14 }, { 1, 53, 16 }, + { 1, 60, 17 }, { 1, 61, 17 }, { 1, 47, 15 }, { 1, 35, 13 }, + { 1, 29, 12 }, { 1, 18, 10 }, { 1, 8, 7 }, { 1, 2, 3 }, }; av_cold int ff_cfhd_init_vlcs(CFHDContext *s) { int i, j, ret = 0; - uint32_t new_cfhd_vlc_bits[NB_VLC_TABLE_18 * 2]; uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2]; uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2]; int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2]; @@ -277,26 +135,22 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) /* Table 9 */ for (i = 0, j = 0; i < NB_VLC_TABLE_9; i++, j++) { - new_cfhd_vlc_bits[j] = table_9_vlc_bits[i]; - new_cfhd_vlc_len[j] = table_9_vlc_len[i]; - new_cfhd_vlc_run[j] = table_9_vlc_run[i]; - new_cfhd_vlc_level[j] = table_9_vlc_level[i]; + new_cfhd_vlc_len[j] = table_9_vlc[i].len; + new_cfhd_vlc_run[j] = table_9_vlc[i].run; + new_cfhd_vlc_level[j] = table_9_vlc[i].level; /* Don't include the zero level nor escape bits */ - if (table_9_vlc_level[i] && - new_cfhd_vlc_bits[j] != table_9_vlc_bits[NB_VLC_TABLE_9-1]) { - new_cfhd_vlc_bits[j] <<= 1; + if (table_9_vlc[i].level && table_9_vlc[i].run) { new_cfhd_vlc_len[j]++; j++; - new_cfhd_vlc_bits[j] = (table_9_vlc_bits[i] << 1) | 1; - new_cfhd_vlc_len[j] = table_9_vlc_len[i] + 1; - new_cfhd_vlc_run[j] = table_9_vlc_run[i]; - new_cfhd_vlc_level[j] = -table_9_vlc_level[i]; + new_cfhd_vlc_len[j] = table_9_vlc[i].len + 1; + new_cfhd_vlc_run[j] = table_9_vlc[i].run; + new_cfhd_vlc_level[j] = -table_9_vlc[i].level; } } - ret = init_vlc(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len, - 1, 1, new_cfhd_vlc_bits, 4, 4, 0); + ret = ff_init_vlc_from_lengths(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len, + 1, NULL, 0, 0, 0, 0, s->avctx); if (ret < 0) return ret; for (i = 0; i < s->vlc_9.table_size; i++) { @@ -318,26 +172,22 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) /* Table 18 */ for (i = 0, j = 0; i < NB_VLC_TABLE_18; i++, j++) { - new_cfhd_vlc_bits[j] = table_18_vlc_bits[i]; - new_cfhd_vlc_len[j] = table_18_vlc_len[i]; - new_cfhd_vlc_run[j] = table_18_vlc_run[i]; - new_cfhd_vlc_level[j] = table_18_vlc_level[i]; + new_cfhd_vlc_len[j] = table_18_vlc[i].len; + new_cfhd_vlc_run[j] = table_18_vlc[i].run; + new_cfhd_vlc_level[j] = table_18_vlc[i].level; /* Don't include the zero level nor escape bits */ - if (table_18_vlc_level[i] && - new_cfhd_vlc_bits[j] != table_18_vlc_bits[NB_VLC_TABLE_18-1]) { - new_cfhd_vlc_bits[j] <<= 1; + if (table_18_vlc[i].level && table_18_vlc[i].run) { new_cfhd_vlc_len[j]++; j++; - new_cfhd_vlc_bits[j] = (table_18_vlc_bits[i] << 1) | 1; - new_cfhd_vlc_len[j] = table_18_vlc_len[i] + 1; - new_cfhd_vlc_run[j] = table_18_vlc_run[i]; - new_cfhd_vlc_level[j] = -table_18_vlc_level[i]; + new_cfhd_vlc_len[j] = table_18_vlc[i].len + 1; + new_cfhd_vlc_run[j] = table_18_vlc[i].run; + new_cfhd_vlc_level[j] = -table_18_vlc[i].level; } } - ret = init_vlc(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len, - 1, 1, new_cfhd_vlc_bits, 4, 4, 0); + ret = ff_init_vlc_from_lengths(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len, + 1, NULL, 0, 0, 0, 0, s->avctx); if (ret < 0) return ret; av_assert0(s->vlc_18.table_size == 4572); From 320c36d9c77cfeb9d9ec4cb856400546aba45eba Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 3 Sep 2022 17:56:48 +0200 Subject: [PATCH 152/590] avcodec/cfhddata: Avoid code duplication when creating codebooks Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhddata.c | 94 ++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 55 deletions(-) diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 7c4b1454f3..017eb9375c 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -124,38 +124,42 @@ static const CFHD_RL_ELEM table_18_vlc[NB_VLC_TABLE_18] = { { 1, 29, 12 }, { 1, 18, 10 }, { 1, 8, 7 }, { 1, 2, 3 }, }; -av_cold int ff_cfhd_init_vlcs(CFHDContext *s) +static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, + const CFHD_RL_ELEM table_vlc[], unsigned table_size, + VLC *vlc, void *logctx) { - int i, j, ret = 0; uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2]; uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2]; int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2]; + unsigned j; + int ret; /** Similar to dv.c, generate signed VLC tables **/ - /* Table 9 */ - for (i = 0, j = 0; i < NB_VLC_TABLE_9; i++, j++) { - new_cfhd_vlc_len[j] = table_9_vlc[i].len; - new_cfhd_vlc_run[j] = table_9_vlc[i].run; - new_cfhd_vlc_level[j] = table_9_vlc[i].level; + for (unsigned i = j = 0; i < table_size; i++, j++) { + new_cfhd_vlc_len[j] = table_vlc[i].len; + new_cfhd_vlc_run[j] = table_vlc[i].run; + new_cfhd_vlc_level[j] = table_vlc[i].level; /* Don't include the zero level nor escape bits */ - if (table_9_vlc[i].level && table_9_vlc[i].run) { + if (table_vlc[i].level && table_vlc[i].run) { new_cfhd_vlc_len[j]++; j++; - new_cfhd_vlc_len[j] = table_9_vlc[i].len + 1; - new_cfhd_vlc_run[j] = table_9_vlc[i].run; - new_cfhd_vlc_level[j] = -table_9_vlc[i].level; + new_cfhd_vlc_len[j] = table_vlc[i].len + 1; + new_cfhd_vlc_run[j] = table_vlc[i].run; + new_cfhd_vlc_level[j] = -table_vlc[i].level; } } - ret = ff_init_vlc_from_lengths(&s->vlc_9, VLC_BITS, j, new_cfhd_vlc_len, - 1, NULL, 0, 0, 0, 0, s->avctx); + ret = ff_init_vlc_from_lengths(vlc, VLC_BITS, j, new_cfhd_vlc_len, + 1, NULL, 0, 0, 0, 0, logctx); if (ret < 0) return ret; - for (i = 0; i < s->vlc_9.table_size; i++) { - int code = s->vlc_9.table[i].sym; - int len = s->vlc_9.table[i].len; + av_assert0(vlc->table_size == out_size); + + for (unsigned i = 0; i < out_size; i++) { + int code = vlc->table[i].sym; + int len = vlc->table[i].len; int level, run; if (len < 0) { // more bits needed @@ -165,49 +169,29 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) run = new_cfhd_vlc_run[code]; level = new_cfhd_vlc_level[code]; } - s->table_9_rl_vlc[i].len = len; - s->table_9_rl_vlc[i].level = level; - s->table_9_rl_vlc[i].run = run; + out[i].len = len; + out[i].level = level; + out[i].run = run; } - /* Table 18 */ - for (i = 0, j = 0; i < NB_VLC_TABLE_18; i++, j++) { - new_cfhd_vlc_len[j] = table_18_vlc[i].len; - new_cfhd_vlc_run[j] = table_18_vlc[i].run; - new_cfhd_vlc_level[j] = table_18_vlc[i].level; + return 0; +} - /* Don't include the zero level nor escape bits */ - if (table_18_vlc[i].level && table_18_vlc[i].run) { - new_cfhd_vlc_len[j]++; - j++; - new_cfhd_vlc_len[j] = table_18_vlc[i].len + 1; - new_cfhd_vlc_run[j] = table_18_vlc[i].run; - new_cfhd_vlc_level[j] = -table_18_vlc[i].level; - } - } +av_cold int ff_cfhd_init_vlcs(CFHDContext *s) +{ + int ret; - ret = ff_init_vlc_from_lengths(&s->vlc_18, VLC_BITS, j, new_cfhd_vlc_len, - 1, NULL, 0, 0, 0, 0, s->avctx); + /* Table 9 */ + ret = cfhd_init_vlc(s->table_9_rl_vlc, FF_ARRAY_ELEMS(s->table_9_rl_vlc), + table_9_vlc, FF_ARRAY_ELEMS(table_9_vlc), + &s->vlc_9, s->avctx); if (ret < 0) return ret; - av_assert0(s->vlc_18.table_size == 4572); - - for (i = 0; i < s->vlc_18.table_size; i++) { - int code = s->vlc_18.table[i].sym; - int len = s->vlc_18.table[i].len; - int level, run; - - if (len < 0) { // more bits needed - run = 0; - level = code; - } else { - run = new_cfhd_vlc_run[code]; - level = new_cfhd_vlc_level[code]; - } - s->table_18_rl_vlc[i].len = len; - s->table_18_rl_vlc[i].level = level; - s->table_18_rl_vlc[i].run = run; - } - - return ret; + /* Table 18 */ + ret = cfhd_init_vlc(s->table_18_rl_vlc, FF_ARRAY_ELEMS(s->table_18_rl_vlc), + table_18_vlc, FF_ARRAY_ELEMS(table_18_vlc), + &s->vlc_18, s->avctx); + if (ret < 0) + return ret; + return 0; } From 9e9c99366a9606bbcdfc805b1631dac006df28b2 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 3 Sep 2022 18:02:17 +0200 Subject: [PATCH 153/590] avcodec/cfhd, cfhddata: Free VLC as soon as it is not needed The VLC is only used to initialize RL VLC. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhd.c | 3 --- libavcodec/cfhd.h | 4 ---- libavcodec/cfhddata.c | 17 ++++++++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index 90b3d0a850..c23eb069c6 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -1404,9 +1404,6 @@ static av_cold int cfhd_close(AVCodecContext *avctx) free_buffers(s); - ff_free_vlc(&s->vlc_9); - ff_free_vlc(&s->vlc_18); - return 0; } diff --git a/libavcodec/cfhd.h b/libavcodec/cfhd.h index 4c066da5fc..9b09c91262 100644 --- a/libavcodec/cfhd.h +++ b/libavcodec/cfhd.h @@ -26,7 +26,6 @@ #include "avcodec.h" #include "bytestream.h" #include "get_bits.h" -#include "vlc.h" #include "cfhddsp.h" enum CFHDParam { @@ -141,10 +140,7 @@ typedef struct CFHDContext { AVCodecContext *avctx; CFHD_RL_VLC_ELEM table_9_rl_vlc[2088]; - VLC vlc_9; - CFHD_RL_VLC_ELEM table_18_rl_vlc[4572]; - VLC vlc_18; int lut[2][256]; diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index 017eb9375c..efe932dc3b 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -23,6 +23,7 @@ #include "libavutil/attributes.h" #include "cfhd.h" +#include "vlc.h" #define NB_VLC_TABLE_9 (71 + 3) #define NB_VLC_TABLE_18 (263 + 1) @@ -126,11 +127,12 @@ static const CFHD_RL_ELEM table_18_vlc[NB_VLC_TABLE_18] = { static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, const CFHD_RL_ELEM table_vlc[], unsigned table_size, - VLC *vlc, void *logctx) + void *logctx) { uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2]; uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2]; int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2]; + VLC vlc; unsigned j; int ret; @@ -151,15 +153,15 @@ static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, } } - ret = ff_init_vlc_from_lengths(vlc, VLC_BITS, j, new_cfhd_vlc_len, + ret = ff_init_vlc_from_lengths(&vlc, VLC_BITS, j, new_cfhd_vlc_len, 1, NULL, 0, 0, 0, 0, logctx); if (ret < 0) return ret; - av_assert0(vlc->table_size == out_size); + av_assert0(vlc.table_size == out_size); for (unsigned i = 0; i < out_size; i++) { - int code = vlc->table[i].sym; - int len = vlc->table[i].len; + int code = vlc.table[i].sym; + int len = vlc.table[i].len; int level, run; if (len < 0) { // more bits needed @@ -173,6 +175,7 @@ static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, out[i].level = level; out[i].run = run; } + ff_free_vlc(&vlc); return 0; } @@ -184,13 +187,13 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) /* Table 9 */ ret = cfhd_init_vlc(s->table_9_rl_vlc, FF_ARRAY_ELEMS(s->table_9_rl_vlc), table_9_vlc, FF_ARRAY_ELEMS(table_9_vlc), - &s->vlc_9, s->avctx); + s->avctx); if (ret < 0) return ret; /* Table 18 */ ret = cfhd_init_vlc(s->table_18_rl_vlc, FF_ARRAY_ELEMS(s->table_18_rl_vlc), table_18_vlc, FF_ARRAY_ELEMS(table_18_vlc), - &s->vlc_18, s->avctx); + s->avctx); if (ret < 0) return ret; return 0; From e6d89d0efd9194198d9964e47bf428be222594ea Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 3 Sep 2022 20:09:18 +0200 Subject: [PATCH 154/590] avcodec/cfhddata: Reduce stack usage Creating CFHD RL VLC tables works by first extending the codes by the sign, followed by creating a VLC, followed by deriving the RL VLC from this VLC (which is then discarded). Extending the codes uses stack arrays. The tables used to initialize the VLC are already sorted from left-to-right in the tree. This means that the corresponding VLC entries are generally also ascending, but not always: Entries from subtables always follow the corresponding main table although it is possible for the right-most node to fit into the main table. This suggests that one can try to use the final destination buffer as scratch buffer for the tables with sign included. Unfortunately it works for neither of the tables if one uses the right-most part of the RL VLC buffer as scratch buffer; using the left-most part of the RL VLC buffer as scratch buffer might work if one traverses the VLC entries from end to start. But it works only for the little RL VLC (table 9), not for table 18. Therefore this patch uses the RL VLC buffer for table 9 as scratch buffer for creating the bigger table 18. Afterwards the left part of the buffer for table 9 is used as scratch buffer to create table 9. This fixes the cfhd part of ticket #9399 (if it is not already fixed). Notice that I do not consider the previous stack usage excessive. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/cfhddata.c | 47 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/libavcodec/cfhddata.c b/libavcodec/cfhddata.c index efe932dc3b..fd5cc8174e 100644 --- a/libavcodec/cfhddata.c +++ b/libavcodec/cfhddata.c @@ -127,11 +127,8 @@ static const CFHD_RL_ELEM table_18_vlc[NB_VLC_TABLE_18] = { static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, const CFHD_RL_ELEM table_vlc[], unsigned table_size, - void *logctx) + CFHD_RL_VLC_ELEM tmp[], void *logctx) { - uint8_t new_cfhd_vlc_len[NB_VLC_TABLE_18 * 2]; - uint16_t new_cfhd_vlc_run[NB_VLC_TABLE_18 * 2]; - int16_t new_cfhd_vlc_level[NB_VLC_TABLE_18 * 2]; VLC vlc; unsigned j; int ret; @@ -139,27 +136,28 @@ static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, /** Similar to dv.c, generate signed VLC tables **/ for (unsigned i = j = 0; i < table_size; i++, j++) { - new_cfhd_vlc_len[j] = table_vlc[i].len; - new_cfhd_vlc_run[j] = table_vlc[i].run; - new_cfhd_vlc_level[j] = table_vlc[i].level; + tmp[j].len = table_vlc[i].len; + tmp[j].run = table_vlc[i].run; + tmp[j].level = table_vlc[i].level; /* Don't include the zero level nor escape bits */ if (table_vlc[i].level && table_vlc[i].run) { - new_cfhd_vlc_len[j]++; + tmp[j].len++; j++; - new_cfhd_vlc_len[j] = table_vlc[i].len + 1; - new_cfhd_vlc_run[j] = table_vlc[i].run; - new_cfhd_vlc_level[j] = -table_vlc[i].level; + tmp[j].len = table_vlc[i].len + 1; + tmp[j].run = table_vlc[i].run; + tmp[j].level = -table_vlc[i].level; } } - ret = ff_init_vlc_from_lengths(&vlc, VLC_BITS, j, new_cfhd_vlc_len, - 1, NULL, 0, 0, 0, 0, logctx); + ret = ff_init_vlc_from_lengths(&vlc, VLC_BITS, j, + &tmp[0].len, sizeof(tmp[0]), + NULL, 0, 0, 0, 0, logctx); if (ret < 0) return ret; av_assert0(vlc.table_size == out_size); - for (unsigned i = 0; i < out_size; i++) { + for (unsigned i = out_size; i-- > 0;) { int code = vlc.table[i].sym; int len = vlc.table[i].len; int level, run; @@ -168,8 +166,8 @@ static av_cold int cfhd_init_vlc(CFHD_RL_VLC_ELEM out[], unsigned out_size, run = 0; level = code; } else { - run = new_cfhd_vlc_run[code]; - level = new_cfhd_vlc_level[code]; + run = tmp[code].run; + level = tmp[code].level; } out[i].len = len; out[i].level = level; @@ -184,16 +182,17 @@ av_cold int ff_cfhd_init_vlcs(CFHDContext *s) { int ret; - /* Table 9 */ - ret = cfhd_init_vlc(s->table_9_rl_vlc, FF_ARRAY_ELEMS(s->table_9_rl_vlc), - table_9_vlc, FF_ARRAY_ELEMS(table_9_vlc), - s->avctx); - if (ret < 0) - return ret; - /* Table 18 */ + /* Table 18 - we reuse the unused table_9_rl_vlc as scratch buffer here */ ret = cfhd_init_vlc(s->table_18_rl_vlc, FF_ARRAY_ELEMS(s->table_18_rl_vlc), table_18_vlc, FF_ARRAY_ELEMS(table_18_vlc), - s->avctx); + s->table_9_rl_vlc, s->avctx); + if (ret < 0) + return ret; + /* Table 9 - table_9_rl_vlc itself is used as scratch buffer; it works + * because we are counting down in the final loop */ + ret = cfhd_init_vlc(s->table_9_rl_vlc, FF_ARRAY_ELEMS(s->table_9_rl_vlc), + table_9_vlc, FF_ARRAY_ELEMS(table_9_vlc), + s->table_9_rl_vlc, s->avctx); if (ret < 0) return ret; return 0; From 5c16df1b92c519238e10664eeab3adb3b9016edd Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 1 Sep 2022 14:42:00 +0200 Subject: [PATCH 155/590] fftools/ffprobe: Report initial and trailing padding Signed-off-by: Andreas Rheinhardt --- doc/ffprobe.xsd | 1 + fftools/ffprobe.c | 2 ++ tests/ref/fate/concat-demuxer-extended-lavf-mxf | 2 +- tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 | 2 +- tests/ref/fate/concat-demuxer-simple1-lavf-mxf | 2 +- tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 | 2 +- tests/ref/fate/concat-demuxer-simple2-lavf-ts | 2 +- tests/ref/fate/ffprobe_compact | 2 +- tests/ref/fate/ffprobe_csv | 2 +- tests/ref/fate/ffprobe_default | 1 + tests/ref/fate/ffprobe_flat | 1 + tests/ref/fate/ffprobe_ini | 1 + tests/ref/fate/ffprobe_json | 1 + tests/ref/fate/ffprobe_xml | 2 +- tests/ref/fate/flv-demux | 2 +- tests/ref/fate/gapless-mp3-side-data | 2 +- tests/ref/fate/mxf-probe-applehdr10 | 2 ++ tests/ref/fate/mxf-probe-d10 | 1 + tests/ref/fate/mxf-probe-dv25 | 2 ++ tests/ref/fate/oggopus-demux | 2 +- tests/ref/fate/ts-demux | 4 ++-- tests/ref/fate/ts-opus-demux | 2 +- 22 files changed, 26 insertions(+), 14 deletions(-) diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd index 6e678a9970..0920380108 100644 --- a/doc/ffprobe.xsd +++ b/doc/ffprobe.xsd @@ -246,6 +246,7 @@ + diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 3344a06409..8ee1b1036c 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3044,6 +3044,8 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id } print_int("bits_per_sample", av_get_bits_per_sample(par->codec_id)); + + print_int("initial_padding", par->initial_padding); break; case AVMEDIA_TYPE_SUBTITLE: diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf b/tests/ref/fate/concat-demuxer-extended-lavf-mxf index 543c7d6a8c..3d448ca0cc 100644 --- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf +++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf @@ -1 +1 @@ -d367d7f6df7292cbf454c6d07fca9b04 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe +05a65d350a18869abeac626ff49c1f4a *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 index 57b22848b9..bd24104bd5 100644 --- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 +++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 @@ -1 +1 @@ -1fac6962d4c5f1070d0d2db5ab7d86aa *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe +8c222118f9d0e41581a5bec66e20fbe8 *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf index dcc98e9bdb..fbe553d6de 100644 --- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf +++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf @@ -100,4 +100,4 @@ video|0|33|1.320000|33|1.320000|1|0.040000|12362|195072|__|1|Strings Metadata audio|1|65280|1.360000|65280|1.360000|1920|0.040000|3840|207872|K_|1|Strings Metadata video|0|37|1.480000|34|1.360000|1|0.040000|24786|212480|K_|1|Strings Metadata 0|mpeg2video|4|video|[0][0][0][0]|0x0000|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001|CPB properties|0|0|0|49152|-1 -1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001 +1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|1|unknown|16|0|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001 diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 index 8937724ed1..3127ca7fbc 100644 --- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 +++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 @@ -69,4 +69,4 @@ audio|1|63360|1.320000|63360|1.320000|1920|0.040000|7680|1861632|K_|1|Strings Me video|0|34|1.360000|34|1.360000|1|0.040000|150000|1924096|K_|1|Strings Metadata audio|1|65280|1.360000|65280|1.360000|1920|0.040000|7680|2074624|K_|1|Strings Metadata 0|mpeg2video|0|video|[0][0][0][0]|0x0000|720|608|0|0|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|tb|1|N/A|25/1|25/1|1/25|0|0.000000|N/A|N/A|30000000|N/A|N/A|N/A|N/A|35|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001|CPB properties|30000000|0|0|1212416|-1 -1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001 +1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|2|unknown|16|0|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001 diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts index 9603ca21d0..92e6829425 100644 --- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts +++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts @@ -211,5 +211,5 @@ video|1|171982|1.910911|168382|1.870911|3600|0.040000|17440|206988|__|MPEGTS Str video|1|175582|1.950911|171982|1.910911|3600|0.040000|15019|224848|__|MPEGTS Stream ID|224 -0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 0 +0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 0 1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 1|CPB properties|0|0|0|49152|-1 diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact index 5374bfca03..8286f5d973 100644 --- a/tests/ref/fate/ffprobe_compact +++ b/tests/ref/fate/ffprobe_compact @@ -26,7 +26,7 @@ packet|codec_type=video|stream_index=1|pts=6144|pts_time=0.120000|dts=6144|dts_t frame|media_type=video|stream_index=1|key_frame=1|pts=6144|pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|best_effort_timestamp=6144|best_effort_timestamp_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|duration=2048|duration_time=0.040000|pkt_pos=793142|pkt_size=230400|width=320|height=240|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified packet|codec_type=video|stream_index=2|pts=6144|pts_time=0.120000|dts=6144|dts_time=0.120000|duration=2048|duration_time=0.040000|size=30000|pos=1023566|flags=K_ frame|media_type=video|stream_index=2|key_frame=1|pts=6144|pts_time=0.120000|pkt_dts=6144|pkt_dts_time=0.120000|best_effort_timestamp=6144|best_effort_timestamp_time=0.120000|pkt_duration=2048|pkt_duration_time=0.040000|duration=2048|duration_time=0.040000|pkt_pos=1023566|pkt_size=30000|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified -stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layout=unknown|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=705600|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:E=mc²|tag:encoder=Lavc pcm_s16le +stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layout=unknown|bits_per_sample=16|initial_padding=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=705600|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:E=mc²|tag:encoder=Lavc pcm_s16le stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|coded_width=320|coded_height=240|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=1|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:title=foobar|tag:duration_ts=field-and-tags-conflict-attempt|tag:encoder=Lavc rawvideo stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|coded_width=100|coded_height=100|closed_captions=0|film_grain=0|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:encoder=Lavc rawvideo format|filename=tests/data/ffprobe-test.nut|nb_streams=3|nb_programs=0|format_name=nut|start_time=0.000000|duration=0.120000|size=1053646|bit_rate=70243066|probe_score=100|tag:title=ffprobe test file|tag:comment='A comment with CSV, XML & JSON special chars': |tag:comment2=I ♥ Üñîçød€ diff --git a/tests/ref/fate/ffprobe_csv b/tests/ref/fate/ffprobe_csv index 7af4db7bc0..d8aa2f9343 100644 --- a/tests/ref/fate/ffprobe_csv +++ b/tests/ref/fate/ffprobe_csv @@ -26,7 +26,7 @@ packet,video,1,6144,0.120000,6144,0.120000,2048,0.040000,230400,793142,K_ frame,video,1,1,6144,0.120000,6144,0.120000,6144,0.120000,2048,0.040000,2048,0.040000,793142,230400,320,240,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified packet,video,2,6144,0.120000,6144,0.120000,2048,0.040000,30000,1023566,K_ frame,video,2,1,6144,0.120000,6144,0.120000,6144,0.120000,2048,0.040000,2048,0.040000,1023566,30000,100,100,rgb24,1:1,I,0,0,0,0,0,unknown,unknown,unknown,unknown,unspecified -stream,0,pcm_s16le,unknown,audio,PSD[16],0x10445350,s16,44100,1,unknown,16,N/A,0/0,0/0,1/44100,0,0.000000,N/A,N/A,705600,N/A,N/A,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,mc²,Lavc pcm_s16le +stream,0,pcm_s16le,unknown,audio,PSD[16],0x10445350,s16,44100,1,unknown,16,0,N/A,0/0,0/0,1/44100,0,0.000000,N/A,N/A,705600,N/A,N/A,N/A,6,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,mc²,Lavc pcm_s16le stream,1,rawvideo,unknown,video,RGB[24],0x18424752,320,240,320,240,0,0,0,1:1,4:3,rgb24,-99,unknown,unknown,unknown,unknown,unspecified,unknown,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,foobar,field-and-tags-conflict-attempt,Lavc rawvideo stream,2,rawvideo,unknown,video,RGB[24],0x18424752,100,100,100,100,0,0,0,1:1,1:1,rgb24,-99,unknown,unknown,unknown,unknown,unspecified,unknown,1,N/A,25/1,25/1,1/51200,0,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,Lavc rawvideo format,tests/data/ffprobe-test.nut,3,0,nut,0.000000,0.120000,1053646,70243066,100,ffprobe test file,"'A comment with CSV, XML & JSON special chars': ",I ♥ Üñîçød€ diff --git a/tests/ref/fate/ffprobe_default b/tests/ref/fate/ffprobe_default index f296fc0dc2..7f7b2702fe 100644 --- a/tests/ref/fate/ffprobe_default +++ b/tests/ref/fate/ffprobe_default @@ -574,6 +574,7 @@ sample_rate=44100 channels=1 channel_layout=unknown bits_per_sample=16 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 diff --git a/tests/ref/fate/ffprobe_flat b/tests/ref/fate/ffprobe_flat index 655c0fe836..c2f08f6658 100644 --- a/tests/ref/fate/ffprobe_flat +++ b/tests/ref/fate/ffprobe_flat @@ -517,6 +517,7 @@ streams.stream.0.sample_rate="44100" streams.stream.0.channels=1 streams.stream.0.channel_layout="unknown" streams.stream.0.bits_per_sample=16 +streams.stream.0.initial_padding=0 streams.stream.0.id="N/A" streams.stream.0.r_frame_rate="0/0" streams.stream.0.avg_frame_rate="0/0" diff --git a/tests/ref/fate/ffprobe_ini b/tests/ref/fate/ffprobe_ini index 58f508faa6..bf9efd880e 100644 --- a/tests/ref/fate/ffprobe_ini +++ b/tests/ref/fate/ffprobe_ini @@ -576,6 +576,7 @@ sample_rate=44100 channels=1 channel_layout=unknown bits_per_sample=16 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 diff --git a/tests/ref/fate/ffprobe_json b/tests/ref/fate/ffprobe_json index 2e8b39f126..eb63664cba 100644 --- a/tests/ref/fate/ffprobe_json +++ b/tests/ref/fate/ffprobe_json @@ -558,6 +558,7 @@ "sample_rate": "44100", "channels": 1, "bits_per_sample": 16, + "initial_padding": 0, "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/44100", diff --git a/tests/ref/fate/ffprobe_xml b/tests/ref/fate/ffprobe_xml index e5152655b9..707033f830 100644 --- a/tests/ref/fate/ffprobe_xml +++ b/tests/ref/fate/ffprobe_xml @@ -32,7 +32,7 @@ - + diff --git a/tests/ref/fate/flv-demux b/tests/ref/fate/flv-demux index a7c98d3d76..9282d934af 100644 --- a/tests/ref/fate/flv-demux +++ b/tests/ref/fate/flv-demux @@ -604,5 +604,5 @@ packet|codec_type=video|stream_index=0|pts=11645|pts_time=11.645000|dts=11645|dt packet|codec_type=audio|stream_index=1|pts=11656|pts_time=11.656000|dts=11656|dts_time=11.656000|duration=46|duration_time=0.046000|size=346|pos=510431|flags=K_|data_hash=CRC32:4e6b44cb packet|codec_type=video|stream_index=0|pts=11678|pts_time=11.678000|dts=11678|dts_time=11.678000|duration=33|duration_time=0.033000|size=1190|pos=510794|flags=__|data_hash=CRC32:a0206c90 stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|width=426|height=240|coded_width=426|coded_height=240|closed_captions=0|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=71:40|pix_fmt=yuv420p|level=21|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=30000/1001|avg_frame_rate=30/1|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=393929|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=351|extradata_size=39|extradata_hash=CRC32:07b85ca9|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 -stream|index=1|codec_name=aac|profile=1|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=22050|channels=2|channel_layout=stereo|bits_per_sample=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=67874|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=252|extradata_size=2|extradata_hash=CRC32:d039c029|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 +stream|index=1|codec_name=aac|profile=1|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=22050|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/1000|start_pts=0|start_time=0.000000|duration_ts=N/A|duration=N/A|bit_rate=67874|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=252|extradata_size=2|extradata_hash=CRC32:d039c029|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 format|filename=Enigma_Principles_of_Lust-part.flv|nb_streams=2|nb_programs=0|format_name=flv|start_time=0.000000|duration=210.209999|size=512000|bit_rate=19485|probe_score=100|tag:hasKeyframes=true|tag:hasMetadata=true|tag:datasize=11970544|tag:hasVideo=true|tag:canSeekToEnd=false|tag:lasttimestamp=210|tag:lastkeyframetimestamp=210|tag:audiosize=1791332|tag:hasAudio=true|tag:audiodelay=0|tag:videosize=10176110|tag:metadatadate=2011-02-27T11:00:33.125000Z|tag:metadatacreator=inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2|tag:hasCuePoints=false diff --git a/tests/ref/fate/gapless-mp3-side-data b/tests/ref/fate/gapless-mp3-side-data index 59907f8ca4..b290e66bd1 100644 --- a/tests/ref/fate/gapless-mp3-side-data +++ b/tests/ref/fate/gapless-mp3-side-data @@ -596,5 +596,5 @@ packet|codec_type=audio|stream_index=0|pts=218603520|pts_time=15.490612|dts=2186 |data_hash=CRC32:d5fb5f9c packet|codec_type=audio|stream_index=0|pts=218972160|pts_time=15.516735|dts=218972160|dts_time=15.516735|duration=368640|duration_time=0.026122|size=418|pos=249718|flags=K_|side_data|side_data_type=Skip Samples|skip_samples=0|discard_padding=1152|skip_reason=0|discard_reason=0 |data_hash=CRC32:3789f3cf -stream|index=0|codec_name=mp3|profile=unknown|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=44100|channels=2|channel_layout=stereo|bits_per_sample=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/14112000|start_pts=353600|start_time=0.025057|duration_ts=219340800|duration=15.542857|bit_rate=128000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=595|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:encoder=LAME3.93 +stream|index=0|codec_name=mp3|profile=unknown|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=44100|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/14112000|start_pts=353600|start_time=0.025057|duration_ts=219340800|duration=15.542857|bit_rate=128000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=595|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:encoder=LAME3.93 format|filename=gapless.mp3|nb_streams=1|nb_programs=0|format_name=mp3|start_time=0.025057|duration=15.542857|size=250264|bit_rate=128812|probe_score=51|tag:title=test diff --git a/tests/ref/fate/mxf-probe-applehdr10 b/tests/ref/fate/mxf-probe-applehdr10 index 90eefad6ad..a38f21b0be 100644 --- a/tests/ref/fate/mxf-probe-applehdr10 +++ b/tests/ref/fate/mxf-probe-applehdr10 @@ -86,6 +86,7 @@ sample_rate=48000 channels=1 channel_layout=unknown bits_per_sample=24 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 @@ -131,6 +132,7 @@ sample_rate=48000 channels=1 channel_layout=unknown bits_per_sample=24 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 diff --git a/tests/ref/fate/mxf-probe-d10 b/tests/ref/fate/mxf-probe-d10 index b2692c6513..308a77e10a 100644 --- a/tests/ref/fate/mxf-probe-d10 +++ b/tests/ref/fate/mxf-probe-d10 @@ -77,6 +77,7 @@ sample_rate=48000 channels=8 channel_layout=unknown bits_per_sample=16 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 diff --git a/tests/ref/fate/mxf-probe-dv25 b/tests/ref/fate/mxf-probe-dv25 index 67a510fc5c..8b12a17838 100644 --- a/tests/ref/fate/mxf-probe-dv25 +++ b/tests/ref/fate/mxf-probe-dv25 @@ -68,6 +68,7 @@ sample_rate=48000 channels=1 channel_layout=unknown bits_per_sample=16 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 @@ -113,6 +114,7 @@ sample_rate=48000 channels=1 channel_layout=unknown bits_per_sample=16 +initial_padding=0 id=N/A r_frame_rate=0/0 avg_frame_rate=0/0 diff --git a/tests/ref/fate/oggopus-demux b/tests/ref/fate/oggopus-demux index 7ea5dfe8a0..09de2bf23c 100644 --- a/tests/ref/fate/oggopus-demux +++ b/tests/ref/fate/oggopus-demux @@ -41,5 +41,5 @@ packet|codec_type=audio|stream_index=0|pts=36124|pts_time=0.752583|dts=36124|dts packet|codec_type=audio|stream_index=0|pts=37084|pts_time=0.772583|dts=37084|dts_time=0.772583|duration=960|duration_time=0.020000|size=217|pos=841|flags=K_|data_hash=CRC32:06797ece packet|codec_type=audio|stream_index=0|pts=38044|pts_time=0.792583|dts=38044|dts_time=0.792583|duration=356|duration_time=0.007417|size=359|pos=841|flags=K_|side_data|side_data_type=Skip Samples|skip_samples=0|discard_padding=604|skip_reason=0|discard_reason=0 |data_hash=CRC32:01ca3f8f -stream|index=0|codec_name=opus|profile=unknown|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/48000|start_pts=0|start_time=0.000000|duration_ts=38756|duration=0.807417|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=41|extradata_size=19|extradata_hash=CRC32:58ba5ff3|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:ENCODER=opusenc from opus-tools 0.1.9|tag:ENCODER_OPTIONS=--discard-comments +stream|index=0|codec_name=opus|profile=unknown|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x0000|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=356|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/48000|start_pts=0|start_time=0.000000|duration_ts=38756|duration=0.807417|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=41|extradata_size=19|extradata_hash=CRC32:58ba5ff3|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:ENCODER=opusenc from opus-tools 0.1.9|tag:ENCODER_OPTIONS=--discard-comments format|filename=intro-partial.opus|nb_streams=1|nb_programs=0|format_name=ogg|start_time=0.000000|duration=0.807417|size=10250|bit_rate=101558|probe_score=100 diff --git a/tests/ref/fate/ts-demux b/tests/ref/fate/ts-demux index a90c65ce1c..39fdc182ca 100644 --- a/tests/ref/fate/ts-demux +++ b/tests/ref/fate/ts-demux @@ -42,6 +42,6 @@ packet|codec_type=video|stream_index=0|pts=3912686363|pts_time=43474.292922|dts= packet|codec_type=audio|stream_index=1|pts=3912644825|pts_time=43473.831389|dts=3912644825|dts_time=43473.831389|duration=2880|duration_time=0.032000|size=906|pos=474888|flags=K_|data_hash=CRC32:0893d398 packet|codec_type=audio|stream_index=2|pts=3912645580|pts_time=43473.839778|dts=3912645580|dts_time=43473.839778|duration=2880|duration_time=0.032000|size=354|pos=491808|flags=K_|data_hash=CRC32:f5963fa6 stream|index=0|codec_name=mpeg2video|profile=4|codec_type=video|codec_tag_string=[2][0][0][0]|codec_tag=0x0002|width=1280|height=720|coded_width=0|coded_height=0|closed_captions=0|film_grain=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=16:9|pix_fmt=yuv420p|level=4|color_range=tv|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|id=0x31|r_frame_rate=60000/1001|avg_frame_rate=60000/1001|time_base=1/90000|start_pts=3912669846|start_time=43474.109400|duration_ts=19519|duration=0.216878|bit_rate=15000000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=15|extradata_size=150|extradata_hash=CRC32:53134fa8|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|side_data|side_data_type=CPB properties|max_bitrate=15000000|min_bitrate=0|avg_bitrate=0|buffer_size=9781248|vbv_delay=-1 -stream|index=1|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=6|channel_layout=5.1(side)|bits_per_sample=0|id=0x34|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912633305|start_time=43473.703389|duration_ts=14400|duration=0.160000|bit_rate=384000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:language=eng -stream|index=2|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|id=0x35|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912634060|start_time=43473.711778|duration_ts=14400|duration=0.160000|bit_rate=192000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:language=es +stream|index=1|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=6|channel_layout=5.1(side)|bits_per_sample=0|initial_padding=0|id=0x34|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912633305|start_time=43473.703389|duration_ts=14400|duration=0.160000|bit_rate=384000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:language=eng +stream|index=2|codec_name=ac3|profile=unknown|codec_type=audio|codec_tag_string=[4][0][0][0]|codec_tag=0x0004|sample_fmt=fltp|sample_rate=48000|channels=2|channel_layout=stereo|bits_per_sample=0|initial_padding=0|id=0x35|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=3912634060|start_time=43473.711778|duration_ts=14400|duration=0.160000|bit_rate=192000|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=5|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|tag:language=es format|filename=mp3ac325-4864-small.ts|nb_streams=3|nb_programs=1|format_name=mpegts|start_time=43473.703389|duration=0.622889|size=512000|bit_rate=6575810|probe_score=50 diff --git a/tests/ref/fate/ts-opus-demux b/tests/ref/fate/ts-opus-demux index ba6059a019..883475058d 100644 --- a/tests/ref/fate/ts-opus-demux +++ b/tests/ref/fate/ts-opus-demux @@ -1022,5 +1022,5 @@ packet|codec_type=audio|stream_index=0|pts=918000|pts_time=10.200000|dts=918000| |data_hash=CRC32:75113c11 packet|codec_type=audio|stream_index=0|pts=919800|pts_time=10.220000|dts=919800|dts_time=10.220000|duration=1800|duration_time=0.020000|size=759|pos=510984|flags=K_|side_data|side_data_type=MPEGTS Stream ID|id=189 |data_hash=CRC32:59fc266f -stream|index=0|codec_name=opus|profile=unknown|codec_type=audio|codec_tag_string=Opus|codec_tag=0x7375704f|sample_fmt=fltp|sample_rate=48000|channels=8|channel_layout=7.1|bits_per_sample=0|id=0x44|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=919800|duration=10.220000|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=512|extradata_size=29|extradata_hash=CRC32:6d6089a7|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 +stream|index=0|codec_name=opus|profile=unknown|codec_type=audio|codec_tag_string=Opus|codec_tag=0x7375704f|sample_fmt=fltp|sample_rate=48000|channels=8|channel_layout=7.1|bits_per_sample=0|initial_padding=0|id=0x44|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=919800|duration=10.220000|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=512|extradata_size=29|extradata_hash=CRC32:6d6089a7|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0 format|filename=test-8-7.1.opus-small.ts|nb_streams=1|nb_programs=1|format_name=mpegts|start_time=0.000000|duration=10.220000|size=512000|bit_rate=400782|probe_score=50 From c0279e67f18ab7bb4e071c08a231dd7d7821b278 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 1 Sep 2022 16:41:58 +0200 Subject: [PATCH 156/590] fate/matroska: Add tests for muxing with initial_padding Signed-off-by: Andreas Rheinhardt --- tests/fate/matroska.mak | 19 +++++ tests/ref/fate/matroska-encoding-delay | 85 ++++++++++++++++++++ tests/ref/fate/matroska-ogg-opus-remux | 92 ++++++++++++++++++++++ tests/ref/fate/matroska-opus-remux | 103 +++++++++++++++++++++++++ 4 files changed, 299 insertions(+) create mode 100644 tests/ref/fate/matroska-encoding-delay create mode 100644 tests/ref/fate/matroska-ogg-opus-remux create mode 100644 tests/ref/fate/matroska-opus-remux diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index b49ec761cf..94532b31dc 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -163,6 +163,25 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, MPEGTS_DEMUXER AC3_DECODER) += fate-matroska-mpegts-remux fate-matroska-mpegts-remux: CMD = transcode mpegts $(TARGET_SAMPLES)/mpegts/pmtchange.ts matroska "-map 0:2 -map 0:2 -c copy -disposition:a:1 -visual_impaired+hearing_impaired -default_mode infer" "-map 0 -c copy" "-show_entries stream_disposition:stream=index" +# Tests maintaining codec delay while remuxing from Matroska. +# For some reason, ffmpeg shifts the timestamps of the input file +# to make them zero before reaching the muxer while it does not +# for the ogg-opus-remux test. +FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, OPUS_PARSER OPUS_DECODER) += fate-matroska-opus-remux +fate-matroska-opus-remux: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/codec_delay_opus.mkv matroska "-avoid_negative_ts make_zero -c copy" "-copyts -c copy" "-show_packets -show_entries stream=codec_name,initial_padding -read_intervals %0.05" + +# Tests maintaining codec delay while remuxing from ogg. +FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, OGG_DEMUXER OPUS_PARSER OPUS_DECODER) += fate-matroska-ogg-opus-remux +fate-matroska-ogg-opus-remux: CMD = transcode ogg $(TARGET_SAMPLES)/ogg/intro-partial.opus matroska "-c copy" "-copyts -c copy" "-show_packets -show_entries stream=codec_name,initial_padding -read_intervals %0.05" + +# This tests reencoding with an audio encoder that adds initial padding. +# The initial padding is currently not maintained. +FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, MXF_DEMUXER PCM_S16LE_DECODER \ + MP2FIXED_ENCODER ARESAMPLE_FILTER \ + MPEG2VIDEO_DECODER MPEGVIDEO_PARSER \ + EXTRACT_EXTRADATA_BSF) += fate-matroska-encoding-delay +fate-matroska-encoding-delay: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Sony-00001.mxf matroska "-c:v copy -af aresample -c:a mp2fixed" "-copyts -c copy" "-show_packets -show_entries stream=codec_name,initial_padding -read_intervals %0.05" + FATE_MATROSKA-$(call REMUX, MATROSKA, SUP_DEMUXER) += fate-matroska-pgs-remux fate-matroska-pgs-remux: CMD = transcode sup $(TARGET_SAMPLES)/sub/pgs_sub.sup matroska "-copyts -c:s copy" "-copyts -c:s copy" diff --git a/tests/ref/fate/matroska-encoding-delay b/tests/ref/fate/matroska-encoding-delay new file mode 100644 index 0000000000..fb7909fe29 --- /dev/null +++ b/tests/ref/fate/matroska-encoding-delay @@ -0,0 +1,85 @@ +df0524cac5393212ee103c1d1221f4b3 *tests/data/fate/matroska-encoding-delay.matroska +961215 tests/data/fate/matroska-encoding-delay.matroska +#extradata 0: 22, 0x32ea0490 +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: mpeg2video +#dimensions 0: 720x608 +#sar 0: 152/135 +#tb 1: 1/1000 +#media_type 1: audio +#codec_id 1: mp2 +#sample_rate 1: 48000 +#channel_layout_name 1: stereo +1, 0, 0, 24, 1152, 0x724077b8 +0, 10, 10, 40, 237628, 0xeff25579, S=1, 40 +1, 24, 24, 24, 1152, 0x80625572 +1, 48, 48, 24, 1152, 0x7d7f4dce +0, 50, 50, 40, 238066, 0xb2265f41 +1, 72, 72, 24, 1152, 0xa6725739 +0, 90, 90, 40, 237723, 0x00d7cd24 +1, 96, 96, 24, 1152, 0xc9e85398 +1, 120, 120, 24, 1152, 0xda1287d3 +0, 130, 130, 40, 238290, 0xbe18b18f +1, 144, 144, 24, 1152, 0x1c9a6102 +[PACKET] +codec_type=audio +stream_index=1 +pts=0 +pts_time=0.000000 +dts=0 +dts_time=0.000000 +duration=24 +duration_time=0.024000 +size=1152 +pos=1232 +flags=K_ +[/PACKET] +[PACKET] +codec_type=video +stream_index=0 +pts=10 +pts_time=0.010000 +dts=10 +dts_time=0.010000 +duration=40 +duration_time=0.040000 +size=237628 +pos=2392 +flags=K_ +[/PACKET] +[PACKET] +codec_type=audio +stream_index=1 +pts=24 +pts_time=0.024000 +dts=24 +dts_time=0.024000 +duration=24 +duration_time=0.024000 +size=1152 +pos=240027 +flags=K_ +[/PACKET] +[PACKET] +codec_type=audio +stream_index=1 +pts=48 +pts_time=0.048000 +dts=48 +dts_time=0.048000 +duration=24 +duration_time=0.024000 +size=1152 +pos=241202 +flags=K_ +[/PACKET] +[STREAM] +codec_name=mpeg2video +[SIDE_DATA] +[/SIDE_DATA] +[/STREAM] +[STREAM] +codec_name=mp2 +initial_padding=0 +[/STREAM] diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux new file mode 100644 index 0000000000..b69c29df8e --- /dev/null +++ b/tests/ref/fate/matroska-ogg-opus-remux @@ -0,0 +1,92 @@ +605e8e89efb3028e261dd10255c7f59a *tests/data/fate/matroska-ogg-opus-remux.matroska +10207 tests/data/fate/matroska-ogg-opus-remux.matroska +#extradata 0: 19, 0x399c0471 +#tb 0: 1/1000 +#media_type 0: audio +#codec_id 0: opus +#sample_rate 0: 48000 +#channel_layout_name 0: stereo +0, -7, -7, 20, 402, 0x89b1c40f +0, 13, 13, 20, 216, 0x7bf97146 +0, 33, 33, 20, 215, 0x6cb86d8b +0, 53, 53, 20, 218, 0x9cfd691c +0, 73, 73, 20, 218, 0xd7fe6a94 +0, 93, 93, 20, 194, 0x35735de6 +0, 113, 113, 20, 216, 0x3ee6705a +0, 133, 133, 20, 218, 0x67eb6cb1 +0, 153, 153, 20, 218, 0x32d0700d +0, 173, 173, 20, 219, 0xcb7f6c60 +0, 193, 193, 20, 218, 0x9c866b33 +0, 213, 213, 20, 217, 0xfe3e6a53 +0, 233, 233, 20, 218, 0x13586833 +0, 253, 253, 20, 222, 0xbcb2669e +0, 273, 273, 20, 218, 0x8dfc6e33 +0, 293, 293, 20, 217, 0xf5957051 +0, 313, 313, 20, 210, 0xed126e6b +0, 333, 333, 20, 216, 0xbf947249 +0, 353, 353, 20, 203, 0x6c7e680a +0, 373, 373, 20, 209, 0xf78f6af4 +0, 393, 393, 20, 217, 0xd60c684d +0, 413, 413, 20, 218, 0x89056a7a +0, 433, 433, 20, 219, 0x0bc674ad +0, 453, 453, 20, 217, 0xb1d86d1a +0, 473, 473, 20, 220, 0x433d685a +0, 493, 493, 20, 364, 0x0c88be84 +0, 513, 513, 20, 221, 0x804a733d +0, 533, 533, 20, 215, 0x6e9d6e9b +0, 553, 553, 20, 215, 0x63016a83 +0, 573, 573, 20, 218, 0xf9a46fbe +0, 593, 593, 20, 216, 0xa0d66c08 +0, 613, 613, 20, 216, 0xa2ca6d0a +0, 633, 633, 20, 216, 0xf50e6f1d +0, 653, 653, 20, 215, 0x6aaa70b6 +0, 673, 673, 20, 219, 0x7ceb6ba0 +0, 693, 693, 20, 220, 0x398d6ca9 +0, 713, 713, 20, 218, 0x7bd06ed5 +0, 733, 733, 20, 219, 0xe2906c62 +0, 753, 753, 20, 217, 0xcf316ba1 +0, 773, 773, 20, 217, 0x470b6eea +0, 793, 793, 20, 359, 0x36c2a18a, S=1, 10 +[PACKET] +codec_type=audio +stream_index=0 +pts=-7 +pts_time=-0.007000 +dts=-7 +dts_time=-0.007000 +duration=20 +duration_time=0.020000 +size=402 +pos=543 +flags=K_ +[/PACKET] +[PACKET] +codec_type=audio +stream_index=0 +pts=13 +pts_time=0.013000 +dts=13 +dts_time=0.013000 +duration=20 +duration_time=0.020000 +size=216 +pos=956 +flags=K_ +[/PACKET] +[PACKET] +codec_type=audio +stream_index=0 +pts=33 +pts_time=0.033000 +dts=33 +dts_time=0.033000 +duration=20 +duration_time=0.020000 +size=215 +pos=1179 +flags=K_ +[/PACKET] +[STREAM] +codec_name=opus +initial_padding=356 +[/STREAM] diff --git a/tests/ref/fate/matroska-opus-remux b/tests/ref/fate/matroska-opus-remux new file mode 100644 index 0000000000..61afeaa751 --- /dev/null +++ b/tests/ref/fate/matroska-opus-remux @@ -0,0 +1,103 @@ +551e45142f0989b281e837a3a86f0218 *tests/data/fate/matroska-opus-remux.matroska +9355 tests/data/fate/matroska-opus-remux.matroska +#extradata 0: 19, 0x3a04048f +#tb 0: 1/1000 +#media_type 0: audio +#codec_id 0: opus +#sample_rate 0: 48000 +#channel_layout_name 0: mono +0, -7, -7, 20, 320, 0x58b9a88d +0, 14, 14, 20, 159, 0x6c9c4b4c +0, 34, 34, 20, 148, 0x0caf4b5d +0, 54, 54, 20, 139, 0xc5624226 +0, 74, 74, 20, 146, 0x633c4937 +0, 94, 94, 20, 153, 0x3d0b4f93 +0, 114, 114, 20, 158, 0xe5c55641 +0, 134, 134, 20, 156, 0xf2fd50ef +0, 154, 154, 20, 158, 0x93b15410 +0, 174, 174, 20, 157, 0xb6f74f5f +0, 194, 194, 20, 159, 0x9aff4957 +0, 214, 214, 20, 153, 0xfc5f4aba +0, 234, 234, 20, 158, 0x01e44f70 +0, 254, 254, 20, 153, 0x227149cf +0, 274, 274, 20, 155, 0x312f4cf6 +0, 294, 294, 20, 155, 0xafc54bae +0, 314, 314, 20, 151, 0x7b4252b3 +0, 334, 334, 20, 155, 0x29074a75 +0, 354, 354, 20, 149, 0x82c44bcd +0, 374, 374, 20, 150, 0x55c24eb5 +0, 394, 394, 20, 156, 0xf71d4f33 +0, 414, 414, 20, 153, 0x9b6c4ae5 +0, 434, 434, 20, 156, 0x75954e51 +0, 454, 454, 20, 155, 0x28ff4ff3 +0, 474, 474, 20, 153, 0xc4424969 +0, 494, 494, 20, 154, 0xfbf94cc8 +0, 514, 514, 20, 155, 0x52c549af +0, 534, 534, 20, 150, 0x6f1e4b7a +0, 554, 554, 20, 158, 0xabb45566 +0, 574, 574, 20, 157, 0xe61d4a99 +0, 594, 594, 20, 159, 0xf45d4fac +0, 614, 614, 20, 159, 0xcd0553a5 +0, 634, 634, 20, 156, 0xdb244e63 +0, 654, 654, 20, 154, 0x78654c52 +0, 674, 674, 20, 154, 0x9f804cc8 +0, 694, 694, 20, 150, 0x1fdf4c80 +0, 714, 714, 20, 155, 0x1adc4f89 +0, 734, 734, 20, 155, 0x4b53511c +0, 754, 754, 20, 151, 0x8ff2546d +0, 774, 774, 20, 158, 0xb7e34f1b +0, 794, 794, 20, 154, 0x4d98474b +0, 814, 814, 20, 154, 0x14924ea8 +0, 834, 834, 20, 153, 0x8d4752bf +0, 854, 854, 20, 149, 0x74785066 +0, 874, 874, 20, 151, 0x36c94a4c +0, 894, 894, 20, 155, 0x82904f3b +0, 914, 914, 20, 154, 0xd76b4a45 +0, 934, 934, 20, 159, 0x9fec548d +0, 954, 954, 20, 154, 0x9a084dcd +0, 974, 974, 20, 155, 0x90a54ac8 +0, 994, 994, 20, 324, 0x8e34a2f5 +0, 1014, 1014, 20, 268, 0x10f37203, S=1, 10 +[PACKET] +codec_type=audio +stream_index=0 +pts=-7 +pts_time=-0.007000 +dts=-7 +dts_time=-0.007000 +duration=20 +duration_time=0.020000 +size=320 +pos=496 +flags=K_ +[/PACKET] +[PACKET] +codec_type=audio +stream_index=0 +pts=14 +pts_time=0.014000 +dts=14 +dts_time=0.014000 +duration=20 +duration_time=0.020000 +size=159 +pos=823 +flags=K_ +[/PACKET] +[PACKET] +codec_type=audio +stream_index=0 +pts=34 +pts_time=0.034000 +dts=34 +dts_time=0.034000 +duration=20 +duration_time=0.020000 +size=148 +pos=989 +flags=K_ +[/PACKET] +[STREAM] +codec_name=opus +initial_padding=312 +[/STREAM] From 7bacef580f81ab7a98401b9b05441115df36d86b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 31 Aug 2022 15:02:00 +0200 Subject: [PATCH 157/590] avformat/matroskaenc: Only write DiscardPadding if nonzero It is possible for the trailing padding to be zero, namely e.g. if the AV_PKT_DATA_SKIP_SAMPLES side data is used for leading padding. Matroska supports this (use a negative DiscardPadding), but players do not; at least Firefox refuses to play such a file. So for now only write DiscardPadding if it is trailing padding and nonzero. The fate-matroska-ogg-opus-remux was affected by this. (I wish CodecDelay would not exist and DiscardPadding would be used to instead trim the codec delay away (with the Block timestamp corresponding to the time at which the actually output audio is output).) Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 12 +++++++----- tests/ref/fate/matroska-ogg-opus-remux | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 1256bdfe36..de6c993e6a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2591,7 +2591,6 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, uint8_t *side_data; size_t side_data_size; uint64_t additional_id; - int64_t discard_padding = 0; unsigned track_number = track->track_num; EBML_WRITER(9); @@ -2619,10 +2618,13 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, AV_PKT_DATA_SKIP_SAMPLES, &side_data_size); if (side_data && side_data_size >= 10) { - discard_padding = av_rescale_q(AV_RL32(side_data + 4), - (AVRational){1, par->sample_rate}, - (AVRational){1, 1000000000}); - ebml_writer_add_sint(&writer, MATROSKA_ID_DISCARDPADDING, discard_padding); + int64_t discard_padding = AV_RL32(side_data + 4); + if (discard_padding) { + discard_padding = av_rescale_q(discard_padding, + (AVRational){1, par->sample_rate}, + (AVRational){1, 1000000000}); + ebml_writer_add_sint(&writer, MATROSKA_ID_DISCARDPADDING, discard_padding); + } } side_data = av_packet_get_side_data(pkt, diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux index b69c29df8e..1fa776ef01 100644 --- a/tests/ref/fate/matroska-ogg-opus-remux +++ b/tests/ref/fate/matroska-ogg-opus-remux @@ -1,5 +1,5 @@ -605e8e89efb3028e261dd10255c7f59a *tests/data/fate/matroska-ogg-opus-remux.matroska -10207 tests/data/fate/matroska-ogg-opus-remux.matroska +a3f98769fe55bc5234cf75fb1949749a *tests/data/fate/matroska-ogg-opus-remux.matroska +10200 tests/data/fate/matroska-ogg-opus-remux.matroska #extradata 0: 19, 0x399c0471 #tb 0: 1/1000 #media_type 0: audio @@ -57,7 +57,7 @@ dts_time=-0.007000 duration=20 duration_time=0.020000 size=402 -pos=543 +pos=540 flags=K_ [/PACKET] [PACKET] @@ -70,7 +70,7 @@ dts_time=0.013000 duration=20 duration_time=0.020000 size=216 -pos=956 +pos=949 flags=K_ [/PACKET] [PACKET] @@ -83,7 +83,7 @@ dts_time=0.033000 duration=20 duration_time=0.020000 size=215 -pos=1179 +pos=1172 flags=K_ [/PACKET] [STREAM] From be0a2515ab25e4531464f84c4c4d5a97e1a3e8ef Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 29 Aug 2022 23:00:48 +0200 Subject: [PATCH 158/590] avformat/matroskaenc: Don't override samplerate for CodecDelay Opus can be decoded to multiple samplerates (namely 48kHz, 24KHz, 16Khz, 12 KHz and 8Khz); libopus as well as our encoder wrapper support these sample rates. The OpusHead contains a field for this original samplerate. Yet the pre-skip (and the granule-position in the Ogg-Opus mapping in general) are always in the 48KHz clock, irrespective of the original sample rate. Before commit c3c22bee6362737cf290929b7f31df9fb88da983, our libopus encoder was buggy: It did not account for the fact that the pre-skip field is always according to a 48kHz clock and wrote a too small value in case one uses the encoder with a sample rate other than 48kHz; this discrepancy between CodecDelay and OpusHead led to Firefox rejecting such streams. In order to account for that, said commit made the muxer always use 48kHz instead of the actual sample rate to convert the initial_padding (in samples in the stream's sample rate) to ns. This meant that both fields are now off by the same factor, so Firefox was happy. Then commit f4bdeddc3cab807e43e0450744dfe9a45661e1d7 fixed the issue in libopusenc; so the OpusHead is correct, but the CodecDelay is still off*. This commit fixes this by effectively reverting c3c22bee6362737cf290929b7f31df9fb88da983. *: Firefox seems to no longer abort when CodecDelay and OpusHead are off. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 +- libavformat/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index de6c993e6a..c525edb39f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1830,7 +1830,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, case AVMEDIA_TYPE_AUDIO: if (par->initial_padding && par->codec_id == AV_CODEC_ID_OPUS) { int64_t codecdelay = av_rescale_q(par->initial_padding, - (AVRational){ 1, 48000 }, + (AVRational){ 1, par->sample_rate }, (AVRational){ 1, 1000000000 }); if (codecdelay < 0) { av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n"); diff --git a/libavformat/version.h b/libavformat/version.h index 7b414039ad..a54ffd6c0e 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ #include "version_major.h" #define LIBAVFORMAT_VERSION_MINOR 30 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From eb325324aabe6ae479bbf15256321da8e39238d4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 31 Aug 2022 06:23:08 +0200 Subject: [PATCH 159/590] avformat/matroskaenc: Actually apply timestamp offset for Opus Matroska generally requires timestamps to be nonnegative, but there is an exception: Data that corresponds to encoder delay and is not supposed to be output anyway can have a negative timestamp. This is achieved by using the CodecDelay header field: The demuxer has to subtract this value from the raw (nonnegative) timestamps of the corresponding track. Therefore the muxer has to add this value first to write this raw timestamp. Support for writing CodecDelay has been added in FFmpeg commit d92b1b1babe69268971863649c225e1747358a74 and in Libav commit a1aa37dd0b96710d4a17718198a3f56aea2040c1. The former simply wrote the header field and did not apply any timestamp offsets, leading to desynchronisation (if one uses multiple tracks). The latter applied it at two places, but not at the one where it actually matters, namely in mkv_write_block(), leading to the same desynchronisation as with the former commit. It furthermore used the wrong stream timebase to convert the delay to the stream's timebase, as the conversion used the timebase from before avpriv_set_pts_info(). When the latter was merged in 82e4f39883932c1b1e5c7792a1be12dec6ab603d, it was only done in a deactivated state that still did not offset the timestamps when muxing due to "assertion failures and av sync errors". a1aa37dd0b96710d4a17718198a3f56aea2040c1 made it definitely more likely to run into assertion failures (namely if the relative block timestamp doesn't fit into an int16_t). Yet all of the above issues have been fixed (in commits 962d63157322466a9a82f9f9d84c1b6f1b582f65, 5d3953a5dcfd5f71391b7f34908517eb6f7e5146 and 4ebeab15b037a21f195696cef1f7522daf42f3ee. This commit therefore enables applying CodecDelay, fixing ticket #7182. There is just one slight regression from this: If one has input with encoder delay where the first timestamp is negative, but the pts of the part of the data that is actually intended to be output is nonnegative, then the timestamps will currently by default be shifted to make them nonnegative before they reach the muxer; the muxer will then ensure that the shifted timestamps are retained. Before this commit, the muxer did not ensure this; instead the timestamps that the demuxer will output were shifted and if the first timestamp of the actually intended output was zero before shifting, then this unintentional shift just cancels the shift performed before the packet reached the muxer. (But notice that this only applies if all the tracks use the same CodecDelay, or the relative sync between tracks will be impaired.) This happens in the matroska-opus-remux and matroska-ogg-opus-remux FATE tests. Future commits will forward the information that the Matroska muxer has a limited capability to handle negative timestamps so that the shifting in libavformat can take advantage of it. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 8 +- tests/ref/fate/matroska-ogg-opus-remux | 108 ++++++++++---------- tests/ref/fate/matroska-opus-remux | 130 ++++++++++++------------- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index c525edb39f..0ded53dc21 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1836,11 +1836,11 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n"); return AVERROR(EINVAL); } -// track->ts_offset = av_rescale_q(par->initial_padding, -// (AVRational){ 1, par->sample_rate }, -// st->time_base); - put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay); + + track->ts_offset = av_rescale_q(par->initial_padding, + (AVRational){ 1, par->sample_rate }, + st->time_base); } if (par->codec_id == AV_CODEC_ID_OPUS) put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux index 1fa776ef01..da9c8d285b 100644 --- a/tests/ref/fate/matroska-ogg-opus-remux +++ b/tests/ref/fate/matroska-ogg-opus-remux @@ -1,4 +1,4 @@ -a3f98769fe55bc5234cf75fb1949749a *tests/data/fate/matroska-ogg-opus-remux.matroska +47b6b69c2ffdf5729557e90c72d241e9 *tests/data/fate/matroska-ogg-opus-remux.matroska 10200 tests/data/fate/matroska-ogg-opus-remux.matroska #extradata 0: 19, 0x399c0471 #tb 0: 1/1000 @@ -6,54 +6,54 @@ a3f98769fe55bc5234cf75fb1949749a *tests/data/fate/matroska-ogg-opus-remux.matros #codec_id 0: opus #sample_rate 0: 48000 #channel_layout_name 0: stereo -0, -7, -7, 20, 402, 0x89b1c40f -0, 13, 13, 20, 216, 0x7bf97146 -0, 33, 33, 20, 215, 0x6cb86d8b -0, 53, 53, 20, 218, 0x9cfd691c -0, 73, 73, 20, 218, 0xd7fe6a94 -0, 93, 93, 20, 194, 0x35735de6 -0, 113, 113, 20, 216, 0x3ee6705a -0, 133, 133, 20, 218, 0x67eb6cb1 -0, 153, 153, 20, 218, 0x32d0700d -0, 173, 173, 20, 219, 0xcb7f6c60 -0, 193, 193, 20, 218, 0x9c866b33 -0, 213, 213, 20, 217, 0xfe3e6a53 -0, 233, 233, 20, 218, 0x13586833 -0, 253, 253, 20, 222, 0xbcb2669e -0, 273, 273, 20, 218, 0x8dfc6e33 -0, 293, 293, 20, 217, 0xf5957051 -0, 313, 313, 20, 210, 0xed126e6b -0, 333, 333, 20, 216, 0xbf947249 -0, 353, 353, 20, 203, 0x6c7e680a -0, 373, 373, 20, 209, 0xf78f6af4 -0, 393, 393, 20, 217, 0xd60c684d -0, 413, 413, 20, 218, 0x89056a7a -0, 433, 433, 20, 219, 0x0bc674ad -0, 453, 453, 20, 217, 0xb1d86d1a -0, 473, 473, 20, 220, 0x433d685a -0, 493, 493, 20, 364, 0x0c88be84 -0, 513, 513, 20, 221, 0x804a733d -0, 533, 533, 20, 215, 0x6e9d6e9b -0, 553, 553, 20, 215, 0x63016a83 -0, 573, 573, 20, 218, 0xf9a46fbe -0, 593, 593, 20, 216, 0xa0d66c08 -0, 613, 613, 20, 216, 0xa2ca6d0a -0, 633, 633, 20, 216, 0xf50e6f1d -0, 653, 653, 20, 215, 0x6aaa70b6 -0, 673, 673, 20, 219, 0x7ceb6ba0 -0, 693, 693, 20, 220, 0x398d6ca9 -0, 713, 713, 20, 218, 0x7bd06ed5 -0, 733, 733, 20, 219, 0xe2906c62 -0, 753, 753, 20, 217, 0xcf316ba1 -0, 773, 773, 20, 217, 0x470b6eea -0, 793, 793, 20, 359, 0x36c2a18a, S=1, 10 +0, 0, 0, 20, 402, 0x89b1c40f +0, 20, 20, 20, 216, 0x7bf97146 +0, 40, 40, 20, 215, 0x6cb86d8b +0, 60, 60, 20, 218, 0x9cfd691c +0, 80, 80, 20, 218, 0xd7fe6a94 +0, 100, 100, 20, 194, 0x35735de6 +0, 120, 120, 20, 216, 0x3ee6705a +0, 140, 140, 20, 218, 0x67eb6cb1 +0, 160, 160, 20, 218, 0x32d0700d +0, 180, 180, 20, 219, 0xcb7f6c60 +0, 200, 200, 20, 218, 0x9c866b33 +0, 220, 220, 20, 217, 0xfe3e6a53 +0, 240, 240, 20, 218, 0x13586833 +0, 260, 260, 20, 222, 0xbcb2669e +0, 280, 280, 20, 218, 0x8dfc6e33 +0, 300, 300, 20, 217, 0xf5957051 +0, 320, 320, 20, 210, 0xed126e6b +0, 340, 340, 20, 216, 0xbf947249 +0, 360, 360, 20, 203, 0x6c7e680a +0, 380, 380, 20, 209, 0xf78f6af4 +0, 400, 400, 20, 217, 0xd60c684d +0, 420, 420, 20, 218, 0x89056a7a +0, 440, 440, 20, 219, 0x0bc674ad +0, 460, 460, 20, 217, 0xb1d86d1a +0, 480, 480, 20, 220, 0x433d685a +0, 500, 500, 20, 364, 0x0c88be84 +0, 520, 520, 20, 221, 0x804a733d +0, 540, 540, 20, 215, 0x6e9d6e9b +0, 560, 560, 20, 215, 0x63016a83 +0, 580, 580, 20, 218, 0xf9a46fbe +0, 600, 600, 20, 216, 0xa0d66c08 +0, 620, 620, 20, 216, 0xa2ca6d0a +0, 640, 640, 20, 216, 0xf50e6f1d +0, 660, 660, 20, 215, 0x6aaa70b6 +0, 680, 680, 20, 219, 0x7ceb6ba0 +0, 700, 700, 20, 220, 0x398d6ca9 +0, 720, 720, 20, 218, 0x7bd06ed5 +0, 740, 740, 20, 219, 0xe2906c62 +0, 760, 760, 20, 217, 0xcf316ba1 +0, 780, 780, 20, 217, 0x470b6eea +0, 800, 800, 20, 359, 0x36c2a18a, S=1, 10 [PACKET] codec_type=audio stream_index=0 -pts=-7 -pts_time=-0.007000 -dts=-7 -dts_time=-0.007000 +pts=0 +pts_time=0.000000 +dts=0 +dts_time=0.000000 duration=20 duration_time=0.020000 size=402 @@ -63,10 +63,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=13 -pts_time=0.013000 -dts=13 -dts_time=0.013000 +pts=20 +pts_time=0.020000 +dts=20 +dts_time=0.020000 duration=20 duration_time=0.020000 size=216 @@ -76,10 +76,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=33 -pts_time=0.033000 -dts=33 -dts_time=0.033000 +pts=40 +pts_time=0.040000 +dts=40 +dts_time=0.040000 duration=20 duration_time=0.020000 size=215 diff --git a/tests/ref/fate/matroska-opus-remux b/tests/ref/fate/matroska-opus-remux index 61afeaa751..286bb65949 100644 --- a/tests/ref/fate/matroska-opus-remux +++ b/tests/ref/fate/matroska-opus-remux @@ -1,4 +1,4 @@ -551e45142f0989b281e837a3a86f0218 *tests/data/fate/matroska-opus-remux.matroska +2ab987ba7bad94b27fae427cdff57723 *tests/data/fate/matroska-opus-remux.matroska 9355 tests/data/fate/matroska-opus-remux.matroska #extradata 0: 19, 0x3a04048f #tb 0: 1/1000 @@ -6,65 +6,65 @@ #codec_id 0: opus #sample_rate 0: 48000 #channel_layout_name 0: mono -0, -7, -7, 20, 320, 0x58b9a88d -0, 14, 14, 20, 159, 0x6c9c4b4c -0, 34, 34, 20, 148, 0x0caf4b5d -0, 54, 54, 20, 139, 0xc5624226 -0, 74, 74, 20, 146, 0x633c4937 -0, 94, 94, 20, 153, 0x3d0b4f93 -0, 114, 114, 20, 158, 0xe5c55641 -0, 134, 134, 20, 156, 0xf2fd50ef -0, 154, 154, 20, 158, 0x93b15410 -0, 174, 174, 20, 157, 0xb6f74f5f -0, 194, 194, 20, 159, 0x9aff4957 -0, 214, 214, 20, 153, 0xfc5f4aba -0, 234, 234, 20, 158, 0x01e44f70 -0, 254, 254, 20, 153, 0x227149cf -0, 274, 274, 20, 155, 0x312f4cf6 -0, 294, 294, 20, 155, 0xafc54bae -0, 314, 314, 20, 151, 0x7b4252b3 -0, 334, 334, 20, 155, 0x29074a75 -0, 354, 354, 20, 149, 0x82c44bcd -0, 374, 374, 20, 150, 0x55c24eb5 -0, 394, 394, 20, 156, 0xf71d4f33 -0, 414, 414, 20, 153, 0x9b6c4ae5 -0, 434, 434, 20, 156, 0x75954e51 -0, 454, 454, 20, 155, 0x28ff4ff3 -0, 474, 474, 20, 153, 0xc4424969 -0, 494, 494, 20, 154, 0xfbf94cc8 -0, 514, 514, 20, 155, 0x52c549af -0, 534, 534, 20, 150, 0x6f1e4b7a -0, 554, 554, 20, 158, 0xabb45566 -0, 574, 574, 20, 157, 0xe61d4a99 -0, 594, 594, 20, 159, 0xf45d4fac -0, 614, 614, 20, 159, 0xcd0553a5 -0, 634, 634, 20, 156, 0xdb244e63 -0, 654, 654, 20, 154, 0x78654c52 -0, 674, 674, 20, 154, 0x9f804cc8 -0, 694, 694, 20, 150, 0x1fdf4c80 -0, 714, 714, 20, 155, 0x1adc4f89 -0, 734, 734, 20, 155, 0x4b53511c -0, 754, 754, 20, 151, 0x8ff2546d -0, 774, 774, 20, 158, 0xb7e34f1b -0, 794, 794, 20, 154, 0x4d98474b -0, 814, 814, 20, 154, 0x14924ea8 -0, 834, 834, 20, 153, 0x8d4752bf -0, 854, 854, 20, 149, 0x74785066 -0, 874, 874, 20, 151, 0x36c94a4c -0, 894, 894, 20, 155, 0x82904f3b -0, 914, 914, 20, 154, 0xd76b4a45 -0, 934, 934, 20, 159, 0x9fec548d -0, 954, 954, 20, 154, 0x9a084dcd -0, 974, 974, 20, 155, 0x90a54ac8 -0, 994, 994, 20, 324, 0x8e34a2f5 -0, 1014, 1014, 20, 268, 0x10f37203, S=1, 10 +0, 0, 0, 20, 320, 0x58b9a88d +0, 21, 21, 20, 159, 0x6c9c4b4c +0, 41, 41, 20, 148, 0x0caf4b5d +0, 61, 61, 20, 139, 0xc5624226 +0, 81, 81, 20, 146, 0x633c4937 +0, 101, 101, 20, 153, 0x3d0b4f93 +0, 121, 121, 20, 158, 0xe5c55641 +0, 141, 141, 20, 156, 0xf2fd50ef +0, 161, 161, 20, 158, 0x93b15410 +0, 181, 181, 20, 157, 0xb6f74f5f +0, 201, 201, 20, 159, 0x9aff4957 +0, 221, 221, 20, 153, 0xfc5f4aba +0, 241, 241, 20, 158, 0x01e44f70 +0, 261, 261, 20, 153, 0x227149cf +0, 281, 281, 20, 155, 0x312f4cf6 +0, 301, 301, 20, 155, 0xafc54bae +0, 321, 321, 20, 151, 0x7b4252b3 +0, 341, 341, 20, 155, 0x29074a75 +0, 361, 361, 20, 149, 0x82c44bcd +0, 381, 381, 20, 150, 0x55c24eb5 +0, 401, 401, 20, 156, 0xf71d4f33 +0, 421, 421, 20, 153, 0x9b6c4ae5 +0, 441, 441, 20, 156, 0x75954e51 +0, 461, 461, 20, 155, 0x28ff4ff3 +0, 481, 481, 20, 153, 0xc4424969 +0, 501, 501, 20, 154, 0xfbf94cc8 +0, 521, 521, 20, 155, 0x52c549af +0, 541, 541, 20, 150, 0x6f1e4b7a +0, 561, 561, 20, 158, 0xabb45566 +0, 581, 581, 20, 157, 0xe61d4a99 +0, 601, 601, 20, 159, 0xf45d4fac +0, 621, 621, 20, 159, 0xcd0553a5 +0, 641, 641, 20, 156, 0xdb244e63 +0, 661, 661, 20, 154, 0x78654c52 +0, 681, 681, 20, 154, 0x9f804cc8 +0, 701, 701, 20, 150, 0x1fdf4c80 +0, 721, 721, 20, 155, 0x1adc4f89 +0, 741, 741, 20, 155, 0x4b53511c +0, 761, 761, 20, 151, 0x8ff2546d +0, 781, 781, 20, 158, 0xb7e34f1b +0, 801, 801, 20, 154, 0x4d98474b +0, 821, 821, 20, 154, 0x14924ea8 +0, 841, 841, 20, 153, 0x8d4752bf +0, 861, 861, 20, 149, 0x74785066 +0, 881, 881, 20, 151, 0x36c94a4c +0, 901, 901, 20, 155, 0x82904f3b +0, 921, 921, 20, 154, 0xd76b4a45 +0, 941, 941, 20, 159, 0x9fec548d +0, 961, 961, 20, 154, 0x9a084dcd +0, 981, 981, 20, 155, 0x90a54ac8 +0, 1001, 1001, 20, 324, 0x8e34a2f5 +0, 1021, 1021, 20, 268, 0x10f37203, S=1, 10 [PACKET] codec_type=audio stream_index=0 -pts=-7 -pts_time=-0.007000 -dts=-7 -dts_time=-0.007000 +pts=0 +pts_time=0.000000 +dts=0 +dts_time=0.000000 duration=20 duration_time=0.020000 size=320 @@ -74,10 +74,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=14 -pts_time=0.014000 -dts=14 -dts_time=0.014000 +pts=21 +pts_time=0.021000 +dts=21 +dts_time=0.021000 duration=20 duration_time=0.020000 size=159 @@ -87,10 +87,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=34 -pts_time=0.034000 -dts=34 -dts_time=0.034000 +pts=41 +pts_time=0.041000 +dts=41 +dts_time=0.041000 duration=20 duration_time=0.020000 size=148 From 1a8309e954b894675aa450db5c117240195385a9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 1 Sep 2022 01:26:48 +0200 Subject: [PATCH 160/590] avformat/mux: Allow muxers to set custom min timestamp Matroska requires pts to be >= 0 with a slight exception: It has a mechanism to deal with codec delay, i.e. with the data added at the beginning that does not correspond to actual input data and should be discarded by the player. Only the audio actually intended to be output needs to have a timestamp >= 0. In order to avoid unnecessary timestamp shifting, this patch allows muxers to inform the shifting code about this so that it can take it into account. Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 7 +++++++ libavformat/mux.c | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 9b07cfb271..23757dc4fc 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -310,6 +310,13 @@ typedef struct FFStream { */ int64_t mux_ts_offset; + /** + * This is the lowest ts allowed in this track; it may be set by the muxer + * during init or write_header and influences the automatic timestamp + * shifting code. + */ + int64_t lowest_ts_allowed; + /** * Internal data to check for wrapping of the time stamp */ diff --git a/libavformat/mux.c b/libavformat/mux.c index a3b50dadb6..5d89458f82 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -632,6 +632,8 @@ static void handle_avoid_negative_ts(FFFormatContext *si, FFStream *sti, if (ts == AV_NOPTS_VALUE) return; + ts -= sti->lowest_ts_allowed; + /* Peek into the muxing queue to improve our estimate * of the lowest timestamp if av_interleaved_write_frame() is used. */ for (const PacketListEntry *pktl = si->packet_buffer.head; @@ -640,6 +642,7 @@ static void handle_avoid_negative_ts(FFFormatContext *si, FFStream *sti, int64_t cmp_ts = use_pts ? pktl->pkt.pts : pktl->pkt.dts; if (cmp_ts == AV_NOPTS_VALUE) continue; + cmp_ts -= ffstream(s->streams[pktl->pkt.stream_index])->lowest_ts_allowed; if (s->output_ts_offset) cmp_ts += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, cmp_tb); if (av_compare_ts(cmp_ts, cmp_tb, ts, tb) < 0) { @@ -669,7 +672,7 @@ static void handle_avoid_negative_ts(FFFormatContext *si, FFStream *sti, pkt->pts += offset; if (si->avoid_negative_ts_use_pts) { - if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < 0) { + if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < sti->lowest_ts_allowed) { av_log(s, AV_LOG_WARNING, "failed to avoid negative " "pts %s in stream %d.\n" "Try -avoid_negative_ts 1 as a possible workaround.\n", @@ -678,7 +681,7 @@ static void handle_avoid_negative_ts(FFFormatContext *si, FFStream *sti, ); } } else { - if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) { + if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < sti->lowest_ts_allowed) { av_log(s, AV_LOG_WARNING, "Packets poorly interleaved, failed to avoid negative " "timestamp %s in stream %d.\n" From bca4fef46a6b0a6f5c31840c4c03303a329dbbe9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 1 Sep 2022 14:19:07 +0200 Subject: [PATCH 161/590] avformat/matroskaenc: Use custom min timestamp Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 1 + libavformat/webm_chunk.c | 4 + tests/fate/matroska.mak | 2 +- tests/ref/fate/matroska-ogg-opus-remux | 108 ++++++++++---------- tests/ref/fate/matroska-opus-remux | 130 ++++++++++++------------- 5 files changed, 125 insertions(+), 120 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 0ded53dc21..97dcff5607 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1841,6 +1841,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, track->ts_offset = av_rescale_q(par->initial_padding, (AVRational){ 1, par->sample_rate }, st->time_base); + ffstream(st)->lowest_ts_allowed = -track->ts_offset; } if (par->codec_id == AV_CODEC_ID_OPUS) put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL); diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 9e71a1209d..916ed0cbab 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -127,6 +127,7 @@ static int webm_chunk_init(AVFormatContext *s) ffformatcontext(s)->avoid_negative_ts_use_pts = ffformatcontext(oc)->avoid_negative_ts_use_pts; oc->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED; + ffformatcontext(oc)->avoid_negative_ts_status = AVOID_NEGATIVE_TS_DISABLED; return 0; } @@ -149,10 +150,13 @@ static int webm_chunk_write_header(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; AVFormatContext *oc = wc->avf; + AVStream *st = s->streams[0], *ost = oc->streams[0]; int ret; ret = avformat_write_header(oc, NULL); ff_format_io_close(s, &oc->pb); + ffstream(st)->lowest_ts_allowed = ffstream(ost)->lowest_ts_allowed; + ffstream(ost)->lowest_ts_allowed = 0; wc->header_written = 1; if (ret < 0) return ret; diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 94532b31dc..63e81f121b 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -166,7 +166,7 @@ fate-matroska-mpegts-remux: CMD = transcode mpegts $(TARGET_SAMPLES)/mpegts/pmtc # Tests maintaining codec delay while remuxing from Matroska. # For some reason, ffmpeg shifts the timestamps of the input file # to make them zero before reaching the muxer while it does not -# for the ogg-opus-remux test. +# for the ogg-opus-remux test. -avoid_negative_ts make_zero counters this. FATE_MATROSKA_FFMPEG_FFPROBE-$(call REMUX, MATROSKA, OPUS_PARSER OPUS_DECODER) += fate-matroska-opus-remux fate-matroska-opus-remux: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/codec_delay_opus.mkv matroska "-avoid_negative_ts make_zero -c copy" "-copyts -c copy" "-show_packets -show_entries stream=codec_name,initial_padding -read_intervals %0.05" diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux index da9c8d285b..1fa776ef01 100644 --- a/tests/ref/fate/matroska-ogg-opus-remux +++ b/tests/ref/fate/matroska-ogg-opus-remux @@ -1,4 +1,4 @@ -47b6b69c2ffdf5729557e90c72d241e9 *tests/data/fate/matroska-ogg-opus-remux.matroska +a3f98769fe55bc5234cf75fb1949749a *tests/data/fate/matroska-ogg-opus-remux.matroska 10200 tests/data/fate/matroska-ogg-opus-remux.matroska #extradata 0: 19, 0x399c0471 #tb 0: 1/1000 @@ -6,54 +6,54 @@ #codec_id 0: opus #sample_rate 0: 48000 #channel_layout_name 0: stereo -0, 0, 0, 20, 402, 0x89b1c40f -0, 20, 20, 20, 216, 0x7bf97146 -0, 40, 40, 20, 215, 0x6cb86d8b -0, 60, 60, 20, 218, 0x9cfd691c -0, 80, 80, 20, 218, 0xd7fe6a94 -0, 100, 100, 20, 194, 0x35735de6 -0, 120, 120, 20, 216, 0x3ee6705a -0, 140, 140, 20, 218, 0x67eb6cb1 -0, 160, 160, 20, 218, 0x32d0700d -0, 180, 180, 20, 219, 0xcb7f6c60 -0, 200, 200, 20, 218, 0x9c866b33 -0, 220, 220, 20, 217, 0xfe3e6a53 -0, 240, 240, 20, 218, 0x13586833 -0, 260, 260, 20, 222, 0xbcb2669e -0, 280, 280, 20, 218, 0x8dfc6e33 -0, 300, 300, 20, 217, 0xf5957051 -0, 320, 320, 20, 210, 0xed126e6b -0, 340, 340, 20, 216, 0xbf947249 -0, 360, 360, 20, 203, 0x6c7e680a -0, 380, 380, 20, 209, 0xf78f6af4 -0, 400, 400, 20, 217, 0xd60c684d -0, 420, 420, 20, 218, 0x89056a7a -0, 440, 440, 20, 219, 0x0bc674ad -0, 460, 460, 20, 217, 0xb1d86d1a -0, 480, 480, 20, 220, 0x433d685a -0, 500, 500, 20, 364, 0x0c88be84 -0, 520, 520, 20, 221, 0x804a733d -0, 540, 540, 20, 215, 0x6e9d6e9b -0, 560, 560, 20, 215, 0x63016a83 -0, 580, 580, 20, 218, 0xf9a46fbe -0, 600, 600, 20, 216, 0xa0d66c08 -0, 620, 620, 20, 216, 0xa2ca6d0a -0, 640, 640, 20, 216, 0xf50e6f1d -0, 660, 660, 20, 215, 0x6aaa70b6 -0, 680, 680, 20, 219, 0x7ceb6ba0 -0, 700, 700, 20, 220, 0x398d6ca9 -0, 720, 720, 20, 218, 0x7bd06ed5 -0, 740, 740, 20, 219, 0xe2906c62 -0, 760, 760, 20, 217, 0xcf316ba1 -0, 780, 780, 20, 217, 0x470b6eea -0, 800, 800, 20, 359, 0x36c2a18a, S=1, 10 +0, -7, -7, 20, 402, 0x89b1c40f +0, 13, 13, 20, 216, 0x7bf97146 +0, 33, 33, 20, 215, 0x6cb86d8b +0, 53, 53, 20, 218, 0x9cfd691c +0, 73, 73, 20, 218, 0xd7fe6a94 +0, 93, 93, 20, 194, 0x35735de6 +0, 113, 113, 20, 216, 0x3ee6705a +0, 133, 133, 20, 218, 0x67eb6cb1 +0, 153, 153, 20, 218, 0x32d0700d +0, 173, 173, 20, 219, 0xcb7f6c60 +0, 193, 193, 20, 218, 0x9c866b33 +0, 213, 213, 20, 217, 0xfe3e6a53 +0, 233, 233, 20, 218, 0x13586833 +0, 253, 253, 20, 222, 0xbcb2669e +0, 273, 273, 20, 218, 0x8dfc6e33 +0, 293, 293, 20, 217, 0xf5957051 +0, 313, 313, 20, 210, 0xed126e6b +0, 333, 333, 20, 216, 0xbf947249 +0, 353, 353, 20, 203, 0x6c7e680a +0, 373, 373, 20, 209, 0xf78f6af4 +0, 393, 393, 20, 217, 0xd60c684d +0, 413, 413, 20, 218, 0x89056a7a +0, 433, 433, 20, 219, 0x0bc674ad +0, 453, 453, 20, 217, 0xb1d86d1a +0, 473, 473, 20, 220, 0x433d685a +0, 493, 493, 20, 364, 0x0c88be84 +0, 513, 513, 20, 221, 0x804a733d +0, 533, 533, 20, 215, 0x6e9d6e9b +0, 553, 553, 20, 215, 0x63016a83 +0, 573, 573, 20, 218, 0xf9a46fbe +0, 593, 593, 20, 216, 0xa0d66c08 +0, 613, 613, 20, 216, 0xa2ca6d0a +0, 633, 633, 20, 216, 0xf50e6f1d +0, 653, 653, 20, 215, 0x6aaa70b6 +0, 673, 673, 20, 219, 0x7ceb6ba0 +0, 693, 693, 20, 220, 0x398d6ca9 +0, 713, 713, 20, 218, 0x7bd06ed5 +0, 733, 733, 20, 219, 0xe2906c62 +0, 753, 753, 20, 217, 0xcf316ba1 +0, 773, 773, 20, 217, 0x470b6eea +0, 793, 793, 20, 359, 0x36c2a18a, S=1, 10 [PACKET] codec_type=audio stream_index=0 -pts=0 -pts_time=0.000000 -dts=0 -dts_time=0.000000 +pts=-7 +pts_time=-0.007000 +dts=-7 +dts_time=-0.007000 duration=20 duration_time=0.020000 size=402 @@ -63,10 +63,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=20 -pts_time=0.020000 -dts=20 -dts_time=0.020000 +pts=13 +pts_time=0.013000 +dts=13 +dts_time=0.013000 duration=20 duration_time=0.020000 size=216 @@ -76,10 +76,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=40 -pts_time=0.040000 -dts=40 -dts_time=0.040000 +pts=33 +pts_time=0.033000 +dts=33 +dts_time=0.033000 duration=20 duration_time=0.020000 size=215 diff --git a/tests/ref/fate/matroska-opus-remux b/tests/ref/fate/matroska-opus-remux index 286bb65949..61afeaa751 100644 --- a/tests/ref/fate/matroska-opus-remux +++ b/tests/ref/fate/matroska-opus-remux @@ -1,4 +1,4 @@ -2ab987ba7bad94b27fae427cdff57723 *tests/data/fate/matroska-opus-remux.matroska +551e45142f0989b281e837a3a86f0218 *tests/data/fate/matroska-opus-remux.matroska 9355 tests/data/fate/matroska-opus-remux.matroska #extradata 0: 19, 0x3a04048f #tb 0: 1/1000 @@ -6,65 +6,65 @@ #codec_id 0: opus #sample_rate 0: 48000 #channel_layout_name 0: mono -0, 0, 0, 20, 320, 0x58b9a88d -0, 21, 21, 20, 159, 0x6c9c4b4c -0, 41, 41, 20, 148, 0x0caf4b5d -0, 61, 61, 20, 139, 0xc5624226 -0, 81, 81, 20, 146, 0x633c4937 -0, 101, 101, 20, 153, 0x3d0b4f93 -0, 121, 121, 20, 158, 0xe5c55641 -0, 141, 141, 20, 156, 0xf2fd50ef -0, 161, 161, 20, 158, 0x93b15410 -0, 181, 181, 20, 157, 0xb6f74f5f -0, 201, 201, 20, 159, 0x9aff4957 -0, 221, 221, 20, 153, 0xfc5f4aba -0, 241, 241, 20, 158, 0x01e44f70 -0, 261, 261, 20, 153, 0x227149cf -0, 281, 281, 20, 155, 0x312f4cf6 -0, 301, 301, 20, 155, 0xafc54bae -0, 321, 321, 20, 151, 0x7b4252b3 -0, 341, 341, 20, 155, 0x29074a75 -0, 361, 361, 20, 149, 0x82c44bcd -0, 381, 381, 20, 150, 0x55c24eb5 -0, 401, 401, 20, 156, 0xf71d4f33 -0, 421, 421, 20, 153, 0x9b6c4ae5 -0, 441, 441, 20, 156, 0x75954e51 -0, 461, 461, 20, 155, 0x28ff4ff3 -0, 481, 481, 20, 153, 0xc4424969 -0, 501, 501, 20, 154, 0xfbf94cc8 -0, 521, 521, 20, 155, 0x52c549af -0, 541, 541, 20, 150, 0x6f1e4b7a -0, 561, 561, 20, 158, 0xabb45566 -0, 581, 581, 20, 157, 0xe61d4a99 -0, 601, 601, 20, 159, 0xf45d4fac -0, 621, 621, 20, 159, 0xcd0553a5 -0, 641, 641, 20, 156, 0xdb244e63 -0, 661, 661, 20, 154, 0x78654c52 -0, 681, 681, 20, 154, 0x9f804cc8 -0, 701, 701, 20, 150, 0x1fdf4c80 -0, 721, 721, 20, 155, 0x1adc4f89 -0, 741, 741, 20, 155, 0x4b53511c -0, 761, 761, 20, 151, 0x8ff2546d -0, 781, 781, 20, 158, 0xb7e34f1b -0, 801, 801, 20, 154, 0x4d98474b -0, 821, 821, 20, 154, 0x14924ea8 -0, 841, 841, 20, 153, 0x8d4752bf -0, 861, 861, 20, 149, 0x74785066 -0, 881, 881, 20, 151, 0x36c94a4c -0, 901, 901, 20, 155, 0x82904f3b -0, 921, 921, 20, 154, 0xd76b4a45 -0, 941, 941, 20, 159, 0x9fec548d -0, 961, 961, 20, 154, 0x9a084dcd -0, 981, 981, 20, 155, 0x90a54ac8 -0, 1001, 1001, 20, 324, 0x8e34a2f5 -0, 1021, 1021, 20, 268, 0x10f37203, S=1, 10 +0, -7, -7, 20, 320, 0x58b9a88d +0, 14, 14, 20, 159, 0x6c9c4b4c +0, 34, 34, 20, 148, 0x0caf4b5d +0, 54, 54, 20, 139, 0xc5624226 +0, 74, 74, 20, 146, 0x633c4937 +0, 94, 94, 20, 153, 0x3d0b4f93 +0, 114, 114, 20, 158, 0xe5c55641 +0, 134, 134, 20, 156, 0xf2fd50ef +0, 154, 154, 20, 158, 0x93b15410 +0, 174, 174, 20, 157, 0xb6f74f5f +0, 194, 194, 20, 159, 0x9aff4957 +0, 214, 214, 20, 153, 0xfc5f4aba +0, 234, 234, 20, 158, 0x01e44f70 +0, 254, 254, 20, 153, 0x227149cf +0, 274, 274, 20, 155, 0x312f4cf6 +0, 294, 294, 20, 155, 0xafc54bae +0, 314, 314, 20, 151, 0x7b4252b3 +0, 334, 334, 20, 155, 0x29074a75 +0, 354, 354, 20, 149, 0x82c44bcd +0, 374, 374, 20, 150, 0x55c24eb5 +0, 394, 394, 20, 156, 0xf71d4f33 +0, 414, 414, 20, 153, 0x9b6c4ae5 +0, 434, 434, 20, 156, 0x75954e51 +0, 454, 454, 20, 155, 0x28ff4ff3 +0, 474, 474, 20, 153, 0xc4424969 +0, 494, 494, 20, 154, 0xfbf94cc8 +0, 514, 514, 20, 155, 0x52c549af +0, 534, 534, 20, 150, 0x6f1e4b7a +0, 554, 554, 20, 158, 0xabb45566 +0, 574, 574, 20, 157, 0xe61d4a99 +0, 594, 594, 20, 159, 0xf45d4fac +0, 614, 614, 20, 159, 0xcd0553a5 +0, 634, 634, 20, 156, 0xdb244e63 +0, 654, 654, 20, 154, 0x78654c52 +0, 674, 674, 20, 154, 0x9f804cc8 +0, 694, 694, 20, 150, 0x1fdf4c80 +0, 714, 714, 20, 155, 0x1adc4f89 +0, 734, 734, 20, 155, 0x4b53511c +0, 754, 754, 20, 151, 0x8ff2546d +0, 774, 774, 20, 158, 0xb7e34f1b +0, 794, 794, 20, 154, 0x4d98474b +0, 814, 814, 20, 154, 0x14924ea8 +0, 834, 834, 20, 153, 0x8d4752bf +0, 854, 854, 20, 149, 0x74785066 +0, 874, 874, 20, 151, 0x36c94a4c +0, 894, 894, 20, 155, 0x82904f3b +0, 914, 914, 20, 154, 0xd76b4a45 +0, 934, 934, 20, 159, 0x9fec548d +0, 954, 954, 20, 154, 0x9a084dcd +0, 974, 974, 20, 155, 0x90a54ac8 +0, 994, 994, 20, 324, 0x8e34a2f5 +0, 1014, 1014, 20, 268, 0x10f37203, S=1, 10 [PACKET] codec_type=audio stream_index=0 -pts=0 -pts_time=0.000000 -dts=0 -dts_time=0.000000 +pts=-7 +pts_time=-0.007000 +dts=-7 +dts_time=-0.007000 duration=20 duration_time=0.020000 size=320 @@ -74,10 +74,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=21 -pts_time=0.021000 -dts=21 -dts_time=0.021000 +pts=14 +pts_time=0.014000 +dts=14 +dts_time=0.014000 duration=20 duration_time=0.020000 size=159 @@ -87,10 +87,10 @@ flags=K_ [PACKET] codec_type=audio stream_index=0 -pts=41 -pts_time=0.041000 -dts=41 -dts_time=0.041000 +pts=34 +pts_time=0.034000 +dts=34 +dts_time=0.034000 duration=20 duration_time=0.020000 size=148 From 8913539a5d2a81a77980b45455b1eb144827fd96 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 1 Sep 2022 20:50:53 +0200 Subject: [PATCH 162/590] avformat/matroskaenc: Write CodecDelay for codecs != Opus The field is not specific to Opus. The mp2fixed encoder signals initial_padding and is used by both the matroska-encoding-delay test as well as the lavf-mkv tests which necessitated several FATE ref changes. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 +- tests/ref/fate/matroska-encoding-delay | 81 +++++++++++++++----------- tests/ref/lavf/mkv | 4 +- tests/ref/lavf/mkv_attachment | 4 +- tests/ref/seek/lavf-mkv | 44 +++++++------- 5 files changed, 74 insertions(+), 61 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 97dcff5607..ed1ad5039d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1828,7 +1828,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, break; case AVMEDIA_TYPE_AUDIO: - if (par->initial_padding && par->codec_id == AV_CODEC_ID_OPUS) { + if (par->initial_padding) { int64_t codecdelay = av_rescale_q(par->initial_padding, (AVRational){ 1, par->sample_rate }, (AVRational){ 1, 1000000000 }); diff --git a/tests/ref/fate/matroska-encoding-delay b/tests/ref/fate/matroska-encoding-delay index fb7909fe29..8dd3bf59e2 100644 --- a/tests/ref/fate/matroska-encoding-delay +++ b/tests/ref/fate/matroska-encoding-delay @@ -1,5 +1,5 @@ -df0524cac5393212ee103c1d1221f4b3 *tests/data/fate/matroska-encoding-delay.matroska -961215 tests/data/fate/matroska-encoding-delay.matroska +b933b7b94de55ae029369312d48d8649 *tests/data/fate/matroska-encoding-delay.matroska +961221 tests/data/fate/matroska-encoding-delay.matroska #extradata 0: 22, 0x32ea0490 #tb 0: 1/1000 #media_type 0: video @@ -11,67 +11,80 @@ df0524cac5393212ee103c1d1221f4b3 *tests/data/fate/matroska-encoding-delay.matros #codec_id 1: mp2 #sample_rate 1: 48000 #channel_layout_name 1: stereo -1, 0, 0, 24, 1152, 0x724077b8 -0, 10, 10, 40, 237628, 0xeff25579, S=1, 40 -1, 24, 24, 24, 1152, 0x80625572 -1, 48, 48, 24, 1152, 0x7d7f4dce -0, 50, 50, 40, 238066, 0xb2265f41 -1, 72, 72, 24, 1152, 0xa6725739 -0, 90, 90, 40, 237723, 0x00d7cd24 -1, 96, 96, 24, 1152, 0xc9e85398 -1, 120, 120, 24, 1152, 0xda1287d3 -0, 130, 130, 40, 238290, 0xbe18b18f -1, 144, 144, 24, 1152, 0x1c9a6102 +1, -10, -10, 24, 1152, 0x724077b8 +0, 0, 0, 40, 237628, 0xeff25579, S=1, 40 +1, 14, 14, 24, 1152, 0x80625572 +1, 38, 38, 24, 1152, 0x7d7f4dce +0, 40, 40, 40, 238066, 0xb2265f41 +1, 62, 62, 24, 1152, 0xa6725739 +0, 80, 80, 40, 237723, 0x00d7cd24 +1, 86, 86, 24, 1152, 0xc9e85398 +1, 110, 110, 24, 1152, 0xda1287d3 +0, 120, 120, 40, 238290, 0xbe18b18f +1, 134, 134, 24, 1152, 0x1c9a6102 [PACKET] codec_type=audio stream_index=1 -pts=0 -pts_time=0.000000 -dts=0 -dts_time=0.000000 +pts=-10 +pts_time=-0.010000 +dts=-10 +dts_time=-0.010000 duration=24 duration_time=0.024000 size=1152 -pos=1232 +pos=1238 flags=K_ [/PACKET] [PACKET] codec_type=video stream_index=0 -pts=10 -pts_time=0.010000 -dts=10 -dts_time=0.010000 +pts=0 +pts_time=0.000000 +dts=0 +dts_time=0.000000 duration=40 duration_time=0.040000 size=237628 -pos=2392 +pos=2398 flags=K_ [/PACKET] [PACKET] codec_type=audio stream_index=1 -pts=24 -pts_time=0.024000 -dts=24 -dts_time=0.024000 +pts=14 +pts_time=0.014000 +dts=14 +dts_time=0.014000 duration=24 duration_time=0.024000 size=1152 -pos=240027 +pos=240033 flags=K_ [/PACKET] [PACKET] codec_type=audio stream_index=1 -pts=48 -pts_time=0.048000 -dts=48 -dts_time=0.048000 +pts=38 +pts_time=0.038000 +dts=38 +dts_time=0.038000 duration=24 duration_time=0.024000 size=1152 -pos=241202 +pos=241208 +flags=K_ +[/PACKET] +[PACKET] +codec_type=video +stream_index=0 +pts=40 +pts_time=0.040000 +dts=40 +dts_time=0.040000 +duration=40 +duration_time=0.040000 +size=238066 +pos=242368 flags=K_ [/PACKET] [STREAM] @@ -81,5 +94,5 @@ codec_name=mpeg2video [/STREAM] [STREAM] codec_name=mp2 -initial_padding=0 +initial_padding=481 [/STREAM] diff --git a/tests/ref/lavf/mkv b/tests/ref/lavf/mkv index d9497a0a64..d54c44a647 100644 --- a/tests/ref/lavf/mkv +++ b/tests/ref/lavf/mkv @@ -1,3 +1,3 @@ -17e637fc06015fea86428840418ffea2 *tests/data/lavf/lavf.mkv -320403 tests/data/lavf/lavf.mkv +0934e35639b6735c1e26595e8f47ba70 *tests/data/lavf/lavf.mkv +320409 tests/data/lavf/lavf.mkv tests/data/lavf/lavf.mkv CRC=0xec6c3c68 diff --git a/tests/ref/lavf/mkv_attachment b/tests/ref/lavf/mkv_attachment index a8cc075bf1..ad96424098 100644 --- a/tests/ref/lavf/mkv_attachment +++ b/tests/ref/lavf/mkv_attachment @@ -1,3 +1,3 @@ -3855fb336711517b32b0ec41e8505b4d *tests/data/lavf/lavf.mkv_attachment -472553 tests/data/lavf/lavf.mkv_attachment +d2708709bdd6817d9cb2b475fdfa903f *tests/data/lavf/lavf.mkv_attachment +472559 tests/data/lavf/lavf.mkv_attachment tests/data/lavf/lavf.mkv_attachment CRC=0xec6c3c68 diff --git a/tests/ref/seek/lavf-mkv b/tests/ref/seek/lavf-mkv index 6b64367802..8ac0354164 100644 --- a/tests/ref/seek/lavf-mkv +++ b/tests/ref/seek/lavf-mkv @@ -1,48 +1,48 @@ -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 651 size: 208 +ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 657 size: 208 ret: 0 st:-1 flags:0 ts:-1.000000 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 ret: 0 st:-1 flags:1 ts: 1.894167 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292283 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292289 size: 27834 ret: 0 st: 0 flags:0 ts: 0.788000 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292283 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292289 size: 27834 ret: 0 st: 0 flags:1 ts:-0.317000 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 ret:-1 st: 1 flags:0 ts: 2.577000 ret: 0 st: 1 flags:1 ts: 1.471000 -ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320124 size: 209 +ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320130 size: 209 ret: 0 st:-1 flags:0 ts: 0.365002 -ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146835 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146841 size: 27925 ret: 0 st:-1 flags:1 ts:-0.740831 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 ret:-1 st: 0 flags:0 ts: 2.153000 ret: 0 st: 0 flags:1 ts: 1.048000 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292283 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292289 size: 27834 ret: 0 st: 1 flags:0 ts:-0.058000 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 651 size: 208 +ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 657 size: 208 ret: 0 st: 1 flags:1 ts: 2.836000 -ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320124 size: 209 +ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320130 size: 209 ret:-1 st:-1 flags:0 ts: 1.730004 ret: 0 st:-1 flags:1 ts: 0.624171 -ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146835 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146841 size: 27925 ret: 0 st: 0 flags:0 ts:-0.482000 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 ret: 0 st: 0 flags:1 ts: 2.413000 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292283 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292289 size: 27834 ret:-1 st: 1 flags:0 ts: 1.307000 ret: 0 st: 1 flags:1 ts: 0.201000 -ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 651 size: 208 +ret: 0 st: 1 flags:1 dts:-0.011000 pts:-0.011000 pos: 657 size: 208 ret: 0 st:-1 flags:0 ts:-0.904994 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 ret: 0 st:-1 flags:1 ts: 1.989173 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292283 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292289 size: 27834 ret: 0 st: 0 flags:0 ts: 0.883000 -ret: 0 st: 0 flags:1 dts: 0.971000 pts: 0.971000 pos: 292283 size: 27834 +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 292289 size: 27834 ret: 0 st: 0 flags:1 ts:-0.222000 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 ret:-1 st: 1 flags:0 ts: 2.672000 ret: 0 st: 1 flags:1 ts: 1.566000 -ret: 0 st: 1 flags:1 dts: 0.993000 pts: 0.993000 pos: 320124 size: 209 +ret: 0 st: 1 flags:1 dts: 0.982000 pts: 0.982000 pos: 320130 size: 209 ret: 0 st:-1 flags:0 ts: 0.460008 -ret: 0 st: 0 flags:1 dts: 0.491000 pts: 0.491000 pos: 146835 size: 27925 +ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146841 size: 27925 ret: 0 st:-1 flags:1 ts:-0.645825 -ret: 0 st: 0 flags:1 dts: 0.011000 pts: 0.011000 pos: 867 size: 27837 +ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 873 size: 27837 From ad12e31b036fa4d9655d9e4e2b70f5610f83fdc9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 20:54:57 +0200 Subject: [PATCH 163/590] avcodec/x86/flacdsp_init: Remove double ';' Inside a function, the second ';' in ";;" is just a null statement, but it is actually illegal outside of functions. Compilers nevertheless accept it without warning, except when in -pedantic mode when e.g. Clang emits a -Wextra-semi warning. Therefore remove the unnecessary ';'. Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/flacdsp_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c index 48e3e7c55c..87daed7005 100644 --- a/libavcodec/x86/flacdsp_init.c +++ b/libavcodec/x86/flacdsp_init.c @@ -34,7 +34,7 @@ void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int chann void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ int len, int shift); \ void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ - int len, int shift); + int len, int shift) #define DECORRELATE_IFUNCS(fmt, opt) \ void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \ From 9b738de6112f475a557a2d911c8c33160ce85846 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 23:23:18 +0200 Subject: [PATCH 164/590] ref/fate/ffprobe_xsd: Change ref file Forgotten in 5c16df1b92c519238e10664eeab3adb3b9016edd, because neither I nor patchwork ran fate with xmllint. Signed-off-by: Andreas Rheinhardt --- tests/ref/fate/ffprobe_xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ref/fate/ffprobe_xsd b/tests/ref/fate/ffprobe_xsd index f1fac9a87c..412fd9a180 100644 --- a/tests/ref/fate/ffprobe_xsd +++ b/tests/ref/fate/ffprobe_xsd @@ -32,7 +32,7 @@ - + From 61c37bc61d6ff08d52c5f9e01b9ba45e957031ca Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 1 Sep 2022 23:49:32 +0200 Subject: [PATCH 165/590] avcodec/libtheoraenc: Do not use invalid error code Signed-off-by: Andreas Rheinhardt --- libavcodec/libtheoraenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c index b453e74c81..da16c6372e 100644 --- a/libavcodec/libtheoraenc.c +++ b/libavcodec/libtheoraenc.c @@ -119,7 +119,7 @@ static int get_stats(AVCodecContext *avctx, int eos) return 0; #else av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n"); - return AVERROR(ENOSUP); + return AVERROR(ENOTSUP); #endif } @@ -158,7 +158,7 @@ static int submit_stats(AVCodecContext *avctx) return 0; #else av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n"); - return AVERROR(ENOSUP); + return AVERROR(ENOTSUP); #endif } From b881d2db8892e88a625dfa4ac2d5b8ca53ab9595 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 01:42:51 +0200 Subject: [PATCH 166/590] tools/.gitignore: Add missing tools Signed-off-by: Andreas Rheinhardt --- tools/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/.gitignore b/tools/.gitignore index c0958f40cb..7c45896923 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -3,6 +3,7 @@ /bisect.need /crypto_bench /cws2fws +/enum_options /fourcc2pixfmt /ffescape /ffeval @@ -12,8 +13,10 @@ /pktdumper /probetest /qt-faststart +/scale_slice_test /sidxindex /trasher /seek_print /uncoded_frame +/venc_data_dump /zmqsend From 2425d5cd7e37387305f85bef63f7441c8b1cc147 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 3 Sep 2022 03:34:57 +0200 Subject: [PATCH 167/590] x86/tx_float: add support for calling assembly functions from assembly Needed for the next patch. We get this for the extremely small cost of a branch on _ns functions, which wouldn't be used anyway with assembly. --- libavutil/tx.c | 4 +- libavutil/tx_priv.h | 1 + libavutil/x86/tx_float.asm | 160 ++++++++++++++++++++++++---------- libavutil/x86/tx_float_init.c | 25 ++++++ 4 files changed, 142 insertions(+), 48 deletions(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index 28e49a5d41..edd2af07c7 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -313,6 +313,8 @@ static void print_flags(AVBPrint *bp, uint64_t f) av_bprintf(bp, "%spreshuf", prev > 1 ? sep : ""); if ((f & AV_TX_FULL_IMDCT) && ++prev) av_bprintf(bp, "%simdct_full", prev > 1 ? sep : ""); + if ((f & FF_TX_ASM_CALL) && ++prev) + av_bprintf(bp, "%sasm_call", prev > 1 ? sep : ""); av_bprintf(bp, "]"); } @@ -484,7 +486,7 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, uint64_t req_flags = flags; /* Flags the codelet may require to be present */ - uint64_t inv_req_mask = AV_TX_FULL_IMDCT | FF_TX_PRESHUFFLE; + uint64_t inv_req_mask = AV_TX_FULL_IMDCT | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL; /* Unaligned codelets are compatible with the aligned flag */ if (req_flags & FF_TX_ALIGNED) diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h index e38490bd56..691942f808 100644 --- a/libavutil/tx_priv.h +++ b/libavutil/tx_priv.h @@ -145,6 +145,7 @@ typedef void TXComplex; #define FF_TX_PRESHUFFLE (1ULL << 61) /* Codelet expects permuted coeffs */ #define FF_TX_INVERSE_ONLY (1ULL << 60) /* For non-orthogonal inverse-only transforms */ #define FF_TX_FORWARD_ONLY (1ULL << 59) /* For non-orthogonal forward-only transforms */ +#define FF_TX_ASM_CALL (1ULL << 58) /* For asm->asm functions only */ typedef enum FFTXCodeletPriority { FF_TX_PRIO_BASE = 0, /* Baseline priority */ diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 191af7d68f..791ad7b322 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -707,20 +707,21 @@ cglobal fft4_ %+ %1 %+ _float, 4, 4, 3, ctx, out, in, stride FFT4 fwd, 0 FFT4 inv, 1 -%macro FFT8_SSE_FN 2 +%macro FFT8_SSE_FN 1 INIT_XMM sse3 -cglobal fft8_ %+ %1, 4, 4, 6, ctx, out, in, tmp -%if %2 +%if %1 +cglobal fft8_asm_float, 0, 0, 0, ctx, out, in, tmp + movaps m0, [inq + 0*mmsize] + movaps m1, [inq + 1*mmsize] + movaps m2, [inq + 2*mmsize] + movaps m3, [inq + 3*mmsize] +%else +cglobal fft8_float, 4, 4, 6, ctx, out, in, tmp mov ctxq, [ctxq + AVTXContext.map] LOAD64_LUT m0, inq, ctxq, (mmsize/2)*0, tmpq LOAD64_LUT m1, inq, ctxq, (mmsize/2)*1, tmpq LOAD64_LUT m2, inq, ctxq, (mmsize/2)*2, tmpq LOAD64_LUT m3, inq, ctxq, (mmsize/2)*3, tmpq -%else - movaps m0, [inq + 0*mmsize] - movaps m1, [inq + 1*mmsize] - movaps m2, [inq + 2*mmsize] - movaps m3, [inq + 3*mmsize] %endif FFT8 m0, m1, m2, m3, m4, m5 @@ -735,22 +736,33 @@ cglobal fft8_ %+ %1, 4, 4, 6, ctx, out, in, tmp movups [outq + 2*mmsize], m5 movups [outq + 3*mmsize], m1 +%if %1 + ret +%else + RET +%endif + +%if %1 +cglobal fft8_ns_float, 4, 4, 6, ctx, out, in, tmp + call ff_tx_fft8_asm_float_sse3 RET +%endif %endmacro -FFT8_SSE_FN float, 1 -FFT8_SSE_FN ns_float, 0 +FFT8_SSE_FN 0 +FFT8_SSE_FN 1 -%macro FFT8_AVX_FN 2 +%macro FFT8_AVX_FN 1 INIT_YMM avx -cglobal fft8_ %+ %1, 4, 4, 4, ctx, out, in, tmp -%if %2 +%if %1 +cglobal fft8_asm_float, 0, 0, 0, ctx, out, in, tmp + movaps m0, [inq + 0*mmsize] + movaps m1, [inq + 1*mmsize] +%else +cglobal fft8_float, 4, 4, 4, ctx, out, in, tmp mov ctxq, [ctxq + AVTXContext.map] LOAD64_LUT m0, inq, ctxq, (mmsize/2)*0, tmpq, m2 LOAD64_LUT m1, inq, ctxq, (mmsize/2)*1, tmpq, m3 -%else - movaps m0, [inq + 0*mmsize] - movaps m1, [inq + 1*mmsize] %endif FFT8_AVX m0, m1, m2, m3 @@ -764,21 +776,32 @@ cglobal fft8_ %+ %1, 4, 4, 4, ctx, out, in, tmp vextractf128 [outq + 16*2], m2, 1 vextractf128 [outq + 16*3], m0, 1 +%if %1 + ret +%else + RET +%endif + +%if %1 +cglobal fft8_ns_float, 4, 4, 4, ctx, out, in, tmp + call ff_tx_fft8_asm_float_avx RET +%endif %endmacro -FFT8_AVX_FN float, 1 -FFT8_AVX_FN ns_float, 0 +FFT8_AVX_FN 0 +FFT8_AVX_FN 1 -%macro FFT16_FN 3 +%macro FFT16_FN 2 INIT_YMM %1 -cglobal fft16_ %+ %2, 4, 4, 8, ctx, out, in, tmp -%if %3 +%if %2 +cglobal fft16_asm_float, 0, 0, 0, ctx, out, in, tmp movaps m0, [inq + 0*mmsize] movaps m1, [inq + 1*mmsize] movaps m2, [inq + 2*mmsize] movaps m3, [inq + 3*mmsize] %else +cglobal fft16_float, 4, 4, 8, ctx, out, in, tmp mov ctxq, [ctxq + AVTXContext.map] LOAD64_LUT m0, inq, ctxq, (mmsize/2)*0, tmpq, m4 LOAD64_LUT m1, inq, ctxq, (mmsize/2)*1, tmpq, m5 @@ -802,23 +825,34 @@ cglobal fft16_ %+ %2, 4, 4, 8, ctx, out, in, tmp vextractf128 [outq + 16*6], m5, 1 vextractf128 [outq + 16*7], m1, 1 +%if %2 + ret +%else + RET +%endif + +%if %2 +cglobal fft16_ns_float, 4, 4, 8, ctx, out, in, tmp + call ff_tx_fft16_asm_float_ %+ %1 RET +%endif %endmacro -FFT16_FN avx, float, 0 -FFT16_FN avx, ns_float, 1 -FFT16_FN fma3, float, 0 -FFT16_FN fma3, ns_float, 1 +FFT16_FN avx, 0 +FFT16_FN avx, 1 +FFT16_FN fma3, 0 +FFT16_FN fma3, 1 -%macro FFT32_FN 3 +%macro FFT32_FN 2 INIT_YMM %1 -cglobal fft32_ %+ %2, 4, 4, 16, ctx, out, in, tmp -%if %3 +%if %2 +cglobal fft32_asm_float, 0, 0, 0, ctx, out, in, tmp movaps m4, [inq + 4*mmsize] movaps m5, [inq + 5*mmsize] movaps m6, [inq + 6*mmsize] movaps m7, [inq + 7*mmsize] %else +cglobal fft32_float, 4, 4, 16, ctx, out, in, tmp mov ctxq, [ctxq + AVTXContext.map] LOAD64_LUT m4, inq, ctxq, (mmsize/2)*4, tmpq, m8, m12 LOAD64_LUT m5, inq, ctxq, (mmsize/2)*5, tmpq, m9, m13 @@ -828,7 +862,7 @@ cglobal fft32_ %+ %2, 4, 4, 16, ctx, out, in, tmp FFT8 m4, m5, m6, m7, m8, m9 -%if %3 +%if %2 movaps m0, [inq + 0*mmsize] movaps m1, [inq + 1*mmsize] movaps m2, [inq + 2*mmsize] @@ -875,14 +909,24 @@ cglobal fft32_ %+ %2, 4, 4, 16, ctx, out, in, tmp vextractf128 [outq + 16*14], m10, 1 vextractf128 [outq + 16*15], m5, 1 +%if %2 + ret +%else + RET +%endif + +%if %2 +cglobal fft32_ns_float, 4, 4, 16, ctx, out, in, tmp + call ff_tx_fft32_asm_float_ %+ %1 RET +%endif %endmacro %if ARCH_X86_64 -FFT32_FN avx, float, 0 -FFT32_FN avx, ns_float, 1 -FFT32_FN fma3, float, 0 -FFT32_FN fma3, ns_float, 1 +FFT32_FN avx, 0 +FFT32_FN avx, 1 +FFT32_FN fma3, 0 +FFT32_FN fma3, 1 %endif %macro FFT_SPLIT_RADIX_DEF 1-2 @@ -923,17 +967,21 @@ ALIGN 16 %endif %endmacro -%macro FFT_SPLIT_RADIX_FN 3 +%macro FFT_SPLIT_RADIX_FN 2 INIT_YMM %1 -cglobal fft_sr_ %+ %2, 4, 8, 16, 272, lut, out, in, len, tmp, itab, rtab, tgt - movsxd lenq, dword [lutq + AVTXContext.len] - mov lutq, [lutq + AVTXContext.map] +%if %2 +cglobal fft_sr_asm_float, 0, 0, 0, ctx, out, in, tmp, len, lut, itab, rtab, tgt +%else +cglobal fft_sr_float, 4, 9, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, tgt + movsxd lenq, dword [ctxq + AVTXContext.len] + mov lutq, [ctxq + AVTXContext.map] mov tgtq, lenq +%endif ; Bottom-most/32-point transform =============================================== ALIGN 16 .32pt: -%if %3 +%if %2 movaps m4, [inq + 4*mmsize] movaps m5, [inq + 5*mmsize] movaps m6, [inq + 6*mmsize] @@ -947,7 +995,7 @@ ALIGN 16 FFT8 m4, m5, m6, m7, m8, m9 -%if %3 +%if %2 movaps m0, [inq + 0*mmsize] movaps m1, [inq + 1*mmsize] movaps m2, [inq + 2*mmsize] @@ -972,7 +1020,7 @@ ALIGN 16 movaps [outq + 5*mmsize], m5 movaps [outq + 7*mmsize], m7 -%if %3 +%if %2 add inq, 8*mmsize %else add lutq, (mmsize/2)*8 @@ -1007,7 +1055,7 @@ ALIGN 16 SWAP m4, m1 SWAP m6, m3 -%if %3 +%if %2 movaps tx1_e0, [inq + 0*mmsize] movaps tx1_e1, [inq + 1*mmsize] movaps tx1_o0, [inq + 2*mmsize] @@ -1021,7 +1069,7 @@ ALIGN 16 FFT16 tx1_e0, tx1_e1, tx1_o0, tx1_o1, tw_e, tw_o, tx2_o0, tx2_o1 -%if %3 +%if %2 movaps tx2_e0, [inq + 4*mmsize] movaps tx2_e1, [inq + 5*mmsize] movaps tx2_o0, [inq + 6*mmsize] @@ -1038,7 +1086,7 @@ ALIGN 16 movaps tw_e, [tab_64_float] vperm2f128 tw_o, tw_o, [tab_64_float + 64 - 4*7], 0x23 -%if %3 +%if %2 add inq, 8*mmsize %else add lutq, (mmsize/2)*8 @@ -1201,7 +1249,11 @@ FFT_SPLIT_RADIX_DEF 131072 sub lenq, 4*mmsize jg .synth_deinterleave +%if %2 + ret +%else RET +%endif ; 64-point deinterleave which only has to load 4 registers ===================== .64pt_deint: @@ -1278,14 +1330,28 @@ FFT_SPLIT_RADIX_DEF 131072 vextractf128 [outq + 15*mmsize + 0], tw_o, 1 vextractf128 [outq + 15*mmsize + 16], tx2_e1, 1 +%if %2 + ret +%else RET +%endif + +%if %2 +cglobal fft_sr_ns_float, 4, 9, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, tgt + movsxd lenq, dword [ctxq + AVTXContext.len] + mov lutq, [ctxq + AVTXContext.map] + mov tgtq, lenq + + call ff_tx_fft_sr_asm_float_ %+ %1 + RET +%endif %endmacro %if ARCH_X86_64 -FFT_SPLIT_RADIX_FN fma3, float, 0 -FFT_SPLIT_RADIX_FN fma3, ns_float, 1 +FFT_SPLIT_RADIX_FN fma3, 0 +FFT_SPLIT_RADIX_FN fma3, 1 %if HAVE_AVX2_EXTERNAL -FFT_SPLIT_RADIX_FN avx2, float, 0 -FFT_SPLIT_RADIX_FN avx2, ns_float, 1 +FFT_SPLIT_RADIX_FN avx2, 0 +FFT_SPLIT_RADIX_FN avx2, 1 %endif %endif diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c index 5db0b57d13..9fd98103c8 100644 --- a/libavutil/x86/tx_float_init.c +++ b/libavutil/x86/tx_float_init.c @@ -43,6 +43,15 @@ TX_DECL_FN(fft_sr_ns, fma3) TX_DECL_FN(fft_sr, avx2) TX_DECL_FN(fft_sr_ns, avx2) +TX_DECL_FN(fft8_asm, sse3) +TX_DECL_FN(fft8_asm, avx) +TX_DECL_FN(fft16_asm, avx) +TX_DECL_FN(fft16_asm, fma3) +TX_DECL_FN(fft32_asm, avx) +TX_DECL_FN(fft32_asm, fma3) +TX_DECL_FN(fft_sr_asm, fma3) +TX_DECL_FN(fft_sr_asm, avx2) + #define DECL_INIT_FN(basis, interleave) \ static av_cold int b ##basis## _i ##interleave(AVTXContext *s, \ const FFTXCodelet *cd, \ @@ -70,30 +79,46 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 192, b8_i0, sse2, SSE2, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), TX_DEF(fft4_inv, FFT, 4, 4, 2, 0, 128, NULL, sse2, SSE2, AV_TX_INPLACE | FF_TX_INVERSE_ONLY, 0), TX_DEF(fft8, FFT, 8, 8, 2, 0, 128, b8_i0, sse3, SSE3, AV_TX_INPLACE, 0), + TX_DEF(fft8_asm, FFT, 8, 8, 2, 0, 192, b8_i0, sse3, SSE3, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 0), TX_DEF(fft8_ns, FFT, 8, 8, 2, 0, 192, b8_i0, sse3, SSE3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), TX_DEF(fft8, FFT, 8, 8, 2, 0, 256, b8_i0, avx, AVX, AV_TX_INPLACE, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft8_asm, FFT, 8, 8, 2, 0, 320, b8_i0, avx, AVX, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft8_ns, FFT, 8, 8, 2, 0, 320, b8_i0, avx, AVX, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft16, FFT, 16, 16, 2, 0, 256, b8_i2, avx, AVX, AV_TX_INPLACE, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft16_asm, FFT, 16, 16, 2, 0, 320, b8_i2, avx, AVX, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft16_ns, FFT, 16, 16, 2, 0, 320, b8_i2, avx, AVX, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft16, FFT, 16, 16, 2, 0, 288, b8_i2, fma3, FMA3, AV_TX_INPLACE, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft16_asm, FFT, 16, 16, 2, 0, 352, b8_i2, fma3, FMA3, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft16_ns, FFT, 16, 16, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), #if ARCH_X86_64 TX_DEF(fft32, FFT, 32, 32, 2, 0, 256, b8_i2, avx, AVX, AV_TX_INPLACE, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft32_asm, FFT, 32, 32, 2, 0, 320, b8_i2, avx, AVX, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft32_ns, FFT, 32, 32, 2, 0, 320, b8_i2, avx, AVX, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft32, FFT, 32, 32, 2, 0, 288, b8_i2, fma3, FMA3, AV_TX_INPLACE, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft32_asm, FFT, 32, 32, 2, 0, 352, b8_i2, fma3, FMA3, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft32_ns, FFT, 32, 32, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 288, b8_i2, fma3, FMA3, 0, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 352, b8_i2, fma3, FMA3, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), #if HAVE_AVX2_EXTERNAL TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 320, b8_i2, avx2, AVX2, 0, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), + TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 384, b8_i2, avx2, AVX2, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 384, b8_i2, avx2, AVX2, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), #endif From 4537d9554d9a0027ba028c8eb16221d9235ebe43 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 3 Sep 2022 03:36:40 +0200 Subject: [PATCH 168/590] x86/tx_float: implement inverse MDCT AVX2 assembly This commit implements an iMDCT in pure assembly. This is capable of processing any mod-8 transforms, rather than just power of two, but since power of two is all we have assembly for currently, that's what's supported. It would really benefit if we could somehow use the C code to decide which function to jump into, but exposing function labels from assebly into C is anything but easy. The post-transform loop could probably be improved. This was somewhat annoying to write, as we must support arbitrary strides during runtime. There's a fast branch for stride == 4 bytes and a slower one which uses vgatherdps. Zen 3 benchmarks for stride == 4 for old (av_imdct_half) vs new (av_tx): 128pt: 2811 decicycles in av_tx (imdct),16775916 runs, 1300 skips 3082 decicycles in av_imdct_half,16776751 runs, 465 skips 256pt: 4920 decicycles in av_tx (imdct),16775820 runs, 1396 skips 5378 decicycles in av_imdct_half,16776411 runs, 805 skips 512pt: 9668 decicycles in av_tx (imdct),16775774 runs, 1442 skips 10626 decicycles in av_imdct_half,16775647 runs, 1569 skips 1024pt: 19812 decicycles in av_tx (imdct),16777144 runs, 72 skips 23036 decicycles in av_imdct_half,16777167 runs, 49 skips --- libavutil/tx.c | 19 ++-- libavutil/tx_priv.h | 8 +- libavutil/x86/tx_float.asm | 185 ++++++++++++++++++++++++++++++++++ libavutil/x86/tx_float_init.c | 32 +++++- 4 files changed, 232 insertions(+), 12 deletions(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index edd2af07c7..da8ebddd9a 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -206,23 +206,24 @@ static void parity_revtab_generator(int *revtab, int n, int inv, int offset, 1, 1, len >> 1, basis, dual_stride, inv_lookup); } -int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int invert_lookup, - int basis, int dual_stride) +int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, + int inv_lookup, int basis, int dual_stride) { - int len = s->len; - int inv = s->inv; - - if (!(s->map = av_mallocz(len*sizeof(*s->map)))) - return AVERROR(ENOMEM); - basis >>= 1; if (len < basis) return AVERROR(EINVAL); + if (!(s->map = av_mallocz((inv_lookup == -1 ? 2 : 1)*len*sizeof(*s->map)))) + return AVERROR(ENOMEM); + av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1))); av_assert0(dual_stride <= basis); + parity_revtab_generator(s->map, len, inv, 0, 0, 0, len, - basis, dual_stride, invert_lookup); + basis, dual_stride, inv_lookup != 0); + if (inv_lookup == -1) + parity_revtab_generator(s->map + len, len, inv, 0, 0, 0, len, + basis, dual_stride, 0); return 0; } diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h index 691942f808..28ac31a597 100644 --- a/libavutil/tx_priv.h +++ b/libavutil/tx_priv.h @@ -288,9 +288,13 @@ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s); * functions in AVX mode. * * If length is smaller than basis/2 this function will not do anything. + * + * If inv_lookup is set to 1, it will flip the lookup from out[map[i]] = src[i] + * to out[i] = src[map[i]]. If set to -1, will generate 2 maps, the first one + * flipped, the second one regular. */ -int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int invert_lookup, - int basis, int dual_stride); +int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, + int inv_lookup, int basis, int dual_stride); /* Typed init function to initialize shared tables. Will initialize all tables * for all factors of a length. */ diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 791ad7b322..1b9131e7fa 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1355,3 +1355,188 @@ FFT_SPLIT_RADIX_FN avx2, 0 FFT_SPLIT_RADIX_FN avx2, 1 %endif %endif + +%macro IMDCT_FN 1 +INIT_YMM %1 +cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, stride, len, lut, exp, t1, t2, t3, t4, t5 + movsxd lenq, dword [ctxq + AVTXContext.len] + mov expq, [ctxq + AVTXContext.exp] + + lea t1d, [lend - 1] + imul t1d, strided + + PUSH outq ; backup original output + mov t5q, [ctxq + AVTXContext.fn] ; subtransform's jump point + PUSH ctxq ; backup original context + mov ctxq, [ctxq + AVTXContext.sub] ; load subtransform's context + mov lutq, [ctxq + AVTXContext.map] ; load subtransform's map + + cmp strideq, 4 + je .stride4 + + shl strideq, 1 + movd xm4, strided + vpbroadcastd m4, xm4 ; stride splatted + movd xm5, t1d + vpbroadcastd m5, xm5 ; offset splatted + + mov t2q, outq ; don't modify the original output + pcmpeqd m15, m15 ; set all bits to 1 + +.stridex_pre: + pmulld m2, m4, [lutq] ; multiply by stride + movaps m0, m15 + psubd m3, m5, m2 ; subtract from offset + movaps m1, m15 + vgatherdps m6, [inq + m2], m0 ; im + vgatherdps m7, [inq + m3], m1 ; re + + movaps m8, [expq + 0*mmsize] ; tab 1 + movaps m9, [expq + 1*mmsize] ; tab 2 + + unpcklps m0, m7, m6 ; re, im, re, im + unpckhps m1, m7, m6 ; re, im, re, im + + vperm2f128 m2, m1, m0, 0x02 ; output order + vperm2f128 m3, m1, m0, 0x13 ; output order + + movshdup m10, m8 ; tab 1 imim + movshdup m11, m9 ; tab 2 imim + movsldup m12, m8 ; tab 1 rere + movsldup m13, m9 ; tab 2 rere + + mulps m10, m2 ; 1 reim * imim + mulps m11, m3 ; 2 reim * imim + + shufps m10, m10, q2301 + shufps m11, m11, q2301 + + fmaddsubps m10, m12, m2, m10 + fmaddsubps m11, m13, m3, m11 + + mova [t2q + 0*mmsize], m10 + mova [t2q + 1*mmsize], m11 + + add expq, mmsize*2 + add lutq, mmsize + add t2q, mmsize*2 + sub lenq, mmsize/2 + jg .stridex_pre + jmp .transform + +.stride4: + lea expq, [expq + lenq*4] + lea lutq, [lutq + lenq*2] + lea t1q, [inq + t1q] + lea t1q, [t1q + strideq - mmsize] + lea t2q, [lenq*2 - mmsize/2] + +.stride4_pre: + movaps m4, [inq] + movaps m3, [t1q] + + movsldup m1, m4 ; im im, im im + movshdup m0, m3 ; re re, re re + movshdup m4, m4 ; re re, re re (2) + movsldup m3, m3 ; im im, im im (2) + + movaps m2, [expq] ; tab + movaps m5, [expq + 2*t2q] ; tab (2) + + vpermpd m0, m0, q0123 ; flip + shufps m7, m2, m2, q2301 + vpermpd m4, m4, q0123 ; flip (2) + shufps m8, m5, m5, q2301 + + mulps m1, m7 ; im im * tab.reim + mulps m3, m8 ; im im * tab.reim (2) + + fmaddsubps m0, m0, m2, m1 + fmaddsubps m4, m4, m5, m3 + + vextractf128 xm3, m0, 1 + vextractf128 xm6, m4, 1 + + ; scatter + movsxd strideq, dword [lutq + 0*4] + movsxd lenq, dword [lutq + 1*4] + movsxd t3q, dword [lutq + 2*4] + movsxd t4q, dword [lutq + 3*4] + + movlps [outq + strideq*8], xm0 + movhps [outq + lenq*8], xm0 + movlps [outq + t3q*8], xm3 + movhps [outq + t4q*8], xm3 + + movsxd strideq, dword [lutq + 0*4 + t2q] + movsxd lenq, dword [lutq + 1*4 + t2q] + movsxd t3q, dword [lutq + 2*4 + t2q] + movsxd t4q, dword [lutq + 3*4 + t2q] + + movlps [outq + strideq*8], xm4 + movhps [outq + lenq*8], xm4 + movlps [outq + t3q*8], xm6 + movhps [outq + t4q*8], xm6 + + add lutq, mmsize/2 + add expq, mmsize + add inq, mmsize + sub t1q, mmsize + sub t2q, mmsize + jg .stride4_pre + +.transform: + movsxd lenq, dword [ctxq + AVTXContext.len] + mov t2q, lenq ; target length (for ptwo transforms) + mov inq, outq ; in-place transform + call t5q ; call the FFT + + POP ctxq ; restore original context + movsxd lenq, dword [ctxq + AVTXContext.len] + mov expq, [ctxq + AVTXContext.exp] + lea expq, [expq + lenq*4] + + lea t1q, [lenq*2] ; high + lea t2q, [lenq*2 - mmsize] ; low + + POP outq + +.post: + movaps m2, [expq + t1q] ; tab h + movaps m3, [expq + t2q] ; tab l + movaps m0, [outq + t1q] ; in h + movaps m1, [outq + t2q] ; in l + + movshdup m4, m2 ; tab h imim + movshdup m5, m3 ; tab l imim + movsldup m6, m2 ; tab h rere + movsldup m7, m3 ; tab l rere + + shufps m2, m0, m0, q2301 ; in h imre + shufps m3, m1, m1, q2301 ; in l imre + + mulps m6, m0 + mulps m7, m1 + + fmaddsubps m4, m4, m2, m6 + fmaddsubps m5, m5, m3, m7 + + vpermpd m3, m5, q0123 ; flip + vpermpd m2, m4, q0123 ; flip + + blendps m1, m2, m5, 01010101b + blendps m0, m3, m4, 01010101b + + movaps [outq + t2q], m1 + movaps [outq + t1q], m0 + + add t1q, mmsize + sub t2q, mmsize + jge .post + + RET +%endmacro + +%if ARCH_X86_64 +IMDCT_FN avx2 +%endif diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c index 9fd98103c8..25de7b3ec6 100644 --- a/libavutil/x86/tx_float_init.c +++ b/libavutil/x86/tx_float_init.c @@ -43,6 +43,8 @@ TX_DECL_FN(fft_sr_ns, fma3) TX_DECL_FN(fft_sr, avx2) TX_DECL_FN(fft_sr_ns, avx2) +TX_DECL_FN(mdct_sr_inv, avx2) + TX_DECL_FN(fft8_asm, sse3) TX_DECL_FN(fft8_asm, avx) TX_DECL_FN(fft16_asm, avx) @@ -65,13 +67,38 @@ static av_cold int b ##basis## _i ##interleave(AVTXContext *s, \ if (cd->max_len == 2) \ return ff_tx_gen_ptwo_revtab(s, inv_lookup); \ else \ - return ff_tx_gen_split_radix_parity_revtab(s, inv_lookup, \ + return ff_tx_gen_split_radix_parity_revtab(s, len, inv, inv_lookup, \ basis, interleave); \ } DECL_INIT_FN(8, 0) DECL_INIT_FN(8, 2) +static av_cold int m_inv_init(AVTXContext *s, const FFTXCodelet *cd, + uint64_t flags, FFTXCodeletOptions *opts, + int len, int inv, const void *scale) +{ + int ret; + FFTXCodeletOptions sub_opts = { .invert_lookup = -1 }; + + s->scale_d = *((SCALE_TYPE *)scale); + s->scale_f = s->scale_d; + + flags &= ~FF_TX_OUT_OF_PLACE; /* We want the subtransform to be */ + flags |= AV_TX_INPLACE; /* in-place */ + flags |= FF_TX_PRESHUFFLE; /* This function handles the permute step */ + flags |= FF_TX_ASM_CALL; /* We want an assembly function, not C */ + + if ((ret = ff_tx_init_subtx(s, TX_TYPE(FFT), flags, &sub_opts, len >> 1, + inv, scale))) + return ret; + + if ((ret = ff_tx_mdct_gen_exp_float(s, s->sub->map))) + return ret; + + return 0; +} + const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { TX_DEF(fft2, FFT, 2, 2, 2, 0, 128, NULL, sse3, SSE3, AV_TX_INPLACE, 0), TX_DEF(fft2, FFT, 2, 2, 2, 0, 192, b8_i0, sse3, SSE3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), @@ -121,6 +148,9 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 384, b8_i2, avx2, AVX2, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), + + TX_DEF(mdct_sr_inv, MDCT, 16, TX_LEN_UNLIMITED, 2, TX_FACTOR_ANY, 384, m_inv_init, avx2, AVX2, + FF_TX_INVERSE_ONLY, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), #endif #endif From 9a9647af3309369e0d35cd99426d1c73df7a634c Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 4 Sep 2022 02:40:07 +0200 Subject: [PATCH 169/590] checkasm/tx: add checkasm support for the iMDCT --- tests/checkasm/av_tx.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/checkasm/av_tx.c b/tests/checkasm/av_tx.c index 9d3823e8ed..1fa6da45ac 100644 --- a/tests/checkasm/av_tx.c +++ b/tests/checkasm/av_tx.c @@ -43,35 +43,36 @@ static const int check_lens[] = { 2, 4, 8, 16, 32, 64, 1024, 16384, }; -static AVTXContext *tx_refs[6 /*AVTXType*/][FF_ARRAY_ELEMS(check_lens)]; +static AVTXContext *tx_refs[AV_TX_NB][2 /* Direction */][FF_ARRAY_ELEMS(check_lens)] = { 0 }; static int init = 0; static void free_tx_refs(void) { for (int i = 0; i < FF_ARRAY_ELEMS(tx_refs); i++) for (int j = 0; j < FF_ARRAY_ELEMS(*tx_refs); j++) - av_tx_uninit(&tx_refs[i][j]); + for (int k = 0; k < FF_ARRAY_ELEMS(**tx_refs); k++) + av_tx_uninit(&tx_refs[i][j][k]); } -#define CHECK_TEMPLATE(PREFIX, TYPE, DATA_TYPE, SCALE, LENGTHS, CHECK_EXPRESSION) \ +#define CHECK_TEMPLATE(PREFIX, TYPE, DIR, DATA_TYPE, SCALE_TYPE, LENGTHS, CHECK_EXPRESSION) \ do { \ int err; \ AVTXContext *tx; \ av_tx_fn fn; \ int num_checks = 0; \ int last_check = 0; \ - const void *scale = &SCALE; \ \ for (int i = 0; i < FF_ARRAY_ELEMS(LENGTHS); i++) { \ int len = LENGTHS[i]; \ + const SCALE_TYPE scale = 1.0 / len; \ \ - if ((err = av_tx_init(&tx, &fn, TYPE, 0, len, &scale, 0x0)) < 0) { \ + if ((err = av_tx_init(&tx, &fn, TYPE, DIR, len, &scale, 0x0)) < 0) { \ fprintf(stderr, "av_tx: %s\n", av_err2str(err)); \ return; \ } \ \ if (check_func(fn, PREFIX "_%i", len)) { \ - AVTXContext *tx_ref = tx_refs[TYPE][i]; \ + AVTXContext *tx_ref = tx_refs[TYPE][DIR][i]; \ if (!tx_ref) \ tx_ref = tx; \ num_checks++; \ @@ -84,8 +85,8 @@ static void free_tx_refs(void) break; \ } \ bench_new(tx, out_new, in, sizeof(DATA_TYPE)); \ - av_tx_uninit(&tx_refs[TYPE][i]); \ - tx_refs[TYPE][i] = tx; \ + av_tx_uninit(&tx_refs[TYPE][DIR][i]); \ + tx_refs[TYPE][DIR][i] = tx; \ } else { \ av_tx_uninit(&tx); \ } \ @@ -99,9 +100,6 @@ static void free_tx_refs(void) void checkasm_check_av_tx(void) { - const float scale_float = 1.0f; - const double scale_double = 1.0f; - declare_func(void, AVTXContext *tx, void *out, void *in, ptrdiff_t stride); void *in = av_malloc(16384*2*8); @@ -109,11 +107,14 @@ void checkasm_check_av_tx(void) void *out_new = av_malloc(16384*2*8); randomize_complex(in, 16384, AVComplexFloat, SCALE_NOOP); - CHECK_TEMPLATE("float_fft", AV_TX_FLOAT_FFT, AVComplexFloat, scale_float, check_lens, + CHECK_TEMPLATE("float_fft", AV_TX_FLOAT_FFT, 0, AVComplexFloat, float, check_lens, !float_near_abs_eps_array(out_ref, out_new, EPS, len*2)); + CHECK_TEMPLATE("float_imdct", AV_TX_FLOAT_MDCT, 1, float, float, check_lens, + !float_near_abs_eps_array(out_ref, out_new, EPS, len)); + randomize_complex(in, 16384, AVComplexDouble, SCALE_NOOP); - CHECK_TEMPLATE("double_fft", AV_TX_DOUBLE_FFT, AVComplexDouble, scale_double, check_lens, + CHECK_TEMPLATE("double_fft", AV_TX_DOUBLE_FFT, 0, AVComplexDouble, double, check_lens, !double_near_abs_eps_array(out_ref, out_new, EPS, len*2)); av_free(in); From a89025f74d06f345ea3dc835c34c5059fe7257e5 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 6 Sep 2022 05:41:46 +0200 Subject: [PATCH 170/590] aarch64/tx_float: fix compilation Forgot to add the new function arguments. --- libavutil/aarch64/tx_float_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/aarch64/tx_float_init.c b/libavutil/aarch64/tx_float_init.c index 2e8d61f688..e7b73b4bf9 100644 --- a/libavutil/aarch64/tx_float_init.c +++ b/libavutil/aarch64/tx_float_init.c @@ -42,7 +42,7 @@ static av_cold int neon_init(AVTXContext *s, const FFTXCodelet *cd, if (cd->max_len == 2) return ff_tx_gen_ptwo_revtab(s, inv_lookup); else - return ff_tx_gen_split_radix_parity_revtab(s, inv_lookup, 8, 0); + return ff_tx_gen_split_radix_parity_revtab(s, len, inv, inv_lookup, 8, 0); } const FFTXCodelet * const ff_tx_codelet_list_float_aarch64[] = { From 0a811f8f944ae051a5e50c1435eae5eb272ef0b4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 2 Sep 2022 19:14:55 +0200 Subject: [PATCH 171/590] lavc: fix and extend AVCodecContext.hwaccel_context doxy Mention: - that it is legacy and optional (every hwaccel that uses it can also work with hwcontext, though some optional information can only be signalled throught hwaccel_context) - that it can be used for encoders (only qsvenc currently) - ownership and lifetime --- libavcodec/avcodec.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 65c8535359..7db5d1b1c5 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1388,13 +1388,26 @@ typedef struct AVCodecContext { const struct AVHWAccel *hwaccel; /** - * Hardware accelerator context. - * For some hardware accelerators, a global context needs to be - * provided by the user. In that case, this holds display-dependent - * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this. - * - encoding: unused - * - decoding: Set by user + * Legacy hardware accelerator context. + * + * For some hardware acceleration methods, the caller may use this field to + * signal hwaccel-specific data to the codec. The struct pointed to by this + * pointer is hwaccel-dependent and defined in the respective header. Please + * refer to the FFmpeg HW accelerator documentation to know how to fill + * this. + * + * In most cases this field is optional - the necessary information may also + * be provided to libavcodec through @ref hw_frames_ctx or @ref + * hw_device_ctx (see avcodec_get_hw_config()). However, in some cases it + * may be the only method of signalling some (optional) information. + * + * The struct and its contents are owned by the caller. + * + * - encoding: May be set by the caller before avcodec_open2(). Must remain + * valid until avcodec_free_context(). + * - decoding: May be set by the caller in the get_format() callback. + * Must remain valid until the next get_format() call, + * or avcodec_free_context() (whichever comes first). */ void *hwaccel_context; From cc867f2c09d2b69cee8a0eccd62aff002cbbfe11 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 2 Sep 2022 22:21:27 +0200 Subject: [PATCH 172/590] lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads This state is not refcounted, so make sure it always has a well-defined owner. Remove the block added in 091341f2ab5bd35ca1a2aae90503adc74f8d3523, as this commit also solves that issue in a more general way. --- libavcodec/pthread_frame.c | 47 ++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 08a6f98898..066269621d 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -148,6 +148,12 @@ typedef struct FrameThreadContext { * Set for the first N packets, where N is the number of threads. * While it is set, ff_thread_en/decode_frame won't return any results. */ + + /* hwaccel state is temporarily stored here in order to transfer its ownership + * to the next decoding thread without the need for extra synchronization */ + const AVHWAccel *stash_hwaccel; + void *stash_hwaccel_context; + void *stash_hwaccel_priv; } FrameThreadContext; #if FF_API_THREAD_SAFE_CALLBACKS @@ -228,9 +234,17 @@ FF_ENABLE_DEPRECATION_WARNINGS ff_thread_finish_setup(avctx); if (p->hwaccel_serializing) { + /* wipe hwaccel state to avoid stale pointers lying around; + * the state was transferred to FrameThreadContext in + * ff_thread_finish_setup(), so nothing is leaked */ + avctx->hwaccel = NULL; + avctx->hwaccel_context = NULL; + avctx->internal->hwaccel_priv_data = NULL; + p->hwaccel_serializing = 0; pthread_mutex_unlock(&p->parent->hwaccel_mutex); } + av_assert0(!avctx->hwaccel); if (p->async_serializing) { p->async_serializing = 0; @@ -294,9 +308,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, dst->color_range = src->color_range; dst->chroma_sample_location = src->chroma_sample_location; - dst->hwaccel = src->hwaccel; - dst->hwaccel_context = src->hwaccel_context; - dst->sample_rate = src->sample_rate; dst->sample_fmt = src->sample_fmt; #if FF_API_OLD_CHANNEL_LAYOUT @@ -309,8 +320,6 @@ FF_ENABLE_DEPRECATION_WARNINGS if (err < 0) return err; - dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data; - if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx || (dst->hw_frames_ctx && dst->hw_frames_ctx->data != src->hw_frames_ctx->data)) { av_buffer_unref(&dst->hw_frames_ctx); @@ -450,6 +459,12 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, pthread_mutex_unlock(&p->mutex); return err; } + + /* transfer hwaccel state stashed from previous thread, if any */ + av_assert0(!p->avctx->hwaccel); + FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel); + FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context); + FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv); } av_packet_unref(p->avpkt); @@ -655,6 +670,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) { async_lock(p->parent); } + /* save hwaccel state for passing to the next thread; + * this is done here so that this worker thread can wipe its own hwaccel + * state after decoding, without requiring synchronization */ + av_assert0(!p->parent->stash_hwaccel); + p->parent->stash_hwaccel = avctx->hwaccel; + p->parent->stash_hwaccel_context = avctx->hwaccel_context; + p->parent->stash_hwaccel_priv = avctx->internal->hwaccel_priv_data; + pthread_mutex_lock(&p->progress_mutex); if(atomic_load(&p->state) == STATE_SETUP_FINISHED){ av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n"); @@ -708,13 +731,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) park_frame_worker_threads(fctx, thread_count); - if (fctx->prev_thread && avctx->internal->hwaccel_priv_data != - fctx->prev_thread->avctx->internal->hwaccel_priv_data) { - if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n"); - } - } - for (i = 0; i < thread_count; i++) { PerThreadContext *p = &fctx->threads[i]; AVCodecContext *ctx = p->avctx; @@ -761,6 +777,13 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&fctx->threads); ff_pthread_free(fctx, thread_ctx_offsets); + /* if we have stashed hwaccel state, move it to the user-facing context, + * so it will be freed in avcodec_close() */ + av_assert0(!avctx->hwaccel); + FFSWAP(const AVHWAccel*, avctx->hwaccel, fctx->stash_hwaccel); + FFSWAP(void*, avctx->hwaccel_context, fctx->stash_hwaccel_context); + FFSWAP(void*, avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv); + av_freep(&avctx->internal->thread_ctx); } From 5a78421746e9406c388407d5625c1c416775ba54 Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 6 Sep 2022 10:07:02 -0300 Subject: [PATCH 173/590] avcodec/decode: remove superfluous initial channels fields They are internal, so there's no need to keep them around as they are just duplicate functionality. Signed-off-by: James Almer --- libavcodec/decode.c | 12 ------------ libavcodec/internal.h | 4 ---- 2 files changed, 16 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 75373989c6..2961705c9d 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -735,12 +735,6 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame) case AVMEDIA_TYPE_AUDIO: avci->initial_sample_rate = frame->sample_rate ? frame->sample_rate : avctx->sample_rate; -#if FF_API_OLD_CHANNEL_LAYOUT -FF_DISABLE_DEPRECATION_WARNINGS - avci->initial_channels = frame->ch_layout.nb_channels; - avci->initial_channel_layout = frame->channel_layout; -FF_ENABLE_DEPRECATION_WARNINGS -#endif ret = av_channel_layout_copy(&avci->initial_ch_layout, &frame->ch_layout); if (ret < 0) { av_frame_unref(frame); @@ -759,15 +753,9 @@ FF_ENABLE_DEPRECATION_WARNINGS avci->initial_height != frame->height; break; case AVMEDIA_TYPE_AUDIO: -FF_DISABLE_DEPRECATION_WARNINGS changed |= avci->initial_sample_rate != frame->sample_rate || avci->initial_sample_rate != avctx->sample_rate || -#if FF_API_OLD_CHANNEL_LAYOUT - avci->initial_channels != frame->channels || - avci->initial_channel_layout != frame->channel_layout || -#endif av_channel_layout_compare(&avci->initial_ch_layout, &frame->ch_layout); -FF_ENABLE_DEPRECATION_WARNINGS break; } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index e2a914c271..35e3dd303a 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -153,10 +153,6 @@ typedef struct AVCodecInternal { int initial_format; int initial_width, initial_height; int initial_sample_rate; -#if FF_API_OLD_CHANNEL_LAYOUT - int initial_channels; - uint64_t initial_channel_layout; -#endif AVChannelLayout initial_ch_layout; #if CONFIG_LCMS2 From d9e3cb7e73c77ccddc4d29ed5c1be3920f72c226 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sun, 4 Sep 2022 23:43:04 -0300 Subject: [PATCH 174/590] avfilter/vf_scale: overwrite the width and height expressions with the original values Instead of the potentially adjusted ones. Otherwise, if config_props() is called again and if using force_original_aspect_ratio, the already adjusted values could be altered again. Example command line scale=size=1920x1000:force_original_aspect_ratio=decrease:force_divisible_by=2 user value 1920x1000 -> 1920x798 on init_dict() -> 1918x798 on frame change when eval_mode == EVAL_MODE_INIT, which after e645a1ddb9 could be at the very first frame. Signed-off-by: James Almer --- libavfilter/vf_scale.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 996f7aaa5b..2b12cf283c 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -491,19 +491,19 @@ static int config_props(AVFilterLink *outlink) if ((ret = scale_eval_dimensions(ctx)) < 0) goto fail; - ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h, + outlink->w = scale->w; + outlink->h = scale->h; + + ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h, scale->force_original_aspect_ratio, scale->force_divisible_by); - if (scale->w > INT_MAX || - scale->h > INT_MAX || - (scale->h * inlink->w) > INT_MAX || - (scale->w * inlink->h) > INT_MAX) + if (outlink->w > INT_MAX || + outlink->h > INT_MAX || + (outlink->h * inlink->w) > INT_MAX || + (outlink->w * inlink->h) > INT_MAX) av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n"); - outlink->w = scale->w; - outlink->h = scale->h; - /* TODO: make algorithm configurable */ scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL; @@ -718,9 +718,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) goto scale; if (scale->eval_mode == EVAL_MODE_INIT) { - snprintf(buf, sizeof(buf)-1, "%d", outlink->w); + snprintf(buf, sizeof(buf) - 1, "%d", scale->w); av_opt_set(scale, "w", buf, 0); - snprintf(buf, sizeof(buf)-1, "%d", outlink->h); + snprintf(buf, sizeof(buf) - 1, "%d", scale->h); av_opt_set(scale, "h", buf, 0); ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", scale->w_expr); From e4759fa951311d7b02a26756af63f7e5b499c7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 6 Sep 2022 12:24:28 +0300 Subject: [PATCH 175/590] x86/tx_float: Fix building for platforms with a symbol prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes building for x86 macOS (both i386 and x86_64) and i386 windows. Signed-off-by: Martin Storsjö --- libavutil/x86/tx_float.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 1b9131e7fa..69f67720c1 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -744,7 +744,7 @@ cglobal fft8_float, 4, 4, 6, ctx, out, in, tmp %if %1 cglobal fft8_ns_float, 4, 4, 6, ctx, out, in, tmp - call ff_tx_fft8_asm_float_sse3 + call mangle(ff_tx_fft8_asm_float_sse3) RET %endif %endmacro @@ -784,7 +784,7 @@ cglobal fft8_float, 4, 4, 4, ctx, out, in, tmp %if %1 cglobal fft8_ns_float, 4, 4, 4, ctx, out, in, tmp - call ff_tx_fft8_asm_float_avx + call mangle(ff_tx_fft8_asm_float_avx) RET %endif %endmacro @@ -833,7 +833,7 @@ cglobal fft16_float, 4, 4, 8, ctx, out, in, tmp %if %2 cglobal fft16_ns_float, 4, 4, 8, ctx, out, in, tmp - call ff_tx_fft16_asm_float_ %+ %1 + call mangle(ff_tx_fft16_asm_float_ %+ %1) RET %endif %endmacro @@ -917,7 +917,7 @@ cglobal fft32_float, 4, 4, 16, ctx, out, in, tmp %if %2 cglobal fft32_ns_float, 4, 4, 16, ctx, out, in, tmp - call ff_tx_fft32_asm_float_ %+ %1 + call mangle(ff_tx_fft32_asm_float_ %+ %1) RET %endif %endmacro @@ -1342,7 +1342,7 @@ cglobal fft_sr_ns_float, 4, 9, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, mov lutq, [ctxq + AVTXContext.map] mov tgtq, lenq - call ff_tx_fft_sr_asm_float_ %+ %1 + call mangle(ff_tx_fft_sr_asm_float_ %+ %1) RET %endif %endmacro From da5f7799a03aa53d0ffd25572aa9c65ba8279e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 5 Sep 2022 15:17:56 +0300 Subject: [PATCH 176/590] slicethread: Limit the automatic number of threads to 16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This matches a similar cap on the number of automatic threads in libavcodec/pthread_slice.c. On systems with lots of cores, this fixes a couple fate failures in 32 bit mode on such machines (where spawning a huge number of threads runs out of address space). Signed-off-by: Martin Storsjö --- libavutil/slicethread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c index ea1c9c8311..115b099736 100644 --- a/libavutil/slicethread.c +++ b/libavutil/slicethread.c @@ -24,6 +24,8 @@ #include "thread.h" #include "avassert.h" +#define MAX_AUTO_THREADS 16 + #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS typedef struct WorkerContext { @@ -105,7 +107,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, if (!nb_threads) { int nb_cpus = av_cpu_count(); if (nb_cpus > 1) - nb_threads = nb_cpus + 1; + nb_threads = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS); else nb_threads = 1; } From 74f5fb6db899dbc4fde9ccf77f37256ddcaaaab9 Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 6 Sep 2022 14:06:03 -0300 Subject: [PATCH 177/590] x86/tx_float: set all operands for shufps Fixes compilation with AVX2 enabled yasm. Signed-off-by: James Almer --- libavutil/x86/tx_float.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 69f67720c1..6d33ee7f30 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1408,8 +1408,8 @@ cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, stride, len, lut, exp, mulps m10, m2 ; 1 reim * imim mulps m11, m3 ; 2 reim * imim - shufps m10, m10, q2301 - shufps m11, m11, q2301 + shufps m10, m10, m10, q2301 + shufps m11, m11, m11, q2301 fmaddsubps m10, m12, m2, m10 fmaddsubps m11, m13, m3, m11 From f4097e4c1f1bb244cae78c363a69d5e84495b616 Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 6 Sep 2022 14:06:33 -0300 Subject: [PATCH 178/590] x86/tx_float: add missing check for AVX2 Fixes compilation with old yasm. Signed-off-by: James Almer --- libavutil/x86/tx_float.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 6d33ee7f30..dbb04e8b4d 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1537,6 +1537,6 @@ cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, stride, len, lut, exp, RET %endmacro -%if ARCH_X86_64 +%if ARCH_X86_64 && HAVE_AVX2_EXTERNAL IMDCT_FN avx2 %endif From 8d9462844a85b0546c827a5f2c4cc7a1ba49dc9d Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sat, 3 Sep 2022 15:58:47 -0700 Subject: [PATCH 179/590] swscale/input: add support for XV36LE --- libswscale/input.c | 25 +++++++++++++++++++++++++ libswscale/utils.c | 1 + libswscale/version.h | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/libswscale/input.c b/libswscale/input.c index 92681c9c53..8032360907 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -685,6 +685,25 @@ static void read_vuya_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unuse dst[i] = src[i * 4 + 3]; } +static void read_xv36le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, + uint32_t *unused2, void *opq) +{ + int i; + for (i = 0; i < width; i++) + AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2) >> 4); +} + + +static void read_xv36le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + int i; + for (i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 0) >> 4); + AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 4) >> 4); + } +} + /* This is almost identical to the previous, end exists only because * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */ static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, @@ -1381,6 +1400,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_AYUV64LE: c->chrToYV12 = read_ayuv64le_UV_c; break; + case AV_PIX_FMT_XV36LE: + c->chrToYV12 = read_xv36le_UV_c; + break; case AV_PIX_FMT_P010LE: case AV_PIX_FMT_P210LE: case AV_PIX_FMT_P410LE: @@ -1759,6 +1781,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_AYUV64LE: c->lumToYV12 = read_ayuv64le_Y_c; break; + case AV_PIX_FMT_XV36LE: + c->lumToYV12 = read_xv36le_Y_c; + break; case AV_PIX_FMT_YUYV422: case AV_PIX_FMT_YVYU422: case AV_PIX_FMT_YA8: diff --git a/libswscale/utils.c b/libswscale/utils.c index a621a35862..a67e07b612 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -262,6 +262,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_VUYX] = { 1, 1 }, [AV_PIX_FMT_RGBAF16BE] = { 1, 0 }, [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, + [AV_PIX_FMT_XV36LE] = { 1, 0 }, }; int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, diff --git a/libswscale/version.h b/libswscale/version.h index 17264b45da..403fc8f9e7 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 104 +#define LIBSWSCALE_VERSION_MICRO 105 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ From 5bdd7261150db5d254d588f6cf8f038c149e63b5 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sun, 4 Sep 2022 15:43:23 -0700 Subject: [PATCH 180/590] swscale/input: add support for P012 As we now have three of these formats, I added macros to generate the conversion functions. --- libswscale/input.c | 123 ++++++++++++++++++++++--------------------- libswscale/utils.c | 2 + libswscale/version.h | 2 +- 3 files changed, 67 insertions(+), 60 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index 8032360907..babedfd541 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -749,67 +749,60 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, nvXXtoUV_c(dstV, dstU, src1, width); } -static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, - const uint8_t *unused2, int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6); - } -} - -static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, - const uint8_t *unused2, int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6); +#define p01x_uv_wrapper(bits, shift) \ + static void p0 ## bits ## LEToUV_c(uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *unused0, \ + const uint8_t *src1, \ + const uint8_t *src2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> shift); \ + AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> shift); \ + } \ + } \ + \ + static void p0 ## bits ## BEToUV_c(uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *unused0, \ + const uint8_t *src1, \ + const uint8_t *src2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> shift); \ + AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> shift); \ + } \ } -} -static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6); - AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6); - } -} - -static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6); - AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6); - } -} - -static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0)); - AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2)); - } -} - -static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0)); - AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2)); - } -} +#define p01x_wrapper(bits, shift) \ + static void p0 ## bits ## LEToY_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, \ + const uint8_t *unused2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> shift); \ + } \ + } \ + \ + static void p0 ## bits ## BEToY_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused1, \ + const uint8_t *unused2, int width, \ + uint32_t *unused, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> shift); \ + } \ + } \ + p01x_uv_wrapper(bits, shift) + +p01x_wrapper(10, 6); +p01x_wrapper(12, 4); +p01x_uv_wrapper(16, 0); #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos)) @@ -1413,6 +1406,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_P410BE: c->chrToYV12 = p010BEToUV_c; break; + case AV_PIX_FMT_P012LE: + c->chrToYV12 = p012LEToUV_c; + break; + case AV_PIX_FMT_P012BE: + c->chrToYV12 = p012BEToUV_c; + break; case AV_PIX_FMT_P016LE: case AV_PIX_FMT_P216LE: case AV_PIX_FMT_P416LE: @@ -1893,6 +1892,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_P410BE: c->lumToYV12 = p010BEToY_c; break; + case AV_PIX_FMT_P012LE: + c->lumToYV12 = p012LEToY_c; + break; + case AV_PIX_FMT_P012BE: + c->lumToYV12 = p012BEToY_c; + break; case AV_PIX_FMT_GRAYF32LE: c->lumToYV12 = grayf32leToY16_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index a67e07b612..a7f77cd39d 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -236,6 +236,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_AYUV64LE] = { 1, 1}, [AV_PIX_FMT_P010LE] = { 1, 1 }, [AV_PIX_FMT_P010BE] = { 1, 1 }, + [AV_PIX_FMT_P012LE] = { 1, 0 }, + [AV_PIX_FMT_P012BE] = { 1, 0 }, [AV_PIX_FMT_P016LE] = { 1, 1 }, [AV_PIX_FMT_P016BE] = { 1, 1 }, [AV_PIX_FMT_GRAYF32LE] = { 1, 1 }, diff --git a/libswscale/version.h b/libswscale/version.h index 403fc8f9e7..dd517a1fc6 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 105 +#define LIBSWSCALE_VERSION_MICRO 106 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ From 198b5b90d5ab1c48aa54e0c6f2b6acd28487b0b3 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sun, 4 Sep 2022 16:32:06 -0700 Subject: [PATCH 181/590] swscale/input: add support for XV30LE --- libswscale/input.c | 25 +++++++++++++++++++++++++ libswscale/utils.c | 1 + libswscale/version.h | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/libswscale/input.c b/libswscale/input.c index babedfd541..f4f08c8f72 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -685,6 +685,25 @@ static void read_vuya_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unuse dst[i] = src[i * 4 + 3]; } +static void read_xv30le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, + uint32_t *unused2, void *opq) +{ + int i; + for (i = 0; i < width; i++) + AV_WN16(dst + i * 2, (AV_RL32(src + i * 4) >> 10) & 0x3FFu); +} + + +static void read_xv30le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, + const uint8_t *unused1, int width, uint32_t *unused2, void *opq) +{ + int i; + for (i = 0; i < width; i++) { + AV_WN16(dstU + i * 2, AV_RL32(src + i * 4) & 0x3FFu); + AV_WN16(dstV + i * 2, (AV_RL32(src + i * 4) >> 20) & 0x3FFu); + } +} + static void read_xv36le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, const uint8_t *unused1, int width, uint32_t *unused2, void *opq) { @@ -1390,6 +1409,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_VUYX: c->chrToYV12 = read_vuyx_UV_c; break; + case AV_PIX_FMT_XV30LE: + c->chrToYV12 = read_xv30le_UV_c; + break; case AV_PIX_FMT_AYUV64LE: c->chrToYV12 = read_ayuv64le_UV_c; break; @@ -1777,6 +1799,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_VUYX: c->lumToYV12 = read_vuyx_Y_c; break; + case AV_PIX_FMT_XV30LE: + c->lumToYV12 = read_xv30le_Y_c; + break; case AV_PIX_FMT_AYUV64LE: c->lumToYV12 = read_ayuv64le_Y_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index a7f77cd39d..ab86037cd4 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -264,6 +264,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_VUYX] = { 1, 1 }, [AV_PIX_FMT_RGBAF16BE] = { 1, 0 }, [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, + [AV_PIX_FMT_XV30LE] = { 1, 0 }, [AV_PIX_FMT_XV36LE] = { 1, 0 }, }; diff --git a/libswscale/version.h b/libswscale/version.h index dd517a1fc6..d2880590a6 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 106 +#define LIBSWSCALE_VERSION_MICRO 107 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ From 4a59eba227135f90a59a412a0175c783dc0be6d5 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sun, 4 Sep 2022 16:42:32 -0700 Subject: [PATCH 182/590] swscale/input: add support for Y212LE --- libswscale/input.c | 45 +++++++++++++++++++++++++++++--------------- libswscale/utils.c | 1 + libswscale/version.h | 2 +- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index f4f08c8f72..be8f3940e1 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -559,23 +559,32 @@ static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con av_assert1(src1 == src2); } -static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, - const uint8_t *unused1, int width, uint32_t *unused2, void *opq) -{ - int i; - for (i = 0; i < width; i++) { - AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6); - AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6); +#define y21xle_wrapper(bits, shift) \ + static void y2 ## bits ## le_UV_c(uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *unused0, \ + const uint8_t *src, \ + const uint8_t *unused1, int width, \ + uint32_t *unused2, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) { \ + AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> shift); \ + AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> shift); \ + } \ + } \ + \ + static void y2 ## bits ## le_Y_c(uint8_t *dst, const uint8_t *src, \ + const uint8_t *unused0, \ + const uint8_t *unused1, int width, \ + uint32_t *unused2, void *opq) \ + { \ + int i; \ + for (i = 0; i < width; i++) \ + AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> shift); \ } -} -static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, - const uint8_t *unused1, int width, uint32_t *unused2, void *opq) -{ - int i; - for (i = 0; i < width; i++) - AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6); -} +y21xle_wrapper(10, 6); +y21xle_wrapper(12, 4); static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused, void *opq) @@ -1447,6 +1456,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_Y210LE: c->chrToYV12 = y210le_UV_c; break; + case AV_PIX_FMT_Y212LE: + c->chrToYV12 = y212le_UV_c; + break; } if (c->chrSrcHSubSample) { switch (srcFormat) { @@ -1932,6 +1944,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_Y210LE: c->lumToYV12 = y210le_Y_c; break; + case AV_PIX_FMT_Y212LE: + c->lumToYV12 = y212le_Y_c; + break; case AV_PIX_FMT_X2RGB10LE: c->lumToYV12 = rgb30leToY_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index ab86037cd4..a5a9bc589a 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -249,6 +249,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_NV24] = { 1, 1 }, [AV_PIX_FMT_NV42] = { 1, 1 }, [AV_PIX_FMT_Y210LE] = { 1, 0 }, + [AV_PIX_FMT_Y212LE] = { 1, 0 }, [AV_PIX_FMT_X2RGB10LE] = { 1, 1 }, [AV_PIX_FMT_X2BGR10LE] = { 1, 1 }, [AV_PIX_FMT_P210BE] = { 1, 1 }, diff --git a/libswscale/version.h b/libswscale/version.h index d2880590a6..908995b7b0 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 107 +#define LIBSWSCALE_VERSION_MICRO 108 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ From 8c7583b7528b11e4e86bc66b27a8a65c80cf0a93 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 01:23:00 +0200 Subject: [PATCH 183/590] avcodec/dvdata: Order code table by codes Right now, it is nearly ordered by "left codes in the tree first"; the only exception is the escape value which has been put at the end. This commit moves it to the place it should have according to the above order. This is in preparation for further commits. Signed-off-by: Andreas Rheinhardt --- libavcodec/dv_tablegen.h | 2 +- libavcodec/dvdata.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/dv_tablegen.h b/libavcodec/dv_tablegen.h index 941b5572be..0dcfffc140 100644 --- a/libavcodec/dv_tablegen.h +++ b/libavcodec/dv_tablegen.h @@ -51,7 +51,7 @@ static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]; static av_cold void dv_vlc_map_tableinit(void) { int i, j; - for (i = 0; i < NB_DV_VLC - 1; i++) { + for (int i = 0; i < NB_DV_VLC; i++) { if (ff_dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE) continue; #if CONFIG_SMALL diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c index 231569a328..1e48db591d 100644 --- a/libavcodec/dvdata.c +++ b/libavcodec/dvdata.c @@ -75,7 +75,7 @@ const uint8_t ff_dv_quant_offset[4] = { 6, 3, 0, 1 }; * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82. */ const uint16_t ff_dv_vlc_bits[NB_DV_VLC] = { - 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016, + 0x0000, 0x0002, 0x0006, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016, 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, @@ -126,11 +126,10 @@ const uint16_t ff_dv_vlc_bits[NB_DV_VLC] = { 0x7fe8, 0x7fe9, 0x7fea, 0x7feb, 0x7fec, 0x7fed, 0x7fee, 0x7fef, 0x7ff0, 0x7ff1, 0x7ff2, 0x7ff3, 0x7ff4, 0x7ff5, 0x7ff6, 0x7ff7, 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff, - 0x0006, }; const uint8_t ff_dv_vlc_len[NB_DV_VLC] = { - 2, 3, 4, 4, 4, 5, 5, 5, + 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, @@ -181,11 +180,10 @@ const uint8_t ff_dv_vlc_len[NB_DV_VLC] = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 4, }; const uint8_t ff_dv_vlc_run[NB_DV_VLC] = { - 0, 0, 1, 0, 0, 2, 1, 0, + 0, 0, 127, 1, 0, 0, 2, 1, 0, 0, 3, 4, 0, 0, 5, 6, 2, 1, 1, 0, 0, 0, 7, 8, 9, 10, 3, 4, 2, 1, 1, 1, 0, @@ -236,11 +234,10 @@ const uint8_t ff_dv_vlc_run[NB_DV_VLC] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 127, }; const uint8_t ff_dv_vlc_level[NB_DV_VLC] = { - 1, 2, 1, 3, 4, 1, 2, 5, + 1, 2, 0, 1, 3, 4, 1, 2, 5, 6, 1, 1, 7, 8, 1, 1, 2, 3, 4, 9, 10, 11, 1, 1, 1, 1, 2, 2, 3, 5, 6, 7, 12, @@ -291,5 +288,4 @@ const uint8_t ff_dv_vlc_level[NB_DV_VLC] = { 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, - 0, }; From 297e91ed2b3b51ec3bfa63a4c955941ba68a2419 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 01:40:38 +0200 Subject: [PATCH 184/590] avcodec/dvdec: Use ff_init_vlc_from_lengths() This is possible because the codes are already ordered from left to right in the tree. It avoids having to create the codes ourselves and will enable the codes table to be removed altogether once the encoder stops using it. Signed-off-by: Andreas Rheinhardt --- libavcodec/dvdec.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 28dbe8c11a..9d521525a3 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -152,7 +152,6 @@ static void dv_init_static(void) { VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 }; VLC dv_vlc = { .table = vlc_buf, .table_allocated = FF_ARRAY_ELEMS(vlc_buf) }; - uint16_t new_dv_vlc_bits[NB_DV_VLC * 2]; uint8_t new_dv_vlc_len[NB_DV_VLC * 2]; uint8_t new_dv_vlc_run[NB_DV_VLC * 2]; int16_t new_dv_vlc_level[NB_DV_VLC * 2]; @@ -160,17 +159,14 @@ static void dv_init_static(void) /* it's faster to include sign bit in a generic VLC parsing scheme */ for (i = 0, j = 0; i < NB_DV_VLC; i++, j++) { - new_dv_vlc_bits[j] = ff_dv_vlc_bits[i]; new_dv_vlc_len[j] = ff_dv_vlc_len[i]; new_dv_vlc_run[j] = ff_dv_vlc_run[i]; new_dv_vlc_level[j] = ff_dv_vlc_level[i]; if (ff_dv_vlc_level[i]) { - new_dv_vlc_bits[j] <<= 1; new_dv_vlc_len[j]++; j++; - new_dv_vlc_bits[j] = (ff_dv_vlc_bits[i] << 1) | 1; new_dv_vlc_len[j] = ff_dv_vlc_len[i] + 1; new_dv_vlc_run[j] = ff_dv_vlc_run[i]; new_dv_vlc_level[j] = -ff_dv_vlc_level[i]; @@ -179,8 +175,9 @@ static void dv_init_static(void) /* NOTE: as a trick, we use the fact the no codes are unused * to accelerate the parsing of partial codes */ - init_vlc(&dv_vlc, TEX_VLC_BITS, j, new_dv_vlc_len, - 1, 1, new_dv_vlc_bits, 2, 2, INIT_VLC_USE_NEW_STATIC); + ff_init_vlc_from_lengths(&dv_vlc, TEX_VLC_BITS, j, + new_dv_vlc_len, 1, + NULL, 0, 0, 0, INIT_VLC_USE_NEW_STATIC, NULL); av_assert1(dv_vlc.table_size == 1664); for (int i = 0; i < dv_vlc.table_size; i++) { From 116e2a9ee2c9eb7eaa99af9a066bcc37825721c7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 02:03:08 +0200 Subject: [PATCH 185/590] avcodec/dv_tablegen, dvdata: Remove ff_dv_vlc_bits The codes can be easily calculated, so the table is unnecessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/dv_tablegen.h | 5 +++- libavcodec/dvdata.c | 54 ---------------------------------------- libavcodec/dvdata.h | 1 - 3 files changed, 4 insertions(+), 56 deletions(-) diff --git a/libavcodec/dv_tablegen.h b/libavcodec/dv_tablegen.h index 0dcfffc140..7f0ab53fa7 100644 --- a/libavcodec/dv_tablegen.h +++ b/libavcodec/dv_tablegen.h @@ -50,8 +50,11 @@ static struct dv_vlc_pair dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE]; static av_cold void dv_vlc_map_tableinit(void) { + uint32_t code = 0; int i, j; for (int i = 0; i < NB_DV_VLC; i++) { + uint32_t cur_code = code >> (32 - ff_dv_vlc_len[i]); + code += 1U << (32 - ff_dv_vlc_len[i]); if (ff_dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE) continue; #if CONFIG_SMALL @@ -63,7 +66,7 @@ static av_cold void dv_vlc_map_tableinit(void) continue; dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].vlc = - ff_dv_vlc_bits[i] << (!!ff_dv_vlc_level[i]); + cur_code << (!!ff_dv_vlc_level[i]); dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].size = ff_dv_vlc_len[i] + (!!ff_dv_vlc_level[i]); } diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c index 1e48db591d..0cd10aed10 100644 --- a/libavcodec/dvdata.c +++ b/libavcodec/dvdata.c @@ -74,60 +74,6 @@ const uint8_t ff_dv_quant_offset[4] = { 6, 3, 0, 1 }; * between (run, level) and vlc is not 1-1. So you have to watch out for that * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82. */ -const uint16_t ff_dv_vlc_bits[NB_DV_VLC] = { - 0x0000, 0x0002, 0x0006, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016, - 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a, - 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2, - 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, - 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x01e0, 0x01e1, 0x01e2, - 0x01e3, 0x01e4, 0x01e5, 0x01e6, 0x01e7, 0x01e8, 0x01e9, 0x01ea, - 0x01eb, 0x01ec, 0x01ed, 0x01ee, 0x01ef, 0x03e0, 0x03e1, 0x03e2, - 0x03e3, 0x03e4, 0x03e5, 0x03e6, 0x07ce, 0x07cf, 0x07d0, 0x07d1, - 0x07d2, 0x07d3, 0x07d4, 0x07d5, 0x0fac, 0x0fad, 0x0fae, 0x0faf, - 0x0fb0, 0x0fb1, 0x0fb2, 0x0fb3, 0x0fb4, 0x0fb5, 0x0fb6, 0x0fb7, - 0x0fb8, 0x0fb9, 0x0fba, 0x0fbb, 0x0fbc, 0x0fbd, 0x0fbe, 0x0fbf, - 0x1f80, 0x1f81, 0x1f82, 0x1f83, 0x1f84, 0x1f85, 0x1f86, 0x1f87, - 0x1f88, 0x1f89, 0x1f8a, 0x1f8b, 0x1f8c, 0x1f8d, 0x1f8e, 0x1f8f, - 0x1f90, 0x1f91, 0x1f92, 0x1f93, 0x1f94, 0x1f95, 0x1f96, 0x1f97, - 0x1f98, 0x1f99, 0x1f9a, 0x1f9b, 0x1f9c, 0x1f9d, 0x1f9e, 0x1f9f, - 0x1fa0, 0x1fa1, 0x1fa2, 0x1fa3, 0x1fa4, 0x1fa5, 0x1fa6, 0x1fa7, - 0x1fa8, 0x1fa9, 0x1faa, 0x1fab, 0x1fac, 0x1fad, 0x1fae, 0x1faf, - 0x1fb0, 0x1fb1, 0x1fb2, 0x1fb3, 0x1fb4, 0x1fb5, 0x1fb6, 0x1fb7, - 0x1fb8, 0x1fb9, 0x1fba, 0x1fbb, 0x1fbc, 0x1fbd, 0x1fbe, 0x1fbf, - 0x7f00, 0x7f01, 0x7f02, 0x7f03, 0x7f04, 0x7f05, 0x7f06, 0x7f07, - 0x7f08, 0x7f09, 0x7f0a, 0x7f0b, 0x7f0c, 0x7f0d, 0x7f0e, 0x7f0f, - 0x7f10, 0x7f11, 0x7f12, 0x7f13, 0x7f14, 0x7f15, 0x7f16, 0x7f17, - 0x7f18, 0x7f19, 0x7f1a, 0x7f1b, 0x7f1c, 0x7f1d, 0x7f1e, 0x7f1f, - 0x7f20, 0x7f21, 0x7f22, 0x7f23, 0x7f24, 0x7f25, 0x7f26, 0x7f27, - 0x7f28, 0x7f29, 0x7f2a, 0x7f2b, 0x7f2c, 0x7f2d, 0x7f2e, 0x7f2f, - 0x7f30, 0x7f31, 0x7f32, 0x7f33, 0x7f34, 0x7f35, 0x7f36, 0x7f37, - 0x7f38, 0x7f39, 0x7f3a, 0x7f3b, 0x7f3c, 0x7f3d, 0x7f3e, 0x7f3f, - 0x7f40, 0x7f41, 0x7f42, 0x7f43, 0x7f44, 0x7f45, 0x7f46, 0x7f47, - 0x7f48, 0x7f49, 0x7f4a, 0x7f4b, 0x7f4c, 0x7f4d, 0x7f4e, 0x7f4f, - 0x7f50, 0x7f51, 0x7f52, 0x7f53, 0x7f54, 0x7f55, 0x7f56, 0x7f57, - 0x7f58, 0x7f59, 0x7f5a, 0x7f5b, 0x7f5c, 0x7f5d, 0x7f5e, 0x7f5f, - 0x7f60, 0x7f61, 0x7f62, 0x7f63, 0x7f64, 0x7f65, 0x7f66, 0x7f67, - 0x7f68, 0x7f69, 0x7f6a, 0x7f6b, 0x7f6c, 0x7f6d, 0x7f6e, 0x7f6f, - 0x7f70, 0x7f71, 0x7f72, 0x7f73, 0x7f74, 0x7f75, 0x7f76, 0x7f77, - 0x7f78, 0x7f79, 0x7f7a, 0x7f7b, 0x7f7c, 0x7f7d, 0x7f7e, 0x7f7f, - 0x7f80, 0x7f81, 0x7f82, 0x7f83, 0x7f84, 0x7f85, 0x7f86, 0x7f87, - 0x7f88, 0x7f89, 0x7f8a, 0x7f8b, 0x7f8c, 0x7f8d, 0x7f8e, 0x7f8f, - 0x7f90, 0x7f91, 0x7f92, 0x7f93, 0x7f94, 0x7f95, 0x7f96, 0x7f97, - 0x7f98, 0x7f99, 0x7f9a, 0x7f9b, 0x7f9c, 0x7f9d, 0x7f9e, 0x7f9f, - 0x7fa0, 0x7fa1, 0x7fa2, 0x7fa3, 0x7fa4, 0x7fa5, 0x7fa6, 0x7fa7, - 0x7fa8, 0x7fa9, 0x7faa, 0x7fab, 0x7fac, 0x7fad, 0x7fae, 0x7faf, - 0x7fb0, 0x7fb1, 0x7fb2, 0x7fb3, 0x7fb4, 0x7fb5, 0x7fb6, 0x7fb7, - 0x7fb8, 0x7fb9, 0x7fba, 0x7fbb, 0x7fbc, 0x7fbd, 0x7fbe, 0x7fbf, - 0x7fc0, 0x7fc1, 0x7fc2, 0x7fc3, 0x7fc4, 0x7fc5, 0x7fc6, 0x7fc7, - 0x7fc8, 0x7fc9, 0x7fca, 0x7fcb, 0x7fcc, 0x7fcd, 0x7fce, 0x7fcf, - 0x7fd0, 0x7fd1, 0x7fd2, 0x7fd3, 0x7fd4, 0x7fd5, 0x7fd6, 0x7fd7, - 0x7fd8, 0x7fd9, 0x7fda, 0x7fdb, 0x7fdc, 0x7fdd, 0x7fde, 0x7fdf, - 0x7fe0, 0x7fe1, 0x7fe2, 0x7fe3, 0x7fe4, 0x7fe5, 0x7fe6, 0x7fe7, - 0x7fe8, 0x7fe9, 0x7fea, 0x7feb, 0x7fec, 0x7fed, 0x7fee, 0x7fef, - 0x7ff0, 0x7ff1, 0x7ff2, 0x7ff3, 0x7ff4, 0x7ff5, 0x7ff6, 0x7ff7, - 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff, -}; - const uint8_t ff_dv_vlc_len[NB_DV_VLC] = { 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h index e0ed043c47..ae104096ad 100644 --- a/libavcodec/dvdata.h +++ b/libavcodec/dvdata.h @@ -28,7 +28,6 @@ extern const uint8_t ff_dv_quant_offset[4]; #define NB_DV_VLC 409 -extern const uint16_t ff_dv_vlc_bits[NB_DV_VLC]; extern const uint8_t ff_dv_vlc_len[NB_DV_VLC]; extern const uint8_t ff_dv_vlc_run[NB_DV_VLC]; extern const uint8_t ff_dv_vlc_level[NB_DV_VLC]; From 1fa535e8f3cb1a4fcec71c39e55b6ba997c0b83e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 02:09:35 +0200 Subject: [PATCH 186/590] avcodec/dvdec: Mark dv_init_static() as av_cold Forgotten in 6d484671ecb612c32cbda0fab65f961743aff5f8. Signed-off-by: Andreas Rheinhardt --- libavcodec/dvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 9d521525a3..7692300bdd 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -148,7 +148,7 @@ static const uint16_t dv_iweight_720_c[64] = { /* XXX: also include quantization */ static RL_VLC_ELEM dv_rl_vlc[1664]; -static void dv_init_static(void) +static av_cold void dv_init_static(void) { VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 }; VLC dv_vlc = { .table = vlc_buf, .table_allocated = FF_ARRAY_ELEMS(vlc_buf) }; From 51ca74b52593bcb1a74083875b688f889cf9b520 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 04:16:17 +0200 Subject: [PATCH 187/590] avcodec/dvdec: Avoid stack buffers Instead reuse the destination RL VLC as scratch space. This is possible, because the (implicit) codes here are already ordered from left-to-right in the tree and because the codelengths are increasing, which implies that mapping from VLC entries to the corresponding entries used to initialize the VLC is monotonically increasing. This means that one can reuse the right end of the destination RL VLC to store the tables used to initialize the VLC with. Signed-off-by: Andreas Rheinhardt --- libavcodec/dvdata.h | 2 ++ libavcodec/dvdec.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h index ae104096ad..31191a8475 100644 --- a/libavcodec/dvdata.h +++ b/libavcodec/dvdata.h @@ -27,6 +27,8 @@ extern const uint8_t ff_dv_quant_shifts[22][4]; extern const uint8_t ff_dv_quant_offset[4]; #define NB_DV_VLC 409 +/* The number of entries with value zero in ff_dv_vlc_level. */ +#define NB_DV_ZERO_LEVEL_ENTRIES 72 extern const uint8_t ff_dv_vlc_len[NB_DV_VLC]; extern const uint8_t ff_dv_vlc_run[NB_DV_VLC]; diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 7692300bdd..afc4bb0bcd 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -152,31 +152,30 @@ static av_cold void dv_init_static(void) { VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 }; VLC dv_vlc = { .table = vlc_buf, .table_allocated = FF_ARRAY_ELEMS(vlc_buf) }; - uint8_t new_dv_vlc_len[NB_DV_VLC * 2]; - uint8_t new_dv_vlc_run[NB_DV_VLC * 2]; - int16_t new_dv_vlc_level[NB_DV_VLC * 2]; + const unsigned offset = FF_ARRAY_ELEMS(dv_rl_vlc) - (2 * NB_DV_VLC - NB_DV_ZERO_LEVEL_ENTRIES); + RL_VLC_ELEM *tmp = dv_rl_vlc + offset; int i, j; /* it's faster to include sign bit in a generic VLC parsing scheme */ for (i = 0, j = 0; i < NB_DV_VLC; i++, j++) { - new_dv_vlc_len[j] = ff_dv_vlc_len[i]; - new_dv_vlc_run[j] = ff_dv_vlc_run[i]; - new_dv_vlc_level[j] = ff_dv_vlc_level[i]; + tmp[j].len = ff_dv_vlc_len[i]; + tmp[j].run = ff_dv_vlc_run[i]; + tmp[j].level = ff_dv_vlc_level[i]; if (ff_dv_vlc_level[i]) { - new_dv_vlc_len[j]++; + tmp[j].len++; j++; - new_dv_vlc_len[j] = ff_dv_vlc_len[i] + 1; - new_dv_vlc_run[j] = ff_dv_vlc_run[i]; - new_dv_vlc_level[j] = -ff_dv_vlc_level[i]; + tmp[j].len = ff_dv_vlc_len[i] + 1; + tmp[j].run = ff_dv_vlc_run[i]; + tmp[j].level = -ff_dv_vlc_level[i]; } } /* NOTE: as a trick, we use the fact the no codes are unused * to accelerate the parsing of partial codes */ ff_init_vlc_from_lengths(&dv_vlc, TEX_VLC_BITS, j, - new_dv_vlc_len, 1, + &tmp[0].len, sizeof(tmp[0]), NULL, 0, 0, 0, INIT_VLC_USE_NEW_STATIC, NULL); av_assert1(dv_vlc.table_size == 1664); @@ -189,8 +188,9 @@ static av_cold void dv_init_static(void) run = 0; level = code; } else { - run = new_dv_vlc_run[code] + 1; - level = new_dv_vlc_level[code]; + av_assert1(i <= code + offset); + run = tmp[code].run + 1; + level = tmp[code].level; } dv_rl_vlc[i].len = len; dv_rl_vlc[i].level = level; From af847fe000f9eb78e3aa013ee64ab2274bfd5e68 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 19:38:38 +0200 Subject: [PATCH 188/590] avcodec/wmavoice: Avoid code table These codes are already ordered from left-to-right in the tree, so one can just use ff_init_vlc_static_from_lengths(). Signed-off-by: Andreas Rheinhardt --- libavcodec/wmavoice.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 8fa9db63ee..4438089e51 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -320,18 +320,10 @@ static av_cold void wmavoice_init_static_data(void) 10, 10, 10, 12, 12, 12, 14, 14, 14, 14 }; - static const uint16_t codes[] = { - 0x0000, 0x0001, 0x0002, // 00/01/10 - 0x000c, 0x000d, 0x000e, // 11+00/01/10 - 0x003c, 0x003d, 0x003e, // 1111+00/01/10 - 0x00fc, 0x00fd, 0x00fe, // 111111+00/01/10 - 0x03fc, 0x03fd, 0x03fe, // 11111111+00/01/10 - 0x0ffc, 0x0ffd, 0x0ffe, // 1111111111+00/01/10 - 0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // 111111111111+xx - }; - INIT_VLC_STATIC(&frame_type_vlc, VLC_NBITS, sizeof(bits), - bits, 1, 1, codes, 2, 2, 132); + INIT_VLC_STATIC_FROM_LENGTHS(&frame_type_vlc, VLC_NBITS, + FF_ARRAY_ELEMS(bits), bits, + 1, NULL, 0, 0, 0, 0, 132); } static av_cold void wmavoice_flush(AVCodecContext *ctx) From f050bc0506643cf2a7211634b4ba3310fa290190 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 21:03:21 +0200 Subject: [PATCH 189/590] avcodec/wmaprodec: Use ff_init_vlc_from_lengths() instead of init_vlc It allows to replace tables of big codes (uint16_t and uint32_t) by tables of smaller symbols (mostly uint8_t). Signed-off-by: Andreas Rheinhardt --- libavcodec/wmaprodata.h | 551 ++++++++++++++++------------------------ libavcodec/wmaprodec.c | 42 +-- 2 files changed, 236 insertions(+), 357 deletions(-) diff --git a/libavcodec/wmaprodata.h b/libavcodec/wmaprodata.h index 53824799d5..3a30be40b5 100644 --- a/libavcodec/wmaprodata.h +++ b/libavcodec/wmaprodata.h @@ -48,42 +48,32 @@ static const uint16_t critical_freq[] = { */ #define HUFF_SCALE_SIZE 121 #define HUFF_SCALE_MAXBITS 19 -static const uint16_t scale_huffcodes[HUFF_SCALE_SIZE] = { - 0xE639, 0xE6C2, 0xE6C1, 0xE6C0, 0xE63F, 0xE63E, 0xE63D, 0xE63C, - 0xE63B, 0xE63A, 0xE638, 0xE637, 0xE636, 0xE635, 0xE634, 0xE632, - 0xE633, 0xE620, 0x737B, 0xE610, 0xE611, 0xE612, 0xE613, 0xE614, - 0xE615, 0xE616, 0xE617, 0xE618, 0xE619, 0xE61A, 0xE61B, 0xE61C, - 0xE61D, 0xE61E, 0xE61F, 0xE6C3, 0xE621, 0xE622, 0xE623, 0xE624, - 0xE625, 0xE626, 0xE627, 0xE628, 0xE629, 0xE62A, 0xE62B, 0xE62C, - 0xE62D, 0xE62E, 0xE62F, 0xE630, 0xE631, 0x1CDF, 0x0E60, 0x0399, - 0x00E7, 0x001D, 0x0000, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006, - 0x0002, 0x0007, 0x0006, 0x000F, 0x0038, 0x0072, 0x039A, 0xE6C4, - 0xE6C5, 0xE6C6, 0xE6C7, 0xE6C8, 0xE6C9, 0xE6CA, 0xE6CB, 0xE6CC, - 0xE6CD, 0xE6CE, 0xE6CF, 0xE6D0, 0xE6D1, 0xE6D2, 0xE6D3, 0xE6D4, - 0xE6D5, 0xE6D6, 0xE6D7, 0xE6D8, 0xE6D9, 0xE6DA, 0xE6DB, 0xE6DC, - 0xE6DD, 0xE6DE, 0xE6DF, 0xE6E0, 0xE6E1, 0xE6E2, 0xE6E3, 0xE6E4, - 0xE6E5, 0xE6E6, 0xE6E7, 0xE6E8, 0xE6E9, 0xE6EA, 0xE6EB, 0xE6EC, - 0xE6ED, 0xE6EE, 0xE6EF, 0xE6F0, 0xE6F1, 0xE6F2, 0xE6F3, 0xE6F4, - 0xE6F5, -}; - -static const uint8_t scale_huffbits[HUFF_SCALE_SIZE] = { - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 18, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 16, 15, 13, - 11, 8, 5, 2, 1, 3, 5, 6, - 6, 7, 7, 7, 9, 10, 13, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, - 19, +static const uint8_t scale_table[HUFF_SCALE_SIZE][2] = { + { 58, 5 }, { 64, 6 }, { 66, 7 }, { 65, 7 }, { 62, 5 }, + { 63, 6 }, { 68, 9 }, { 69, 10 }, { 54, 15 }, { 19, 19 }, + { 20, 19 }, { 21, 19 }, { 22, 19 }, { 23, 19 }, { 24, 19 }, + { 25, 19 }, { 26, 19 }, { 27, 19 }, { 28, 19 }, { 29, 19 }, + { 30, 19 }, { 31, 19 }, { 32, 19 }, { 33, 19 }, { 34, 19 }, + { 17, 19 }, { 36, 19 }, { 37, 19 }, { 38, 19 }, { 39, 19 }, + { 40, 19 }, { 41, 19 }, { 42, 19 }, { 43, 19 }, { 44, 19 }, + { 45, 19 }, { 46, 19 }, { 47, 19 }, { 48, 19 }, { 49, 19 }, + { 50, 19 }, { 51, 19 }, { 52, 19 }, { 15, 19 }, { 16, 19 }, + { 14, 19 }, { 13, 19 }, { 12, 19 }, { 11, 19 }, { 10, 19 }, + { 0, 19 }, { 9, 19 }, { 8, 19 }, { 7, 19 }, { 6, 19 }, + { 5, 19 }, { 4, 19 }, { 55, 13 }, { 70, 13 }, { 3, 19 }, + { 2, 19 }, { 1, 19 }, { 35, 19 }, { 71, 19 }, { 72, 19 }, + { 73, 19 }, { 74, 19 }, { 75, 19 }, { 76, 19 }, { 77, 19 }, + { 78, 19 }, { 79, 19 }, { 80, 19 }, { 81, 19 }, { 82, 19 }, + { 83, 19 }, { 84, 19 }, { 85, 19 }, { 86, 19 }, { 87, 19 }, + { 88, 19 }, { 89, 19 }, { 90, 19 }, { 91, 19 }, { 92, 19 }, + { 93, 19 }, { 94, 19 }, { 95, 19 }, { 96, 19 }, { 97, 19 }, + { 98, 19 }, { 99, 19 }, { 100, 19 }, { 101, 19 }, { 102, 19 }, + { 103, 19 }, { 104, 19 }, { 105, 19 }, { 106, 19 }, { 107, 19 }, + { 108, 19 }, { 109, 19 }, { 110, 19 }, { 111, 19 }, { 112, 19 }, + { 113, 19 }, { 114, 19 }, { 115, 19 }, { 116, 19 }, { 117, 19 }, + { 118, 19 }, { 119, 19 }, { 120, 19 }, { 18, 18 }, { 53, 16 }, + { 56, 11 }, { 57, 8 }, { 67, 7 }, { 61, 3 }, { 59, 2 }, + { 60, 1 }, }; /** @} */ @@ -94,46 +84,31 @@ static const uint8_t scale_huffbits[HUFF_SCALE_SIZE] = { */ #define HUFF_SCALE_RL_SIZE 120 #define HUFF_SCALE_RL_MAXBITS 21 -static const uint32_t scale_rl_huffcodes[HUFF_SCALE_RL_SIZE] = { - 0x00010C, 0x000001, 0x10FE2A, 0x000003, 0x000003, 0x000001, 0x000013, - 0x000020, 0x000029, 0x000014, 0x000016, 0x000045, 0x000049, 0x00002F, - 0x000042, 0x00008E, 0x00008F, 0x000129, 0x000009, 0x00000D, 0x0004AC, - 0x00002C, 0x000561, 0x0002E6, 0x00087C, 0x0002E2, 0x00095C, 0x000018, - 0x000001, 0x000016, 0x000044, 0x00002A, 0x000007, 0x000159, 0x000143, - 0x000128, 0x00015A, 0x00012D, 0x00002B, 0x0000A0, 0x000142, 0x00012A, - 0x0002EF, 0x0004AF, 0x00087D, 0x004AE9, 0x0043F9, 0x000067, 0x000199, - 0x002B05, 0x001583, 0x0021FE, 0x10FE2C, 0x000004, 0x00002E, 0x00010D, - 0x00000A, 0x000244, 0x000017, 0x000245, 0x000011, 0x00010E, 0x00012C, - 0x00002A, 0x00002F, 0x000121, 0x000046, 0x00087E, 0x0000BA, 0x000032, - 0x0087F0, 0x0056DC, 0x0002EC, 0x0043FA, 0x002B6F, 0x004AE8, 0x0002B7, - 0x10FE2B, 0x000001, 0x000051, 0x000010, 0x0002EE, 0x000B9C, 0x002576, - 0x000198, 0x0056DD, 0x0000CD, 0x000AC0, 0x000170, 0x004AEF, 0x00002D, - 0x0004AD, 0x0021FF, 0x0005CF, 0x002B04, 0x10FE29, 0x10FE28, 0x0002ED, - 0x002E74, 0x021FC4, 0x004AEE, 0x010FE3, 0x087F17, 0x000000, 0x000097, - 0x0002E3, 0x000ADA, 0x002575, 0x00173B, 0x0043FB, 0x002E75, 0x10FE2D, - 0x0015B6, 0x00056C, 0x000057, 0x000123, 0x000120, 0x00021E, 0x000172, - 0x0002B1, -}; - -static const uint8_t scale_rl_huffbits[HUFF_SCALE_RL_SIZE] = { - 9, 2, 21, 2, 4, 5, 5, - 6, 6, 7, 7, 7, 7, 6, - 7, 8, 8, 9, 10, 10, 11, - 12, 11, 12, 12, 12, 12, 11, - 4, 5, 7, 8, 9, 9, 9, - 9, 9, 9, 8, 8, 9, 9, - 12, 11, 12, 15, 15, 13, 15, - 14, 13, 14, 21, 5, 6, 9, - 10, 10, 11, 10, 11, 9, 9, - 6, 8, 9, 7, 12, 10, 12, - 16, 15, 12, 15, 14, 15, 10, - 21, 6, 7, 11, 12, 14, 14, - 15, 15, 14, 12, 11, 15, 12, - 11, 14, 13, 14, 21, 21, 12, - 16, 18, 15, 17, 20, 7, 8, - 12, 12, 14, 15, 15, 16, 21, - 13, 11, 7, 9, 9, 10, 11, - 10, +static const uint8_t scale_rl_table[HUFF_SCALE_RL_SIZE][2] = { + { 103, 7 }, { 80, 11 }, { 60, 11 }, { 18, 10 }, { 56, 10 }, + { 21, 12 }, { 90, 12 }, { 58, 11 }, { 27, 11 }, { 69, 12 }, + { 84, 15 }, { 48, 15 }, { 86, 14 }, { 47, 13 }, { 19, 10 }, + { 32, 9 }, { 78, 6 }, { 5, 5 }, { 28, 4 }, { 53, 5 }, + { 9, 7 }, { 31, 8 }, { 38, 8 }, { 10, 7 }, { 88, 11 }, + { 25, 12 }, { 105, 12 }, { 118, 11 }, { 23, 12 }, { 82, 14 }, + { 98, 16 }, { 110, 16 }, { 108, 15 }, { 93, 13 }, { 68, 10 }, + { 72, 12 }, { 97, 12 }, { 81, 12 }, { 42, 12 }, { 64, 8 }, + { 4, 4 }, { 1, 2 }, { 7, 6 }, { 14, 7 }, { 0, 9 }, + { 55, 9 }, { 61, 9 }, { 117, 10 }, { 24, 12 }, { 44, 12 }, + { 67, 12 }, { 70, 16 }, { 99, 18 }, { 96, 21 }, { 95, 21 }, + { 2, 21 }, { 77, 21 }, { 52, 21 }, { 111, 21 }, { 102, 20 }, + { 101, 17 }, { 46, 15 }, { 73, 15 }, { 109, 15 }, { 51, 14 }, + { 92, 14 }, { 30, 7 }, { 11, 7 }, { 66, 7 }, { 15, 8 }, + { 16, 8 }, { 116, 9 }, { 65, 9 }, { 57, 10 }, { 59, 10 }, + { 115, 9 }, { 12, 7 }, { 35, 9 }, { 17, 9 }, { 41, 9 }, + { 20, 11 }, { 91, 11 }, { 26, 12 }, { 75, 15 }, { 45, 15 }, + { 107, 14 }, { 83, 14 }, { 100, 15 }, { 89, 15 }, { 43, 11 }, + { 62, 9 }, { 37, 9 }, { 104, 8 }, { 6, 5 }, { 39, 8 }, + { 40, 9 }, { 34, 9 }, { 79, 7 }, { 8, 6 }, { 63, 6 }, + { 87, 12 }, { 94, 14 }, { 49, 14 }, { 50, 13 }, { 22, 11 }, + { 119, 10 }, { 33, 9 }, { 36, 9 }, { 113, 11 }, { 106, 12 }, + { 112, 13 }, { 71, 15 }, { 85, 15 }, { 74, 14 }, { 76, 10 }, + { 114, 7 }, { 29, 5 }, { 54, 6 }, { 13, 6 }, { 3, 2 }, }; @@ -165,167 +140,99 @@ static const uint8_t scale_rl_level[HUFF_SCALE_RL_SIZE] = { */ #define HUFF_COEF0_SIZE 272 #define HUFF_COEF0_MAXBITS 21 -static const uint32_t coef0_huffcodes[HUFF_COEF0_SIZE] = { - 0x00004A, 0x00002B, 0x000000, 0x000003, 0x000006, 0x000009, 0x00000F, - 0x000010, 0x000016, 0x000011, 0x000016, 0x000028, 0x00002F, 0x000026, - 0x000029, 0x000045, 0x000055, 0x00005D, 0x000042, 0x00004E, 0x000051, - 0x00005E, 0x00008D, 0x0000A8, 0x0000AD, 0x000080, 0x000096, 0x00009F, - 0x0000AA, 0x0000BE, 0x00011C, 0x000153, 0x000158, 0x000170, 0x000104, - 0x00010D, 0x000105, 0x000103, 0x00012F, 0x000177, 0x000175, 0x000157, - 0x000174, 0x000225, 0x00023B, 0x00020D, 0x00021F, 0x000281, 0x00027B, - 0x000282, 0x0002AC, 0x0002FD, 0x00044F, 0x000478, 0x00044D, 0x0002EC, - 0x00044E, 0x000564, 0x000409, 0x00040B, 0x000501, 0x000545, 0x0004F3, - 0x000541, 0x00043B, 0x0004F1, 0x0004F4, 0x0008FD, 0x000A94, 0x000811, - 0x000B88, 0x000B91, 0x000B93, 0x0008EA, 0x000899, 0x000B8A, 0x000972, - 0x0009E5, 0x000A8F, 0x000A84, 0x000A8E, 0x000A00, 0x000830, 0x0008E8, - 0x000B95, 0x000871, 0x00083A, 0x000814, 0x000873, 0x000BFE, 0x001728, - 0x001595, 0x001712, 0x00102A, 0x001021, 0x001729, 0x00152E, 0x0013C3, - 0x001721, 0x001597, 0x00151B, 0x0010F2, 0x001403, 0x001703, 0x001503, - 0x001708, 0x0013C1, 0x00170E, 0x00170C, 0x0010E1, 0x0011EA, 0x001020, - 0x001500, 0x0017FA, 0x001704, 0x001705, 0x0017F0, 0x0017FB, 0x0021E6, - 0x002B2D, 0x0020C6, 0x002B29, 0x002E4A, 0x0023AC, 0x001519, 0x0023F3, - 0x002B2C, 0x0021C0, 0x0017FE, 0x0023D7, 0x0017F9, 0x0012E7, 0x0013C0, - 0x002261, 0x0023D3, 0x002057, 0x002056, 0x0021D2, 0x0020C7, 0x0023D2, - 0x0020EC, 0x0044C0, 0x002FE2, 0x00475B, 0x002A03, 0x002FE3, 0x0021E2, - 0x0021D0, 0x002A31, 0x002E13, 0x002E05, 0x0047E5, 0x00000E, 0x000024, - 0x000088, 0x0000B9, 0x00010C, 0x000224, 0x0002B3, 0x000283, 0x0002ED, - 0x00047B, 0x00041E, 0x00043D, 0x0004F5, 0x0005FD, 0x000A92, 0x000B96, - 0x000838, 0x000971, 0x000B83, 0x000B80, 0x000BF9, 0x0011D3, 0x0011E8, - 0x0011D7, 0x001527, 0x0011F8, 0x001073, 0x0010F0, 0x0010E4, 0x0017F8, - 0x001062, 0x001402, 0x0017E3, 0x00151A, 0x001077, 0x00152B, 0x00170D, - 0x0021D3, 0x002E41, 0x0013C2, 0x000029, 0x0000A9, 0x00025D, 0x000419, - 0x000544, 0x000B8B, 0x0009E4, 0x0011D2, 0x001526, 0x001724, 0x0012E6, - 0x00150B, 0x0017FF, 0x002E26, 0x002E4B, 0x002B28, 0x0021E3, 0x002A14, - 0x00475A, 0x002E12, 0x000057, 0x00023E, 0x000A90, 0x000BF0, 0x001072, - 0x001502, 0x0023D6, 0x0020ED, 0x002A30, 0x0044C7, 0x00008C, 0x00047F, - 0x00152A, 0x002262, 0x002E04, 0x0000A1, 0x0005F9, 0x000173, 0x000875, - 0x000171, 0x00152D, 0x0002E3, 0x0017E2, 0x0002AD, 0x0021C1, 0x000479, - 0x0021E7, 0x00041F, 0x005C4E, 0x000543, 0x005C4F, 0x000A91, 0x00898D, - 0x000B97, 0x008746, 0x000970, 0x008745, 0x000B85, 0x00A856, 0x00152F, - 0x010E8E, 0x0010E5, 0x00A857, 0x00170F, 0x021D11, 0x002A58, 0x010E8F, - 0x002E40, 0x021D13, 0x002A59, 0x043A25, 0x002A02, 0x043A21, 0x0044C1, - 0x087448, 0x0047E4, 0x043A20, 0x00542A, 0x087449, 0x00898C, +static const uint8_t coef0_lens[HUFF_COEF0_SIZE] = { + 2, 9, 14, 14, 13, 12, 13, 14, 15, 15, 12, 10, 10, 10, 13, 14, 15, 15, 12, + 11, 13, 14, 14, 13, 15, 15, 14, 12, 12, 8, 10, 10, 15, 15, 14, 13, 14, 14, + 13, 15, 20, 20, 19, 21, 21, 20, 19, 17, 17, 18, 18, 15, 15, 13, 12, 14, 15, + 15, 14, 15, 15, 12, 11, 6, 7, 8, 9, 13, 13, 13, 14, 14, 11, 10, 7, 8, + 14, 14, 14, 14, 12, 13, 13, 12, 12, 12, 11, 9, 13, 14, 14, 12, 11, 11, 11, + 9, 8, 7, 14, 15, 15, 14, 14, 12, 13, 15, 16, 17, 17, 14, 12, 12, 12, 15, + 15, 14, 14, 14, 13, 13, 9, 9, 11, 11, 10, 7, 6, 13, 15, 15, 14, 14, 14, + 13, 14, 15, 15, 13, 14, 14, 14, 14, 10, 9, 10, 10, 11, 11, 10, 8, 9, 13, + 14, 14, 12, 11, 14, 15, 15, 13, 12, 14, 14, 14, 14, 13, 14, 14, 3, 5, 8, + 10, 10, 15, 15, 14, 14, 16, 16, 15, 12, 11, 11, 11, 7, 8, 8, 9, 12, 13, + 13, 12, 14, 15, 15, 13, 10, 11, 11, 13, 14, 14, 13, 14, 14, 11, 10, 13, 15, + 15, 14, 12, 11, 4, 6, 6, 8, 12, 12, 12, 13, 13, 12, 13, 13, 14, 14, 13, + 13, 13, 9, 7, 9, 11, 14, 14, 13, 14, 14, 13, 10, 8, 7, 5, 9, 12, 13, + 14, 15, 15, 12, 12, 10, 14, 14, 13, 12, 13, 14, 14, 12, 13, 13, 12, 12, 12, + 9, 7, 6, 3, 4, 4, }; -static const uint8_t coef0_huffbits[HUFF_COEF0_SIZE] = { - 8, 7, 2, 3, 3, 4, 4, - 5, 5, 6, 6, 6, 6, 7, - 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, - 11, 11, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 13, - 12, 12, 12, 12, 12, 12, 13, - 13, 13, 13, 13, 13, 13, 12, - 12, 13, 13, 13, 13, 13, 13, - 13, 13, 14, 14, 13, 13, 14, - 13, 13, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 13, 14, - 14, 14, 14, 14, 14, 14, 15, - 14, 15, 14, 14, 14, 14, 14, - 14, 15, 14, 14, 14, 14, 14, - 14, 14, 15, 15, 15, 15, 14, - 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 4, 7, - 8, 9, 10, 10, 10, 11, 11, - 11, 12, 12, 12, 12, 12, 12, - 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 13, 14, - 15, 14, 14, 6, 9, 11, 12, - 12, 12, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 15, 15, - 15, 15, 7, 10, 12, 13, 14, - 14, 14, 15, 15, 15, 8, 11, - 13, 14, 15, 9, 12, 9, 13, - 10, 13, 10, 14, 11, 15, 11, - 15, 12, 15, 12, 15, 12, 16, - 12, 17, 13, 17, 13, 17, 13, - 18, 14, 17, 14, 19, 14, 18, - 14, 19, 14, 20, 15, 20, 15, - 21, 15, 20, 16, 21, 16, +static const uint16_t coef0_syms[HUFF_COEF0_SIZE] = { + 2, 25, 111, 94, 69, 58, 87, 93, 136, 135, 59, 37, 34, 36, 82, + 182, 120, 138, 195, 45, 168, 216, 178, 86, 140, 219, 186, 162, 239, 18, + 156, 35, 127, 236, 109, 85, 180, 253, 88, 147, 268, 264, 256, 266, 270, + 262, 260, 248, 246, 252, 258, 137, 189, 230, 64, 179, 146, 208, 101, 118, + 238, 163, 46, 9, 153, 0, 26, 247, 169, 76, 202, 131, 194, 38, 13, + 19, 132, 106, 191, 97, 65, 198, 77, 62, 66, 164, 48, 27, 81, 183, + 102, 60, 47, 49, 159, 227, 20, 14, 112, 263, 144, 217, 104, 63, 79, + 209, 269, 250, 254, 203, 241, 196, 61, 220, 148, 124, 185, 100, 80, 78, + 193, 28, 50, 235, 41, 1, 10, 171, 226, 150, 103, 114, 115, 170, 105, + 211, 149, 249, 108, 188, 107, 255, 231, 155, 42, 40, 55, 160, 39, 21, + 29, 215, 234, 184, 228, 51, 116, 142, 145, 172, 165, 181, 130, 113, 117, + 89, 128, 204, 3, 7, 154, 157, 43, 141, 265, 133, 225, 271, 244, 221, + 74, 54, 56, 52, 15, 222, 22, 30, 83, 199, 173, 73, 123, 210, 143, + 175, 44, 53, 237, 174, 139, 134, 110, 218, 129, 161, 213, 177, 267, 151, + 125, 67, 223, 5, 11, 192, 23, 214, 243, 166, 200, 176, 68, 224, 187, + 257, 261, 232, 96, 251, 31, 16, 32, 57, 207, 121, 91, 126, 119, 99, + 158, 24, 212, 8, 33, 70, 92, 205, 240, 242, 75, 197, 233, 259, 190, + 98, 71, 201, 122, 206, 72, 90, 95, 84, 167, 245, 229, 17, 12, 4, + 152, 6, }; #define HUFF_COEF1_SIZE 244 #define HUFF_COEF1_MAXBITS 22 -static const uint32_t coef1_huffcodes[HUFF_COEF1_SIZE] = { - 0x0001E2, 0x00007F, 0x000000, 0x000002, 0x000008, 0x00000E, 0x000019, - 0x00002F, 0x000037, 0x000060, 0x00006C, 0x000095, 0x0000C6, 0x0000F0, - 0x00012E, 0x000189, 0x0001A5, 0x0001F8, 0x000253, 0x00030A, 0x000344, - 0x00034D, 0x0003F2, 0x0004BD, 0x0005D7, 0x00062A, 0x00068B, 0x000693, - 0x000797, 0x00097D, 0x000BAB, 0x000C52, 0x000C5E, 0x000D21, 0x000D20, - 0x000F1A, 0x000FCE, 0x000FD1, 0x0012F1, 0x001759, 0x0018AC, 0x0018A7, - 0x0018BF, 0x001A2B, 0x001E52, 0x001E50, 0x001E31, 0x001FB8, 0x0025E6, - 0x0025E7, 0x002EB4, 0x002EB7, 0x003169, 0x00315B, 0x00317C, 0x00316C, - 0x0034CA, 0x00348D, 0x003F40, 0x003CA2, 0x003F76, 0x004BC3, 0x004BE5, - 0x003F73, 0x004BF8, 0x004BF9, 0x006131, 0x00628B, 0x006289, 0x0062DA, - 0x00628A, 0x0062D4, 0x006997, 0x0062B4, 0x006918, 0x00794D, 0x007E7B, - 0x007E87, 0x007EEA, 0x00794E, 0x00699D, 0x007967, 0x00699F, 0x0062DB, - 0x007E7A, 0x007EEB, 0x00BAC0, 0x0097C9, 0x00C537, 0x00C5AB, 0x00D233, - 0x00D338, 0x00BAC1, 0x00D23D, 0x012F91, 0x00D339, 0x00FDC8, 0x00D23C, - 0x00FDDC, 0x00FDC9, 0x00FDDD, 0x00D33C, 0x000003, 0x000016, 0x00003E, - 0x0000C3, 0x0001A1, 0x000347, 0x00062E, 0x000BAA, 0x000F2D, 0x001A2A, - 0x001E58, 0x00309B, 0x003CA3, 0x005D6A, 0x00629A, 0x006996, 0x00794F, - 0x007EE5, 0x00BAD7, 0x00C5AA, 0x00C5F4, 0x00FDDF, 0x00FDDE, 0x018A20, - 0x018A6D, 0x01A67B, 0x01A464, 0x025F21, 0x01F9E2, 0x01F9E3, 0x00000A, - 0x00003D, 0x000128, 0x0003C7, 0x000C24, 0x0018A3, 0x002EB1, 0x003CB2, - 0x00691F, 0x007E79, 0x000013, 0x0000BB, 0x00034E, 0x000D14, 0x0025FD, - 0x004BE7, 0x000024, 0x000188, 0x0007EF, 0x000035, 0x000308, 0x0012F2, - 0x00005C, 0x0003F6, 0x0025E0, 0x00006D, 0x000698, 0x000096, 0x000C25, - 0x0000C7, 0x000F1B, 0x0000F3, 0x0012FF, 0x000174, 0x001A66, 0x0001A0, - 0x003099, 0x0001E4, 0x00316B, 0x000252, 0x003F31, 0x00030B, 0x004BE6, - 0x000346, 0x0062FB, 0x00034F, 0x007966, 0x0003F5, 0x007E86, 0x0005D4, - 0x00C511, 0x00062C, 0x00C5F5, 0x000692, 0x00F299, 0x000795, 0x00F298, - 0x0007E9, 0x018A21, 0x00097E, 0x0175AD, 0x000C27, 0x01A67A, 0x000C57, - 0x02EB59, 0x000D22, 0x0314D9, 0x000F19, 0x03F3C2, 0x000FCD, 0x0348CB, - 0x0012F8, 0x04BE41, 0x0018A0, 0x03F3C1, 0x0018A1, 0x04BE40, 0x0018B7, - 0x0629B0, 0x001A64, 0x0D2329, 0x001E30, 0x03F3C3, 0x001F9F, 0x0BAD62, - 0x001F99, 0x0FCF00, 0x00309A, 0x0629B1, 0x002EB6, 0x175AC3, 0x00314C, - 0x069195, 0x003168, 0x0BAD63, 0x00348E, 0x175AC1, 0x003F30, 0x07E781, - 0x003F41, 0x0D2328, 0x003F42, 0x1F9E03, 0x004BC2, 0x175AC2, 0x003F74, - 0x175AC0, 0x005D61, 0x3F3C05, 0x006130, 0x3F3C04, 0x0062B5, -}; - -static const uint8_t coef1_huffbits[HUFF_COEF1_SIZE] = { - 9, 7, 2, 3, 4, 4, 5, - 6, 6, 7, 7, 8, 8, 8, - 9, 9, 9, 9, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, - 11, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 14, - 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 15, 15, - 14, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, - 15, 15, 16, 16, 16, 16, 16, - 16, 16, 16, 17, 16, 16, 16, - 16, 16, 16, 16, 3, 5, 6, - 8, 9, 10, 11, 12, 12, 13, - 13, 14, 14, 15, 15, 15, 15, - 15, 16, 16, 16, 16, 16, 17, - 17, 17, 17, 18, 17, 17, 4, - 6, 9, 10, 12, 13, 14, 14, - 15, 15, 5, 8, 10, 12, 14, - 15, 6, 9, 11, 6, 10, 13, - 7, 10, 14, 7, 11, 8, 12, - 8, 12, 8, 13, 9, 13, 9, - 14, 9, 14, 10, 14, 10, 15, - 10, 15, 10, 15, 10, 15, 11, - 16, 11, 16, 11, 16, 11, 16, - 11, 17, 12, 17, 12, 17, 12, - 18, 12, 18, 12, 18, 12, 18, - 13, 19, 13, 18, 13, 19, 13, - 19, 13, 20, 13, 18, 13, 20, - 13, 20, 14, 19, 14, 21, 14, - 19, 14, 20, 14, 21, 14, 19, - 14, 20, 14, 21, 15, 21, 14, - 21, 15, 22, 15, 22, 15, +static const uint8_t coef1_table[HUFF_COEF1_SIZE][2] = { + { 2, 2 }, { 3, 3 }, { 102, 3 }, { 4, 4 }, { 148, 6 }, + { 134, 9 }, { 171, 10 }, { 18, 10 }, { 11, 8 }, { 159, 8 }, + { 14, 9 }, { 156, 14 }, { 235, 15 }, { 61, 15 }, { 38, 13 }, + { 153, 13 }, { 48, 14 }, { 49, 14 }, { 23, 11 }, { 203, 13 }, + { 208, 19 }, { 204, 19 }, { 129, 18 }, { 94, 17 }, { 87, 16 }, + { 62, 15 }, { 174, 15 }, { 147, 15 }, { 29, 12 }, { 191, 12 }, + { 64, 15 }, { 65, 15 }, { 146, 14 }, { 164, 13 }, { 142, 5 }, + { 132, 4 }, { 103, 5 }, { 154, 7 }, { 165, 9 }, { 181, 11 }, + { 109, 12 }, { 30, 12 }, { 86, 16 }, { 92, 16 }, { 239, 15 }, + { 138, 14 }, { 39, 13 }, { 50, 14 }, { 115, 15 }, { 238, 21 }, + { 228, 21 }, { 236, 21 }, { 222, 21 }, { 216, 20 }, { 226, 20 }, + { 196, 18 }, { 192, 17 }, { 120, 16 }, { 221, 14 }, { 51, 14 }, + { 24, 11 }, { 143, 8 }, { 7, 6 }, { 9, 7 }, { 152, 10 }, + { 136, 12 }, { 160, 12 }, { 241, 15 }, { 66, 15 }, { 168, 14 }, + { 219, 14 }, { 113, 14 }, { 193, 12 }, { 19, 10 }, { 173, 10 }, + { 105, 8 }, { 149, 9 }, { 15, 9 }, { 205, 13 }, { 207, 13 }, + { 125, 17 }, { 190, 17 }, { 182, 16 }, { 68, 15 }, { 70, 15 }, + { 67, 15 }, { 137, 13 }, { 31, 12 }, { 223, 14 }, { 116, 15 }, + { 210, 19 }, { 220, 19 }, { 198, 18 }, { 126, 17 }, { 88, 16 }, + { 41, 13 }, { 25, 11 }, { 40, 13 }, { 73, 15 }, { 243, 15 }, + { 53, 14 }, { 195, 12 }, { 183, 11 }, { 225, 14 }, { 52, 14 }, + { 71, 15 }, { 121, 16 }, { 89, 16 }, { 170, 14 }, { 55, 14 }, + { 69, 15 }, { 83, 15 }, { 209, 13 }, { 108, 11 }, { 32, 12 }, + { 54, 14 }, { 122, 16 }, { 184, 16 }, { 176, 15 }, { 42, 13 }, + { 12, 8 }, { 161, 8 }, { 6, 5 }, { 167, 9 }, { 106, 9 }, + { 20, 10 }, { 145, 12 }, { 111, 13 }, { 43, 13 }, { 26, 11 }, + { 175, 10 }, { 107, 10 }, { 34, 12 }, { 33, 12 }, { 197, 12 }, + { 74, 15 }, { 128, 17 }, { 232, 20 }, { 212, 20 }, { 224, 19 }, + { 202, 18 }, { 90, 16 }, { 57, 14 }, { 227, 14 }, { 97, 16 }, + { 93, 16 }, { 140, 15 }, { 185, 11 }, { 27, 11 }, { 16, 9 }, + { 158, 11 }, { 211, 13 }, { 56, 14 }, { 117, 15 }, { 72, 15 }, + { 166, 13 }, { 91, 16 }, { 95, 16 }, { 80, 15 }, { 101, 16 }, + { 194, 17 }, { 127, 17 }, { 82, 15 }, { 21, 10 }, { 144, 10 }, + { 177, 10 }, { 151, 6 }, { 10, 7 }, { 157, 7 }, { 8, 6 }, + { 5, 4 }, { 13, 8 }, { 0, 9 }, { 213, 13 }, { 46, 13 }, + { 199, 12 }, { 35, 12 }, { 162, 12 }, { 135, 10 }, { 169, 9 }, + { 45, 13 }, { 59, 14 }, { 114, 14 }, { 44, 13 }, { 188, 16 }, + { 186, 16 }, { 75, 15 }, { 79, 15 }, { 118, 15 }, { 187, 11 }, + { 112, 13 }, { 139, 14 }, { 178, 15 }, { 81, 15 }, { 110, 12 }, + { 28, 11 }, { 163, 8 }, { 133, 6 }, { 104, 6 }, { 17, 9 }, + { 22, 10 }, { 229, 14 }, { 172, 14 }, { 217, 13 }, { 201, 12 }, + { 36, 12 }, { 218, 20 }, { 242, 22 }, { 240, 22 }, { 234, 21 }, + { 230, 19 }, { 206, 18 }, { 200, 18 }, { 214, 18 }, { 130, 17 }, + { 131, 17 }, { 141, 15 }, { 84, 15 }, { 76, 15 }, { 215, 13 }, + { 58, 14 }, { 231, 14 }, { 233, 14 }, { 180, 15 }, { 77, 15 }, + { 37, 12 }, { 189, 11 }, { 179, 10 }, { 155, 10 }, { 47, 13 }, + { 96, 16 }, { 99, 16 }, { 119, 15 }, { 63, 14 }, { 237, 14 }, + { 78, 15 }, { 85, 15 }, { 60, 14 }, { 98, 16 }, { 100, 16 }, + { 124, 16 }, { 123, 16 }, { 150, 11 }, { 1, 7 }, }; @@ -418,122 +325,94 @@ static const float coef1_level[HUFF_COEF1_SIZE] = { */ #define HUFF_VEC4_SIZE 127 #define HUFF_VEC4_MAXBITS 14 -static const uint16_t vec4_huffcodes[HUFF_VEC4_SIZE] = { - 0x0019, 0x0027, 0x00F2, 0x03BA, 0x0930, 0x1267, 0x0031, 0x0030, - 0x0097, 0x0221, 0x058B, 0x0124, 0x00EB, 0x01D4, 0x03D8, 0x0584, - 0x0364, 0x045F, 0x0F66, 0x0931, 0x24CD, 0x002F, 0x0039, 0x00E8, - 0x02C3, 0x078A, 0x0037, 0x0029, 0x0084, 0x01B1, 0x00ED, 0x0086, - 0x00F9, 0x03AB, 0x01EB, 0x08BC, 0x011E, 0x00F3, 0x0220, 0x058A, - 0x00EC, 0x008E, 0x012B, 0x01EA, 0x0119, 0x04B0, 0x04B1, 0x03B8, - 0x0691, 0x0365, 0x01ED, 0x049A, 0x0EA9, 0x0EA8, 0x08BD, 0x24CC, - 0x0026, 0x0035, 0x00DB, 0x02C4, 0x07B2, 0x0038, 0x002B, 0x007F, - 0x01B3, 0x00F4, 0x0091, 0x0116, 0x03BB, 0x0215, 0x0932, 0x002D, - 0x002A, 0x008A, 0x01DE, 0x0028, 0x0020, 0x005C, 0x0090, 0x0068, - 0x01EE, 0x00E9, 0x008D, 0x012A, 0x0087, 0x005D, 0x0118, 0x0349, - 0x01EF, 0x01E3, 0x08B9, 0x00F0, 0x00D3, 0x0214, 0x049B, 0x00DA, - 0x0089, 0x0125, 0x0217, 0x012D, 0x0690, 0x0094, 0x007D, 0x011F, - 0x007E, 0x0059, 0x0127, 0x01A5, 0x0111, 0x00F8, 0x045D, 0x03B9, - 0x0259, 0x0580, 0x02C1, 0x01DF, 0x0585, 0x0216, 0x0163, 0x01B0, - 0x03C4, 0x08B8, 0x078B, 0x0755, 0x0581, 0x0F67, 0x0000, -}; - -static const uint8_t vec4_huffbits[HUFF_VEC4_SIZE] = { - 5, 6, 8, 10, 12, 13, 6, 6, - 8, 10, 11, 9, 8, 9, 10, 11, - 10, 11, 12, 12, 14, 6, 6, 8, - 10, 11, 6, 6, 8, 9, 8, 8, - 8, 10, 9, 12, 9, 8, 10, 11, - 8, 8, 9, 9, 9, 11, 11, 10, - 11, 10, 9, 11, 12, 12, 12, 14, - 6, 6, 8, 10, 11, 6, 6, 7, - 9, 8, 8, 9, 10, 10, 12, 6, - 6, 8, 9, 6, 6, 7, 8, 7, - 9, 8, 8, 9, 8, 7, 9, 10, - 9, 9, 12, 8, 8, 10, 11, 8, - 8, 9, 10, 9, 11, 8, 7, 9, - 7, 7, 9, 9, 9, 8, 11, 10, - 10, 11, 10, 9, 11, 10, 9, 9, - 10, 12, 11, 11, 11, 12, 1, +static const uint8_t vec4_table[HUFF_VEC4_SIZE][2] = { + { 126, 1 }, { 76, 6 }, { 28, 8 }, { 93, 10 }, { 69, 10 }, + { 117, 10 }, { 98, 10 }, { 31, 8 }, { 84, 8 }, { 38, 10 }, + { 9, 10 }, { 108, 9 }, { 96, 8 }, { 73, 8 }, { 67, 9 }, + { 121, 12 }, { 90, 12 }, { 110, 11 }, { 35, 12 }, { 54, 12 }, + { 17, 11 }, { 86, 9 }, { 44, 9 }, { 82, 8 }, { 41, 8 }, + { 36, 9 }, { 103, 9 }, { 78, 8 }, { 66, 8 }, { 11, 9 }, + { 97, 9 }, { 4, 12 }, { 19, 12 }, { 70, 12 }, { 55, 14 }, + { 20, 14 }, { 5, 13 }, { 51, 11 }, { 94, 11 }, { 106, 9 }, + { 101, 8 }, { 83, 9 }, { 42, 9 }, { 45, 11 }, { 46, 11 }, + { 112, 10 }, { 99, 9 }, { 8, 8 }, { 56, 6 }, { 1, 6 }, + { 75, 6 }, { 27, 6 }, { 72, 6 }, { 62, 6 }, { 113, 11 }, + { 124, 11 }, { 114, 10 }, { 15, 11 }, { 116, 11 }, { 24, 10 }, + { 59, 10 }, { 39, 11 }, { 10, 11 }, { 118, 9 }, { 105, 7 }, + { 71, 6 }, { 77, 7 }, { 85, 7 }, { 21, 6 }, { 7, 6 }, + { 6, 6 }, { 0, 5 }, { 79, 7 }, { 100, 11 }, { 48, 11 }, + { 87, 10 }, { 107, 9 }, { 92, 8 }, { 57, 6 }, { 119, 9 }, + { 29, 9 }, { 16, 10 }, { 49, 10 }, { 64, 9 }, { 95, 8 }, + { 58, 8 }, { 26, 6 }, { 61, 6 }, { 22, 6 }, { 23, 8 }, + { 81, 8 }, { 13, 9 }, { 53, 12 }, { 52, 12 }, { 123, 11 }, + { 33, 10 }, { 12, 8 }, { 40, 8 }, { 30, 8 }, { 47, 10 }, + { 111, 10 }, { 3, 10 }, { 68, 10 }, { 74, 9 }, { 115, 9 }, + { 91, 8 }, { 120, 10 }, { 25, 11 }, { 122, 11 }, { 89, 9 }, + { 2, 8 }, { 37, 8 }, { 65, 8 }, { 43, 9 }, { 34, 9 }, + { 14, 10 }, { 60, 11 }, { 18, 12 }, { 125, 12 }, { 50, 9 }, + { 80, 9 }, { 88, 9 }, { 109, 8 }, { 32, 8 }, { 102, 7 }, + { 104, 7 }, { 63, 7 }, }; #define HUFF_VEC2_SIZE 137 #define HUFF_VEC2_MAXBITS 12 -static const uint16_t vec2_huffcodes[HUFF_VEC2_SIZE] = { - 0x055, 0x01C, 0x01A, 0x02B, 0x028, 0x067, 0x08B, 0x039, - 0x170, 0x10D, 0x2A5, 0x047, 0x464, 0x697, 0x523, 0x8CB, - 0x01B, 0x00E, 0x000, 0x010, 0x012, 0x036, 0x048, 0x04C, - 0x0C2, 0x09B, 0x171, 0x03B, 0x224, 0x34A, 0x2D6, 0x019, - 0x00F, 0x002, 0x014, 0x017, 0x006, 0x05D, 0x054, 0x0C7, - 0x0B4, 0x192, 0x10E, 0x233, 0x043, 0x02C, 0x00F, 0x013, - 0x006, 0x02F, 0x02C, 0x068, 0x077, 0x0DF, 0x111, 0x1A4, - 0x16A, 0x2A4, 0x027, 0x011, 0x018, 0x02D, 0x00F, 0x04A, - 0x040, 0x097, 0x01F, 0x11B, 0x022, 0x16D, 0x066, 0x035, - 0x005, 0x02B, 0x049, 0x009, 0x075, 0x0CB, 0x0AA, 0x187, - 0x106, 0x08A, 0x047, 0x060, 0x06E, 0x01D, 0x074, 0x0C4, - 0x01E, 0x118, 0x1A7, 0x038, 0x042, 0x053, 0x076, 0x0A8, - 0x0CA, 0x082, 0x110, 0x18D, 0x12D, 0x0B9, 0x0C8, 0x0DE, - 0x01C, 0x0AB, 0x113, 0x18C, 0x10F, 0x09A, 0x0A5, 0x0B7, - 0x11A, 0x186, 0x1A6, 0x259, 0x153, 0x18A, 0x193, 0x020, - 0x10C, 0x046, 0x03A, 0x107, 0x149, 0x16C, 0x2D7, 0x225, - 0x258, 0x316, 0x696, 0x317, 0x042, 0x522, 0x290, 0x8CA, - 0x001, -}; - -static const uint8_t vec2_huffbits[HUFF_VEC2_SIZE] = { - 7, 6, 6, 6, 7, 7, 8, 9, - 9, 10, 10, 11, 11, 11, 12, 12, - 6, 4, 5, 5, 6, 6, 7, 8, - 8, 9, 9, 10, 10, 10, 11, 6, - 4, 5, 5, 6, 7, 7, 8, 8, - 9, 9, 10, 10, 11, 6, 5, 5, - 6, 6, 7, 7, 8, 8, 9, 9, - 10, 10, 7, 6, 6, 6, 7, 7, - 8, 8, 9, 9, 10, 10, 7, 6, - 7, 7, 7, 8, 8, 8, 9, 9, - 10, 8, 7, 7, 7, 8, 8, 8, - 9, 9, 9, 9, 8, 8, 8, 8, - 8, 9, 9, 9, 9, 8, 8, 8, - 9, 9, 9, 9, 10, 9, 9, 9, - 9, 9, 9, 10, 9, 9, 9, 10, - 10, 11, 10, 10, 10, 10, 11, 10, - 10, 10, 11, 10, 11, 12, 11, 12, - 3, +static const uint8_t vec2_table[HUFF_VEC2_SIZE][2] = { + { 18, 5 }, { 119, 10 }, { 132, 11 }, { 44, 11 }, { 68, 10 }, + { 121, 11 }, { 11, 11 }, { 75, 8 }, { 72, 7 }, { 36, 7 }, + { 104, 9 }, { 122, 10 }, { 27, 10 }, { 88, 9 }, { 66, 9 }, + { 33, 5 }, { 48, 6 }, { 91, 9 }, { 7, 9 }, { 85, 8 }, + { 62, 7 }, { 136, 3 }, { 64, 8 }, { 97, 9 }, { 80, 10 }, + { 123, 10 }, { 92, 8 }, { 120, 10 }, { 9, 10 }, { 42, 10 }, + { 108, 10 }, { 59, 6 }, { 20, 6 }, { 23, 8 }, { 109, 9 }, + { 25, 9 }, { 58, 7 }, { 4, 7 }, { 134, 11 }, { 133, 12 }, + { 14, 12 }, { 124, 10 }, { 110, 9 }, { 93, 8 }, { 38, 8 }, + { 78, 9 }, { 105, 9 }, { 73, 7 }, { 50, 7 }, { 40, 9 }, + { 56, 10 }, { 30, 11 }, { 126, 11 }, { 125, 10 }, { 69, 10 }, + { 111, 9 }, { 35, 6 }, { 60, 6 }, { 31, 6 }, { 2, 6 }, + { 16, 6 }, { 1, 6 }, { 86, 8 }, { 76, 8 }, { 94, 8 }, + { 52, 8 }, { 46, 5 }, { 19, 5 }, { 98, 9 }, { 54, 9 }, + { 28, 10 }, { 127, 10 }, { 106, 9 }, { 81, 8 }, { 6, 8 }, + { 89, 9 }, { 12, 11 }, { 135, 12 }, { 15, 12 }, { 43, 10 }, + { 112, 9 }, { 67, 9 }, { 82, 7 }, { 22, 7 }, { 74, 7 }, + { 63, 7 }, { 128, 10 }, { 115, 10 }, { 100, 9 }, { 65, 8 }, + { 47, 5 }, { 34, 5 }, { 95, 8 }, { 57, 10 }, { 10, 10 }, + { 116, 9 }, { 0, 7 }, { 3, 6 }, { 45, 6 }, { 61, 6 }, + { 8, 9 }, { 26, 9 }, { 101, 8 }, { 37, 7 }, { 49, 6 }, + { 83, 7 }, { 24, 8 }, { 113, 9 }, { 79, 9 }, { 87, 8 }, + { 117, 9 }, { 129, 10 }, { 131, 10 }, { 107, 9 }, { 99, 9 }, + { 39, 8 }, { 102, 8 }, { 41, 9 }, { 118, 9 }, { 96, 8 }, + { 77, 8 }, { 70, 7 }, { 5, 7 }, { 51, 7 }, { 55, 9 }, + { 29, 10 }, { 130, 11 }, { 13, 11 }, { 114, 9 }, { 90, 9 }, + { 71, 6 }, { 21, 6 }, { 84, 7 }, { 103, 8 }, { 53, 8 }, + { 17, 4 }, { 32, 4 }, }; #define HUFF_VEC1_SIZE 101 #define HUFF_VEC1_MAXBITS 11 -static const uint16_t vec1_huffcodes[HUFF_VEC1_SIZE] = { - 0x01A, 0x003, 0x017, 0x010, 0x00C, 0x009, 0x005, 0x000, - 0x00D, 0x00A, 0x009, 0x00C, 0x00F, 0x002, 0x004, 0x007, - 0x00B, 0x00F, 0x01C, 0x006, 0x010, 0x015, 0x01C, 0x022, - 0x03B, 0x00E, 0x019, 0x023, 0x034, 0x036, 0x03A, 0x047, - 0x008, 0x00A, 0x01E, 0x031, 0x037, 0x050, 0x053, 0x06B, - 0x06F, 0x08C, 0x0E8, 0x0EA, 0x0EB, 0x016, 0x03E, 0x03F, - 0x06C, 0x089, 0x08A, 0x0A3, 0x0A4, 0x0D4, 0x0DD, 0x0EC, - 0x0EE, 0x11A, 0x1D2, 0x024, 0x025, 0x02E, 0x027, 0x0C2, - 0x0C0, 0x0DA, 0x0DB, 0x111, 0x144, 0x116, 0x14A, 0x145, - 0x1B8, 0x1AB, 0x1DA, 0x1DE, 0x1DB, 0x1DF, 0x236, 0x237, - 0x3A6, 0x3A7, 0x04D, 0x04C, 0x05E, 0x05F, 0x183, 0x182, - 0x186, 0x221, 0x187, 0x220, 0x22E, 0x22F, 0x296, 0x354, - 0x297, 0x355, 0x372, 0x373, 0x016, -}; - -static const uint8_t vec1_huffbits[HUFF_VEC1_SIZE] = { - 7, 6, 5, 5, 5, 5, 5, 5, - 4, 4, 4, 4, 4, 5, 5, 5, - 5, 5, 5, 6, 6, 6, 6, 6, - 6, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 5, +static const uint8_t vec1_table[HUFF_VEC1_SIZE][2] = { + { 7, 5 }, { 32, 8 }, { 59, 10 }, { 60, 10 }, { 83, 11 }, + { 82, 11 }, { 62, 10 }, { 33, 8 }, { 45, 9 }, { 61, 10 }, + { 84, 11 }, { 85, 11 }, { 1, 6 }, { 13, 5 }, { 19, 6 }, + { 25, 7 }, { 34, 8 }, { 46, 9 }, { 47, 9 }, { 14, 5 }, + { 6, 5 }, { 64, 10 }, { 87, 11 }, { 86, 11 }, { 63, 10 }, + { 88, 11 }, { 90, 11 }, { 35, 8 }, { 26, 7 }, { 0, 7 }, + { 48, 9 }, { 65, 10 }, { 66, 10 }, { 36, 8 }, { 15, 5 }, + { 20, 6 }, { 91, 11 }, { 89, 11 }, { 67, 10 }, { 49, 9 }, + { 50, 9 }, { 69, 10 }, { 92, 11 }, { 93, 11 }, { 27, 7 }, + { 5, 5 }, { 37, 8 }, { 68, 10 }, { 71, 10 }, { 51, 9 }, + { 52, 9 }, { 70, 10 }, { 94, 11 }, { 96, 11 }, { 38, 8 }, + { 21, 6 }, { 16, 5 }, { 4, 5 }, { 28, 7 }, { 53, 9 }, + { 95, 11 }, { 97, 11 }, { 73, 10 }, { 39, 8 }, { 29, 7 }, + { 72, 10 }, { 98, 11 }, { 99, 11 }, { 54, 9 }, { 40, 8 }, + { 22, 6 }, { 30, 7 }, { 55, 9 }, { 74, 10 }, { 76, 10 }, + { 56, 9 }, { 75, 10 }, { 77, 10 }, { 17, 5 }, { 3, 5 }, + { 23, 6 }, { 41, 8 }, { 57, 9 }, { 78, 10 }, { 79, 10 }, + { 31, 7 }, { 10, 4 }, { 9, 4 }, { 100, 5 }, { 2, 5 }, + { 11, 4 }, { 8, 4 }, { 18, 5 }, { 42, 8 }, { 58, 9 }, + { 80, 10 }, { 81, 10 }, { 43, 8 }, { 44, 8 }, { 24, 6 }, + { 12, 4 }, }; diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 7cfd0c04be..1909ce2dad 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -318,27 +318,27 @@ static av_cold int get_rate(AVCodecContext *avctx) static av_cold void decode_init_static(void) { - INIT_VLC_STATIC(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE, - scale_huffbits, 1, 1, - scale_huffcodes, 2, 2, 616); - INIT_VLC_STATIC(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE, - scale_rl_huffbits, 1, 1, - scale_rl_huffcodes, 4, 4, 1406); - INIT_VLC_STATIC(&coef_vlc[0], VLCBITS, HUFF_COEF0_SIZE, - coef0_huffbits, 1, 1, - coef0_huffcodes, 4, 4, 2108); - INIT_VLC_STATIC(&coef_vlc[1], VLCBITS, HUFF_COEF1_SIZE, - coef1_huffbits, 1, 1, - coef1_huffcodes, 4, 4, 3912); - INIT_VLC_STATIC(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE, - vec4_huffbits, 1, 1, - vec4_huffcodes, 2, 2, 604); - INIT_VLC_STATIC(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE, - vec2_huffbits, 1, 1, - vec2_huffcodes, 2, 2, 562); - INIT_VLC_STATIC(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE, - vec1_huffbits, 1, 1, - vec1_huffcodes, 2, 2, 562); + INIT_VLC_STATIC_FROM_LENGTHS(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE, + &scale_table[0][1], 2, + &scale_table[0][0], 2, 1, 0, 0, 616); + INIT_VLC_STATIC_FROM_LENGTHS(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE, + &scale_rl_table[0][1], 2, + &scale_rl_table[0][0], 2, 1, 0, 0, 1406); + INIT_VLC_STATIC_FROM_LENGTHS(&coef_vlc[0], VLCBITS, HUFF_COEF0_SIZE, + coef0_lens, 1, + coef0_syms, 2, 2, 0, 0, 2108); + INIT_VLC_STATIC_FROM_LENGTHS(&coef_vlc[1], VLCBITS, HUFF_COEF1_SIZE, + &coef1_table[0][1], 2, + &coef1_table[0][0], 2, 1, 0, 0, 3912); + INIT_VLC_STATIC_FROM_LENGTHS(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE, + &vec4_table[0][1], 2, + &vec4_table[0][0], 2, 1, 0, 0, 604); + INIT_VLC_STATIC_FROM_LENGTHS(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE, + &vec2_table[0][1], 2, + &vec2_table[0][0], 2, 1, 0, 0, 562); + INIT_VLC_STATIC_FROM_LENGTHS(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE, + &vec1_table[0][1], 2, + &vec1_table[0][0], 2, 1, 0, 0, 562); /** calculate sine values for the decorrelation matrix */ for (int i = 0; i < 33; i++) From cca7f571bac7e5c7fb35f2faef5e4a23eb77516a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 21:09:40 +0200 Subject: [PATCH 190/590] avcodec/wmaprodec: Move applying offset to VLC creation Signed-off-by: Andreas Rheinhardt --- libavcodec/wmaprodec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 1909ce2dad..698841dcaf 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -320,7 +320,7 @@ static av_cold void decode_init_static(void) { INIT_VLC_STATIC_FROM_LENGTHS(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE, &scale_table[0][1], 2, - &scale_table[0][0], 2, 1, 0, 0, 616); + &scale_table[0][0], 2, 1, -60, 0, 616); INIT_VLC_STATIC_FROM_LENGTHS(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE, &scale_rl_table[0][1], 2, &scale_rl_table[0][0], 2, 1, 0, 0, 1406); @@ -1056,7 +1056,7 @@ static int decode_scale_factors(WMAProDecodeCtx* s) s->channel[c].scale_factor_step = get_bits(&s->gb, 2) + 1; val = 45 / s->channel[c].scale_factor_step; for (sf = s->channel[c].scale_factors; sf < sf_end; sf++) { - val += get_vlc2(&s->gb, sf_vlc.table, SCALEVLCBITS, SCALEMAXDEPTH) - 60; + val += get_vlc2(&s->gb, sf_vlc.table, SCALEVLCBITS, SCALEMAXDEPTH); *sf = val; } } else { From 232e88928eee71afa55233d021eeda25eb3ed5b4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 4 Sep 2022 22:44:04 +0200 Subject: [PATCH 191/590] avcodec/wmaprodec: Use symbol table more efficiently By using a symbol table one can already bake in applying a LUT on the return value of get_vlc2(). So change the symbol table for the vec2 and vec4 tables to avoid using the symbol_to_vec2/4 LUTs. Signed-off-by: Andreas Rheinhardt --- libavcodec/wmaprodata.h | 147 +++++++++++++++++----------------------- libavcodec/wmaprodec.c | 22 +++--- 2 files changed, 72 insertions(+), 97 deletions(-) diff --git a/libavcodec/wmaprodata.h b/libavcodec/wmaprodata.h index 3a30be40b5..057ce1d02d 100644 --- a/libavcodec/wmaprodata.h +++ b/libavcodec/wmaprodata.h @@ -325,67 +325,73 @@ static const float coef1_level[HUFF_COEF1_SIZE] = { */ #define HUFF_VEC4_SIZE 127 #define HUFF_VEC4_MAXBITS 14 -static const uint8_t vec4_table[HUFF_VEC4_SIZE][2] = { - { 126, 1 }, { 76, 6 }, { 28, 8 }, { 93, 10 }, { 69, 10 }, - { 117, 10 }, { 98, 10 }, { 31, 8 }, { 84, 8 }, { 38, 10 }, - { 9, 10 }, { 108, 9 }, { 96, 8 }, { 73, 8 }, { 67, 9 }, - { 121, 12 }, { 90, 12 }, { 110, 11 }, { 35, 12 }, { 54, 12 }, - { 17, 11 }, { 86, 9 }, { 44, 9 }, { 82, 8 }, { 41, 8 }, - { 36, 9 }, { 103, 9 }, { 78, 8 }, { 66, 8 }, { 11, 9 }, - { 97, 9 }, { 4, 12 }, { 19, 12 }, { 70, 12 }, { 55, 14 }, - { 20, 14 }, { 5, 13 }, { 51, 11 }, { 94, 11 }, { 106, 9 }, - { 101, 8 }, { 83, 9 }, { 42, 9 }, { 45, 11 }, { 46, 11 }, - { 112, 10 }, { 99, 9 }, { 8, 8 }, { 56, 6 }, { 1, 6 }, - { 75, 6 }, { 27, 6 }, { 72, 6 }, { 62, 6 }, { 113, 11 }, - { 124, 11 }, { 114, 10 }, { 15, 11 }, { 116, 11 }, { 24, 10 }, - { 59, 10 }, { 39, 11 }, { 10, 11 }, { 118, 9 }, { 105, 7 }, - { 71, 6 }, { 77, 7 }, { 85, 7 }, { 21, 6 }, { 7, 6 }, - { 6, 6 }, { 0, 5 }, { 79, 7 }, { 100, 11 }, { 48, 11 }, - { 87, 10 }, { 107, 9 }, { 92, 8 }, { 57, 6 }, { 119, 9 }, - { 29, 9 }, { 16, 10 }, { 49, 10 }, { 64, 9 }, { 95, 8 }, - { 58, 8 }, { 26, 6 }, { 61, 6 }, { 22, 6 }, { 23, 8 }, - { 81, 8 }, { 13, 9 }, { 53, 12 }, { 52, 12 }, { 123, 11 }, - { 33, 10 }, { 12, 8 }, { 40, 8 }, { 30, 8 }, { 47, 10 }, - { 111, 10 }, { 3, 10 }, { 68, 10 }, { 74, 9 }, { 115, 9 }, - { 91, 8 }, { 120, 10 }, { 25, 11 }, { 122, 11 }, { 89, 9 }, - { 2, 8 }, { 37, 8 }, { 65, 8 }, { 43, 9 }, { 34, 9 }, - { 14, 10 }, { 60, 11 }, { 18, 12 }, { 125, 12 }, { 50, 9 }, - { 80, 9 }, { 88, 9 }, { 109, 8 }, { 32, 8 }, { 102, 7 }, - { 104, 7 }, { 63, 7 }, +static const uint8_t vec4_lens[HUFF_VEC4_SIZE] = { + 1, 6, 8, 10, 10, 10, 10, 8, 8, 10, 10, 9, 8, 8, 9, 12, 12, 11, + 12, 12, 11, 9, 9, 8, 8, 9, 9, 8, 8, 9, 9, 12, 12, 12, 14, 14, + 13, 11, 11, 9, 8, 9, 9, 11, 11, 10, 9, 8, 6, 6, 6, 6, 6, 6, + 11, 11, 10, 11, 11, 10, 10, 11, 11, 9, 7, 6, 7, 7, 6, 6, 6, 5, + 7, 11, 11, 10, 9, 8, 6, 9, 9, 10, 10, 9, 8, 8, 6, 6, 6, 8, + 8, 9, 12, 12, 11, 10, 8, 8, 8, 10, 10, 10, 10, 9, 9, 8, 10, 11, + 11, 9, 8, 8, 8, 9, 9, 10, 11, 12, 12, 9, 9, 9, 8, 8, 7, 7, + 7, +}; + +/* The entry in the following table with symbol zero indicates + * that four further entries are coded explicitly; all other + * entries encode four numbers in the 0..15 range via + * the four nibbles of (symbol - 1). */ +static const uint16_t vec4_syms[HUFF_VEC4_SIZE] = { + 0, 4370, 275, 8195, 4146, 12545, 8225, 290, 4625, 515, + 20, 8706, 8210, 4355, 4131, 16385, 5121, 8961, 321, 1041, + 51, 4641, 546, 4610, 530, 513, 8451, 4385, 4130, 33, + 8211, 5, 66, 4161, 1281, 81, 6, 801, 8196, 8481, + 8449, 4611, 531, 561, 769, 12290, 8226, 19, 4097, 2, + 4369, 274, 4354, 4114, 12291, 16641, 12305, 49, 12321, 260, + 4100, 516, 21, 12546, 8466, 4353, 4371, 4626, 257, 18, + 17, 1, 4386, 8241, 771, 4865, 8705, 8194, 4098, 12561, + 276, 50, 785, 4116, 8209, 4099, 273, 4113, 258, 259, + 4609, 35, 1026, 1025, 16401, 305, 34, 529, 289, 770, + 12289, 4, 4145, 4356, 12306, 8193, 12801, 261, 16386, 4881, + 3, 514, 4129, 545, 306, 36, 4101, 65, 20481, 786, + 4401, 4866, 8721, 291, 8450, 8465, 4115, }; #define HUFF_VEC2_SIZE 137 #define HUFF_VEC2_MAXBITS 12 +/* The entry in the following table with symbol zero indicates + * that two further entries are coded explicitly; all other + * entries encode two numbers in the 0..15 range via + * (symbol - 1) & 0xF and (symbol - 1) >> 4. */ static const uint8_t vec2_table[HUFF_VEC2_SIZE][2] = { - { 18, 5 }, { 119, 10 }, { 132, 11 }, { 44, 11 }, { 68, 10 }, - { 121, 11 }, { 11, 11 }, { 75, 8 }, { 72, 7 }, { 36, 7 }, - { 104, 9 }, { 122, 10 }, { 27, 10 }, { 88, 9 }, { 66, 9 }, - { 33, 5 }, { 48, 6 }, { 91, 9 }, { 7, 9 }, { 85, 8 }, - { 62, 7 }, { 136, 3 }, { 64, 8 }, { 97, 9 }, { 80, 10 }, - { 123, 10 }, { 92, 8 }, { 120, 10 }, { 9, 10 }, { 42, 10 }, - { 108, 10 }, { 59, 6 }, { 20, 6 }, { 23, 8 }, { 109, 9 }, - { 25, 9 }, { 58, 7 }, { 4, 7 }, { 134, 11 }, { 133, 12 }, - { 14, 12 }, { 124, 10 }, { 110, 9 }, { 93, 8 }, { 38, 8 }, - { 78, 9 }, { 105, 9 }, { 73, 7 }, { 50, 7 }, { 40, 9 }, - { 56, 10 }, { 30, 11 }, { 126, 11 }, { 125, 10 }, { 69, 10 }, - { 111, 9 }, { 35, 6 }, { 60, 6 }, { 31, 6 }, { 2, 6 }, - { 16, 6 }, { 1, 6 }, { 86, 8 }, { 76, 8 }, { 94, 8 }, - { 52, 8 }, { 46, 5 }, { 19, 5 }, { 98, 9 }, { 54, 9 }, - { 28, 10 }, { 127, 10 }, { 106, 9 }, { 81, 8 }, { 6, 8 }, - { 89, 9 }, { 12, 11 }, { 135, 12 }, { 15, 12 }, { 43, 10 }, - { 112, 9 }, { 67, 9 }, { 82, 7 }, { 22, 7 }, { 74, 7 }, - { 63, 7 }, { 128, 10 }, { 115, 10 }, { 100, 9 }, { 65, 8 }, - { 47, 5 }, { 34, 5 }, { 95, 8 }, { 57, 10 }, { 10, 10 }, - { 116, 9 }, { 0, 7 }, { 3, 6 }, { 45, 6 }, { 61, 6 }, - { 8, 9 }, { 26, 9 }, { 101, 8 }, { 37, 7 }, { 49, 6 }, - { 83, 7 }, { 24, 8 }, { 113, 9 }, { 79, 9 }, { 87, 8 }, - { 117, 9 }, { 129, 10 }, { 131, 10 }, { 107, 9 }, { 99, 9 }, - { 39, 8 }, { 102, 8 }, { 41, 9 }, { 118, 9 }, { 96, 8 }, - { 77, 8 }, { 70, 7 }, { 5, 7 }, { 51, 7 }, { 55, 9 }, - { 29, 10 }, { 130, 11 }, { 13, 11 }, { 114, 9 }, { 90, 9 }, - { 71, 6 }, { 21, 6 }, { 84, 7 }, { 103, 8 }, { 53, 8 }, - { 17, 4 }, { 32, 4 }, + { 19, 5 }, { 165, 10 }, { 211, 11 }, { 46, 11 }, { 75, 10 }, + { 177, 11 }, { 12, 11 }, { 86, 8 }, { 83, 7 }, { 38, 7 }, + { 133, 9 }, { 178, 10 }, { 28, 10 }, { 104, 9 }, { 73, 9 }, + { 35, 5 }, { 52, 6 }, { 113, 9 }, { 8, 9 }, { 101, 8 }, + { 69, 7 }, { 0, 3 }, { 71, 8 }, { 119, 9 }, { 91, 10 }, + { 179, 10 }, { 114, 8 }, { 166, 10 }, { 10, 10 }, { 44, 10 }, + { 145, 10 }, { 66, 6 }, { 21, 6 }, { 24, 8 }, { 146, 9 }, + { 26, 9 }, { 65, 7 }, { 5, 7 }, { 226, 11 }, { 225, 12 }, + { 15, 12 }, { 180, 10 }, { 147, 9 }, { 115, 8 }, { 40, 8 }, + { 89, 9 }, { 134, 9 }, { 84, 7 }, { 54, 7 }, { 42, 9 }, + { 60, 10 }, { 31, 11 }, { 193, 11 }, { 181, 10 }, { 76, 10 }, + { 148, 9 }, { 37, 6 }, { 67, 6 }, { 33, 6 }, { 3, 6 }, + { 17, 6 }, { 2, 6 }, { 102, 8 }, { 87, 8 }, { 116, 8 }, + { 56, 8 }, { 50, 5 }, { 20, 5 }, { 120, 9 }, { 58, 9 }, + { 29, 10 }, { 194, 10 }, { 135, 9 }, { 97, 8 }, { 7, 8 }, + { 105, 9 }, { 13, 11 }, { 241, 12 }, { 16, 12 }, { 45, 10 }, + { 149, 9 }, { 74, 9 }, { 98, 7 }, { 23, 7 }, { 85, 7 }, + { 70, 7 }, { 195, 10 }, { 161, 10 }, { 129, 9 }, { 72, 8 }, + { 51, 5 }, { 36, 5 }, { 117, 8 }, { 61, 10 }, { 11, 10 }, + { 162, 9 }, { 1, 7 }, { 4, 6 }, { 49, 6 }, { 68, 6 }, + { 9, 9 }, { 27, 9 }, { 130, 8 }, { 39, 7 }, { 53, 6 }, + { 99, 7 }, { 25, 8 }, { 150, 9 }, { 90, 9 }, { 103, 8 }, + { 163, 9 }, { 196, 10 }, { 210, 10 }, { 136, 9 }, { 121, 9 }, + { 41, 8 }, { 131, 8 }, { 43, 9 }, { 164, 9 }, { 118, 8 }, + { 88, 8 }, { 81, 7 }, { 6, 7 }, { 55, 7 }, { 59, 9 }, + { 30, 10 }, { 209, 11 }, { 14, 11 }, { 151, 9 }, { 106, 9 }, + { 82, 6 }, { 22, 6 }, { 100, 7 }, { 132, 8 }, { 57, 8 }, + { 18, 4 }, { 34, 4 }, }; @@ -414,37 +420,6 @@ static const uint8_t vec1_table[HUFF_VEC1_SIZE][2] = { { 80, 10 }, { 81, 10 }, { 43, 8 }, { 44, 8 }, { 24, 6 }, { 12, 4 }, }; - - -static const uint16_t symbol_to_vec4[HUFF_VEC4_SIZE] = { - 0, 1, 2, 3, 4, 5, 16, 17, 18, 19, - 20, 32, 33, 34, 35, 48, 49, 50, 64, 65, - 80, 256, 257, 258, 259, 260, 272, 273, 274, 275, - 288, 289, 290, 304, 305, 320, 512, 513, 514, 515, - 528, 529, 530, 544, 545, 560, 768, 769, 770, 784, - 785, 800, 1024, 1025, 1040, 1280, 4096, 4097, 4098, 4099, - 4100, 4112, 4113, 4114, 4115, 4128, 4129, 4130, 4144, 4145, - 4160, 4352, 4353, 4354, 4355, 4368, 4369, 4370, 4384, 4385, - 4400, 4608, 4609, 4610, 4624, 4625, 4640, 4864, 4865, 4880, - 5120, 8192, 8193, 8194, 8195, 8208, 8209, 8210, 8224, 8225, - 8240, 8448, 8449, 8450, 8464, 8465, 8480, 8704, 8705, 8720, - 8960, 12288, 12289, 12290, 12304, 12305, 12320, 12544, 12545, 12560, - 12800, 16384, 16385, 16400, 16640, 20480, 0, -}; - - -static const uint8_t symbol_to_vec2[HUFF_VEC2_SIZE] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 112, 113, 114, 115, 116, 117, 118, 119, 120, 128, 129, 130, 131, 132, - 133, 134, 135, 144, 145, 146, 147, 148, 149, 150, 160, 161, 162, 163, 164, - 165, 176, 177, 178, 179, 180, 192, 193, 194, 195, 208, 209, 210, 224, 225, - 240, 0, -}; /** @} */ diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 698841dcaf..701dfa955c 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -331,11 +331,11 @@ static av_cold void decode_init_static(void) &coef1_table[0][1], 2, &coef1_table[0][0], 2, 1, 0, 0, 3912); INIT_VLC_STATIC_FROM_LENGTHS(&vec4_vlc, VLCBITS, HUFF_VEC4_SIZE, - &vec4_table[0][1], 2, - &vec4_table[0][0], 2, 1, 0, 0, 604); + vec4_lens, 1, + vec4_syms, 2, 2, -1, 0, 604); INIT_VLC_STATIC_FROM_LENGTHS(&vec2_vlc, VLCBITS, HUFF_VEC2_SIZE, &vec2_table[0][1], 2, - &vec2_table[0][0], 2, 1, 0, 0, 562); + &vec2_table[0][0], 2, 1, -1, 0, 562); INIT_VLC_STATIC_FROM_LENGTHS(&vec1_vlc, VLCBITS, HUFF_VEC1_SIZE, &vec1_table[0][1], 2, &vec1_table[0][0], 2, 1, 0, 0, 562); @@ -957,10 +957,10 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) idx = get_vlc2(&s->gb, vec4_vlc.table, VLCBITS, VEC4MAXDEPTH); - if (idx == HUFF_VEC4_SIZE - 1) { + if ((int)idx < 0) { for (i = 0; i < 4; i += 2) { idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH); - if (idx == HUFF_VEC2_SIZE - 1) { + if ((int)idx < 0) { uint32_t v0, v1; v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (v0 == HUFF_VEC1_SIZE - 1) @@ -971,15 +971,15 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) vals[i ] = av_float2int(v0); vals[i+1] = av_float2int(v1); } else { - vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ]; - vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF]; + vals[i] = fval_tab[idx >> 4 ]; + vals[i+1] = fval_tab[idx & 0xF]; } } } else { - vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12 ]; - vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF]; - vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF]; - vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF]; + vals[0] = fval_tab[ idx >> 12 ]; + vals[1] = fval_tab[(idx >> 8) & 0xF]; + vals[2] = fval_tab[(idx >> 4) & 0xF]; + vals[3] = fval_tab[ idx & 0xF]; } /** decode sign */ From ff6f2c558640bcb6ee9f6b17f259645c4193151b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 2 Sep 2022 20:51:24 +0200 Subject: [PATCH 192/590] avcodec/ffv1: Only allocate ThreadFrames for the decoder The FFV1 decoder only uses the last frame's data to conceal errors. The encoder does not have this problem and therefore only uses the current frame and none of the ThreadFrames. So only allocate them for the decoder. Signed-off-by: Andreas Rheinhardt --- libavcodec/ffv1.c | 13 ------------- libavcodec/ffv1dec.c | 23 ++++++++++++++++++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index c8781cdaaa..b6204740ed 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -43,11 +43,6 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx) s->avctx = avctx; s->flags = avctx->flags; - s->picture.f = av_frame_alloc(); - s->last_picture.f = av_frame_alloc(); - if (!s->picture.f || !s->last_picture.f) - return AVERROR(ENOMEM); - s->width = avctx->width; s->height = avctx->height; @@ -198,14 +193,6 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) FFV1Context *s = avctx->priv_data; int i, j; - if (s->picture.f) - ff_thread_release_ext_buffer(avctx, &s->picture); - av_frame_free(&s->picture.f); - - if (s->last_picture.f) - ff_thread_release_ext_buffer(avctx, &s->last_picture); - av_frame_free(&s->last_picture.f); - for (j = 0; j < s->max_slice_count; j++) { FFV1Context *fs = s->slice_context[j]; for (i = 0; i < s->plane_count; i++) { diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 794c58cc40..d4bc60a7da 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -823,6 +823,11 @@ static av_cold int decode_init(AVCodecContext *avctx) if ((ret = ff_ffv1_common_init(avctx)) < 0) return ret; + f->picture.f = av_frame_alloc(); + f->last_picture.f = av_frame_alloc(); + if (!f->picture.f || !f->last_picture.f) + return AVERROR(ENOMEM); + if (avctx->extradata_size > 0 && (ret = read_extra_header(f)) < 0) return ret; @@ -1068,6 +1073,22 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) } #endif +static av_cold int ffv1_decode_close(AVCodecContext *avctx) +{ + FFV1Context *const s = avctx->priv_data; + + if (s->picture.f) { + ff_thread_release_ext_buffer(avctx, &s->picture); + av_frame_free(&s->picture.f); + } + + if (s->last_picture.f) { + ff_thread_release_ext_buffer(avctx, &s->last_picture); + av_frame_free(&s->last_picture.f); + } + return ff_ffv1_close(avctx); +} + const FFCodec ff_ffv1_decoder = { .p.name = "ffv1", CODEC_LONG_NAME("FFmpeg video codec #1"), @@ -1075,7 +1096,7 @@ const FFCodec ff_ffv1_decoder = { .p.id = AV_CODEC_ID_FFV1, .priv_data_size = sizeof(FFV1Context), .init = decode_init, - .close = ff_ffv1_close, + .close = ffv1_decode_close, FF_CODEC_DECODE_CB(decode_frame), UPDATE_THREAD_CONTEXT(update_thread_context), .p.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ | From a5b6e292271f18d309389e7672e362332dc7dd7c Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Thu, 1 Sep 2022 10:12:57 +0800 Subject: [PATCH 193/590] lavc/qsvenc: use VBR if maxrate is not specified on Windows Currently AVBR is disabled and VBR is the default method if maxrate is not specified on Linux, but AVBR is the default one if maxrate is not specified on Windows. In order to make user experience better accross Linux and Windows, use VBR by default on Windows if maxrate is not specified. User need to set both avbr_accuracy and avbr_convergence to non-zero explicitly and not to specify maxrate if AVBR is expected. In addition, AVBR works for H264 and HEVC only in the SDK. $ ffmpeg.exe -v verbose -f lavfi -i yuvtestsrc -vf "format=nv12" -c:v vp9_qsv -f null - --- doc/encoders.texi | 45 ++++++++++++++++++++++++++-------------- libavcodec/qsvenc.c | 5 ++++- libavcodec/qsvenc.h | 6 ++++-- libavcodec/qsvenc_h264.c | 1 + libavcodec/qsvenc_hevc.c | 1 + 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index d36464d629..d2046e437d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3244,9 +3244,9 @@ the average bitrate. than the average bitrate. @item -@var{AVBR} - average VBR mode, when @option{maxrate} is not specified. This mode -is further configured by the @option{avbr_accuracy} and -@option{avbr_convergence} options. +@var{AVBR} - average VBR mode, when @option{maxrate} is not specified, both +@option{avbr_accuracy} and @option{avbr_convergence} are set to non-zero. This +mode is available for H264 and HEVC on Windows. @end itemize @end itemize @@ -3300,19 +3300,6 @@ Specifies how many asynchronous operations an application performs before the application explicitly synchronizes the result. If zero, the value is not specified. -@item @var{avbr_accuracy} -Accuracy of the AVBR ratecontrol (unit of tenth of percent). - -@item @var{avbr_convergence} -Convergence of the AVBR ratecontrol (unit of 100 frames) - -The parameters @var{avbr_accuracy} and @var{avbr_convergence} are for the -average variable bitrate control (AVBR) algorithm. -The algorithm focuses on overall encoding quality while meeting the specified -bitrate, @var{target_bitrate}, within the accuracy range @var{avbr_accuracy}, -after a @var{avbr_Convergence} period. This method does not follow HRD and the -instant bitrate is not capped or padded. - @item @var{preset} This option itemizes a range of choices from veryfast (best speed) to veryslow (best quality). @@ -3518,6 +3505,19 @@ Provides a hint to encoder about the scenario for the encoding session. @item remotegaming @end table +@item @var{avbr_accuracy} +Accuracy of the AVBR ratecontrol (unit of tenth of percent). + +@item @var{avbr_convergence} +Convergence of the AVBR ratecontrol (unit of 100 frames) + +The parameters @var{avbr_accuracy} and @var{avbr_convergence} are for the +average variable bitrate control (AVBR) algorithm. +The algorithm focuses on overall encoding quality while meeting the specified +bitrate, @var{target_bitrate}, within the accuracy range @var{avbr_accuracy}, +after a @var{avbr_Convergence} period. This method does not follow HRD and the +instant bitrate is not capped or padded. + @end table @subsection HEVC Options @@ -3681,6 +3681,19 @@ Provides a hint to encoder about the scenario for the encoding session. @item remotegaming @end table +@item @var{avbr_accuracy} +Accuracy of the AVBR ratecontrol (unit of tenth of percent). + +@item @var{avbr_convergence} +Convergence of the AVBR ratecontrol (unit of 100 frames) + +The parameters @var{avbr_accuracy} and @var{avbr_convergence} are for the +average variable bitrate control (AVBR) algorithm. +The algorithm focuses on overall encoding quality while meeting the specified +bitrate, @var{target_bitrate}, within the accuracy range @var{avbr_accuracy}, +after a @var{avbr_Convergence} period. This method does not follow HRD and the +instant bitrate is not capped or padded. + @end table @subsection MPEG2 Options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 7ac5390f10..31ff3b76ed 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -479,7 +479,10 @@ static int select_rc_mode(AVCodecContext *avctx, QSVEncContext *q) rc_desc = "constant bitrate (CBR)"; } #if QSV_HAVE_AVBR - else if (!avctx->rc_max_rate) { + else if (!avctx->rc_max_rate && + (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) && + q->avbr_accuracy && + q->avbr_convergence) { rc_mode = MFX_RATECONTROL_AVBR; rc_desc = "average variable bitrate (AVBR)"; } diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index a983651dda..ff859f2a7e 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -52,8 +52,6 @@ #define QSV_COMMON_OPTS \ { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE }, \ -{ "avbr_accuracy", "Accuracy of the AVBR ratecontrol (unit of tenth of percent)", OFFSET(qsv.avbr_accuracy), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, UINT16_MAX, VE }, \ -{ "avbr_convergence", "Convergence of the AVBR ratecontrol (unit of 100 frames)", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, UINT16_MAX, VE }, \ { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ { "veryfast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, \ { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_6 }, INT_MIN, INT_MAX, VE, "preset" }, \ @@ -124,6 +122,10 @@ { "gamestreaming", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCENARIO_GAME_STREAMING }, .flags = VE, "scenario" }, \ { "remotegaming", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCENARIO_REMOTE_GAMING }, .flags = VE, "scenario" }, +#define QSV_OPTION_AVBR \ +{ "avbr_accuracy", "Accuracy of the AVBR ratecontrol (unit of tenth of percent)", OFFSET(qsv.avbr_accuracy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE }, \ +{ "avbr_convergence", "Convergence of the AVBR ratecontrol (unit of 100 frames)", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, UINT16_MAX, VE }, + extern const AVCodecHWConfigInternal *const ff_qsv_enc_hw_configs[]; typedef int SetEncodeCtrlCB (AVCodecContext *avctx, diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 1bbdc45203..3fae8f0200 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -115,6 +115,7 @@ static const AVOption options[] = { QSV_OPTION_LOW_DELAY_BRC QSV_OPTION_MAX_MIN_QP QSV_OPTION_SCENARIO + QSV_OPTION_AVBR { "cavlc", "Enable CAVLC", OFFSET(qsv.cavlc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, #if QSV_HAVE_VCM diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 5986c3f1a6..98e002a305 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -236,6 +236,7 @@ static const AVOption options[] = { QSV_OPTION_ADAPTIVE_I QSV_OPTION_ADAPTIVE_B QSV_OPTION_SCENARIO + QSV_OPTION_AVBR { "idr_interval", "Distance (in I-frames) between IDR frames", OFFSET(qsv.idr_interval), AV_OPT_TYPE_INT, { .i64 = 0 }, -1, INT_MAX, VE, "idr_interval" }, { "begin_only", "Output an IDR-frame only at the beginning of the stream", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "idr_interval" }, From b7dbffe69801d15cd1ba59223f94b449c2ac8dbc Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Tue, 6 Sep 2022 12:53:37 +0800 Subject: [PATCH 194/590] lavu/hwcontext_qsv: add support for AV_PIX_FMT_VUYX on Linux AV_PIX_FMT_VUYX is used for 8bit 4:4:4 content in FFmpeg VAAPI, so AV_PIX_FMT_VUYX should be used for 8bit 4:4:4 content in FFmpeg QSV too because QSV is based on VAAPI on Linux. However the SDK only declares support for AYUV and does nothing with the alpha, so this commit fudged a mapping between AV_PIX_FMT_VUYX and MFX_FOURCC_AYUV. Reviewed-by: Philip Langdale Signed-off-by: Haihao Xiang --- libavutil/hwcontext_qsv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 510f422562..9fa0dfa1c0 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -119,6 +119,10 @@ static const struct { MFX_FOURCC_YUY2 }, { AV_PIX_FMT_Y210, MFX_FOURCC_Y210 }, + // VUYX is used for VAAPI child device, + // the SDK only delares support for AYUV + { AV_PIX_FMT_VUYX, + MFX_FOURCC_AYUV }, #endif }; @@ -1502,6 +1506,14 @@ static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface) surface->Data.U16 = (mfxU16 *)frame->data[0] + 1; surface->Data.V16 = (mfxU16 *)frame->data[0] + 3; break; + case AV_PIX_FMT_VUYX: + surface->Data.V = frame->data[0]; + surface->Data.U = frame->data[0] + 1; + surface->Data.Y = frame->data[0] + 2; + // Only set Data.A to a valid address, the SDK doesn't + // use the value from the frame. + surface->Data.A = frame->data[0] + 3; + break; #endif default: return MFX_ERR_UNSUPPORTED; From db85e01fd7976150a522a1881f3479661d8c1a79 Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Tue, 6 Sep 2022 12:53:38 +0800 Subject: [PATCH 195/590] lavc/qsv: Add support for decoding & encoding 8bit 4:4:4 content AV_PIX_FMT_VUYX is used in FFmpeg and MFX_FOURCC_AYUV is used in the SDK Reviewed-by: Philip Langdale Signed-off-by: Haihao Xiang --- libavcodec/qsv.c | 14 ++++++++++++++ libavcodec/qsvdec.c | 2 ++ libavcodec/qsvenc_hevc.c | 1 + libavcodec/qsvenc_vp9.c | 1 + 4 files changed, 18 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 3449789a2c..51aac16695 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -211,6 +211,7 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc) #if CONFIG_VAAPI case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422; case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210; + case MFX_FOURCC_AYUV: return AV_PIX_FMT_VUYX; #endif } return AV_PIX_FMT_NONE; @@ -243,6 +244,9 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc) case AV_PIX_FMT_Y210: *fourcc = MFX_FOURCC_Y210; return AV_PIX_FMT_Y210; + case AV_PIX_FMT_VUYX: + *fourcc = MFX_FOURCC_AYUV; + return AV_PIX_FMT_VUYX; #endif default: return AVERROR(ENOSYS); @@ -277,6 +281,16 @@ int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface) surface->Data.U16 = (mfxU16 *)frame->data[0] + 1; surface->Data.V16 = (mfxU16 *)frame->data[0] + 3; break; + + case AV_PIX_FMT_VUYX: + surface->Data.V = frame->data[0]; + surface->Data.U = frame->data[0] + 1; + surface->Data.Y = frame->data[0] + 2; + // Only set Data.A to a valid address, the SDK doesn't + // use the value from the frame. + surface->Data.A = frame->data[0] + 3; + break; + default: return AVERROR(ENOSYS); } diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 0f0d719e23..0254a394bd 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -141,6 +141,7 @@ static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, frame->linesize[0] = 2 * FFALIGN(avctx->width, 128); break; case AV_PIX_FMT_Y210: + case AV_PIX_FMT_VUYX: frame->linesize[0] = 4 * FFALIGN(avctx->width, 128); break; default: @@ -1041,6 +1042,7 @@ const FFCodec ff_##x##_qsv_decoder = { \ AV_PIX_FMT_P010, \ AV_PIX_FMT_YUYV422, \ AV_PIX_FMT_Y210, \ + AV_PIX_FMT_VUYX, \ AV_PIX_FMT_QSV, \ AV_PIX_FMT_NONE }, \ .hw_configs = qsv_hw_configs, \ diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 98e002a305..45b373d643 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -315,6 +315,7 @@ const FFCodec ff_hevc_qsv_encoder = { AV_PIX_FMT_QSV, AV_PIX_FMT_BGRA, AV_PIX_FMT_X2RGB10, + AV_PIX_FMT_VUYX, AV_PIX_FMT_NONE }, .p.priv_class = &class, .defaults = qsv_enc_defaults, diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c index 61d50156d3..044a882d1a 100644 --- a/libavcodec/qsvenc_vp9.c +++ b/libavcodec/qsvenc_vp9.c @@ -113,6 +113,7 @@ const FFCodec ff_vp9_qsv_encoder = { .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, AV_PIX_FMT_P010, + AV_PIX_FMT_VUYX, AV_PIX_FMT_QSV, AV_PIX_FMT_NONE }, .p.priv_class = &class, From 6e91d405be3c8a1ded025498085e0e606e337030 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Thu, 25 Aug 2022 20:21:53 -0700 Subject: [PATCH 196/590] avformat/imfdec: check if Asset/Id exists before trying to read it Fixes Coverity issue #1512406 Signed-off-by: Andreas Rheinhardt --- libavformat/imfdec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 5bbe7a53f8..fde91a6419 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -233,7 +233,12 @@ static int parse_imf_asset_map_from_xml_dom(AVFormatContext *s, asset = &(asset_map->assets[asset_map->asset_count]); - if (ff_imf_xml_read_uuid(ff_imf_xml_get_child_element_by_name(asset_element, "Id"), asset->uuid)) { + if (!(node = ff_imf_xml_get_child_element_by_name(asset_element, "Id"))) { + av_log(s, AV_LOG_ERROR, "Unable to parse asset map XML - missing Id node\n"); + return AVERROR_INVALIDDATA; + } + + if (ff_imf_xml_read_uuid(node, asset->uuid)) { av_log(s, AV_LOG_ERROR, "Could not parse UUID from asset in asset map.\n"); return AVERROR_INVALIDDATA; } From e4c127271198ebb799f19cb96cc1a6b62506e0d1 Mon Sep 17 00:00:00 2001 From: Qi Tiezheng Date: Thu, 18 Aug 2022 14:27:44 +0800 Subject: [PATCH 197/590] avcodec/mips: Fix MMI macro replaces in HEVC Decoder The latest commit of Loongson MMI macro replaces were incorrect. It makes a mass of green tints on HEVC videos when playing. I've compared it with the older MMI implementation, and found out that several lines have been replaced by wrong macros. Signed-off-by: Qi Tiezheng Reviewed-by: Shiyou Yin Signed-off-by: Michael Niedermayer --- libavcodec/mips/hevcdsp_mmi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mips/hevcdsp_mmi.c b/libavcodec/mips/hevcdsp_mmi.c index 0ea88a7c08..1da56d3d87 100644 --- a/libavcodec/mips/hevcdsp_mmi.c +++ b/libavcodec/mips/hevcdsp_mmi.c @@ -80,7 +80,7 @@ void ff_hevc_put_hevc_qpel_h##w##_8_mmi(int16_t *dst, const uint8_t *_src, \ "paddh %[ftmp3], %[ftmp3], %[ftmp4] \n\t" \ "paddh %[ftmp5], %[ftmp5], %[ftmp6] \n\t" \ "paddh %[ftmp3], %[ftmp3], %[ftmp5] \n\t" \ - MMI_ULDC1(%[ftmp3], %[dst], 0x00) \ + MMI_USDC1(%[ftmp3], %[dst], 0x00) \ \ "daddi %[x], %[x], -0x01 \n\t" \ PTR_ADDIU "%[src], %[src], 0x04 \n\t" \ @@ -178,7 +178,7 @@ void ff_hevc_put_hevc_qpel_hv##w##_8_mmi(int16_t *dst, const uint8_t *_src,\ "paddh %[ftmp3], %[ftmp3], %[ftmp4] \n\t" \ "paddh %[ftmp5], %[ftmp5], %[ftmp6] \n\t" \ "paddh %[ftmp3], %[ftmp3], %[ftmp5] \n\t" \ - MMI_ULDC1(%[ftmp3], %[tmp], 0x00) \ + MMI_USDC1(%[ftmp3], %[tmp], 0x00) \ \ "daddi %[x], %[x], -0x01 \n\t" \ PTR_ADDIU "%[src], %[src], 0x04 \n\t" \ @@ -690,10 +690,10 @@ void ff_hevc_put_hevc_epel_bi_hv##w##_8_mmi(uint8_t *_dst, \ \ "1: \n\t" \ "2: \n\t" \ - MMI_ULDC1(%[ftmp3], %[src], 0x00) \ - MMI_ULDC1(%[ftmp4], %[src], 0x01) \ - MMI_ULDC1(%[ftmp5], %[src], 0x02) \ - MMI_ULDC1(%[ftmp6], %[src], 0x03) \ + MMI_ULWC1(%[ftmp2], %[src], 0x00) \ + MMI_ULWC1(%[ftmp3], %[src], 0x01) \ + MMI_ULWC1(%[ftmp4], %[src], 0x02) \ + MMI_ULWC1(%[ftmp5], %[src], 0x03) \ "punpcklbh %[ftmp2], %[ftmp2], %[ftmp0] \n\t" \ "pmullh %[ftmp2], %[ftmp2], %[ftmp1] \n\t" \ "punpcklbh %[ftmp3], %[ftmp3], %[ftmp0] \n\t" \ @@ -707,7 +707,7 @@ void ff_hevc_put_hevc_epel_bi_hv##w##_8_mmi(uint8_t *_dst, \ "paddh %[ftmp2], %[ftmp2], %[ftmp3] \n\t" \ "paddh %[ftmp4], %[ftmp4], %[ftmp5] \n\t" \ "paddh %[ftmp2], %[ftmp2], %[ftmp4] \n\t" \ - MMI_ULDC1(%[ftmp2], %[tmp], 0x00) \ + MMI_USDC1(%[ftmp2], %[tmp], 0x00) \ \ "daddi %[x], %[x], -0x01 \n\t" \ PTR_ADDIU "%[src], %[src], 0x04 \n\t" \ @@ -773,7 +773,7 @@ void ff_hevc_put_hevc_epel_bi_hv##w##_8_mmi(uint8_t *_dst, \ "paddw %[ftmp5], %[ftmp5], %[ftmp6] \n\t" \ "psraw %[ftmp5], %[ftmp5], %[ftmp0] \n\t" \ "packsswh %[ftmp3], %[ftmp3], %[ftmp5] \n\t" \ - MMI_ULDC1(%[ftmp4], %[tmp], 0x02) \ + MMI_ULDC1(%[ftmp4], %[src2], 0x00) \ "li %[rtmp0], 0x10 \n\t" \ "dmtc1 %[rtmp0], %[ftmp8] \n\t" \ "punpcklhw %[ftmp5], %[ftmp2], %[ftmp3] \n\t" \ From 5ca781598e1a7c24aec7ebada16e8ad8c5725a41 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 5 Sep 2022 18:12:10 +0200 Subject: [PATCH 198/590] avcodec/flac_parser: ensure there are more headers for scoring Previously invalid frame may be returned, happened when seeking. Fixes #7684 --- libavcodec/flac_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index a1d9cd7f29..11cd5540cf 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -600,7 +600,7 @@ static int score_header(FLACParseContext *fpc, FLACHeaderMarker *header) static void score_sequences(FLACParseContext *fpc) { FLACHeaderMarker *curr; - int best_score = 0;//FLAC_HEADER_NOT_SCORED_YET; + int best_score = FLAC_HEADER_NOT_SCORED_YET; /* First pass to clear all old scores. */ for (curr = fpc->headers; curr; curr = curr->next) curr->max_score = FLAC_HEADER_NOT_SCORED_YET; @@ -682,7 +682,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, } fpc->avctx = avctx; - if (fpc->best_header_valid) + if (fpc->best_header_valid && fpc->nb_headers_buffered >= FLAC_MIN_HEADERS) return get_best_header(fpc, poutbuf, poutbuf_size); /* If a best_header was found last call remove it with the buffer data. */ From 0912e79376601f5620e29e448086515760982909 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 5 Sep 2022 20:16:13 +0200 Subject: [PATCH 199/590] avcodec/flac_parser: add missed opportunity to check crc Fixes #9621 --- libavcodec/flac_parser.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 11cd5540cf..5b3a4e6e67 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -455,7 +455,7 @@ static int check_header_mismatch(FLACParseContext *fpc, int log_level_offset) { FLACFrameInfo *header_fi = &header->fi, *child_fi = &child->fi; - int deduction, deduction_expected = 0, i; + int check_crc, deduction, deduction_expected = 0, i; deduction = check_header_fi_mismatch(fpc, header_fi, child_fi, log_level_offset); /* Check sample and frame numbers. */ @@ -491,8 +491,22 @@ static int check_header_mismatch(FLACParseContext *fpc, "sample/frame number mismatch in adjacent frames\n"); } + if (fpc->last_fi.is_var_size == header_fi->is_var_size) { + if (fpc->last_fi.is_var_size && + fpc->last_fi.frame_or_sample_num + fpc->last_fi.blocksize == header_fi->frame_or_sample_num) { + check_crc = 0; + } else if (!fpc->last_fi.is_var_size && + fpc->last_fi.frame_or_sample_num + 1 == header_fi->frame_or_sample_num) { + check_crc = 0; + } else { + check_crc = !deduction && !deduction_expected; + } + } else { + check_crc = !deduction && !deduction_expected; + } + /* If we have suspicious headers, check the CRC between them */ - if (deduction && !deduction_expected) { + if (check_crc || (deduction && !deduction_expected)) { FLACHeaderMarker *curr; int read_len; uint8_t *buf; From d2428d80ce4b791587a53cdb4828a84d077384f2 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 8 Sep 2022 01:43:01 +0200 Subject: [PATCH 200/590] swscale/input: Remove spec-incompliant ';' These macros are definitions, not only declarations and therefore should not contain a semicolon. Such a semicolon is actually spec-incompliant, but compilers happen to accept them. Reviewed-by: Philip Langdale Signed-off-by: Andreas Rheinhardt --- libswscale/input.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index be8f3940e1..88e318e664 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -583,8 +583,8 @@ static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> shift); \ } -y21xle_wrapper(10, 6); -y21xle_wrapper(12, 4); +y21xle_wrapper(10, 6) +y21xle_wrapper(12, 4) static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused, void *opq) @@ -828,9 +828,9 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV, } \ p01x_uv_wrapper(bits, shift) -p01x_wrapper(10, 6); -p01x_wrapper(12, 4); -p01x_uv_wrapper(16, 0); +p01x_wrapper(10, 6) +p01x_wrapper(12, 4) +p01x_uv_wrapper(16, 0) #define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos)) From 31581ae7ee6d007f2f2dcd16de5df991ba7aa1b6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 21 Jul 2022 20:15:06 +0200 Subject: [PATCH 201/590] avfilter/vf_showinfo: remove backspaces They mess with storing editing and comparing the results Signed-off-by: Michael Niedermayer --- libavfilter/vf_showinfo.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 2c8514fc80..9b4a9fc981 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -733,12 +733,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) av_log(ctx, AV_LOG_INFO, " %08"PRIX32, plane_checksum[plane]); av_log(ctx, AV_LOG_INFO, "] mean:["); for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) - av_log(ctx, AV_LOG_INFO, "%"PRId64" ", (sum[plane] + pixelcount[plane]/2) / pixelcount[plane]); - av_log(ctx, AV_LOG_INFO, "\b] stdev:["); + av_log(ctx, AV_LOG_INFO, "%s%"PRId64, + plane ? " ":"", + (sum[plane] + pixelcount[plane]/2) / pixelcount[plane]); + av_log(ctx, AV_LOG_INFO, "] stdev:["); for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) - av_log(ctx, AV_LOG_INFO, "%3.1f ", + av_log(ctx, AV_LOG_INFO, "%s%3.1f", + plane ? " ":"", sqrt((sum2[plane] - sum[plane]*(double)sum[plane]/pixelcount[plane])/pixelcount[plane])); - av_log(ctx, AV_LOG_INFO, "\b]"); + av_log(ctx, AV_LOG_INFO, "]"); } av_log(ctx, AV_LOG_INFO, "\n"); From 836b8001c924deb9263b0f5b7c74ccfaab1f4fdc Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 15 Aug 2022 20:14:42 -0300 Subject: [PATCH 202/590] avformat/mov: don't read duration from mvhd atom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This duration is equal to the longest duration in all track's tkhd atoms, which may be comprised of the sum of all edit lists in each track. Empty edit lists in tracks represent start_time, and the actual media duration is stored in the mdhd atom. This change lets the generic demux code derive the longest track duration taken from mdhd atoms, so the correct duration and start_time combination will be reported. Should fix ticket #9775. Reviewed-by: zhilizhao(赵志立) Signed-off-by: James Almer --- libavformat/mov.c | 4 ---- tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index a1bc627991..720a72f3ec 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1520,10 +1520,6 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale); c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ - // set the AVFormatContext duration because the duration of individual tracks - // may be inaccurate - if (!c->trex_data) - c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale); avio_rb32(pb); /* preferred scale */ avio_rb16(pb); /* preferred volume */ diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac index f967ac05bc..1f89e9af85 100644 --- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac +++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac @@ -5,7 +5,7 @@ duration_ts=103326 [/STREAM] [FORMAT] start_time=0.000000 -duration=2.344000 +duration=2.342993 [/FORMAT] packet|pts=-1024|dts=-1024|duration=1024|flags=KD|side_data| From 04e49bbbb1cdf4a67e6533dc8ae29a8de1ba6837 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:52 +0800 Subject: [PATCH 203/590] libavcodec/qsvenc: skip parameter resetting on mjpeg_qsv mjpeg_qsv don't support dynamic resetting, so skip it. Signed-off-by: Wenbin Chen --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 31ff3b76ed..941a12ffbd 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1683,7 +1683,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, { int needReset = 0, ret = 0; - if (!frame) + if (!frame || avctx->codec_id == AV_CODEC_ID_MJPEG) return 0; needReset = update_qp(avctx, q); From c679de9be0d76e4eadc42f68421a569ff304c3e6 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:53 +0800 Subject: [PATCH 204/590] libavcodec/qsvenc: Add max_frame_size reset support to qsv Signed-off-by: Wenbin Chen --- doc/encoders.texi | 4 ++++ libavcodec/qsvenc.c | 20 ++++++++++++++++++++ libavcodec/qsvenc.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index d2046e437d..e619827c90 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3331,6 +3331,10 @@ Following options can be used durning qsv encoding. @item @var{b_quant_offset} Supported in h264_qsv and hevc_qsv. Change these value to reset qsv codec's qp configuration. + +@item @var{max_frame_size} +Supported in h264_qsv and hevc_qsv. +Change this value to reset qsv codec's MaxFrameSize configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 941a12ffbd..b1f49e95fa 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -827,6 +827,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; if (q->max_frame_size >= 0) q->extco2.MaxFrameSize = q->max_frame_size; + q->old_max_frame_size = q->max_frame_size; if (q->int_ref_type >= 0) q->extco2.IntRefType = q->int_ref_type; if (q->int_ref_cycle_size >= 0) @@ -1678,6 +1679,24 @@ static int update_qp(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_max_frame_size, q->max_frame_size); + if (!updated) + return 0; + + q->extco2.MaxFrameSize = FFMAX(0, q->max_frame_size); + av_log(avctx, AV_LOG_DEBUG, + "Reset MaxFrameSize: %d;\n", q->extco2.MaxFrameSize); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1687,6 +1706,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, return 0; needReset = update_qp(avctx, q); + needReset |= update_max_frame_size(avctx, q); if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index ff859f2a7e..9914351de4 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -251,6 +251,8 @@ typedef struct QSVEncContext { float old_i_quant_offset; float old_b_quant_factor; float old_b_quant_offset; + // This is used for max_frame_size reset + int old_max_frame_size; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From d60f657a50773ae8371585539bf484aa072bfc71 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:54 +0800 Subject: [PATCH 205/590] libavcodec/qsvenc: Add gop_size reset support to qsvenc Signed-off-by: Wenbin Chen --- doc/encoders.texi | 3 +++ libavcodec/qsvenc.c | 16 ++++++++++++++++ libavcodec/qsvenc.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index e619827c90..51178c9f5c 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3335,6 +3335,9 @@ Change these value to reset qsv codec's qp configuration. @item @var{max_frame_size} Supported in h264_qsv and hevc_qsv. Change this value to reset qsv codec's MaxFrameSize configuration. + +@item @var{gop_size} +Change this value to reset qsv codec's gop configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index b1f49e95fa..58b6284b30 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -639,6 +639,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.CodecProfile = q->profile; q->param.mfx.TargetUsage = avctx->compression_level; q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); + q->old_gop_size = avctx->gop_size; q->param.mfx.GopRefDist = FFMAX(-1, avctx->max_b_frames) + 1; q->param.mfx.GopOptFlag = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? MFX_GOP_CLOSED : MFX_GOP_STRICT; @@ -1697,6 +1698,20 @@ static int update_max_frame_size(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_gop_size(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + UPDATE_PARAM(q->old_gop_size, avctx->gop_size); + if (!updated) + return 0; + + q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size); + av_log(avctx, AV_LOG_DEBUG, "reset GopPicSize to %d\n", + q->param.mfx.GopPicSize); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1707,6 +1722,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset = update_qp(avctx, q); needReset |= update_max_frame_size(avctx, q); + needReset |= update_gop_size(avctx, q); if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 9914351de4..ead790fd2c 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -253,6 +253,8 @@ typedef struct QSVEncContext { float old_b_quant_offset; // This is used for max_frame_size reset int old_max_frame_size; + // This is used for gop reset + int old_gop_size; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From f3ba1458b6787484978e9a8f1560dcabfefba92d Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:55 +0800 Subject: [PATCH 206/590] libavcodec/qsvenc: Add "slice" intra refresh type to qsvenc Add "slice" intra refresh type to h264_qsv and hevc_qsv. This type means horizontal refresh by slices without overlapping. Also update the doc. Signed-off-by: Wenbin Chen --- doc/encoders.texi | 12 ++++++++---- libavcodec/qsvenc_h264.c | 1 + libavcodec/qsvenc_hevc.c | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 51178c9f5c..333a47d2a7 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3441,8 +3441,10 @@ Specifies intra refresh type. The major goal of intra refresh is improvement of error resilience without significant impact on encoded bitstream size caused by I frames. The SDK encoder achieves this by encoding part of each frame in refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} means -vertical refresh, by column of MBs. To enable intra refresh, B frame should be -set to 0. +vertical refresh, by column of MBs. @var{horizontal} means horizontal refresh, +by rows of MBs. @var{slice} means horizontal refresh by slices without +overlapping. In case of @var{slice}, in_ref_cycle_size is ignored. To enable +intra refresh, B frame should be set to 0. @item @var{int_ref_cycle_size} Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are @@ -3641,8 +3643,10 @@ Specifies intra refresh type. The major goal of intra refresh is improvement of error resilience without significant impact on encoded bitstream size caused by I frames. The SDK encoder achieves this by encoding part of each frame in refresh cycle using intra MBs. @var{none} means no refresh. @var{vertical} means -vertical refresh, by column of MBs. To enable intra refresh, B frame should be -set to 0. +vertical refresh, by column of MBs. @var{horizontal} means horizontal refresh, +by rows of MBs. @var{slice} means horizontal refresh by slices without +overlapping. In case of @var{slice}, in_ref_cycle_size is ignored. To enable +intra refresh, B frame should be set to 0. @item @var{int_ref_cycle_size} Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 3fae8f0200..85826ae4be 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -140,6 +140,7 @@ static const AVOption options[] = { { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, "int_ref_type" }, { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, "int_ref_type" }, { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, "int_ref_type" }, + { "slice" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, .flags = VE, "int_ref_type" }, { "int_ref_cycle_size", "Number of frames in the intra refresh cycle", OFFSET(qsv.int_ref_cycle_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE }, { "int_ref_qp_delta", "QP difference for the refresh MBs", OFFSET(qsv.int_ref_qp_delta), AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN, INT16_MAX, VE }, { "recovery_point_sei", "Insert recovery point SEI messages", OFFSET(qsv.recovery_point_sei), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 45b373d643..6ec6230999 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -271,6 +271,7 @@ static const AVOption options[] = { { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .flags = VE, "int_ref_type" }, { "vertical", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = VE, "int_ref_type" }, { "horizontal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, .flags = VE, "int_ref_type" }, + { "slice" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 }, .flags = VE, "int_ref_type" }, { "int_ref_cycle_size", "Number of frames in the intra refresh cycle", OFFSET(qsv.int_ref_cycle_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, UINT16_MAX, VE }, { "int_ref_qp_delta", "QP difference for the refresh MBs", OFFSET(qsv.int_ref_qp_delta), AV_OPT_TYPE_INT, { .i64 = INT16_MIN }, INT16_MIN, INT16_MAX, VE }, { "int_ref_cycle_dist", "Distance between the beginnings of the intra-refresh cycles in frames", OFFSET(qsv.int_ref_cycle_dist), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT16_MAX, VE }, From 9155ec096b0076bf5090c22c8c2f0f67bd8ee086 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:56 +0800 Subject: [PATCH 207/590] libavcodec/qsvenc: Add intra refresh reset support to qsvenc Signed-off-by: Wenbin Chen --- doc/encoders.texi | 7 +++++++ libavcodec/qsvenc.c | 33 +++++++++++++++++++++++++++++++++ libavcodec/qsvenc.h | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 333a47d2a7..f2fef0deab 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3338,6 +3338,13 @@ Change this value to reset qsv codec's MaxFrameSize configuration. @item @var{gop_size} Change this value to reset qsv codec's gop configuration. + +@item @var{int_ref_type} +@item @var{int_ref_cycle_size} +@item @var{int_ref_qp_delta} +@item @var{int_ref_cycle_dist} +Supported in h264_qsv and hevc_qsv. +Change these value to reset qsv codec's Intra Refresh configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 58b6284b30..4ed73e7817 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -831,10 +831,13 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->old_max_frame_size = q->max_frame_size; if (q->int_ref_type >= 0) q->extco2.IntRefType = q->int_ref_type; + q->old_int_ref_type = q->int_ref_type; if (q->int_ref_cycle_size >= 0) q->extco2.IntRefCycleSize = q->int_ref_cycle_size; + q->old_int_ref_cycle_size = q->int_ref_cycle_size; if (q->int_ref_qp_delta != INT16_MIN) q->extco2.IntRefQPDelta = q->int_ref_qp_delta; + q->old_int_ref_qp_delta = q->int_ref_qp_delta; if (q->max_slice_size >= 0) q->extco2.MaxSliceSize = q->max_slice_size; q->extco2.DisableDeblockingIdc = q->dblk_idc; @@ -923,6 +926,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) } if (q->int_ref_cycle_dist >= 0) q->extco3.IntRefCycleDist = q->int_ref_cycle_dist; + q->old_int_ref_cycle_dist = q->int_ref_cycle_dist; if (q->low_delay_brc >= 0) q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; if (q->max_frame_size_i >= 0) @@ -1712,6 +1716,34 @@ static int update_gop_size(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_rir(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_int_ref_type, q->int_ref_type); + UPDATE_PARAM(q->old_int_ref_cycle_size, q->int_ref_cycle_size); + UPDATE_PARAM(q->old_int_ref_qp_delta, q->int_ref_qp_delta); + UPDATE_PARAM(q->old_int_ref_cycle_dist, q->int_ref_cycle_dist); + if (!updated) + return 0; + + q->extco2.IntRefType = FFMAX(0, q->int_ref_type); + q->extco2.IntRefCycleSize = FFMAX(0, q->int_ref_cycle_size); + q->extco2.IntRefQPDelta = + q->int_ref_qp_delta != INT16_MIN ? q->int_ref_qp_delta : 0; + q->extco3.IntRefCycleDist = FFMAX(0, q->int_ref_cycle_dist); + av_log(avctx, AV_LOG_DEBUG, + "Reset IntRefType: %d; IntRefCycleSize: %d; " + "IntRefQPDelta: %d; IntRefCycleDist: %d\n", + q->extco2.IntRefType, q->extco2.IntRefCycleSize, + q->extco2.IntRefQPDelta, q->extco3.IntRefCycleDist); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1723,6 +1755,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset = update_qp(avctx, q); needReset |= update_max_frame_size(avctx, q); needReset |= update_gop_size(avctx, q); + needReset |= update_rir(avctx, q); if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index ead790fd2c..3ec8608e67 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -255,6 +255,11 @@ typedef struct QSVEncContext { int old_max_frame_size; // This is used for gop reset int old_gop_size; + // These are used for intra refresh reset + int old_int_ref_type; + int old_int_ref_cycle_size; + int old_int_ref_qp_delta; + int old_int_ref_cycle_dist; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From 005c7a4f61ef047726270b59c08742f9ce6f7182 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:57 +0800 Subject: [PATCH 208/590] libavcodec/qsvenc: Add max/min qp reset support in qsvenc Signed-off-by: Wenbin Chen --- doc/encoders.texi | 11 +++++++ libavcodec/qsvenc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/qsvenc.h | 9 ++++++ 3 files changed, 98 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index f2fef0deab..d17e3a074b 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3345,6 +3345,17 @@ Change this value to reset qsv codec's gop configuration. @item @var{int_ref_cycle_dist} Supported in h264_qsv and hevc_qsv. Change these value to reset qsv codec's Intra Refresh configuration. + +@item @var{qmax} +@item @var{qmin} +@item @var{max_qp_i} +@item @var{min_qp_i} +@item @var{max_qp_p} +@item @var{min_qp_p} +@item @var{max_qp_b} +@item @var{min_qp_b} +Supported in h264_qsv. +Change these value to reset qsv codec's max/min qp configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 4ed73e7817..3be19e04f4 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -861,22 +861,30 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco2.MinQPI = avctx->qmin > 51 ? 51 : avctx->qmin; q->extco2.MinQPP = q->extco2.MinQPB = q->extco2.MinQPI; } + q->old_qmin = avctx->qmin; if (avctx->qmax >= 0) { q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax; q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; } + q->old_qmax = avctx->qmax; if (q->min_qp_i >= 0) q->extco2.MinQPI = q->min_qp_i > 51 ? 51 : q->min_qp_i; + q->old_min_qp_i = q->min_qp_i; if (q->max_qp_i >= 0) q->extco2.MaxQPI = q->max_qp_i > 51 ? 51 : q->max_qp_i; + q->old_max_qp_i = q->max_qp_i; if (q->min_qp_p >= 0) q->extco2.MinQPP = q->min_qp_p > 51 ? 51 : q->min_qp_p; + q->old_min_qp_p = q->min_qp_p; if (q->max_qp_p >= 0) q->extco2.MaxQPP = q->max_qp_p > 51 ? 51 : q->max_qp_p; + q->old_max_qp_p = q->max_qp_p; if (q->min_qp_b >= 0) q->extco2.MinQPB = q->min_qp_b > 51 ? 51 : q->min_qp_b; + q->old_min_qp_b = q->min_qp_b; if (q->max_qp_b >= 0) q->extco2.MaxQPB = q->max_qp_b > 51 ? 51 : q->max_qp_b; + q->old_max_qp_b = q->max_qp_b; if (q->mbbrc >= 0) q->extco2.MBBRC = q->mbbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; @@ -1744,6 +1752,71 @@ static int update_rir(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_min_max_qp(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264) + return 0; + + UPDATE_PARAM(q->old_qmax, avctx->qmin); + UPDATE_PARAM(q->old_qmax, avctx->qmin); + UPDATE_PARAM(q->old_min_qp_i, q->min_qp_i); + UPDATE_PARAM(q->old_max_qp_i, q->max_qp_i); + UPDATE_PARAM(q->old_min_qp_p, q->min_qp_p); + UPDATE_PARAM(q->old_max_qp_p, q->max_qp_p); + UPDATE_PARAM(q->old_min_qp_b, q->min_qp_b); + UPDATE_PARAM(q->old_max_qp_b, q->max_qp_b); + if (!updated) + return 0; + + if ((avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) || + (q->max_qp_i >= 0 && q->min_qp_i >= 0 && q->min_qp_i > q->max_qp_i) || + (q->max_qp_p >= 0 && q->min_qp_p >= 0 && q->min_qp_p > q->max_qp_p) || + (q->max_qp_b >= 0 && q->min_qp_b >= 0 && q->min_qp_b > q->max_qp_b)) { + av_log(avctx, AV_LOG_ERROR, + "qmin and or qmax are set but invalid," + " please make sure min <= max\n"); + return AVERROR(EINVAL); + } + + q->extco2.MinQPI = 0; + q->extco2.MaxQPI = 0; + q->extco2.MinQPP = 0; + q->extco2.MaxQPP = 0; + q->extco2.MinQPB = 0; + q->extco2.MaxQPB = 0; + if (avctx->qmin >= 0) { + q->extco2.MinQPI = avctx->qmin > 51 ? 51 : avctx->qmin; + q->extco2.MinQPB = q->extco2.MinQPP = q->extco2.MinQPI; + } + if (avctx->qmax >= 0) { + q->extco2.MaxQPI = avctx->qmax > 51 ? 51 : avctx->qmax; + q->extco2.MaxQPB = q->extco2.MaxQPP = q->extco2.MaxQPI; + } + if (q->min_qp_i >= 0) + q->extco2.MinQPI = q->min_qp_i > 51 ? 51 : q->min_qp_i; + if (q->max_qp_i >= 0) + q->extco2.MaxQPI = q->max_qp_i > 51 ? 51 : q->max_qp_i; + if (q->min_qp_p >= 0) + q->extco2.MinQPP = q->min_qp_p > 51 ? 51 : q->min_qp_p; + if (q->max_qp_p >= 0) + q->extco2.MaxQPP = q->max_qp_p > 51 ? 51 : q->max_qp_p; + if (q->min_qp_b >= 0) + q->extco2.MinQPB = q->min_qp_b > 51 ? 51 : q->min_qp_b; + if (q->max_qp_b >= 0) + q->extco2.MaxQPB = q->max_qp_b > 51 ? 51 : q->max_qp_b; + + av_log(avctx, AV_LOG_VERBOSE, "Reset MinQPI: %d; MaxQPI: %d; " + "MinQPP: %d; MaxQPP: %d; " + "MinQPB: %d; MaxQPB: %d\n", + q->extco2.MinQPI, q->extco2.MaxQPI, + q->extco2.MinQPP, q->extco2.MaxQPP, + q->extco2.MinQPB, q->extco2.MaxQPB); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1756,6 +1829,11 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_max_frame_size(avctx, q); needReset |= update_gop_size(avctx, q); needReset |= update_rir(avctx, q); + + ret = update_min_max_qp(avctx, q); + if (ret < 0) + return ret; + needReset |= ret; if (!needReset) return 0; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 3ec8608e67..e7be10935c 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -260,6 +260,15 @@ typedef struct QSVEncContext { int old_int_ref_cycle_size; int old_int_ref_qp_delta; int old_int_ref_cycle_dist; + // These are used for max/min qp reset; + int old_qmax; + int old_qmin; + int old_max_qp_i; + int old_min_qp_i; + int old_max_qp_p; + int old_min_qp_p; + int old_max_qp_b; + int old_min_qp_b; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From a2fd553dd3079601249e56f6aa1a6fe711d0663c Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Tue, 6 Sep 2022 17:22:58 +0800 Subject: [PATCH 209/590] libavcodec/qsvenc: Add low_delay_brc reset support to qsvenc Signed-off-by: Wenbin Chen --- doc/encoders.texi | 4 ++++ libavcodec/qsvenc.c | 23 ++++++++++++++++++++++- libavcodec/qsvenc.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index d17e3a074b..ac71f50ad2 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3356,6 +3356,10 @@ Change these value to reset qsv codec's Intra Refresh configuration. @item @var{min_qp_b} Supported in h264_qsv. Change these value to reset qsv codec's max/min qp configuration. + +@item @var{low_delay_brc} +Supported in h264_qsv and hevc_qsv. +Change this value to reset qsv codec's low_delay_brc configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 3be19e04f4..84c6e292aa 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -937,6 +937,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->old_int_ref_cycle_dist = q->int_ref_cycle_dist; if (q->low_delay_brc >= 0) q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; + q->old_low_delay_brc = q->low_delay_brc; if (q->max_frame_size_i >= 0) q->extco3.MaxFrameSizeI = q->max_frame_size_i; if (q->max_frame_size_p >= 0) @@ -1817,6 +1818,26 @@ static int update_min_max_qp(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_low_delay_brc(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_low_delay_brc, q->low_delay_brc); + if (!updated) + return 0; + + q->extco3.LowDelayBRC = MFX_CODINGOPTION_UNKNOWN; + if (q->low_delay_brc >= 0) + q->extco3.LowDelayBRC = q->low_delay_brc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; + av_log(avctx, AV_LOG_DEBUG, "Reset LowDelayBRC: %s\n", + print_threestate(q->extco3.LowDelayBRC)); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1829,7 +1850,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_max_frame_size(avctx, q); needReset |= update_gop_size(avctx, q); needReset |= update_rir(avctx, q); - + needReset |= update_low_delay_brc(avctx, q); ret = update_min_max_qp(avctx, q); if (ret < 0) return ret; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index e7be10935c..f2b7ee361f 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -269,6 +269,8 @@ typedef struct QSVEncContext { int old_min_qp_p; int old_max_qp_b; int old_min_qp_b; + // This is used for low_delay_brc reset + int old_low_delay_brc; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From 200f5e578f2fbf70a966f08257e0500a6f1ddd6c Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Thu, 8 Sep 2022 11:25:03 +0200 Subject: [PATCH 210/590] lavc/aarch64: Add neon implementation for vsad16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation of vsad16 function for arm64. Performance comparison tests are shown below. - vsad_0_c: 285.2 - vsad_0_neon: 39.5 Benchmarks and tests are run with checkasm tool on AWS Graviton 3. Co-authored-by: Martin Storsjö Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 5 ++ libavcodec/aarch64/me_cmp_neon.S | 65 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index fb7c3f5059..ddc5d05611 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -41,6 +41,9 @@ int sse8_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, int sse4_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h); +int vsad16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, + ptrdiff_t stride, int h); + av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { int cpu_flags = av_get_cpu_flags(); @@ -57,5 +60,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->sse[0] = sse16_neon; c->sse[1] = sse8_neon; c->sse[2] = sse4_neon; + + c->vsad[0] = vsad16_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 4198985c6c..1d0b166d69 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -584,3 +584,68 @@ function sse4_neon, export=1 ret endfunc + +function vsad16_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v0.16b}, [x1], x3 // Load pix1[0], first iteration + ld1 {v1.16b}, [x2], x3 // Load pix2[0], first iteration + + sub w4, w4, #1 // we need to make h-1 iterations + movi v16.8h, #0 + + cmp w4, #3 // check if we can make 3 iterations at once + usubl v31.8h, v0.8b, v1.8b // Signed difference pix1[0] - pix2[0], first iteration + usubl2 v30.8h, v0.16b, v1.16b // Signed difference pix1[0] - pix2[0], first iteration + + b.lt 2f + +1: + // abs(pix1[0] - pix2[0] - pix1[0 + stride] + pix2[0 + stride]) + ld1 {v0.16b}, [x1], x3 // Load pix1[0 + stride], first iteration + ld1 {v1.16b}, [x2], x3 // Load pix2[0 + stride], first iteration + ld1 {v2.16b}, [x1], x3 // Load pix1[0 + stride], second iteration + ld1 {v3.16b}, [x2], x3 // Load pix2[0 + stride], second iteration + usubl v29.8h, v0.8b, v1.8b // Signed difference pix1[0 + stride] - pix2[0 + stride], first iteration + usubl2 v28.8h, v0.16b, v1.16b // Signed difference pix1[0 + stride] - pix2[0 + stride], first iteration + ld1 {v4.16b}, [x1], x3 // Load pix1[0 + stride], third iteration + ld1 {v5.16b}, [x2], x3 // Load pix2[0 + stride], third iteration + usubl v27.8h, v2.8b, v3.8b // Signed difference pix1[0 + stride] - pix2[0 + stride], second iteration + saba v16.8h, v31.8h, v29.8h // Signed absolute difference and accumulate the result. first iteration + usubl2 v26.8h, v2.16b, v3.16b // Signed difference pix1[0 + stride] - pix2[0 + stride], second iteration + saba v16.8h, v30.8h, v28.8h // Signed absolute difference and accumulate the result. first iteration + usubl v25.8h, v4.8b, v5.8b // Signed difference pix1[0 + stride] - pix2[0 + stride], third iteration + usubl2 v24.8h, v4.16b, v5.16b // Signed difference pix1[0 + stride] - pix2[0 + stride], third iteration + saba v16.8h, v29.8h, v27.8h // Signed absolute difference and accumulate the result. second iteration + mov v31.16b, v25.16b + saba v16.8h, v28.8h, v26.8h // Signed absolute difference and accumulate the result. second iteration + sub w4, w4, #3 // h -= 3 + mov v30.16b, v24.16b + saba v16.8h, v27.8h, v25.8h // Signed absolute difference and accumulate the result. third iteration + cmp w4, #3 + saba v16.8h, v26.8h, v24.8h // Signed absolute difference and accumulate the result. third iteration + + b.ge 1b + cbz w4, 3f +2: + ld1 {v0.16b}, [x1], x3 + ld1 {v1.16b}, [x2], x3 + subs w4, w4, #1 + usubl v29.8h, v0.8b, v1.8b + usubl2 v28.8h, v0.16b, v1.16b + saba v16.8h, v31.8h, v29.8h + mov v31.16b, v29.16b + saba v16.8h, v30.8h, v28.8h + mov v30.16b, v28.16b + + b.ne 2b +3: + uaddlv s17, v16.8h + fmov w0, s17 + + ret +endfunc From c495a4b32d352e087318d3a09a9bb4f2b55cfa04 Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Thu, 8 Sep 2022 11:25:04 +0200 Subject: [PATCH 211/590] lavc/aarch64: Add neon implementation of vsse16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation of vsse16 for arm64. Performance comparison tests are shown below. - vsse_0_c: 257.7 - vsse_0_neon: 59.2 Benchmarks and tests are run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 4 ++ libavcodec/aarch64/me_cmp_neon.S | 87 ++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index ddc5d05611..7b81e48d16 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -43,6 +43,8 @@ int sse4_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, int vsad16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); +int vsse16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, + ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { @@ -62,5 +64,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->sse[2] = sse4_neon; c->vsad[0] = vsad16_neon; + + c->vsse[0] = vsse16_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 1d0b166d69..b3f376aa60 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -649,3 +649,90 @@ function vsad16_neon, export=1 ret endfunc + +function vsse16_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v0.16b}, [x1], x3 // Load pix1[0], first iteration + ld1 {v1.16b}, [x2], x3 // Load pix2[0], first iteration + + sub w4, w4, #1 // we need to make h-1 iterations + movi v16.4s, #0 + movi v17.4s, #0 + + cmp w4, #3 // check if we can make 3 iterations at once + usubl v31.8h, v0.8b, v1.8b // Signed difference of pix1[0] - pix2[0], first iteration + usubl2 v30.8h, v0.16b, v1.16b // Signed difference of pix1[0] - pix2[0], first iteration + b.le 2f + + +1: + // x = abs(pix1[0] - pix2[0] - pix1[0 + stride] + pix2[0 + stride]) + // res = (x) * (x) + ld1 {v0.16b}, [x1], x3 // Load pix1[0 + stride], first iteration + ld1 {v1.16b}, [x2], x3 // Load pix2[0 + stride], first iteration + ld1 {v2.16b}, [x1], x3 // Load pix1[0 + stride], second iteration + ld1 {v3.16b}, [x2], x3 // Load pix2[0 + stride], second iteration + usubl v29.8h, v0.8b, v1.8b + usubl2 v28.8h, v0.16b, v1.16b + ld1 {v4.16b}, [x1], x3 // Load pix1[0 + stride], third iteration + ld1 {v5.16b}, [x2], x3 // Load pix1[0 + stride], third iteration + sabd v31.8h, v31.8h, v29.8h + sabd v30.8h, v30.8h, v28.8h + usubl v27.8h, v2.8b, v3.8b + usubl2 v26.8h, v2.16b, v3.16b + usubl v25.8h, v4.8b, v5.8b + usubl2 v24.8h, v4.16b, v5.16b + sabd v29.8h, v29.8h, v27.8h + sabd v27.8h, v27.8h, v25.8h + umlal v16.4s, v31.4h, v31.4h + umlal2 v17.4s, v31.8h, v31.8h + sabd v28.8h, v28.8h, v26.8h + sabd v26.8h, v26.8h, v24.8h + umlal v16.4s, v30.4h, v30.4h + umlal2 v17.4s, v30.8h, v30.8h + mov v31.16b, v25.16b + umlal v16.4s, v29.4h, v29.4h + umlal2 v17.4s, v29.8h, v29.8h + mov v30.16b, v24.16b + umlal v16.4s, v28.4h, v28.4h + umlal2 v17.4s, v28.8h, v28.8h + sub w4, w4, #3 + umlal v16.4s, v27.4h, v27.4h + umlal2 v17.4s, v27.8h, v27.8h + cmp w4, #3 + umlal v16.4s, v26.4h, v26.4h + umlal2 v17.4s, v26.8h, v26.8h + + b.ge 1b + + cbz w4, 3f + +// iterate by once +2: + ld1 {v0.16b}, [x1], x3 + ld1 {v1.16b}, [x2], x3 + subs w4, w4, #1 + usubl v29.8h, v0.8b, v1.8b + usubl2 v28.8h, v0.16b, v1.16b + sabd v31.8h, v31.8h, v29.8h + sabd v30.8h, v30.8h, v28.8h + umlal v16.4s, v31.4h, v31.4h + umlal2 v17.4s, v31.8h, v31.8h + mov v31.16b, v29.16b + umlal v16.4s, v30.4h, v30.4h + umlal2 v17.4s, v30.8h, v30.8h + mov v30.16b, v28.16b + b.ne 2b + +3: + add v16.4s, v16.4s, v17.4s + uaddlv d17, v16.4s + fmov w0, s17 + + ret +endfunc From ce03ea3e796bdf9013da51d53e89759a92707c4a Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Thu, 8 Sep 2022 11:25:05 +0200 Subject: [PATCH 212/590] lavc/aarch64: Add neon implementation for vsad_intra16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation for vsad_intra16 function for arm64. Performance comparison tests are shown below. - vsad_4_c: 177.5 - vsad_4_neon: 23.5 Benchmarks and tests are run with checkasm tool on AWS Gravtion 3. Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 3 ++ libavcodec/aarch64/me_cmp_neon.S | 48 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index 7b81e48d16..af83f7ed1e 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -43,6 +43,8 @@ int sse4_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, int vsad16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); +int vsad_intra16_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, + ptrdiff_t stride, int h) ; int vsse16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); @@ -64,6 +66,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->sse[2] = sse4_neon; c->vsad[0] = vsad16_neon; + c->vsad[4] = vsad_intra16_neon; c->vsse[0] = vsse16_neon; } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index b3f376aa60..ce198ea227 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -736,3 +736,51 @@ function vsse16_neon, export=1 ret endfunc + +function vsad_intra16_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *dummy + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v0.16b}, [x1], x3 + sub w4, w4, #1 // we need to make h-1 iterations + cmp w4, #3 + movi v16.8h, #0 + b.lt 2f + +// make 4 iterations at once +1: + // v = abs( pix1[0] - pix1[0 + stride] ) + // score = sum(v) + ld1 {v1.16b}, [x1], x3 + ld1 {v2.16b}, [x1], x3 + uabal v16.8h, v0.8b, v1.8b + ld1 {v3.16b}, [x1], x3 + uabal2 v16.8h, v0.16b, v1.16b + sub w4, w4, #3 + uabal v16.8h, v1.8b, v2.8b + cmp w4, #3 + uabal2 v16.8h, v1.16b, v2.16b + mov v0.16b, v3.16b + uabal v16.8h, v2.8b, v3.8b + uabal2 v16.8h, v2.16b, v3.16b + b.ge 1b + cbz w4, 3f + +// iterate by one +2: + ld1 {v1.16b}, [x1], x3 + subs w4, w4, #1 + uabal v16.8h, v0.8b, v1.8b + uabal2 v16.8h, v0.16b, v1.16b + mov v0.16b, v1.16b + cbnz w4, 2b + +3: + uaddlv s17, v16.8h + fmov w0, s17 + + ret +endfunc From 908abe8032d2e56f9b94a7ae387e415de4c29115 Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Thu, 8 Sep 2022 11:25:06 +0200 Subject: [PATCH 213/590] lavc/aarch64: Add neon implementation for vsse_intra16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation for vsse_intra16 for arm64. Performance tests are shown below. - vsse_4_c: 155.2 - vsse_4_neon: 36.2 Benchmarks and tests are run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 3 ++ libavcodec/aarch64/me_cmp_neon.S | 63 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index af83f7ed1e..8c295d5457 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -47,6 +47,8 @@ int vsad_intra16_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h) ; int vsse16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); +int vsse_intra16_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, + ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { @@ -69,5 +71,6 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->vsad[4] = vsad_intra16_neon; c->vsse[0] = vsse16_neon; + c->vsse[4] = vsse_intra16_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index ce198ea227..cf2b8da425 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -784,3 +784,66 @@ function vsad_intra16_neon, export=1 ret endfunc + +function vsse_intra16_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *dummy + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v0.16b}, [x1], x3 + movi v16.4s, #0 + movi v17.4s, #0 + + sub w4, w4, #1 // we need to make h-1 iterations + cmp w4, #3 + b.lt 2f + +1: + // v = abs( pix1[0] - pix1[0 + stride] ) + // score = sum( v * v ) + ld1 {v1.16b}, [x1], x3 + ld1 {v2.16b}, [x1], x3 + uabd v30.16b, v0.16b, v1.16b + ld1 {v3.16b}, [x1], x3 + umull v29.8h, v30.8b, v30.8b + umull2 v28.8h, v30.16b, v30.16b + uabd v27.16b, v1.16b, v2.16b + uadalp v16.4s, v29.8h + umull v26.8h, v27.8b, v27.8b + umull2 v27.8h, v27.16b, v27.16b + uadalp v17.4s, v28.8h + uabd v25.16b, v2.16b, v3.16b + uadalp v16.4s, v26.8h + umull v24.8h, v25.8b, v25.8b + umull2 v25.8h, v25.16b, v25.16b + uadalp v17.4s, v27.8h + sub w4, w4, #3 + uadalp v16.4s, v24.8h + cmp w4, #3 + uadalp v17.4s, v25.8h + mov v0.16b, v3.16b + + b.ge 1b + cbz w4, 3f + +// iterate by one +2: + ld1 {v1.16b}, [x1], x3 + subs w4, w4, #1 + uabd v30.16b, v0.16b, v1.16b + mov v0.16b, v1.16b + umull v29.8h, v30.8b, v30.8b + umull2 v30.8h, v30.16b, v30.16b + uadalp v16.4s, v29.8h + uadalp v17.4s, v30.8h + cbnz w4, 2b + +3: + add v16.4s, v16.4s, v17.4S + uaddlv d17, v16.4s + fmov w0, s17 + + ret +endfunc From 06b98e396adc467a5164a03d71dd71508a2d8881 Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Thu, 8 Sep 2022 11:25:07 +0200 Subject: [PATCH 214/590] lavc/aarch64: Provide neon implementation of nsse16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add vectorized implementation of nsse16 function. Performance comparison tests are shown below. - nsse_0_c: 682.2 - nsse_0_neon: 116.5 Benchmarks and tests run with checkasm tool on AWS Graviton 3. Co-authored-by: Martin Storsjö Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 15 +++ libavcodec/aarch64/me_cmp_neon.S | 122 +++++++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index 8c295d5457..ade3e9a4c1 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -49,6 +49,10 @@ int vsse16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); int vsse_intra16_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h); +int nsse16_neon(int multiplier, const uint8_t *s, const uint8_t *s2, + ptrdiff_t stride, int h); +int nsse16_neon_wrapper(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, + ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { @@ -72,5 +76,16 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->vsse[0] = vsse16_neon; c->vsse[4] = vsse_intra16_neon; + + c->nsse[0] = nsse16_neon_wrapper; } } + +int nsse16_neon_wrapper(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, + ptrdiff_t stride, int h) +{ + if (c) + return nsse16_neon(c->avctx->nsse_weight, s1, s2, stride, h); + else + return nsse16_neon(8, s1, s2, stride, h); +} diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index cf2b8da425..f8998749a5 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -847,3 +847,125 @@ function vsse_intra16_neon, export=1 ret endfunc + +function nsse16_neon, export=1 + // x0 multiplier + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // w4 int h + + str x0, [sp, #-0x40]! + stp x1, x2, [sp, #0x10] + stp x3, x4, [sp, #0x20] + str x30, [sp, #0x30] + bl X(sse16_neon) + ldr x30, [sp, #0x30] + mov w9, w0 // here we store score1 + ldr x5, [sp] + ldp x1, x2, [sp, #0x10] + ldp x3, x4, [sp, #0x20] + add sp, sp, #0x40 + + movi v16.8h, #0 + movi v17.8h, #0 + movi v18.8h, #0 + movi v19.8h, #0 + + ld1 {v0.16b}, [x1], x3 + subs w4, w4, #1 // we need to make h-1 iterations + ld1 {v2.16b}, [x2], x3 + ext v1.16b, v0.16b, v0.16b, #1 // x1 + 1 + cmp w4, #2 + ext v3.16b, v2.16b, v2.16b, #1 // x2 + 1 + + b.lt 2f + +// make 2 iterations at once +1: + ld1 {v4.16b}, [x1], x3 + ld1 {v6.16b}, [x2], x3 + ld1 {v20.16b}, [x1], x3 + ext v5.16b, v4.16b, v4.16b, #1 // x1 + stride + 1 + usubl v31.8h, v0.8b, v4.8b + usubl2 v30.8h, v0.16b, v4.16b + ld1 {v22.16b}, [x2], x3 + usubl v29.8h, v1.8b, v5.8b + usubl2 v28.8h, v1.16b, v5.16b + ext v7.16b, v6.16b, v6.16b, #1 // x2 + stride + 1 + saba v16.8h, v31.8h, v29.8h + ext v21.16b, v20.16b, v20.16b, #1 + saba v17.8h, v30.8h, v28.8h + usubl v27.8h, v2.8b, v6.8b + usubl2 v26.8h, v2.16b, v6.16b + ext v23.16b, v22.16b, v22.16b, #1 + usubl v25.8h, v3.8b, v7.8b + usubl2 v24.8h, v3.16b, v7.16b + saba v18.8h, v27.8h, v25.8h + saba v19.8h, v26.8h, v24.8h + + usubl v31.8h, v4.8b, v20.8b + usubl2 v30.8h, v4.16b, v20.16b + usubl v29.8h, v5.8b, v21.8b + usubl2 v28.8h, v5.16b, v21.16b + saba v16.8h, v31.8h, v29.8h + saba v17.8h, v30.8h, v28.8h + usubl v27.8h, v6.8b, v22.8b + usubl2 v26.8h, v6.16b, v22.16b + usubl v25.8h, v7.8b, v23.8b + usubl2 v24.8h, v7.16b, v23.16b + saba v18.8h, v27.8h, v25.8h + saba v19.8h, v26.8h, v24.8h + sub w4, w4, #2 + + mov v0.16b, v20.16b + mov v1.16b, v21.16b + cmp w4, #2 + mov v2.16b, v22.16b + mov v3.16b, v23.16b + + b.ge 1b + cbz w4, 3f + +// iterate by one +2: + ld1 {v4.16b}, [x1], x3 + subs w4, w4, #1 + ld1 {v6.16b}, [x2], x3 + ext v5.16b, v4.16b, v4.16b, #1 // x1 + stride + 1 + usubl v31.8h, v0.8b, v4.8b + ext v7.16b, v6.16b, v6.16b, #1 // x2 + stride + 1 + + usubl2 v30.8h, v0.16b, v4.16b + usubl v29.8h, v1.8b, v5.8b + usubl2 v28.8h, v1.16b, v5.16b + saba v16.8h, v31.8h, v29.8h + saba v17.8h, v30.8h, v28.8h + usubl v27.8h, v2.8b, v6.8b + usubl2 v26.8h, v2.16b, v6.16b + usubl v25.8h, v3.8b, v7.8b + usubl2 v24.8h, v3.16b, v7.16b + saba v18.8h, v27.8h, v25.8h + saba v19.8h, v26.8h, v24.8h + + mov v0.16b, v4.16b + mov v1.16b, v5.16b + mov v2.16b, v6.16b + mov v3.16b, v7.16b + + cbnz w4, 2b + +3: + sqsub v17.8h, v17.8h, v19.8h + sqsub v16.8h, v16.8h, v18.8h + ins v17.h[7], wzr + sqadd v16.8h, v16.8h, v17.8h + saddlv s16, v16.8h + sqabs s16, s16 + fmov w0, s16 + + mul w0, w0, w5 + add w0, w0, w9 + + ret +endfunc From a5ab4be081aee22e675d0e78aa9ca0d08f4a5d6f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 7 Sep 2022 22:36:45 +0200 Subject: [PATCH 215/590] tests/fate-run: Allow to set input options for encoding pass This will be useful in the next commit. Signed-off-by: Andreas Rheinhardt --- tests/fate-run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 4008bcbc16..61cc59acc0 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -247,12 +247,13 @@ transcode(){ ffprobe_opts=$6 additional_input=$7 final_decode=$8 + enc_opt_in=$9 test -z "$additional_input" || additional_input="$DEC_OPTS $additional_input" encfile="${outdir}/${test}.${enc_fmt}" test $keep -ge 1 || cleanfiles="$cleanfiles $encfile" tsrcfile=$(target_path $srcfile) tencfile=$(target_path $encfile) - ffmpeg -f $src_fmt $DEC_OPTS -i $tsrcfile $additional_input \ + ffmpeg -f $src_fmt $DEC_OPTS $enc_opt_in -i $tsrcfile $additional_input \ $ENC_OPTS $enc_opt $FLAGS -f $enc_fmt -y $tencfile || return do_md5sum $encfile echo $(wc -c $encfile) From 91e9a6df33d8b14577fe1ec9623d9d0466fdd7d3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 7 Sep 2022 23:57:15 +0200 Subject: [PATCH 216/590] fate/matroska: Add test for updating AV1 extradata Signed-off-by: Andreas Rheinhardt --- tests/fate/matroska.mak | 6 +++++ tests/ref/fate/webm-av1-extradata-update | 32 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/ref/fate/webm-av1-extradata-update diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 63e81f121b..39137ad4be 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -49,6 +49,12 @@ FATE_MATROSKA-$(call ALLYES, FLAC_DECODER FLAC_ENCODER FLAC_PARSER \ fate-matroska-flac-extradata-update: CMD = transcode matroska $(TARGET_SAMPLES)/mkv/flac_channel_layouts.mka \ matroska "-map 0 -map 0:0 -c flac -frames:a:2 8" "-map 0 -c copy" +# This tests that the Matroska/WebM muxer writes the AV1 CodecPrivate +# via extradata obtained from packet side data. It also tests that +# the aspect ratio is only written with pixels as DisplayUnit for WebM. +FATE_MATROSKA-$(call REMUX, WEBM MATROSKA, IVF_DEMUXER AV1_PARSER EXTRACT_EXTRADATA_BSF) += fate-webm-av1-extradata-update +fate-webm-av1-extradata-update: CMD = transcode ivf $(TARGET_SAMPLES)/av1/decode_model.ivf webm "-c copy -bsf extract_extradata -sar 3:1" "-c copy" "" "" "-nofind_stream_info" "-nofind_stream_info" + # This test tests demuxing Vorbis and chapters from ogg and muxing it in and # demuxing it from Matroska/WebM. It furthermore tests the WebM muxer, in # particular its DASH mode. Finally, it tests writing the Cues at the front. diff --git a/tests/ref/fate/webm-av1-extradata-update b/tests/ref/fate/webm-av1-extradata-update new file mode 100644 index 0000000000..9dd2056e0e --- /dev/null +++ b/tests/ref/fate/webm-av1-extradata-update @@ -0,0 +1,32 @@ +fbf3091fdf05b2856c578e7c948d68c3 *tests/data/fate/webm-av1-extradata-update.webm +23048 tests/data/fate/webm-av1-extradata-update.webm +#extradata 0: 35, 0x527207cd +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: av1 +#dimensions 0: 240x100 +#sar 0: 3/1 +0, 0, 0, 0, 8168, 0x1851ab62 +0, 42, 42, 0, 7040, 0x967788f9, F=0x0 +0, 83, 83, 0, 4, 0x01f400e2, F=0x0 +0, 125, 125, 0, 48, 0x49ad107e, F=0x0 +0, 167, 167, 0, 4, 0x021c00fa, F=0x0 +0, 208, 208, 0, 279, 0x69728439, F=0x0 +0, 250, 250, 0, 4, 0x01c400d2, F=0x0 +0, 292, 292, 0, 63, 0x9bbf1836, F=0x0 +0, 333, 333, 0, 4, 0x026c012a, F=0x0 +0, 375, 375, 0, 1065, 0xce2003ac, F=0x0 +0, 417, 417, 0, 4, 0x019400c2, F=0x0 +0, 458, 458, 0, 52, 0x7a0112f1, F=0x0 +0, 500, 500, 0, 4, 0x021c010a, F=0x0 +0, 542, 542, 0, 689, 0x1e8b49e7, F=0x0 +0, 583, 583, 0, 4, 0x01e400f2, F=0x0 +0, 625, 625, 0, 209, 0x124c6790, F=0x0 +0, 667, 667, 0, 42, 0xea690e31, F=0x0 +0, 708, 708, 0, 3521, 0xd76ee284, F=0x0 +0, 750, 750, 0, 63, 0x4572188f, F=0x0 +0, 792, 792, 0, 386, 0xb078c259, F=0x0 +0, 833, 833, 0, 178, 0x1ebb5121, F=0x0 +0, 875, 875, 0, 60, 0x729317f7, F=0x0 +0, 917, 917, 0, 40, 0xad970a66, F=0x0 +0, 958, 958, 0, 61, 0xcc0d1a20, F=0x0 From 8c283e8fe631135a0c36d50f9c8d558f43cfef7b Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 10 Sep 2022 02:26:02 +0200 Subject: [PATCH 217/590] lavu/tx: propagate the codelet flags into the context The field is documented as a combination of both. --- libavutil/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index da8ebddd9a..aeb0d9dada 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -620,7 +620,7 @@ av_cold int ff_tx_init_subtx(AVTXContext *s, enum AVTXType type, sctx->len = len; sctx->inv = inv; sctx->type = type; - sctx->flags = flags; + sctx->flags = cd->flags | flags; sctx->cd_self = cd; s->fn[s->nb_sub] = cd->function; From 645a1f4422ad9c8c954e7c42bef2281cac96ab18 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 10 Sep 2022 02:26:49 +0200 Subject: [PATCH 218/590] lavu/tx: add the inplace flag to PFA FFTs They support in-place, because they have to use a temporary buffer. --- libavutil/tx_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c index 35b61fa477..542c15e480 100644 --- a/libavutil/tx_template.c +++ b/libavutil/tx_template.c @@ -836,7 +836,7 @@ static const FFTXCodelet TX_NAME(ff_tx_fft_pfa_##N##xM_def) = { \ .name = TX_NAME_STR("fft_pfa_" #N "xM"), \ .function = TX_NAME(ff_tx_fft_pfa_##N##xM), \ .type = TX_TYPE(FFT), \ - .flags = AV_TX_UNALIGNED | FF_TX_OUT_OF_PLACE, \ + .flags = AV_TX_UNALIGNED | AV_TX_INPLACE | FF_TX_OUT_OF_PLACE, \ .factors = { N, TX_FACTOR_ANY }, \ .min_len = N*2, \ .max_len = TX_LEN_UNLIMITED, \ From 51172223fd1a5b71b46fc0d398f4fdc9ed081b83 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 10 Sep 2022 02:28:10 +0200 Subject: [PATCH 219/590] lavu/tx: generalize MDCTs The same code can perform any-length MDCTs with minimal changes. --- libavutil/tx_template.c | 75 +++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c index 542c15e480..1d4c4d294b 100644 --- a/libavutil/tx_template.c +++ b/libavutil/tx_template.c @@ -940,12 +940,12 @@ static const FFTXCodelet TX_NAME(ff_tx_mdct_naive_inv_def) = { .prio = FF_TX_PRIO_MIN, }; -static av_cold int TX_NAME(ff_tx_mdct_sr_init)(AVTXContext *s, - const FFTXCodelet *cd, - uint64_t flags, - FFTXCodeletOptions *opts, - int len, int inv, - const void *scale) +static av_cold int TX_NAME(ff_tx_mdct_init)(AVTXContext *s, + const FFTXCodelet *cd, + uint64_t flags, + FFTXCodeletOptions *opts, + int len, int inv, + const void *scale) { int ret; FFTXCodeletOptions sub_opts = { .invert_lookup = inv }; @@ -955,32 +955,49 @@ static av_cold int TX_NAME(ff_tx_mdct_sr_init)(AVTXContext *s, flags &= ~FF_TX_OUT_OF_PLACE; /* We want the subtransform to be */ flags |= AV_TX_INPLACE; /* in-place */ - flags |= FF_TX_PRESHUFFLE; /* This function handles the permute step */ + flags |= FF_TX_PRESHUFFLE; /* First try with an in-place transform */ if ((ret = ff_tx_init_subtx(s, TX_TYPE(FFT), flags, &sub_opts, len >> 1, - inv, scale))) - return ret; + inv, scale))) { + flags &= ~FF_TX_PRESHUFFLE; /* Now try with a generic FFT */ + if ((ret = ff_tx_init_subtx(s, TX_TYPE(FFT), flags, &sub_opts, len >> 1, + inv, scale))) + return ret; + } + + /* If we need to preshuffle just steal the map from the subcontext */ + if (s->sub[0].flags & FF_TX_PRESHUFFLE) { + s->map = s->sub[0].map; + s->sub[0].map = NULL; + } else { + s->map = av_malloc((len >> 1)*sizeof(*s->map)); + if (!s->map) + return AVERROR(ENOMEM); + + for (int i = 0; i < len >> 1; i++) + s->map[i] = i; + } - if ((ret = TX_TAB(ff_tx_mdct_gen_exp)(s, inv ? s->sub->map : NULL))) + if ((ret = TX_TAB(ff_tx_mdct_gen_exp)(s, inv ? s->map : NULL))) return ret; /* Saves a multiply in a hot path. */ if (inv) for (int i = 0; i < (s->len >> 1); i++) - s->sub->map[i] <<= 1; + s->map[i] <<= 1; return 0; } -static void TX_NAME(ff_tx_mdct_sr_fwd)(AVTXContext *s, void *_dst, void *_src, - ptrdiff_t stride) +static void TX_NAME(ff_tx_mdct_fwd)(AVTXContext *s, void *_dst, void *_src, + ptrdiff_t stride) { TXSample *src = _src, *dst = _dst; TXComplex *exp = s->exp, tmp, *z = _dst; const int len2 = s->len >> 1; const int len4 = s->len >> 2; const int len3 = len2 * 3; - const int *sub_map = s->sub->map; + const int *sub_map = s->map; stride /= sizeof(*dst); @@ -1011,14 +1028,14 @@ static void TX_NAME(ff_tx_mdct_sr_fwd)(AVTXContext *s, void *_dst, void *_src, } } -static void TX_NAME(ff_tx_mdct_sr_inv)(AVTXContext *s, void *_dst, void *_src, - ptrdiff_t stride) +static void TX_NAME(ff_tx_mdct_inv)(AVTXContext *s, void *_dst, void *_src, + ptrdiff_t stride) { TXComplex *z = _dst, *exp = s->exp; const TXSample *src = _src, *in1, *in2; const int len2 = s->len >> 1; const int len4 = s->len >> 2; - const int *sub_map = s->sub->map; + const int *sub_map = s->map; stride /= sizeof(*src); in1 = src; @@ -1043,28 +1060,28 @@ static void TX_NAME(ff_tx_mdct_sr_inv)(AVTXContext *s, void *_dst, void *_src, } } -static const FFTXCodelet TX_NAME(ff_tx_mdct_sr_fwd_def) = { - .name = TX_NAME_STR("mdct_sr_fwd"), - .function = TX_NAME(ff_tx_mdct_sr_fwd), +static const FFTXCodelet TX_NAME(ff_tx_mdct_fwd_def) = { + .name = TX_NAME_STR("mdct_fwd"), + .function = TX_NAME(ff_tx_mdct_fwd), .type = TX_TYPE(MDCT), .flags = AV_TX_UNALIGNED | FF_TX_OUT_OF_PLACE | FF_TX_FORWARD_ONLY, - .factors[0] = 2, + .factors = { 2, TX_FACTOR_ANY }, .min_len = 2, .max_len = TX_LEN_UNLIMITED, - .init = TX_NAME(ff_tx_mdct_sr_init), + .init = TX_NAME(ff_tx_mdct_init), .cpu_flags = FF_TX_CPU_FLAGS_ALL, .prio = FF_TX_PRIO_BASE, }; -static const FFTXCodelet TX_NAME(ff_tx_mdct_sr_inv_def) = { - .name = TX_NAME_STR("mdct_sr_inv"), - .function = TX_NAME(ff_tx_mdct_sr_inv), +static const FFTXCodelet TX_NAME(ff_tx_mdct_inv_def) = { + .name = TX_NAME_STR("mdct_inv"), + .function = TX_NAME(ff_tx_mdct_inv), .type = TX_TYPE(MDCT), .flags = AV_TX_UNALIGNED | FF_TX_OUT_OF_PLACE | FF_TX_INVERSE_ONLY, - .factors[0] = 2, + .factors = { 2, TX_FACTOR_ANY }, .min_len = 2, .max_len = TX_LEN_UNLIMITED, - .init = TX_NAME(ff_tx_mdct_sr_init), + .init = TX_NAME(ff_tx_mdct_init), .cpu_flags = FF_TX_CPU_FLAGS_ALL, .prio = FF_TX_PRIO_BASE, }; @@ -1477,8 +1494,8 @@ const FFTXCodelet * const TX_NAME(ff_tx_codelet_list)[] = { &TX_NAME(ff_tx_fft_pfa_9xM_def), &TX_NAME(ff_tx_fft_pfa_15xM_def), &TX_NAME(ff_tx_fft_naive_def), - &TX_NAME(ff_tx_mdct_sr_fwd_def), - &TX_NAME(ff_tx_mdct_sr_inv_def), + &TX_NAME(ff_tx_mdct_fwd_def), + &TX_NAME(ff_tx_mdct_inv_def), &TX_NAME(ff_tx_mdct_pfa_3xM_fwd_def), &TX_NAME(ff_tx_mdct_pfa_5xM_fwd_def), &TX_NAME(ff_tx_mdct_pfa_7xM_fwd_def), From c92edd969aaf8b12434ff4bd731aa4bc5548fbbf Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 10 Sep 2022 02:31:43 +0200 Subject: [PATCH 220/590] lavu/tx: rotate 3 & 15-point exptabs This just inverts their signs. Simplifies SIMD. --- libavutil/tx_template.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c index 1d4c4d294b..0c7ddd26f6 100644 --- a/libavutil/tx_template.c +++ b/libavutil/tx_template.c @@ -109,11 +109,11 @@ static av_cold void TX_TAB(ff_tx_init_tab_53)(void) TX_TAB(ff_tx_tab_53)[0] = RESCALE(cos(2 * M_PI / 12)); TX_TAB(ff_tx_tab_53)[1] = RESCALE(cos(2 * M_PI / 12)); TX_TAB(ff_tx_tab_53)[2] = RESCALE(cos(2 * M_PI / 6)); - TX_TAB(ff_tx_tab_53)[3] = RESCALE(cos(2 * M_PI / 6)); + TX_TAB(ff_tx_tab_53)[3] = RESCALE(cos(8 * M_PI / 6)); TX_TAB(ff_tx_tab_53)[4] = RESCALE(cos(2 * M_PI / 5)); - TX_TAB(ff_tx_tab_53)[5] = RESCALE(sin(2 * M_PI / 5)); + TX_TAB(ff_tx_tab_53)[5] = RESCALE(sin(8 * M_PI / 5)); TX_TAB(ff_tx_tab_53)[6] = RESCALE(cos(2 * M_PI / 10)); - TX_TAB(ff_tx_tab_53)[7] = RESCALE(sin(2 * M_PI / 10)); + TX_TAB(ff_tx_tab_53)[7] = RESCALE(sin(6 * M_PI / 5)); } static av_cold void TX_TAB(ff_tx_init_tab_7)(void) @@ -226,8 +226,8 @@ static av_always_inline void NAME(TXComplex *out, TXComplex *in, \ \ SMUL(t[4].re, t[0].re, tab[4], tab[6], t[2].re, t[0].re); \ SMUL(t[4].im, t[0].im, tab[4], tab[6], t[2].im, t[0].im); \ - CMUL(t[5].re, t[1].re, tab[5], tab[7], t[3].re, t[1].re); \ - CMUL(t[5].im, t[1].im, tab[5], tab[7], t[3].im, t[1].im); \ + CMUL(t[5].re, t[1].re, -tab[5], -tab[7], t[3].re, t[1].re); \ + CMUL(t[5].im, t[1].im, -tab[5], -tab[7], t[3].im, t[1].im); \ \ BF(z0[0].re, z0[3].re, t[0].re, t[1].re); \ BF(z0[0].im, z0[3].im, t[0].im, t[1].im); \ From 9783749c66bf6ca2ce7a6db4c74957fe77cbe803 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 10 Jun 2022 23:09:09 +0200 Subject: [PATCH 221/590] avcodec/fmvc: Move frame allocation to a later stage This way more things are checked before allocation Signed-off-by: Michael Niedermayer --- libavcodec/fmvc.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c index 863c65c351..3ee915cc4c 100644 --- a/libavcodec/fmvc.c +++ b/libavcodec/fmvc.c @@ -400,20 +400,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, GetByteContext *gb = &s->gb; PutByteContext *pb = &s->pb; int ret, y, x; + int key_frame; if (avpkt->size < 8) return AVERROR_INVALIDDATA; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) - return ret; - bytestream2_init(gb, avpkt->data, avpkt->size); bytestream2_skip(gb, 2); - frame->key_frame = !!bytestream2_get_le16(gb); - frame->pict_type = frame->key_frame ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + key_frame = !!bytestream2_get_le16(gb); - if (frame->key_frame) { + if (key_frame) { const uint8_t *src; unsigned type, size; uint8_t *dst; @@ -433,6 +430,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR_PATCHWELCOME; } + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + frame->key_frame = 1; + frame->pict_type = AV_PICTURE_TYPE_I; + src = s->buffer; dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0]; for (y = 0; y < avctx->height; y++) { @@ -513,6 +516,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, dst = &rect[block_h * s->stride]; } + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + frame->key_frame = 0; + frame->pict_type = AV_PICTURE_TYPE_P; + ssrc = s->buffer; ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0]; for (y = 0; y < avctx->height; y++) { From 9af7de086768b089c882f37a64717da616ef1de6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 8 Sep 2022 23:07:47 +0200 Subject: [PATCH 222/590] tools/target_dec_fuzzer: Adjust threshold for UTVIDEO Fixes: Timeout Fixes: 47969/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_fuzzer-5097256832860160 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index aa3ba0e523..5b335d3130 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -281,6 +281,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_TQI: maxpixels /= 1024; break; case AV_CODEC_ID_TRUEMOTION2: maxpixels /= 1024; break; case AV_CODEC_ID_TSCC: maxpixels /= 1024; break; + case AV_CODEC_ID_UTVIDEO: maxpixels /= 1024; break; case AV_CODEC_ID_VB: maxpixels /= 1024; break; case AV_CODEC_ID_VC1: maxpixels /= 8192; break; case AV_CODEC_ID_VC1IMAGE: maxpixels /= 8192; break; From d32a9f3137c91de86547601a38fea0693c3497f1 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 9 Sep 2022 00:32:23 +0200 Subject: [PATCH 223/590] libavformat/hls: Free keys Fixes: memleak Fixes: 50703/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-6399058578636800 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Steven Liu Signed-off-by: Michael Niedermayer --- libavformat/hls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3dc7bd3930..e622425e80 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -250,6 +250,7 @@ static void free_init_section_list(struct playlist *pls) { int i; for (i = 0; i < pls->n_init_sections; i++) { + av_freep(&pls->init_sections[i]->key); av_freep(&pls->init_sections[i]->url); av_freep(&pls->init_sections[i]); } From caf8d4d256cc21f09570bdcbdbe8dde4406834ca Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 5 Sep 2022 14:53:50 -0700 Subject: [PATCH 224/590] swscale/output: add support for P012 This generalises the existing P010 support. --- libswscale/output.c | 140 ++++++++++++++---------- libswscale/utils.c | 4 +- libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-p012be | 1 + tests/ref/fate/filter-pixdesc-p012le | 1 + tests/ref/fate/filter-pixfmts-copy | 2 + tests/ref/fate/filter-pixfmts-crop | 2 + tests/ref/fate/filter-pixfmts-field | 2 + tests/ref/fate/filter-pixfmts-hflip | 2 + tests/ref/fate/filter-pixfmts-il | 2 + tests/ref/fate/filter-pixfmts-null | 2 + tests/ref/fate/filter-pixfmts-pad | 1 + tests/ref/fate/filter-pixfmts-scale | 2 + tests/ref/fate/filter-pixfmts-transpose | 2 + tests/ref/fate/filter-pixfmts-vflip | 2 + 15 files changed, 105 insertions(+), 62 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-p012be create mode 100644 tests/ref/fate/filter-pixdesc-p012le diff --git a/libswscale/output.c b/libswscale/output.c index 40a4476c6d..da6c026916 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -460,17 +460,18 @@ static void yuv2nv12cX_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither, #define output_pixel(pos, val) \ if (big_endian) { \ - AV_WB16(pos, av_clip_uintp2(val >> shift, 10) << 6); \ + AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \ } else { \ - AV_WL16(pos, av_clip_uintp2(val >> shift, 10) << 6); \ + AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits) << output_shift); \ } -static void yuv2p010l1_c(const int16_t *src, +static void yuv2p01xl1_c(const int16_t *src, uint16_t *dest, int dstW, - int big_endian) + int big_endian, int output_bits) { int i; - int shift = 5; + int shift = 15 - output_bits; + int output_shift = 16 - output_bits; for (i = 0; i < dstW; i++) { int val = src[i] + (1 << (shift - 1)); @@ -478,12 +479,13 @@ static void yuv2p010l1_c(const int16_t *src, } } -static void yuv2p010lX_c(const int16_t *filter, int filterSize, +static void yuv2p01xlX_c(const int16_t *filter, int filterSize, const int16_t **src, uint16_t *dest, int dstW, - int big_endian) + int big_endian, int output_bits) { int i, j; - int shift = 17; + int shift = 11 + 16 - output_bits; + int output_shift = 16 - output_bits; for (i = 0; i < dstW; i++) { int val = 1 << (shift - 1); @@ -495,14 +497,15 @@ static void yuv2p010lX_c(const int16_t *filter, int filterSize, } } -static void yuv2p010cX_c(int big_endian, const uint8_t *chrDither, +static void yuv2p01xcX_c(int big_endian, const uint8_t *chrDither, const int16_t *chrFilter, int chrFilterSize, const int16_t **chrUSrc, const int16_t **chrVSrc, - uint8_t *dest8, int chrDstW) + uint8_t *dest8, int chrDstW, int output_bits) { uint16_t *dest = (uint16_t*)dest8; - int shift = 17; int i, j; + int shift = 11 + 16 - output_bits; + int output_shift = 16 - output_bits; for (i = 0; i < chrDstW; i++) { int u = 1 << (shift - 1); @@ -518,52 +521,65 @@ static void yuv2p010cX_c(int big_endian, const uint8_t *chrDither, } } -static void yuv2p010l1_LE_c(const int16_t *src, - uint8_t *dest, int dstW, - const uint8_t *dither, int offset) -{ - yuv2p010l1_c(src, (uint16_t*)dest, dstW, 0); -} - -static void yuv2p010l1_BE_c(const int16_t *src, - uint8_t *dest, int dstW, - const uint8_t *dither, int offset) -{ - yuv2p010l1_c(src, (uint16_t*)dest, dstW, 1); -} - -static void yuv2p010lX_LE_c(const int16_t *filter, int filterSize, - const int16_t **src, uint8_t *dest, int dstW, - const uint8_t *dither, int offset) -{ - yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0); -} - -static void yuv2p010lX_BE_c(const int16_t *filter, int filterSize, - const int16_t **src, uint8_t *dest, int dstW, - const uint8_t *dither, int offset) -{ - yuv2p010lX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1); -} - -static void yuv2p010cX_LE_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither, - const int16_t *chrFilter, int chrFilterSize, - const int16_t **chrUSrc, const int16_t **chrVSrc, - uint8_t *dest8, int chrDstW) -{ - yuv2p010cX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, dest8, chrDstW); -} - -static void yuv2p010cX_BE_c(enum AVPixelFormat dstFormat, const uint8_t *chrDither, - const int16_t *chrFilter, int chrFilterSize, - const int16_t **chrUSrc, const int16_t **chrVSrc, - uint8_t *dest8, int chrDstW) -{ - yuv2p010cX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, dest8, chrDstW); -} - #undef output_pixel +#define yuv2p01x_wrapper(bits) \ + static void yuv2p0 ## bits ## l1_LE_c(const int16_t *src, \ + uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset) \ + { \ + yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 0, bits); \ + } \ + \ + static void yuv2p0 ## bits ## l1_BE_c(const int16_t *src, \ + uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset) \ + { \ + yuv2p01xl1_c(src, (uint16_t*)dest, dstW, 1, bits); \ + } \ + \ + static void yuv2p0 ## bits ## lX_LE_c(const int16_t *filter, \ + int filterSize, const int16_t **src, \ + uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset) \ + { \ + yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 0, bits); \ + } \ + \ + static void yuv2p0 ## bits ## lX_BE_c(const int16_t *filter, \ + int filterSize, const int16_t **src, \ + uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset) \ + { \ + yuv2p01xlX_c(filter, filterSize, src, (uint16_t*)dest, dstW, 1, bits); \ + } \ + \ + static void yuv2p0 ## bits ## cX_LE_c(enum AVPixelFormat dstFormat, \ + const uint8_t *chrDither, \ + const int16_t *chrFilter, \ + int chrFilterSize, \ + const int16_t **chrUSrc, \ + const int16_t **chrVSrc, \ + uint8_t *dest8, int chrDstW) \ + { \ + yuv2p01xcX_c(0, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \ + dest8, chrDstW, bits); \ + } \ + \ + static void yuv2p0 ## bits ## cX_BE_c(enum AVPixelFormat dstFormat, \ + const uint8_t *chrDither, \ + const int16_t *chrFilter, \ + int chrFilterSize, \ + const int16_t **chrUSrc, \ + const int16_t **chrVSrc, \ + uint8_t *dest8, int chrDstW) \ + { \ + yuv2p01xcX_c(1, chrDither, chrFilter, chrFilterSize, chrUSrc, chrVSrc, \ + dest8, chrDstW, bits); \ + } + +yuv2p01x_wrapper(10) +yuv2p01x_wrapper(12) #define accumulate_bit(acc, val) \ acc <<= 1; \ @@ -2675,10 +2691,16 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); if (isSemiPlanarYUV(dstFormat) && isDataInHighBits(dstFormat)) { - av_assert0(desc->comp[0].depth == 10); - *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c; - *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c; - *yuv2nv12cX = isBE(dstFormat) ? yuv2p010cX_BE_c : yuv2p010cX_LE_c; + if (desc->comp[0].depth == 10) { + *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c; + *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c; + *yuv2nv12cX = isBE(dstFormat) ? yuv2p010cX_BE_c : yuv2p010cX_LE_c; + } else if (desc->comp[0].depth == 12) { + *yuv2plane1 = isBE(dstFormat) ? yuv2p012l1_BE_c : yuv2p012l1_LE_c; + *yuv2planeX = isBE(dstFormat) ? yuv2p012lX_BE_c : yuv2p012lX_LE_c; + *yuv2nv12cX = isBE(dstFormat) ? yuv2p012cX_BE_c : yuv2p012cX_LE_c; + } else + av_assert0(0); } else if (is16BPS(dstFormat)) { *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; diff --git a/libswscale/utils.c b/libswscale/utils.c index a5a9bc589a..599c326754 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -236,8 +236,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_AYUV64LE] = { 1, 1}, [AV_PIX_FMT_P010LE] = { 1, 1 }, [AV_PIX_FMT_P010BE] = { 1, 1 }, - [AV_PIX_FMT_P012LE] = { 1, 0 }, - [AV_PIX_FMT_P012BE] = { 1, 0 }, + [AV_PIX_FMT_P012LE] = { 1, 1 }, + [AV_PIX_FMT_P012BE] = { 1, 1 }, [AV_PIX_FMT_P016LE] = { 1, 1 }, [AV_PIX_FMT_P016BE] = { 1, 1 }, [AV_PIX_FMT_GRAYF32LE] = { 1, 1 }, diff --git a/libswscale/version.h b/libswscale/version.h index 908995b7b0..284c13cc23 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 108 +#define LIBSWSCALE_VERSION_MICRO 109 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/filter-pixdesc-p012be b/tests/ref/fate/filter-pixdesc-p012be new file mode 100644 index 0000000000..217ca49157 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-p012be @@ -0,0 +1 @@ +pixdesc-p012be 784a49bf554861da9d0809a615bcf813 diff --git a/tests/ref/fate/filter-pixdesc-p012le b/tests/ref/fate/filter-pixdesc-p012le new file mode 100644 index 0000000000..681cd48b4b --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-p012le @@ -0,0 +1 @@ +pixdesc-p012le 0268fd44f63022e21ada69704534fc85 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 371b94c62e..d92dd169dc 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -62,6 +62,8 @@ nv24 f30fc8d0ac40af69e119ea919a314572 nv42 29a212f70f8780fe0eb99abcae81894d p010be 7f9842d6015026136bad60d03c035cc3 p010le c453421b9f726bdaf2bacf59a492c43b +p012be 7f9842d6015026136bad60d03c035cc3 +p012le 1929db89609c4b8c6d9c9030a9e7843d p016be 7f9842d6015026136bad60d03c035cc3 p016le c453421b9f726bdaf2bacf59a492c43b p210be 847e9c6e292b17349e69570829252b3e diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 364e881aef..f7103a5906 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -60,6 +60,8 @@ nv24 514c8f12082f0737e558778cbe7de258 nv42 ece9baae1c5de579dac2c66a89e08ef3 p010be 8b2de2eb6b099bbf355bfc55a0694ddc p010le 373b50c766dfd0a8e79c9a73246d803a +p012be 8b2de2eb6b099bbf355bfc55a0694ddc +p012le a1e4f713e145dfc465bfe0cc77096a03 p016be 8b2de2eb6b099bbf355bfc55a0694ddc p016le 373b50c766dfd0a8e79c9a73246d803a p210be 2947f43774352ef61f9e83777548c7c5 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 768b3f474a..910728e512 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -62,6 +62,8 @@ nv24 3b100fb527b64ee2b2d7120da573faf5 nv42 1841ce853152d86b27c130f319ea0db2 p010be a0311a09bba7383553267d2b3b9c075e p010le ee09a18aefa3ebe97715b3a7312cb8ff +p012be a0311a09bba7383553267d2b3b9c075e +p012le f1cc90d292046109a626db2da9f0f9b6 p016be a0311a09bba7383553267d2b3b9c075e p016le ee09a18aefa3ebe97715b3a7312cb8ff p210be 58d46f566ab28e3bcfb715c7aa53cf58 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 6fbc472a4e..1e37027ec2 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -60,6 +60,8 @@ nv24 f0c5b2f42970f8d4003621d8857a872f nv42 4dcf9aec82b110712b396a8b365dcb13 p010be 744b13e44d39e1ff7588983fa03e0101 p010le a50b160346ab94f55a425065b57006f0 +p012be 744b13e44d39e1ff7588983fa03e0101 +p012le aeb31f50c66f376b0530c7bb6287212b p016be 744b13e44d39e1ff7588983fa03e0101 p016le a50b160346ab94f55a425065b57006f0 p210be 6f5a76d6467b86d55fe5589d3af8a7ea diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 09748c2d08..9efbf5d8e1 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -62,6 +62,8 @@ nv24 554153c71d142e3fd8e40b7dcaaec229 nv42 d699724c8deaeb4f87faf2766512eec3 p010be 3df51286ef66b53e3e283dbbab582263 p010le eadcd8241e97e35b2b47d5eb2eaea6cd +p012be 3df51286ef66b53e3e283dbbab582263 +p012le 38945445b360fa737e9e37257393e823 p016be 3df51286ef66b53e3e283dbbab582263 p016le eadcd8241e97e35b2b47d5eb2eaea6cd p210be 29ec4e8912d456cd15203a96487c42e8 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 371b94c62e..d92dd169dc 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -62,6 +62,8 @@ nv24 f30fc8d0ac40af69e119ea919a314572 nv42 29a212f70f8780fe0eb99abcae81894d p010be 7f9842d6015026136bad60d03c035cc3 p010le c453421b9f726bdaf2bacf59a492c43b +p012be 7f9842d6015026136bad60d03c035cc3 +p012le 1929db89609c4b8c6d9c9030a9e7843d p016be 7f9842d6015026136bad60d03c035cc3 p016le c453421b9f726bdaf2bacf59a492c43b p210be 847e9c6e292b17349e69570829252b3e diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad index 07aaea6b06..d659ef6121 100644 --- a/tests/ref/fate/filter-pixfmts-pad +++ b/tests/ref/fate/filter-pixfmts-pad @@ -27,6 +27,7 @@ nv21 0fdeb2cdd56cf5a7147dc273456fa217 nv24 193b9eadcc06ad5081609f76249b3e47 nv42 1738ad3c31c6c16e17679f5b09ce4677 p010le fbbc23cc1d764a5e6fb71883d985f3ed +p012le 3a92c1bd3e9de050bf6abcc3fd911ab7 p016le fbbc23cc1d764a5e6fb71883d985f3ed p210le 680912c059de39c3401cac856bd1b0c1 p216le 8718662e226a4581561e7bb532af2d83 diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index e1bbe961e1..017eeee84f 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -62,6 +62,8 @@ nv24 2aa6e805bf6d4179ed8d7dea37d75db3 nv42 80714d1eb2d8bcaeab3abc3124df1abd p010be 1d6726d94bf1385996a9a9840dd0e878 p010le 4b316f2b9e18972299beb73511278fa8 +p012be e4dc7ccd654c2d74fde9c7b2711d960b +p012le cd4b6bdcd8967fc0e869ce3b8a014133 p016be 31e204018cbb53f8988c4e1174ea8ce9 p016le d5afe557f492a09317e525d7cb782f5b p210be 2cc6dfcf5e006c8ed5238988a06fd45e diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index 0c2993d5b0..f1b16ca528 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -59,6 +59,8 @@ nv24 ea9de8b47faed722ee40182f89489beb nv42 636af6cd6a4f3ac5edc0fc3ce3c56d63 p010be ad0de2cc9bff81688b182a870fcf7000 p010le e7ff5143595021246733ce6bd0a769e8 +p012be ad0de2cc9bff81688b182a870fcf7000 +p012le 024ef1cf56a4872f202b96a6a4bbf10a p016be ad0de2cc9bff81688b182a870fcf7000 p016le e7ff5143595021246733ce6bd0a769e8 p410be 8b3e0ccb31b6a20ff00a29253fb2dec3 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 5cac61a9d2..814008cefd 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -62,6 +62,8 @@ nv24 334420b9d3df84499d2ca16bb66eed2b nv42 ba4063e2795c17fea3c8a646b01fd1f5 p010be 06e9354b6e0e38ba41736352cedc0bd5 p010le fd18d322bffbf5816902c13102872e22 +p012be 06e9354b6e0e38ba41736352cedc0bd5 +p012le cdf6a3c38d9d4e3f079fa369e1dda662 p016be 06e9354b6e0e38ba41736352cedc0bd5 p016le fd18d322bffbf5816902c13102872e22 p210be ca886ab2b3ea5c153f1954b3709f7249 From 366f073c624779af852bacbc9a0a416e27ff96f7 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 5 Sep 2022 13:41:00 -0700 Subject: [PATCH 225/590] swscale/output: add support for XV36LE --- libswscale/output.c | 29 ++++++++++++++++++++++++ libswscale/utils.c | 2 +- libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-xv36le | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 1 + tests/ref/fate/filter-pixfmts-il | 1 + tests/ref/fate/filter-pixfmts-null | 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 14 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-xv36le diff --git a/libswscale/output.c b/libswscale/output.c index da6c026916..228dab462e 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2600,6 +2600,32 @@ yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, } } +static void +yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + int i; + for (i = 0; i < dstW; i++) { + int Y = 1 << 14, U = 1 << 14, V = 1 << 14; + int j; + + for (j = 0; j < lumFilterSize; j++) + Y += lumSrc[j][i] * lumFilter[j]; + + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][i] * chrFilter[j]; + V += chrVSrc[j][i] * chrFilter[j]; + } + + AV_WL16(dest + 8 * i + 2, av_clip_uintp2(Y >> 15, 12) << 4); + AV_WL16(dest + 8 * i + 0, av_clip_uintp2(U >> 15, 12) << 4); + AV_WL16(dest + 8 * i + 4, av_clip_uintp2(V >> 15, 12) << 4); + } +} + static void yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, @@ -3192,5 +3218,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_VUYX: *yuv2packedX = yuv2vuyx_X_c; break; + case AV_PIX_FMT_XV36LE: + *yuv2packedX = yuv2xv36le_X_c; + break; } } diff --git a/libswscale/utils.c b/libswscale/utils.c index 599c326754..9166e80002 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -266,7 +266,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_RGBAF16BE] = { 1, 0 }, [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, [AV_PIX_FMT_XV30LE] = { 1, 0 }, - [AV_PIX_FMT_XV36LE] = { 1, 0 }, + [AV_PIX_FMT_XV36LE] = { 1, 1 }, }; int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, diff --git a/libswscale/version.h b/libswscale/version.h index 284c13cc23..c35e51138d 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 109 +#define LIBSWSCALE_VERSION_MICRO 110 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/filter-pixdesc-xv36le b/tests/ref/fate/filter-pixdesc-xv36le new file mode 100644 index 0000000000..8ba8099423 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-xv36le @@ -0,0 +1 @@ +pixdesc-xv36le 9d00bb58092f8b6d5d6fd71a8aec719a diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index d92dd169dc..c88594f3aa 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -95,6 +95,7 @@ vuya 3d5e934651cae1ce334001cb1829ad22 vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 +xv36le 3f8ced42a081639a39ec5929dd77b017 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c ya16be 37c07787e544f900c87b853253bfc8dd diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index f7103a5906..bdad0d02cd 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -92,6 +92,7 @@ vuya 76578a705ff3a37559653c1289bd03dd vuyx 5d2bae51a2f4892bd5f177f190cc323b x2bgr10le 84de725b85662c362862820dc4a309aa x2rgb10le f4265aca7a67dbfa9354370098ca6f33 +xv36le 90a187adf00a1b15c33d064ae2582804 xyz12be cb4571f9aaa7b59f999ef327276104b7 xyz12le cd6aae8d26b18bdb4b9d068586276d91 ya16be a3d18014454942a96f15a49947c0c55d diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 910728e512..04c51dba45 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -95,6 +95,7 @@ vuya f72bcf29d75cd143d0c565f7cc49119a vuyx 6257cd1ce11330660e9fa9c675acbdcc x2bgr10le dbe21538d7cb1744914f6bd46ec09b55 x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 +xv36le aa5a867879a70e1040dfafe3e03167d5 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 ya16be 40403b5277364777e0671da4d38e01ac diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index 258c8563f0..27d72b72aa 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -84,6 +84,7 @@ vuya a3891d4168ff208948fd0b3ba0910495 vuyx d7a900e970c9a69ed41f8b220114b9fa x2bgr10le 86474d84f26c5c51d6f75bf7e1de8da8 x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 +xv36le 1bde4bee8b938d7bf20e75bc848e4765 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 ya16be 0f13e0f52586d172aaa07710fa3e8f31 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 1e37027ec2..b949628061 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -92,6 +92,7 @@ vuya 7e530261e7ac4eae4fd616fd7572d0b8 vuyx 3ce9890363cad3984521293be1eb679c x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a x2rgb10le d4a8189b65395a88d0a38a7053f3359f +xv36le cc569285784e38a489f4a286598f05da xyz12be 25f90259ff8a226befdaec3dfe82996e xyz12le 926c0791d59aaff61b2778e8ada3316d ya16be d5b342355bdd9e3197e01b13b7c6301e diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 9efbf5d8e1..064f75b125 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -94,6 +94,7 @@ vuya b9deab5ba249dd608b709c09255a4932 vuyx 49cc92fcc002ec0f312017014dd68c0c x2bgr10le 135acaff8318cf9861bb0f7849a9e5e9 x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 +xv36le 066378fad80e34bc3edd22f657be6ff8 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 xyz12le 090ba6b1170baf2b1358b43b971d33b0 ya16be 7bc720918bc0132e9717acbde89874e0 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index d92dd169dc..c88594f3aa 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -95,6 +95,7 @@ vuya 3d5e934651cae1ce334001cb1829ad22 vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 +xv36le 3f8ced42a081639a39ec5929dd77b017 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c ya16be 37c07787e544f900c87b853253bfc8dd diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 017eeee84f..3381a118d6 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -95,6 +95,7 @@ vuya ffa817e283bf6a0b6fba21b07523ccaa vuyx ba182200e20e0c82765eba15217848d3 x2bgr10le d57b9a99033cc7b65ddd111578f2d385 x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 +xv36le eaf5fbd9d5ea04aeefb40f3d7c2ea289 xyz12be c7ba8345998c0141ddc079cdd29b1a40 xyz12le 95f5d3a0de834cc495c9032a14987cde ya16be 20d4842899d61068f5fb6af478bf26a6 diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index f1b16ca528..e270096a60 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -86,6 +86,7 @@ vuya 9ece18a345beb17cd19e09e443eca4bf vuyx 4c2929cd1c6e5512f62e802f482f0ef2 x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 +xv36le f15a1d1af2a2967ec6a5efebc87e1ef1 xyz12be 68e5cba640f6e4ef72dff950e88b5342 xyz12le 8b6b6a6db4d7561e80db88ccaecce7a9 ya16be 3e161cb5f225922a80fefdc9cc02a4f9 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 814008cefd..73a7ba0ee8 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -95,6 +95,7 @@ vuya fb849f76e56181e005c31fce75d7038c vuyx 7a8079a97610e2c1c97aa8832b58a102 x2bgr10le 795b66a5fc83cd2cf300aae51c230f80 x2rgb10le 262c502230cf3724f8e2cf4737f18a42 +xv36le aad3c6b5799b4e46a9c9ac27ee7db9bd xyz12be 810644e008deb231850d779aaa27cc7e xyz12le 829701db461b43533cf9241e0743bc61 ya16be 55b1dbbe4d56ed0d22461685ce85520d From 68181623e984b249402ac6fd0849c032b05ae143 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 5 Sep 2022 20:00:59 -0700 Subject: [PATCH 226/590] swscale/output: add support for XV30LE --- libswscale/output.c | 31 ++++++++++++++++++++++++ libswscale/utils.c | 2 +- libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-xv30le | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 1 + tests/ref/fate/filter-pixfmts-il | 1 + tests/ref/fate/filter-pixfmts-null | 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 14 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-xv30le diff --git a/libswscale/output.c b/libswscale/output.c index 228dab462e..39e2a04609 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2600,6 +2600,34 @@ yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, } } +static void +yuv2xv30le_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ + int i; + for (i = 0; i < dstW; i++) { + int Y = 1 << 16, U = 1 << 16, V = 1 << 16; + int j; + + for (j = 0; j < lumFilterSize; j++) + Y += lumSrc[j][i] * lumFilter[j]; + + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][i] * chrFilter[j]; + V += chrVSrc[j][i] * chrFilter[j]; + } + + Y = av_clip_uintp2(Y >> 17, 10); + U = av_clip_uintp2(U >> 17, 10); + V = av_clip_uintp2(V >> 17, 10); + + AV_WL32(dest + 4 * i, U | Y << 10 | V << 20); + } +} + static void yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, @@ -3218,6 +3246,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_VUYX: *yuv2packedX = yuv2vuyx_X_c; break; + case AV_PIX_FMT_XV30LE: + *yuv2packedX = yuv2xv30le_X_c; + break; case AV_PIX_FMT_XV36LE: *yuv2packedX = yuv2xv36le_X_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index 9166e80002..ec67020cc9 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -265,7 +265,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_VUYX] = { 1, 1 }, [AV_PIX_FMT_RGBAF16BE] = { 1, 0 }, [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, - [AV_PIX_FMT_XV30LE] = { 1, 0 }, + [AV_PIX_FMT_XV30LE] = { 1, 1 }, [AV_PIX_FMT_XV36LE] = { 1, 1 }, }; diff --git a/libswscale/version.h b/libswscale/version.h index c35e51138d..e8f1dadb8b 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 110 +#define LIBSWSCALE_VERSION_MICRO 111 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/filter-pixdesc-xv30le b/tests/ref/fate/filter-pixdesc-xv30le new file mode 100644 index 0000000000..9b5ad5417e --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-xv30le @@ -0,0 +1 @@ +pixdesc-xv30le fb76a14d6d5cf3a0b48f30b2fb59becd diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index c88594f3aa..67383c43f8 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -95,6 +95,7 @@ vuya 3d5e934651cae1ce334001cb1829ad22 vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 +xv30le c14b5a953bf3be56346f66ca174a5b1b xv36le 3f8ced42a081639a39ec5929dd77b017 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index bdad0d02cd..bdb2536f7d 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -92,6 +92,7 @@ vuya 76578a705ff3a37559653c1289bd03dd vuyx 5d2bae51a2f4892bd5f177f190cc323b x2bgr10le 84de725b85662c362862820dc4a309aa x2rgb10le f4265aca7a67dbfa9354370098ca6f33 +xv30le a9edb820819b900a4a897fee4562a4fb xv36le 90a187adf00a1b15c33d064ae2582804 xyz12be cb4571f9aaa7b59f999ef327276104b7 xyz12le cd6aae8d26b18bdb4b9d068586276d91 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 04c51dba45..853e1b064c 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -95,6 +95,7 @@ vuya f72bcf29d75cd143d0c565f7cc49119a vuyx 6257cd1ce11330660e9fa9c675acbdcc x2bgr10le dbe21538d7cb1744914f6bd46ec09b55 x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 +xv30le e940366c78efc9e292e9de28cf04dba9 xv36le aa5a867879a70e1040dfafe3e03167d5 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index 27d72b72aa..3e190c2d43 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -84,6 +84,7 @@ vuya a3891d4168ff208948fd0b3ba0910495 vuyx d7a900e970c9a69ed41f8b220114b9fa x2bgr10le 86474d84f26c5c51d6f75bf7e1de8da8 x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 +xv30le 25aac48128d94010a3660839500caee5 xv36le 1bde4bee8b938d7bf20e75bc848e4765 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index b949628061..fd5e9723fd 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -92,6 +92,7 @@ vuya 7e530261e7ac4eae4fd616fd7572d0b8 vuyx 3ce9890363cad3984521293be1eb679c x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a x2rgb10le d4a8189b65395a88d0a38a7053f3359f +xv30le 072aa2b61ce1e764f9d1957e8abee9a9 xv36le cc569285784e38a489f4a286598f05da xyz12be 25f90259ff8a226befdaec3dfe82996e xyz12le 926c0791d59aaff61b2778e8ada3316d diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 064f75b125..d82f08d637 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -94,6 +94,7 @@ vuya b9deab5ba249dd608b709c09255a4932 vuyx 49cc92fcc002ec0f312017014dd68c0c x2bgr10le 135acaff8318cf9861bb0f7849a9e5e9 x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 +xv30le 7f6414a3fc700380025c29812e8376a9 xv36le 066378fad80e34bc3edd22f657be6ff8 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 xyz12le 090ba6b1170baf2b1358b43b971d33b0 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index c88594f3aa..67383c43f8 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -95,6 +95,7 @@ vuya 3d5e934651cae1ce334001cb1829ad22 vuyx 3f68ea6ec492b30d867cb5401562264e x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 +xv30le c14b5a953bf3be56346f66ca174a5b1b xv36le 3f8ced42a081639a39ec5929dd77b017 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 3381a118d6..10b94ac516 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -95,6 +95,7 @@ vuya ffa817e283bf6a0b6fba21b07523ccaa vuyx ba182200e20e0c82765eba15217848d3 x2bgr10le d57b9a99033cc7b65ddd111578f2d385 x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 +xv30le afe68d8a47e8460e0164970b1da0c5be xv36le eaf5fbd9d5ea04aeefb40f3d7c2ea289 xyz12be c7ba8345998c0141ddc079cdd29b1a40 xyz12le 95f5d3a0de834cc495c9032a14987cde diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index e270096a60..24f4249639 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -86,6 +86,7 @@ vuya 9ece18a345beb17cd19e09e443eca4bf vuyx 4c2929cd1c6e5512f62e802f482f0ef2 x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 +xv30le b1ac5a12f46d32c70acb63f89838ab76 xv36le f15a1d1af2a2967ec6a5efebc87e1ef1 xyz12be 68e5cba640f6e4ef72dff950e88b5342 xyz12le 8b6b6a6db4d7561e80db88ccaecce7a9 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 73a7ba0ee8..4fff17e7ab 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -95,6 +95,7 @@ vuya fb849f76e56181e005c31fce75d7038c vuyx 7a8079a97610e2c1c97aa8832b58a102 x2bgr10le 795b66a5fc83cd2cf300aae51c230f80 x2rgb10le 262c502230cf3724f8e2cf4737f18a42 +xv30le 7e29ee107a1fabf3c7251f337d4b9fe5 xv36le aad3c6b5799b4e46a9c9ac27ee7db9bd xyz12be 810644e008deb231850d779aaa27cc7e xyz12le 829701db461b43533cf9241e0743bc61 From 09a8e5debb284984871bd3eabd139b7207eedcdc Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 5 Sep 2022 21:47:29 -0700 Subject: [PATCH 227/590] swscale/output: add support for Y210LE and Y212LE --- libswscale/output.c | 48 ++++++++++++++++++++++++ libswscale/utils.c | 4 +- libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-y210le | 1 + tests/ref/fate/filter-pixdesc-y212le | 1 + tests/ref/fate/filter-pixfmts-copy | 2 + tests/ref/fate/filter-pixfmts-field | 2 + tests/ref/fate/filter-pixfmts-fieldorder | 2 + tests/ref/fate/filter-pixfmts-il | 2 + tests/ref/fate/filter-pixfmts-null | 2 + tests/ref/fate/filter-pixfmts-scale | 2 + tests/ref/fate/filter-pixfmts-vflip | 2 + 12 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-y210le create mode 100644 tests/ref/fate/filter-pixdesc-y212le diff --git a/libswscale/output.c b/libswscale/output.c index 39e2a04609..2f599698e9 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2732,6 +2732,48 @@ yuv2vuyx_X_c(SwsContext *c, const int16_t *lumFilter, chrUSrc, chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 0); } +#define output_pixel(pos, val, bits) \ + AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); + +#define yuv2y2xx_wrapper(bits) \ + static void \ + yuv2y2 ## bits ## le_X_c(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, \ + const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, \ + uint8_t *dest, int dstW, int y) \ + { \ + int i, j; \ + int shift = 11 + 16 - bits; \ + int output_shift = 16 - bits; \ + for (i = 0; i < ((dstW + 1) >> 1); i++) { \ + int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1); \ + int U = 1 << (shift - 1), V = 1 << (shift - 1); \ + \ + for (j = 0; j < lumFilterSize; j++) { \ + Y1 += lumSrc[j][i * 2] * lumFilter[j]; \ + Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; \ + } \ + \ + for (j = 0; j < chrFilterSize; j++) { \ + U += chrUSrc[j][i] * chrFilter[j]; \ + V += chrVSrc[j][i] * chrFilter[j]; \ + } \ + \ + output_pixel(dest + 8 * i + 0, Y1, bits); \ + output_pixel(dest + 8 * i + 2, U, bits); \ + output_pixel(dest + 8 * i + 4, Y2, bits); \ + output_pixel(dest + 8 * i + 6, V, bits); \ + } \ + } + +yuv2y2xx_wrapper(10) +yuv2y2xx_wrapper(12) + +#undef output_pixel + av_cold void ff_sws_init_output_funcs(SwsContext *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, @@ -3252,5 +3294,11 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_XV36LE: *yuv2packedX = yuv2xv36le_X_c; break; + case AV_PIX_FMT_Y210LE: + *yuv2packedX = yuv2y210le_X_c; + break; + case AV_PIX_FMT_Y212LE: + *yuv2packedX = yuv2y212le_X_c; + break; } } diff --git a/libswscale/utils.c b/libswscale/utils.c index ec67020cc9..14e2700733 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -248,8 +248,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 }, [AV_PIX_FMT_NV24] = { 1, 1 }, [AV_PIX_FMT_NV42] = { 1, 1 }, - [AV_PIX_FMT_Y210LE] = { 1, 0 }, - [AV_PIX_FMT_Y212LE] = { 1, 0 }, + [AV_PIX_FMT_Y210LE] = { 1, 1 }, + [AV_PIX_FMT_Y212LE] = { 1, 1 }, [AV_PIX_FMT_X2RGB10LE] = { 1, 1 }, [AV_PIX_FMT_X2BGR10LE] = { 1, 1 }, [AV_PIX_FMT_P210BE] = { 1, 1 }, diff --git a/libswscale/version.h b/libswscale/version.h index e8f1dadb8b..9bb3b171a7 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 8 -#define LIBSWSCALE_VERSION_MICRO 111 +#define LIBSWSCALE_VERSION_MICRO 112 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/filter-pixdesc-y210le b/tests/ref/fate/filter-pixdesc-y210le new file mode 100644 index 0000000000..c6dc202948 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-y210le @@ -0,0 +1 @@ +pixdesc-y210le 7b0ba4b531e7dccca7f2a49102b23991 diff --git a/tests/ref/fate/filter-pixdesc-y212le b/tests/ref/fate/filter-pixdesc-y212le new file mode 100644 index 0000000000..5dd6357bf3 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-y212le @@ -0,0 +1 @@ +pixdesc-y212le d481592126b10ef2d5f71a2ccac0ebe5 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 67383c43f8..b28a114c7b 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -99,6 +99,8 @@ xv30le c14b5a953bf3be56346f66ca174a5b1b xv36le 3f8ced42a081639a39ec5929dd77b017 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c +y210le 0736b017e0814daf38d3350c42796f7a +y212le 825768be8fe92708ae80be84855066ed ya16be 37c07787e544f900c87b853253bfc8dd ya16le e8cab8fad88cba6d285b224d8bf0d4df ya8 dbb99fbcdc204aaa1a7397ff561f1a67 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 853e1b064c..4e5a798471 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -99,6 +99,8 @@ xv30le e940366c78efc9e292e9de28cf04dba9 xv36le aa5a867879a70e1040dfafe3e03167d5 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 +y210le 025beb25f047a762e3788dbea4b60864 +y212le ac2a47c45187dd54d0f55293cbffd954 ya16be 40403b5277364777e0671da4d38e01ac ya16le 54f3295f5326a13d456ac53e973ba398 ya8 28cea4f98ed452bd3da9c752e5e3399c diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index 3e190c2d43..bebaf07371 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -88,6 +88,8 @@ xv30le 25aac48128d94010a3660839500caee5 xv36le 1bde4bee8b938d7bf20e75bc848e4765 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 +y210le ee45acfb1386288af98af5313162ff3e +y212le 2f08fb195b948056c844acb1eee8d649 ya16be 0f13e0f52586d172aaa07710fa3e8f31 ya16le d481d93ea1a1a04d759d9994958983de ya8 055ac5ab5ff8533dd319edc17a398af1 diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index d82f08d637..ec9d809721 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -98,6 +98,8 @@ xv30le 7f6414a3fc700380025c29812e8376a9 xv36le 066378fad80e34bc3edd22f657be6ff8 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 xyz12le 090ba6b1170baf2b1358b43b971d33b0 +y210le 306ec4238b49dbc8625a97b678ea1c5f +y212le d5a2b4677ddb4a3bc3e5cd5cbb20f426 ya16be 7bc720918bc0132e9717acbde89874e0 ya16le 61203295a8d39601b841de90f2c9797b ya8 a38d6e288f582f1a04310232ed764afc diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 67383c43f8..b28a114c7b 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -99,6 +99,8 @@ xv30le c14b5a953bf3be56346f66ca174a5b1b xv36le 3f8ced42a081639a39ec5929dd77b017 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c +y210le 0736b017e0814daf38d3350c42796f7a +y212le 825768be8fe92708ae80be84855066ed ya16be 37c07787e544f900c87b853253bfc8dd ya16le e8cab8fad88cba6d285b224d8bf0d4df ya8 dbb99fbcdc204aaa1a7397ff561f1a67 diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 10b94ac516..525306ec12 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -99,6 +99,8 @@ xv30le afe68d8a47e8460e0164970b1da0c5be xv36le eaf5fbd9d5ea04aeefb40f3d7c2ea289 xyz12be c7ba8345998c0141ddc079cdd29b1a40 xyz12le 95f5d3a0de834cc495c9032a14987cde +y210le 1c2708a520477f955d1fedf6ca7a41bd +y212le 39a3c0c843041ad4501b3107dd91ef17 ya16be 20d4842899d61068f5fb6af478bf26a6 ya16le 6a05895adce85143ae1c1b3470cb4070 ya8 0a9db5bb4b009de9197eede5e9d19e16 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 4fff17e7ab..b7b0526588 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -99,6 +99,8 @@ xv30le 7e29ee107a1fabf3c7251f337d4b9fe5 xv36le aad3c6b5799b4e46a9c9ac27ee7db9bd xyz12be 810644e008deb231850d779aaa27cc7e xyz12le 829701db461b43533cf9241e0743bc61 +y210le 9544c81f8e1fc95e9fa4009dbecfea25 +y212le c801725ae31e3b8f5be269359d49f191 ya16be 55b1dbbe4d56ed0d22461685ce85520d ya16le d5bf02471823a16dc523a46cace0101a ya8 4299c6ca3b470a7d8a420e26eb485b1d From 09cce812453f989a0537c62b6db1020ea266553d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 10 Sep 2022 22:06:16 +0200 Subject: [PATCH 228/590] avfilter/vf_gblur: allow filtering with zero horizontal sigma --- libavfilter/vf_gblur.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c index bb4c342116..ca1dcb3dab 100644 --- a/libavfilter/vf_gblur.c +++ b/libavfilter/vf_gblur.c @@ -125,7 +125,7 @@ static void gaussianiir2d(AVFilterContext *ctx, int plane) const int nb_threads = ff_filter_get_nb_threads(ctx); ThreadData td; - if (s->sigma <= 0 || s->steps < 0) + if (s->sigma < 0 || s->steps < 0) return; td.width = width; @@ -247,7 +247,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) uint16_t *dst16 = (uint16_t *)out->data[plane]; int y, x; - if (!s->sigma || !(s->planes & (1 << plane))) { + if (!(s->planes & (1 << plane))) { if (out != in) av_image_copy_plane(out->data[plane], out->linesize[plane], in->data[plane], in->linesize[plane], From 38cacce22a613d660d4d78e65b0ecdb7be0b908c Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Fri, 9 Sep 2022 17:00:24 +0800 Subject: [PATCH 229/590] swscale/la: Optimize hscale functions with lasx. ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -s 640x480 -y /dev/null -an before: 101fps after: 138fps Signed-off-by: Hao Chen Reviewed-by: yinshiyou-hf@loongson.cn Signed-off-by: Michael Niedermayer --- libswscale/loongarch/Makefile | 3 + libswscale/loongarch/input_lasx.c | 202 ++++ libswscale/loongarch/swscale_init_loongarch.c | 50 + libswscale/loongarch/swscale_lasx.c | 972 ++++++++++++++++++ libswscale/loongarch/swscale_loongarch.h | 50 + libswscale/swscale.c | 2 + libswscale/swscale_internal.h | 2 + libswscale/utils.c | 13 +- 8 files changed, 1293 insertions(+), 1 deletion(-) create mode 100644 libswscale/loongarch/Makefile create mode 100644 libswscale/loongarch/input_lasx.c create mode 100644 libswscale/loongarch/swscale_init_loongarch.c create mode 100644 libswscale/loongarch/swscale_lasx.c create mode 100644 libswscale/loongarch/swscale_loongarch.h diff --git a/libswscale/loongarch/Makefile b/libswscale/loongarch/Makefile new file mode 100644 index 0000000000..586a1717b6 --- /dev/null +++ b/libswscale/loongarch/Makefile @@ -0,0 +1,3 @@ +OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_init_loongarch.o +LASX-OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_lasx.o \ + loongarch/input_lasx.o \ diff --git a/libswscale/loongarch/input_lasx.c b/libswscale/loongarch/input_lasx.c new file mode 100644 index 0000000000..4830072eaf --- /dev/null +++ b/libswscale/loongarch/input_lasx.c @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 "swscale_loongarch.h" +#include "libavutil/loongarch/loongson_intrinsics.h" + +void planar_rgb_to_uv_lasx(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], + int width, int32_t *rgb2yuv, void *opq) +{ + int i; + uint16_t *dstU = (uint16_t *)_dstU; + uint16_t *dstV = (uint16_t *)_dstV; + int set = 0x4001 << (RGB2YUV_SHIFT - 7); + int len = width - 15; + int32_t tem_ru = rgb2yuv[RU_IDX], tem_gu = rgb2yuv[GU_IDX]; + int32_t tem_bu = rgb2yuv[BU_IDX], tem_rv = rgb2yuv[RV_IDX]; + int32_t tem_gv = rgb2yuv[GV_IDX], tem_bv = rgb2yuv[BV_IDX]; + int shift = RGB2YUV_SHIFT - 6; + const uint8_t *src0 = src[0], *src1 = src[1], *src2 = src[2]; + __m256i ru, gu, bu, rv, gv, bv; + __m256i mask = {0x0D0C090805040100, 0x1D1C191815141110, + 0x0D0C090805040100, 0x1D1C191815141110}; + __m256i temp = __lasx_xvreplgr2vr_w(set); + __m256i sra = __lasx_xvreplgr2vr_w(shift); + + ru = __lasx_xvreplgr2vr_w(tem_ru); + gu = __lasx_xvreplgr2vr_w(tem_gu); + bu = __lasx_xvreplgr2vr_w(tem_bu); + rv = __lasx_xvreplgr2vr_w(tem_rv); + gv = __lasx_xvreplgr2vr_w(tem_gv); + bv = __lasx_xvreplgr2vr_w(tem_bv); + for (i = 0; i < len; i += 16) { + __m256i _g, _b, _r; + __m256i g_l, g_h, b_l, b_h, r_l, r_h; + __m256i v_l, v_h, u_l, u_h, u_lh, v_lh; + + _g = __lasx_xvldx(src0, i); + _b = __lasx_xvldx(src1, i); + _r = __lasx_xvldx(src2, i); + g_l = __lasx_vext2xv_wu_bu(_g); + b_l = __lasx_vext2xv_wu_bu(_b); + r_l = __lasx_vext2xv_wu_bu(_r); + _g = __lasx_xvpermi_d(_g, 0x01); + _b = __lasx_xvpermi_d(_b, 0x01); + _r = __lasx_xvpermi_d(_r, 0x01); + g_h = __lasx_vext2xv_wu_bu(_g); + b_h = __lasx_vext2xv_wu_bu(_b); + r_h = __lasx_vext2xv_wu_bu(_r); + u_l = __lasx_xvmadd_w(temp, ru, r_l); + u_h = __lasx_xvmadd_w(temp, ru, r_h); + v_l = __lasx_xvmadd_w(temp, rv, r_l); + v_h = __lasx_xvmadd_w(temp, rv, r_h); + u_l = __lasx_xvmadd_w(u_l, gu, g_l); + u_l = __lasx_xvmadd_w(u_l, bu, b_l); + u_h = __lasx_xvmadd_w(u_h, gu, g_h); + u_h = __lasx_xvmadd_w(u_h, bu, b_h); + v_l = __lasx_xvmadd_w(v_l, gv, g_l); + v_l = __lasx_xvmadd_w(v_l, bv, b_l); + v_h = __lasx_xvmadd_w(v_h, gv, g_h); + v_h = __lasx_xvmadd_w(v_h, bv, b_h); + u_l = __lasx_xvsra_w(u_l, sra); + u_h = __lasx_xvsra_w(u_h, sra); + v_l = __lasx_xvsra_w(v_l, sra); + v_h = __lasx_xvsra_w(v_h, sra); + u_lh = __lasx_xvshuf_b(u_h, u_l, mask); + v_lh = __lasx_xvshuf_b(v_h, v_l, mask); + u_lh = __lasx_xvpermi_d(u_lh, 0xD8); + v_lh = __lasx_xvpermi_d(v_lh, 0xD8); + __lasx_xvst(u_lh, (dstU + i), 0); + __lasx_xvst(v_lh, (dstV + i), 0); + } + if (width - i >= 8) { + __m256i _g, _b, _r; + __m256i g_l, b_l, r_l; + __m256i v_l, u_l, u, v; + + _g = __lasx_xvldrepl_d((src0 + i), 0); + _b = __lasx_xvldrepl_d((src1 + i), 0); + _r = __lasx_xvldrepl_d((src2 + i), 0); + g_l = __lasx_vext2xv_wu_bu(_g); + b_l = __lasx_vext2xv_wu_bu(_b); + r_l = __lasx_vext2xv_wu_bu(_r); + u_l = __lasx_xvmadd_w(temp, ru, r_l); + v_l = __lasx_xvmadd_w(temp, rv, r_l); + u_l = __lasx_xvmadd_w(u_l, gu, g_l); + u_l = __lasx_xvmadd_w(u_l, bu, b_l); + v_l = __lasx_xvmadd_w(v_l, gv, g_l); + v_l = __lasx_xvmadd_w(v_l, bv, b_l); + u_l = __lasx_xvsra_w(u_l, sra); + v_l = __lasx_xvsra_w(v_l, sra); + u = __lasx_xvshuf_b(u_l, u_l, mask); + v = __lasx_xvshuf_b(v_l, v_l, mask); + __lasx_xvstelm_d(u, (dstU + i), 0, 0); + __lasx_xvstelm_d(u, (dstU + i), 8, 2); + __lasx_xvstelm_d(v, (dstV + i), 0, 0); + __lasx_xvstelm_d(v, (dstV + i), 8, 2); + i += 8; + } + for (; i < width; i++) { + int g = src[0][i]; + int b = src[1][i]; + int r = src[2][i]; + + dstU[i] = (tem_ru * r + tem_gu * g + tem_bu * b + set) >> shift; + dstV[i] = (tem_rv * r + tem_gv * g + tem_bv * b + set) >> shift; + } +} + +void planar_rgb_to_y_lasx(uint8_t *_dst, const uint8_t *src[4], int width, + int32_t *rgb2yuv, void *opq) +{ + int i; + int shift = (RGB2YUV_SHIFT - 6); + int set = 0x801 << (RGB2YUV_SHIFT - 7); + int len = width - 15; + uint16_t *dst = (uint16_t *)_dst; + int32_t tem_ry = rgb2yuv[RY_IDX], tem_gy = rgb2yuv[GY_IDX]; + int32_t tem_by = rgb2yuv[BY_IDX]; + const uint8_t *src0 = src[0], *src1 = src[1], *src2 = src[2]; + __m256i mask = {0x0D0C090805040100, 0x1D1C191815141110, + 0x0D0C090805040100, 0x1D1C191815141110}; + __m256i temp = __lasx_xvreplgr2vr_w(set); + __m256i sra = __lasx_xvreplgr2vr_w(shift); + __m256i ry = __lasx_xvreplgr2vr_w(tem_ry); + __m256i gy = __lasx_xvreplgr2vr_w(tem_gy); + __m256i by = __lasx_xvreplgr2vr_w(tem_by); + + for (i = 0; i < len; i += 16) { + __m256i _g, _b, _r; + __m256i g_l, g_h, b_l, b_h, r_l, r_h; + __m256i y_l, y_h, y_lh; + + _g = __lasx_xvldx(src0, i); + _b = __lasx_xvldx(src1, i); + _r = __lasx_xvldx(src2, i); + g_l = __lasx_vext2xv_wu_bu(_g); + b_l = __lasx_vext2xv_wu_bu(_b); + r_l = __lasx_vext2xv_wu_bu(_r); + _g = __lasx_xvpermi_d(_g, 0x01); + _b = __lasx_xvpermi_d(_b, 0x01); + _r = __lasx_xvpermi_d(_r, 0x01); + g_h = __lasx_vext2xv_wu_bu(_g); + b_h = __lasx_vext2xv_wu_bu(_b); + r_h = __lasx_vext2xv_wu_bu(_r); + y_l = __lasx_xvmadd_w(temp, ry, r_l); + y_h = __lasx_xvmadd_w(temp, ry, r_h); + y_l = __lasx_xvmadd_w(y_l, gy, g_l); + y_l = __lasx_xvmadd_w(y_l, by, b_l); + y_h = __lasx_xvmadd_w(y_h, gy, g_h); + y_h = __lasx_xvmadd_w(y_h, by, b_h); + y_l = __lasx_xvsra_w(y_l, sra); + y_h = __lasx_xvsra_w(y_h, sra); + y_lh = __lasx_xvshuf_b(y_h, y_l, mask); + y_lh = __lasx_xvpermi_d(y_lh, 0xD8); + __lasx_xvst(y_lh, (dst + i), 0); + } + if (width - i >= 8) { + __m256i _g, _b, _r; + __m256i g_l, b_l, r_l; + __m256i y_l, y; + + _g = __lasx_xvldrepl_d((src0 + i), 0); + _b = __lasx_xvldrepl_d((src1 + i), 0); + _r = __lasx_xvldrepl_d((src2 + i), 0); + g_l = __lasx_vext2xv_wu_bu(_g); + b_l = __lasx_vext2xv_wu_bu(_b); + r_l = __lasx_vext2xv_wu_bu(_r); + y_l = __lasx_xvmadd_w(temp, ry, r_l); + y_l = __lasx_xvmadd_w(y_l, gy, g_l); + y_l = __lasx_xvmadd_w(y_l, by, b_l); + y_l = __lasx_xvsra_w(y_l, sra); + y = __lasx_xvshuf_b(y_l, y_l, mask); + __lasx_xvstelm_d(y, (dst + i), 0, 0); + __lasx_xvstelm_d(y, (dst + i), 8, 2); + i += 8; + } + for (; i < width; i++) { + int g = src[0][i]; + int b = src[1][i]; + int r = src[2][i]; + + dst[i] = (tem_ry * r + tem_gy * g + tem_by * b + set) >> shift; + } +} diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c new file mode 100644 index 0000000000..197dc6e1e7 --- /dev/null +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 "swscale_loongarch.h" +#include "libswscale/swscale_internal.h" +#include "libavutil/loongarch/cpu.h" + +av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) +{ + int cpu_flags = av_get_cpu_flags(); + if (have_lasx(cpu_flags)) { + if (c->srcBpc == 8) { + if (c->dstBpc <= 14) { + c->hyScale = c->hcScale = ff_hscale_8_to_15_lasx; + } else { + c->hyScale = c->hcScale = ff_hscale_8_to_19_lasx; + } + } else { + c->hyScale = c->hcScale = c->dstBpc > 14 ? ff_hscale_16_to_19_lasx + : ff_hscale_16_to_15_lasx; + } + switch (c->srcFormat) { + case AV_PIX_FMT_GBRAP: + case AV_PIX_FMT_GBRP: + { + c->readChrPlanar = planar_rgb_to_uv_lasx; + c->readLumPlanar = planar_rgb_to_y_lasx; + } + break; + } + } +} diff --git a/libswscale/loongarch/swscale_lasx.c b/libswscale/loongarch/swscale_lasx.c new file mode 100644 index 0000000000..3e0bae2cc2 --- /dev/null +++ b/libswscale/loongarch/swscale_lasx.c @@ -0,0 +1,972 @@ +/* + * Copyright (C) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 "swscale_loongarch.h" +#include "libavutil/loongarch/loongson_intrinsics.h" +#include "libavutil/intreadwrite.h" + +#define SCALE_8_16(_sh) \ +{ \ + src0 = __lasx_xvldrepl_d(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_d(src + filterPos[1], 0); \ + src2 = __lasx_xvldrepl_d(src + filterPos[2], 0); \ + src3 = __lasx_xvldrepl_d(src + filterPos[3], 0); \ + src4 = __lasx_xvldrepl_d(src + filterPos[4], 0); \ + src5 = __lasx_xvldrepl_d(src + filterPos[5], 0); \ + src6 = __lasx_xvldrepl_d(src + filterPos[6], 0); \ + src7 = __lasx_xvldrepl_d(src + filterPos[7], 0); \ + src8 = __lasx_xvldrepl_d(src + filterPos[8], 0); \ + src9 = __lasx_xvldrepl_d(src + filterPos[9], 0); \ + src10 = __lasx_xvldrepl_d(src + filterPos[10], 0); \ + src11 = __lasx_xvldrepl_d(src + filterPos[11], 0); \ + src12 = __lasx_xvldrepl_d(src + filterPos[12], 0); \ + src13 = __lasx_xvldrepl_d(src + filterPos[13], 0); \ + src14 = __lasx_xvldrepl_d(src + filterPos[14], 0); \ + src15 = __lasx_xvldrepl_d(src + filterPos[15], 0); \ + DUP4_ARG2(__lasx_xvld, filter, 0, filter, 32, filter, 64, \ + filter, 96, filter0, filter1, filter2, filter3); \ + DUP4_ARG2(__lasx_xvld, filter, 128, filter, 160, \ + filter, 192, filter, 224, filter4, \ + filter5, filter6, filter7); \ + DUP4_ARG2(__lasx_xvilvl_d, src1, src0, src3, src2, \ + src5, src4, src7, src6, src0, src2, src4, src6); \ + DUP4_ARG2(__lasx_xvilvl_d, src9, src8, src11, src10, \ + src13, src12, src15, src14, src8, src10, src12, src14); \ + DUP4_ARG1(__lasx_vext2xv_hu_bu, src0, src2, src4, src6, \ + src0, src2, src4, src6); \ + DUP4_ARG1(__lasx_vext2xv_hu_bu, src8, src10, src12, \ + src14, src8, src10, src12, src14); \ + DUP4_ARG2(__lasx_xvdp2_w_h, filter0, src0, filter1, src2, \ + filter2, src4, filter3, src6, src0, src1, src2, src3); \ + DUP4_ARG2(__lasx_xvdp2_w_h, filter4, src8, filter5, src10, \ + filter6, src12, filter7, src14, src4, src5, src6, src7);\ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src2 = __lasx_xvhaddw_d_w(src2, src2); \ + src3 = __lasx_xvhaddw_d_w(src3, src3); \ + src4 = __lasx_xvhaddw_d_w(src4, src4); \ + src5 = __lasx_xvhaddw_d_w(src5, src5); \ + src6 = __lasx_xvhaddw_d_w(src6, src6); \ + src7 = __lasx_xvhaddw_d_w(src7, src7); \ + DUP4_ARG2(__lasx_xvpickev_w, src1, src0, src3, src2, \ + src5, src4, src7, src6, src0, src1, src2, src3); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src2 = __lasx_xvhaddw_d_w(src2, src2); \ + src3 = __lasx_xvhaddw_d_w(src3, src3); \ + src0 = __lasx_xvpickev_w(src1, src0); \ + src1 = __lasx_xvpickev_w(src3, src2); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src1 = __lasx_xvsrai_w(src1, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + src1 = __lasx_xvmin_w(src1, vmax); \ + src0 = __lasx_xvperm_w(src0, shuf); \ + src1 = __lasx_xvperm_w(src1, shuf); \ + src0 = __lasx_xvpickev_h(src1, src0); \ + src0 = __lasx_xvpermi_d(src0, 0xd8); \ + __lasx_xvst(src0, dst, 0); \ + filterPos += 16; \ + filter += 128; \ + dst += 16; \ +} + +#define SCALE_8_8(_sh) \ +{ \ + src0 = __lasx_xvldrepl_d(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_d(src + filterPos[1], 0); \ + src2 = __lasx_xvldrepl_d(src + filterPos[2], 0); \ + src3 = __lasx_xvldrepl_d(src + filterPos[3], 0); \ + src4 = __lasx_xvldrepl_d(src + filterPos[4], 0); \ + src5 = __lasx_xvldrepl_d(src + filterPos[5], 0); \ + src6 = __lasx_xvldrepl_d(src + filterPos[6], 0); \ + src7 = __lasx_xvldrepl_d(src + filterPos[7], 0); \ + DUP4_ARG2(__lasx_xvld, filter, 0, filter, 32, filter, 64, \ + filter, 96, filter0, filter1, filter2, filter3); \ + filterPos += 8; \ + filter += 64; \ + DUP4_ARG2(__lasx_xvilvl_d, src1, src0, src3, src2, \ + src5, src4, src7, src6, src0, src2, src4, src6); \ + DUP4_ARG1(__lasx_vext2xv_hu_bu, src0, src2, src4, src6, \ + src0, src2, src4, src6); \ + DUP4_ARG2(__lasx_xvdp2_w_h, filter0, src0, filter1, src2, \ + filter2, src4, filter3, src6, src0, src1, src2,src3); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src2 = __lasx_xvhaddw_d_w(src2, src2); \ + src3 = __lasx_xvhaddw_d_w(src3, src3); \ + src0 = __lasx_xvpickev_w(src1, src0); \ + src1 = __lasx_xvpickev_w(src3, src2); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src0 = __lasx_xvpickev_w(src1, src0); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + src0 = __lasx_xvperm_w(src0, shuf); \ +} + +#define SCALE_8_4(_sh) \ +{ \ + src0 = __lasx_xvldrepl_d(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_d(src + filterPos[1], 0); \ + src2 = __lasx_xvldrepl_d(src + filterPos[2], 0); \ + src3 = __lasx_xvldrepl_d(src + filterPos[3], 0); \ + filter0 = __lasx_xvld(filter, 0); \ + filter1 = __lasx_xvld(filter, 32); \ + filterPos += 4; \ + filter += 32; \ + src0 = __lasx_xvilvl_d(src1, src0); \ + src2 = __lasx_xvilvl_d(src3, src2); \ + src0 = __lasx_vext2xv_hu_bu(src0); \ + src2 = __lasx_vext2xv_hu_bu(src2); \ + src0 = __lasx_xvdp2_w_h(src0, filter0); \ + src1 = __lasx_xvdp2_w_h(src2, filter1); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src0 = __lasx_xvpickev_w(src1, src0); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src0 = __lasx_xvpickev_w(src0, src0); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + src0 = __lasx_xvperm_w(src0, shuf); \ +} + +#define SCALE_8_2(_sh) \ +{ \ + src0 = __lasx_xvldrepl_d(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_d(src + filterPos[1], 0); \ + filter0 = __lasx_xvld(filter, 0); \ + src0 = __lasx_xvilvl_d(src1, src0); \ + src0 = __lasx_vext2xv_hu_bu(src0); \ + src0 = __lasx_xvdp2_w_h(filter0, src0); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src0 = __lasx_xvhaddw_q_d(src0, src0); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + dst[0] = __lasx_xvpickve2gr_w(src0, 0); \ + dst[1] = __lasx_xvpickve2gr_w(src0, 4); \ + filterPos += 2; \ + filter += 16; \ + dst += 2; \ +} + +#define SCALE_4_16(_sh) \ +{ \ + src0 = __lasx_xvldrepl_w(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_w(src + filterPos[1], 0); \ + src2 = __lasx_xvldrepl_w(src + filterPos[2], 0); \ + src3 = __lasx_xvldrepl_w(src + filterPos[3], 0); \ + src4 = __lasx_xvldrepl_w(src + filterPos[4], 0); \ + src5 = __lasx_xvldrepl_w(src + filterPos[5], 0); \ + src6 = __lasx_xvldrepl_w(src + filterPos[6], 0); \ + src7 = __lasx_xvldrepl_w(src + filterPos[7], 0); \ + src8 = __lasx_xvldrepl_w(src + filterPos[8], 0); \ + src9 = __lasx_xvldrepl_w(src + filterPos[9], 0); \ + src10 = __lasx_xvldrepl_w(src + filterPos[10], 0); \ + src11 = __lasx_xvldrepl_w(src + filterPos[11], 0); \ + src12 = __lasx_xvldrepl_w(src + filterPos[12], 0); \ + src13 = __lasx_xvldrepl_w(src + filterPos[13], 0); \ + src14 = __lasx_xvldrepl_w(src + filterPos[14], 0); \ + src15 = __lasx_xvldrepl_w(src + filterPos[15], 0); \ + DUP4_ARG2(__lasx_xvld, filter, 0, filter, 32, filter, 64, \ + filter, 96, filter0, filter1, filter2, filter3); \ + DUP4_ARG2(__lasx_xvilvl_w, src1, src0, src3, src2, src5, \ + src4, src7, src6, src0, src2, src4, src6); \ + DUP4_ARG2(__lasx_xvilvl_w, src9, src8, src11, src10, src13, \ + src12, src15, src14, src8, src10, src12, src14); \ + DUP4_ARG2(__lasx_xvilvl_d, src2, src0, src6, src4, src10, \ + src8, src14, src12, src0, src1, src2, src3); \ + DUP4_ARG1(__lasx_vext2xv_hu_bu, src0, src1, src2, src3, \ + src0, src1, src2, src3); \ + DUP4_ARG2(__lasx_xvdp2_w_h, filter0, src0, filter1, src1, \ + filter2, src2, filter3, src3, src0, src1, src2, src3); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src2 = __lasx_xvhaddw_d_w(src2, src2); \ + src3 = __lasx_xvhaddw_d_w(src3, src3); \ + src0 = __lasx_xvpickev_w(src1, src0); \ + src1 = __lasx_xvpickev_w(src3, src2); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src1 = __lasx_xvsrai_w(src1, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + src1 = __lasx_xvmin_w(src1, vmax); \ + src0 = __lasx_xvpickev_h(src1, src0); \ + src0 = __lasx_xvperm_w(src0, shuf); \ + __lasx_xvst(src0, dst, 0); \ + filterPos += 16; \ + filter += 64; \ + dst += 16; \ +} + +#define SCALE_4_8(_sh) \ +{ \ + src0 = __lasx_xvldrepl_w(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_w(src + filterPos[1], 0); \ + src2 = __lasx_xvldrepl_w(src + filterPos[2], 0); \ + src3 = __lasx_xvldrepl_w(src + filterPos[3], 0); \ + src4 = __lasx_xvldrepl_w(src + filterPos[4], 0); \ + src5 = __lasx_xvldrepl_w(src + filterPos[5], 0); \ + src6 = __lasx_xvldrepl_w(src + filterPos[6], 0); \ + src7 = __lasx_xvldrepl_w(src + filterPos[7], 0); \ + filter0 = __lasx_xvld(filter, 0); \ + filter1 = __lasx_xvld(filter, 32); \ + filterPos += 8; \ + filter += 32; \ + DUP4_ARG2(__lasx_xvilvl_w, src1, src0, src3, src2, src5, \ + src4, src7, src6, src0, src2, src4, src6); \ + src0 = __lasx_xvilvl_d(src2, src0); \ + src1 = __lasx_xvilvl_d(src6, src4); \ + \ + src0 = __lasx_vext2xv_hu_bu(src0); \ + src1 = __lasx_vext2xv_hu_bu(src1); \ + src0 = __lasx_xvdp2_w_h(filter0, src0); \ + src1 = __lasx_xvdp2_w_h(filter1, src1); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src1 = __lasx_xvhaddw_d_w(src1, src1); \ + src0 = __lasx_xvpickev_w(src1, src0); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ +} + +#define SCALE_4_4(_sh) \ +{ \ + src0 = __lasx_xvldrepl_w(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_w(src + filterPos[1], 0); \ + src2 = __lasx_xvldrepl_w(src + filterPos[2], 0); \ + src3 = __lasx_xvldrepl_w(src + filterPos[3], 0); \ + filter0 = __lasx_xvld(filter, 0); \ + filterPos += 4; \ + filter += 16; \ + src0 = __lasx_xvilvl_w(src1, src0); \ + src1 = __lasx_xvilvl_w(src3, src2); \ + \ + src0 = __lasx_xvilvl_d(src1, src0); \ + src0 = __lasx_vext2xv_hu_bu(src0); \ + src0 = __lasx_xvdp2_w_h(filter0, src0); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + src0 = __lasx_xvpickev_w(src0, src0); \ + src0 = __lasx_xvpermi_d(src0, 0xd8); \ +} + +#define SCALE_4_2(_sh) \ +{ \ + src0 = __lasx_xvldrepl_w(src + filterPos[0], 0); \ + src1 = __lasx_xvldrepl_w(src + filterPos[1], 0); \ + filter0 = __lasx_xvld(filter, 0); \ + src0 = __lasx_xvilvl_w(src1, src0); \ + src0 = __lasx_vext2xv_hu_bu(src0); \ + src0 = __lasx_xvdp2_w_h(filter0, src0); \ + src0 = __lasx_xvhaddw_d_w(src0, src0); \ + src0 = __lasx_xvsrai_w(src0, _sh); \ + src0 = __lasx_xvmin_w(src0, vmax); \ + dst[0] = __lasx_xvpickve2gr_w(src0, 0); \ + dst[1] = __lasx_xvpickve2gr_w(src0, 2); \ + filterPos += 2; \ + filter += 8; \ + dst += 2; \ +} + +#define SCALE_16 \ +{ \ + int dex = j << 1; \ + src0 = __lasx_xvldrepl_d((srcPos1 + j), 0); \ + src1 = __lasx_xvldrepl_d((srcPos2 + j), 0); \ + src2 = __lasx_xvldrepl_d((srcPos3 + j), 0); \ + src3 = __lasx_xvldrepl_d((srcPos4 + j), 0); \ + DUP4_ARG2(__lasx_xvldx, filterStart1, dex, filterStart2, dex, \ + filterStart3, dex, filterStart4, dex, filter0, \ + filter1, filter2, filter3); \ + src0 = __lasx_xvpermi_q(src0, src1, 0x02); \ + src1 = __lasx_xvpermi_q(src2, src3, 0x02); \ + filter0 = __lasx_xvpermi_q(filter0, filter1, 0x02); \ + filter1 = __lasx_xvpermi_q(filter2, filter3, 0x02); \ + src0 = __lasx_xvilvl_b(zero, src0); \ + src1 = __lasx_xvilvl_b(zero, src1); \ + out0 = __lasx_xvdp2_w_h(filter0, src0); \ + out1 = __lasx_xvdp2_w_h(filter1, src1); \ + src0 = __lasx_xvhaddw_d_w(out0, out0); \ + src1 = __lasx_xvhaddw_d_w(out1, out1); \ + out0 = __lasx_xvpackev_d(src1, src0); \ + out1 = __lasx_xvpackod_d(src1, src0); \ + out0 = __lasx_xvadd_w(out0, out1); \ + out = __lasx_xvadd_w(out, out0); \ +} + +void ff_hscale_8_to_15_lasx(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize) +{ + int i; + int max = (1 << 15) - 1; + + if (filterSize == 8) { + __m256i src0, src1, src2, src3, src4, src5, src6, src7; + __m256i src8, src9, src10, src11, src12, src13, src14, src15; + __m256i filter0, filter1, filter2, filter3; + __m256i filter4, filter5, filter6, filter7; + __m256i vmax = __lasx_xvreplgr2vr_w(max); + __m256i shuf = {0x0000000400000000, 0x0000000500000001, + 0x0000000600000002, 0x0000000700000003}; + int len = dstW >> 4; + int res = dstW & 15; + while (len--) { + SCALE_8_16(7); + } + if (res & 8) { + SCALE_8_8(7); + src0 = __lasx_xvpickev_h(src0, src0); + __lasx_xvstelm_d(src0, dst, 0, 0); + __lasx_xvstelm_d(src0, dst, 8, 2); + dst += 8; + } + if (res & 4) { + SCALE_8_4(7); + src0 = __lasx_xvpickev_h(src0, src0); + __lasx_xvstelm_d(src0, dst, 0, 0); + dst += 4; + } + if (res & 2) { + SCALE_8_2(7); + } + if (res & 1) { + int val = 0; + src0 = __lasx_xvldrepl_d(src + filterPos[0], 0); + filter0 = __lasx_xvld(filter, 0); + src0 = __lasx_vext2xv_hu_bu(src0); + src0 = __lasx_xvdp2_w_h(filter0, src0); + src0 = __lasx_xvhaddw_d_w(src0, src0); + src0 = __lasx_xvhaddw_q_d(src0, src0); + val = __lasx_xvpickve2gr_w(src0, 0); + dst[0] = FFMIN(val >> 7, max); + } + } else if (filterSize == 4) { + __m256i src0, src1, src2, src3, src4, src5, src6, src7; + __m256i src8, src9, src10, src11, src12, src13, src14, src15; + __m256i filter0, filter1, filter2, filter3; + __m256i vmax = __lasx_xvreplgr2vr_w(max); + __m256i shuf = {0x0000000400000000, 0x0000000500000001, + 0x0000000600000002, 0x0000000700000003}; + int len = dstW >> 4; + int res = dstW & 15; + while (len--) { + SCALE_4_16(7); + } + if (res & 8) { + SCALE_4_8(7); + src0 = __lasx_xvpickev_h(src1, src0); + src0 = __lasx_xvperm_w(src0, shuf); + __lasx_xvstelm_d(src0, dst, 0, 0); + __lasx_xvstelm_d(src0, dst, 8, 1); + dst += 8; + } + if (res & 4) { + SCALE_4_4(7); + src0 = __lasx_xvpickev_h(src0, src0); + __lasx_xvstelm_d(src0, dst, 0, 0); + dst += 4; + } + if (res & 2) { + SCALE_4_2(7); + } + if (res & 1) { + int val = 0; + const uint8_t *srcPos = src + filterPos[0]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[0] = FFMIN(val >> 7, max); + } + } else if (filterSize > 8) { + int filterlen = filterSize - 7; + int len = dstW >> 2; + int res = dstW & 3; + __m256i zero = __lasx_xvldi(0); + + while (len--) { + __m256i src0, src1, src2, src3; + __m256i filter0, filter1, filter2, filter3, out0, out1; + __m256i out = zero; + const uint8_t *srcPos1 = src + filterPos[0]; + const uint8_t *srcPos2 = src + filterPos[1]; + const uint8_t *srcPos3 = src + filterPos[2]; + const uint8_t *srcPos4 = src + filterPos[3]; + const int16_t *filterStart1 = filter; + const int16_t *filterStart2 = filterStart1 + filterSize; + const int16_t *filterStart3 = filterStart2 + filterSize; + const int16_t *filterStart4 = filterStart3 + filterSize; + int j, val1 = 0, val2 = 0, val3 = 0, val4 = 0; + + for (j = 0; j < filterlen; j += 8) { + SCALE_16 + } + val1 = __lasx_xvpickve2gr_w(out, 0); + val2 = __lasx_xvpickve2gr_w(out, 4); + val3 = __lasx_xvpickve2gr_w(out, 2); + val4 = __lasx_xvpickve2gr_w(out, 6); + for (; j < filterSize; j++) { + val1 += ((int)srcPos1[j]) * filterStart1[j]; + val2 += ((int)srcPos2[j]) * filterStart2[j]; + val3 += ((int)srcPos3[j]) * filterStart3[j]; + val4 += ((int)srcPos4[j]) * filterStart4[j]; + } + dst[0] = FFMIN(val1 >> 7, max); + dst[1] = FFMIN(val2 >> 7, max); + dst[2] = FFMIN(val3 >> 7, max); + dst[3] = FFMIN(val4 >> 7, max); + dst += 4; + filterPos += 4; + filter = filterStart4 + filterSize; + } + for(i = 0; i < res; i++) { + int j, val = 0; + const uint8_t *srcPos = src + filterPos[i]; + __m256i src1, filter0, out0; + + for (j = 0; j < filterlen; j += 8) { + src1 = __lasx_xvldrepl_d((srcPos + j), 0); + filter0 = __lasx_xvld(filter + j, 0); + src1 = __lasx_xvilvl_b(zero, src1); + out0 = __lasx_xvdp2_w_h(filter0, src1); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val += __lasx_xvpickve2gr_w(out0, 0); + } + for (; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> 7, max); + filter += filterSize; + } + } else { + for (i = 0; i < dstW; i++) { + int val = 0; + const uint8_t *srcPos = src + filterPos[i]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> 7, max); + filter += filterSize; + } + } +} + +void ff_hscale_8_to_19_lasx(SwsContext *c, int16_t *_dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize) +{ + int i; + int max = (1 << 19) - 1; + int32_t *dst = (int32_t *) _dst; + + if (filterSize == 8) { + __m256i src0, src1, src2, src3, src4, src5, src6, src7; + __m256i filter0, filter1, filter2, filter3; + __m256i vmax = __lasx_xvreplgr2vr_w(max); + __m256i shuf = {0x0000000400000000, 0x0000000500000001, + 0x0000000600000002, 0x0000000700000003}; + int len = dstW >> 3; + int res = dstW & 7; + while (len--) { + SCALE_8_8(3); + __lasx_xvst(src0, dst, 0); + dst += 8; + } + if (res & 4) { + SCALE_8_4(3); + __lasx_xvstelm_d(src0, dst, 0, 0); + __lasx_xvstelm_d(src0, dst, 8, 1); + dst += 4; + } + if (res & 2) { + SCALE_8_2(3); + } + if (res & 1) { + int val = 0; + __m256i src0, filter0, out0; + + src0 = __lasx_xvldrepl_d(src + filterPos[0], 0); + filter0 = __lasx_xvld(filter, 0); + src0 = __lasx_vext2xv_hu_bu(src0); + out0 = __lasx_xvdp2_w_h(filter0, src0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val = __lasx_xvpickve2gr_w(out0, 0); + dst[0] = FFMIN(val >> 3, max); + } + } else if (filterSize == 4) { + __m256i src0, src1, src2, src3, src4, src5, src6, src7; + __m256i filter0, filter1; + __m256i vmax = __lasx_xvreplgr2vr_w(max); + __m256i shuf = {0x0000000100000000, 0x0000000500000004, + 0x0000000300000002, 0x0000000700000006}; + int len = dstW >> 3; + int res = dstW & 7; + while (len--) { + SCALE_4_8(3); + src0 = __lasx_xvperm_w(src0, shuf); + __lasx_xvst(src0, dst, 0); + dst += 8; + } + if (res & 4) { + SCALE_4_4(3); + __lasx_xvstelm_d(src0, dst, 0, 0); + __lasx_xvstelm_d(src0, dst, 8, 1); + dst += 4; + } + if (res & 2) { + SCALE_4_2(3); + } + if (res & 1) { + int val = 0; + const uint8_t *srcPos = src + filterPos[0]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[0] = FFMIN(val >> 3, max); + } + } else if (filterSize > 8) { + int len = dstW >> 2; + int res = dstW & 3; + int filterlen = filterSize - 7; + __m256i zero = __lasx_xvldi(0); + + while (len--) { + __m256i src0, src1, src2, src3; + __m256i filter0, filter1, filter2, filter3, out0, out1; + __m256i out = zero; + const uint8_t *srcPos1 = src + filterPos[0]; + const uint8_t *srcPos2 = src + filterPos[1]; + const uint8_t *srcPos3 = src + filterPos[2]; + const uint8_t *srcPos4 = src + filterPos[3]; + const int16_t *filterStart1 = filter; + const int16_t *filterStart2 = filterStart1 + filterSize; + const int16_t *filterStart3 = filterStart2 + filterSize; + const int16_t *filterStart4 = filterStart3 + filterSize; + int j, val1 = 0, val2 = 0, val3 = 0, val4 = 0; + + for (j = 0; j < filterlen; j += 8) { + SCALE_16 + } + val1 = __lasx_xvpickve2gr_w(out, 0); + val2 = __lasx_xvpickve2gr_w(out, 4); + val3 = __lasx_xvpickve2gr_w(out, 2); + val4 = __lasx_xvpickve2gr_w(out, 6); + for (; j < filterSize; j++) { + val1 += ((int)srcPos1[j]) * filterStart1[j]; + val2 += ((int)srcPos2[j]) * filterStart2[j]; + val3 += ((int)srcPos3[j]) * filterStart3[j]; + val4 += ((int)srcPos4[j]) * filterStart4[j]; + } + dst[0] = FFMIN(val1 >> 3, max); + dst[1] = FFMIN(val2 >> 3, max); + dst[2] = FFMIN(val3 >> 3, max); + dst[3] = FFMIN(val4 >> 3, max); + dst += 4; + filterPos += 4; + filter = filterStart4 + filterSize; + } + for (i = 0; i < res; i++) { + int j, val = 0; + const uint8_t *srcPos = src + filterPos[i]; + __m256i src1, filter0, out0; + + for (j = 0; j < filterlen; j += 8) { + src1 = __lasx_xvldrepl_d((srcPos + j), 0); + filter0 = __lasx_xvld(filter + j, 0); + src1 = __lasx_xvilvl_b(zero, src1); + out0 = __lasx_xvdp2_w_h(filter0, src1); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val += __lasx_xvpickve2gr_w(out0, 0); + } + for (; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> 3, max); + filter += filterSize; + } + } else { + for (i = 0; i < dstW; i++) { + int val = 0; + const uint8_t *srcPos = src + filterPos[i]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> 3, max); + filter += filterSize; + } + } +} + +#undef SCALE_16 + +#define SCALE_8 \ +{ \ + __m256i src0, src1, src2, src3, filter0, filter1, out0, out1; \ + DUP4_ARG2(__lasx_xvld, src + filterPos[0], 0, src + filterPos[1], 0, \ + src + filterPos[2], 0, src + filterPos[3], 0, src0, src1, src2,\ + src3); \ + filter0 = __lasx_xvld(filter, 0); \ + filter1 = __lasx_xvld(filter, 32); \ + src0 = __lasx_xvpermi_q(src0, src1, 0x02); \ + src2 = __lasx_xvpermi_q(src2, src3, 0x02); \ + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); \ + out1 = __lasx_xvdp2_w_hu_h(src2, filter1); \ + src0 = __lasx_xvhaddw_d_w(out0, out0); \ + src1 = __lasx_xvhaddw_d_w(out1, out1); \ + out0 = __lasx_xvpackev_d(src1, src0); \ + out1 = __lasx_xvpackod_d(src1, src0); \ + out0 = __lasx_xvadd_w(out0, out1); \ + out0 = __lasx_xvsra_w(out0, shift); \ + out0 = __lasx_xvmin_w(out0, v_max); \ + dst[0] = __lasx_xvpickve2gr_w(out0, 0); \ + dst[1] = __lasx_xvpickve2gr_w(out0, 4); \ + dst[2] = __lasx_xvpickve2gr_w(out0, 2); \ + dst[3] = __lasx_xvpickve2gr_w(out0, 6); \ + filterPos += 4; \ + filter += 32; \ + dst += 4; \ +} + +#define SCALE_16 \ +{ \ + int dex = j << 1; \ + DUP4_ARG2(__lasx_xvldx, srcPos1, dex, srcPos2, dex, srcPos3, dex, \ + srcPos4, dex, src0, src1, src2, src3); \ + DUP4_ARG2(__lasx_xvldx, filterStart1, dex, filterStart2, dex, \ + filterStart3, dex, filterStart4, dex, filter0, \ + filter1, filter2, filter3); \ + src0 = __lasx_xvpermi_q(src0, src1, 0x02); \ + src1 = __lasx_xvpermi_q(src2, src3, 0x02); \ + filter0 = __lasx_xvpermi_q(filter0, filter1, 0x02); \ + filter1 = __lasx_xvpermi_q(filter2, filter3, 0x02); \ + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); \ + out1 = __lasx_xvdp2_w_hu_h(src1, filter1); \ + src0 = __lasx_xvhaddw_d_w(out0, out0); \ + src1 = __lasx_xvhaddw_d_w(out1, out1); \ + out0 = __lasx_xvpackev_d(src1, src0); \ + out1 = __lasx_xvpackod_d(src1, src0); \ + out0 = __lasx_xvadd_w(out0, out1); \ + out = __lasx_xvadd_w(out, out0); \ +} + +void ff_hscale_16_to_15_lasx(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *_src, const int16_t *filter, + const int32_t *filterPos, int filterSize) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat); + int i; + const uint16_t *src = (const uint16_t *) _src; + int sh = desc->comp[0].depth - 1; + int max = (1 << 15) - 1; + int len = dstW >> 2; + int res = dstW & 3; + __m256i shift; + __m256i zero = __lasx_xvldi(0); + + if (sh < 15) { + sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : + (desc->comp[0].depth - 1); + } else if (desc->flags && AV_PIX_FMT_FLAG_FLOAT) { + sh = 15; + } + shift = __lasx_xvreplgr2vr_w(sh); + + if (filterSize == 8) { + __m256i v_max = __lasx_xvreplgr2vr_w(max); + for (i = 0; i < len; i++) { + SCALE_8 + } + for (i = 0; i < res; i++) { + int val = 0; + __m256i src0, filter0, out0; + + src0 = __lasx_xvld(src + filterPos[i], 0); + filter0 = __lasx_xvld(filter, 0); + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val = __lasx_xvpickve2gr_w(out0, 0); + dst[i] = FFMIN(val >> sh, max); + filter += 8; + } + } else if (filterSize == 4) { + __m256i v_max = __lasx_xvreplgr2vr_w(max); + for (i = 0; i < len; i++) { + __m256i src1, src2, src3, src4, src0, filter0, out0; + + src1 = __lasx_xvldrepl_d(src + filterPos[0], 0); + src2 = __lasx_xvldrepl_d(src + filterPos[1], 0); + src3 = __lasx_xvldrepl_d(src + filterPos[2], 0); + src4 = __lasx_xvldrepl_d(src + filterPos[3], 0); + filter0 = __lasx_xvld(filter, 0); + src1 = __lasx_xvextrins_d(src1, src2, 0x10); + src3 = __lasx_xvextrins_d(src3, src4, 0x10); + src0 = __lasx_xvpermi_q(src1, src3, 0x02); + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvsra_w(out0, shift); + out0 = __lasx_xvmin_w(out0, v_max); + dst[0] = __lasx_xvpickve2gr_w(out0, 0); + dst[1] = __lasx_xvpickve2gr_w(out0, 2); + dst[2] = __lasx_xvpickve2gr_w(out0, 4); + dst[3] = __lasx_xvpickve2gr_w(out0, 6); + dst += 4; + filterPos += 4; + filter += 16; + } + for (i = 0; i < res; i++) { + int val = 0; + const uint16_t *srcPos = src + filterPos[i]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> sh, max); + filter += 4; + } + } else if (filterSize > 8) { + int filterlen = filterSize - 7; + + for (i = 0; i < len; i++) { + __m256i src0, src1, src2, src3; + __m256i filter0, filter1, filter2, filter3, out0, out1; + __m256i out = zero; + const uint16_t *srcPos1 = src + filterPos[0]; + const uint16_t *srcPos2 = src + filterPos[1]; + const uint16_t *srcPos3 = src + filterPos[2]; + const uint16_t *srcPos4 = src + filterPos[3]; + const int16_t *filterStart1 = filter; + const int16_t *filterStart2 = filterStart1 + filterSize; + const int16_t *filterStart3 = filterStart2 + filterSize; + const int16_t *filterStart4 = filterStart3 + filterSize; + int j, val1 = 0, val2 = 0, val3 = 0, val4 = 0; + + for (j = 0; j < filterlen; j += 8) { + SCALE_16 + } + val1 = __lasx_xvpickve2gr_w(out, 0); + val2 = __lasx_xvpickve2gr_w(out, 4); + val3 = __lasx_xvpickve2gr_w(out, 2); + val4 = __lasx_xvpickve2gr_w(out, 6); + for (; j < filterSize; j++) { + val1 += ((int)srcPos1[j]) * filterStart1[j]; + val2 += ((int)srcPos2[j]) * filterStart2[j]; + val3 += ((int)srcPos3[j]) * filterStart3[j]; + val4 += ((int)srcPos4[j]) * filterStart4[j]; + } + dst[0] = FFMIN(val1 >> sh, max); + dst[1] = FFMIN(val2 >> sh, max); + dst[2] = FFMIN(val3 >> sh, max); + dst[3] = FFMIN(val4 >> sh, max); + dst += 4; + filterPos += 4; + filter = filterStart4 + filterSize; + } + for (i = 0; i < res; i++) { + int j, val = 0; + const uint16_t *srcPos = src + filterPos[i]; + __m256i src0, filter0, out0; + + for (j = 0; j < filterlen; j += 8) { + int dex = j << 1; + src0 = __lasx_xvldx(srcPos, dex); + filter0 = __lasx_xvldx(filter, dex); + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val += __lasx_xvpickve2gr_w(out0, 0); + } + for (; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> sh, max); + filter += filterSize; + } + } else { + for (i = 0; i < dstW; i++) { + int val = 0; + const uint16_t *srcPos = src + filterPos[i]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> sh, max); + filter += filterSize; + } + } +} + +void ff_hscale_16_to_19_lasx(SwsContext *c, int16_t *_dst, int dstW, + const uint8_t *_src, const int16_t *filter, + const int32_t *filterPos, int filterSize) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat); + int i; + int32_t *dst = (int32_t *) _dst; + const uint16_t *src = (const uint16_t *) _src; + int sh = desc->comp[0].depth - 5; + int max = (1 << 19) - 1; + int len = dstW >> 2; + int res = dstW & 3; + __m256i shift; + __m256i zero = __lasx_xvldi(0); + + if ((isAnyRGB(c->srcFormat) || c->srcFormat == AV_PIX_FMT_PAL8) + && desc->comp[0].depth<16) { + sh = 9; + } else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { + sh = 11; + } + shift = __lasx_xvreplgr2vr_w(sh); + + if (filterSize == 8) { + __m256i v_max = __lasx_xvreplgr2vr_w(max); + for (i = 0; i < len; i++) { + SCALE_8 + } + for (i = 0; i < res; i++) { + int val = 0; + __m256i src0, filter0, out0; + + src0 = __lasx_xvld(src + filterPos[i], 0); + filter0 = __lasx_xvld(filter, 0); + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val = __lasx_xvpickve2gr_w(out0, 0); + dst[i] = FFMIN(val >> sh, max); + filter += 8; + } + } else if (filterSize == 4) { + __m256i v_max = __lasx_xvreplgr2vr_w(max); + for (i = 0; i < len; i++) { + __m256i src1, src2, src3, src4, src0, filter0, out0; + + src1 = __lasx_xvldrepl_d(src + filterPos[0], 0); + src2 = __lasx_xvldrepl_d(src + filterPos[1], 0); + src3 = __lasx_xvldrepl_d(src + filterPos[2], 0); + src4 = __lasx_xvldrepl_d(src + filterPos[3], 0); + filter0 = __lasx_xvld(filter, 0); + src1 = __lasx_xvextrins_d(src1, src2, 0x10); + src3 = __lasx_xvextrins_d(src3, src4, 0x10); + src0 = __lasx_xvpermi_q(src1, src3, 0x02); + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvsra_w(out0, shift); + out0 = __lasx_xvmin_w(out0, v_max); + dst[0] = __lasx_xvpickve2gr_w(out0, 0); + dst[1] = __lasx_xvpickve2gr_w(out0, 2); + dst[2] = __lasx_xvpickve2gr_w(out0, 4); + dst[3] = __lasx_xvpickve2gr_w(out0, 6); + dst += 4; + filterPos += 4; + filter += 16; + } + for (i = 0; i < res; i++) { + int val = 0; + const uint16_t *srcPos = src + filterPos[i]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> sh, max); + filter += 4; + } + } else if (filterSize > 8) { + int filterlen = filterSize - 7; + + for (i = 0; i < len; i ++) { + __m256i src0, src1, src2, src3; + __m256i filter0, filter1, filter2, filter3, out0, out1; + __m256i out = zero; + const uint16_t *srcPos1 = src + filterPos[0]; + const uint16_t *srcPos2 = src + filterPos[1]; + const uint16_t *srcPos3 = src + filterPos[2]; + const uint16_t *srcPos4 = src + filterPos[3]; + const int16_t *filterStart1 = filter; + const int16_t *filterStart2 = filterStart1 + filterSize; + const int16_t *filterStart3 = filterStart2 + filterSize; + const int16_t *filterStart4 = filterStart3 + filterSize; + int j, val1 = 0, val2 = 0, val3 = 0, val4 = 0; + + for (j = 0; j < filterlen; j += 8) { + SCALE_16 + } + val1 = __lasx_xvpickve2gr_w(out, 0); + val2 = __lasx_xvpickve2gr_w(out, 4); + val3 = __lasx_xvpickve2gr_w(out, 2); + val4 = __lasx_xvpickve2gr_w(out, 6); + for (; j < filterSize; j++) { + val1 += ((int)srcPos1[j]) * filterStart1[j]; + val2 += ((int)srcPos2[j]) * filterStart2[j]; + val3 += ((int)srcPos3[j]) * filterStart3[j]; + val4 += ((int)srcPos4[j]) * filterStart4[j]; + } + dst[0] = FFMIN(val1 >> sh, max); + dst[1] = FFMIN(val2 >> sh, max); + dst[2] = FFMIN(val3 >> sh, max); + dst[3] = FFMIN(val4 >> sh, max); + dst += 4; + filterPos += 4; + filter = filterStart4 + filterSize; + } + for (i = 0; i < res; i++) { + int j, val = 0; + const uint16_t *srcPos = src + filterPos[i]; + __m256i src0, filter0, out0; + + for (j = 0; j < filterlen; j += 8) { + int dex = j << 1; + src0 = __lasx_xvldx(srcPos, dex); + filter0 = __lasx_xvldx(filter, dex); + out0 = __lasx_xvdp2_w_hu_h(src0, filter0); + out0 = __lasx_xvhaddw_d_w(out0, out0); + out0 = __lasx_xvhaddw_q_d(out0, out0); + val += __lasx_xvpickve2gr_w(out0, 0); + } + for (; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> sh, max); + filter += filterSize; + } + } else { + for (i = 0; i < dstW; i++) { + int val = 0; + const uint16_t *srcPos = src + filterPos[i]; + + for (int j = 0; j < filterSize; j++) { + val += ((int)srcPos[j]) * filter[j]; + } + dst[i] = FFMIN(val >> sh, max); + filter += filterSize; + } + } +} + +#undef SCALE_8 +#undef SCALE_16 diff --git a/libswscale/loongarch/swscale_loongarch.h b/libswscale/loongarch/swscale_loongarch.h new file mode 100644 index 0000000000..790304a01c --- /dev/null +++ b/libswscale/loongarch/swscale_loongarch.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 SWSCALE_LOONGARCH_SWSCALE_LOONGARCH_H +#define SWSCALE_LOONGARCH_SWSCALE_LOONGARCH_H + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +void ff_hscale_8_to_15_lasx(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); + +void ff_hscale_8_to_19_lasx(SwsContext *c, int16_t *_dst, int dstW, + const uint8_t *src, const int16_t *filter, + const int32_t *filterPos, int filterSize); + +void ff_hscale_16_to_19_lasx(SwsContext *c, int16_t *_dst, int dstW, + const uint8_t *_src, const int16_t *filter, + const int32_t *filterPos, int filterSize); + +void ff_hscale_16_to_15_lasx(SwsContext *c, int16_t *dst, int dstW, + const uint8_t *_src, const int16_t *filter, + const int32_t *filterPos, int filterSize); + +void planar_rgb_to_uv_lasx(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], + int width, int32_t *rgb2yuv, void *opq); + +void planar_rgb_to_y_lasx(uint8_t *_dst, const uint8_t *src[4], int width, + int32_t *rgb2yuv, void *opq); + +#endif /* SWSCALE_LOONGARCH_SWSCALE_LOONGARCH_H */ diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 7b40f49da4..367d045a02 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -598,6 +598,8 @@ void ff_sws_init_scale(SwsContext *c) ff_sws_init_swscale_aarch64(c); #elif ARCH_ARM ff_sws_init_swscale_arm(c); +#elif ARCH_LOONGARCH64 + ff_sws_init_swscale_loongarch(c); #endif } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 6c14ce8536..abeebbb002 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -698,6 +698,7 @@ av_cold void ff_sws_init_range_convert(SwsContext *c); SwsFunc ff_yuv2rgb_init_x86(SwsContext *c); SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c); +SwsFunc ff_yuv2rgb_init_loongarch(SwsContext *c); static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt) { @@ -983,6 +984,7 @@ void ff_sws_init_swscale_vsx(SwsContext *c); void ff_sws_init_swscale_x86(SwsContext *c); void ff_sws_init_swscale_aarch64(SwsContext *c); void ff_sws_init_swscale_arm(SwsContext *c); +void ff_sws_init_swscale_loongarch(SwsContext *c); void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc); diff --git a/libswscale/utils.c b/libswscale/utils.c index 14e2700733..45baa22b23 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -53,6 +53,7 @@ #include "libavutil/ppc/cpu.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" +#include "libavutil/loongarch/cpu.h" #include "rgb2rgb.h" #include "swscale.h" @@ -659,6 +660,15 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos, filterAlign = 1; } + if (have_lasx(cpu_flags)) { + int reNum = minFilterSize & (0x07); + + if (minFilterSize < 5) + filterAlign = 4; + if (reNum < 3) + filterAlign = 1; + } + av_assert0(minFilterSize > 0); filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1)); av_assert0(filterSize > 0); @@ -1844,7 +1854,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, { const int filterAlign = X86_MMX(cpu_flags) ? 4 : PPC_ALTIVEC(cpu_flags) ? 8 : - have_neon(cpu_flags) ? 4 : 1; + have_neon(cpu_flags) ? 4 : + have_lasx(cpu_flags) ? 8 : 1; if ((ret = initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc, From 74d09b068dad88b037f6d0be4b0594eb2e2759e9 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Fri, 9 Sep 2022 17:00:25 +0800 Subject: [PATCH 230/590] swscale/la: Add yuv2rgb_lasx.c and rgb2rgb_lasx.c files ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -pix_fmt rgb24 -y /dev/null -an before: 178fps after: 210fps Signed-off-by: Hao Chen Reviewed-by: yinshiyou-hf@loongson.cn Signed-off-by: Michael Niedermayer --- libswscale/loongarch/Makefile | 2 + libswscale/loongarch/rgb2rgb_lasx.c | 52 +++ libswscale/loongarch/swscale_init_loongarch.c | 42 +++ libswscale/loongarch/swscale_loongarch.h | 22 ++ libswscale/loongarch/yuv2rgb_lasx.c | 321 ++++++++++++++++++ libswscale/rgb2rgb.c | 2 + libswscale/rgb2rgb.h | 1 + libswscale/yuv2rgb.c | 2 + 8 files changed, 444 insertions(+) create mode 100644 libswscale/loongarch/rgb2rgb_lasx.c create mode 100644 libswscale/loongarch/yuv2rgb_lasx.c diff --git a/libswscale/loongarch/Makefile b/libswscale/loongarch/Makefile index 586a1717b6..4345971514 100644 --- a/libswscale/loongarch/Makefile +++ b/libswscale/loongarch/Makefile @@ -1,3 +1,5 @@ OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_init_loongarch.o LASX-OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_lasx.o \ loongarch/input_lasx.o \ + loongarch/yuv2rgb_lasx.o \ + loongarch/rgb2rgb_lasx.o diff --git a/libswscale/loongarch/rgb2rgb_lasx.c b/libswscale/loongarch/rgb2rgb_lasx.c new file mode 100644 index 0000000000..1b6be90217 --- /dev/null +++ b/libswscale/loongarch/rgb2rgb_lasx.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 "swscale_loongarch.h" +#include "libavutil/loongarch/loongson_intrinsics.h" + +void ff_interleave_bytes_lasx(const uint8_t *src1, const uint8_t *src2, + uint8_t *dest, int width, int height, + int src1Stride, int src2Stride, int dstStride) +{ + int h; + int len = width & (0xFFFFFFF0); + + for (h = 0; h < height; h++) { + int w, index = 0; + __m256i src_1, src_2, dst; + + for (w = 0; w < len; w += 16) { + DUP2_ARG2(__lasx_xvld, src1 + w, 0, src2 + w, 0, src_1, src_2); + src_1 = __lasx_xvpermi_d(src_1, 0xD8); + src_2 = __lasx_xvpermi_d(src_2, 0xD8); + dst = __lasx_xvilvl_b(src_2, src_1); + __lasx_xvst(dst, dest + index, 0); + index += 32; + } + for (; w < width; w++) { + dest[(w << 1) + 0] = src1[w]; + dest[(w << 1) + 1] = src2[w]; + } + dest += dstStride; + src1 += src1Stride; + src2 += src2Stride; + } +} diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 197dc6e1e7..1e0bb1b116 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -21,6 +21,7 @@ #include "swscale_loongarch.h" #include "libswscale/swscale_internal.h" +#include "libswscale/rgb2rgb.h" #include "libavutil/loongarch/cpu.h" av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) @@ -48,3 +49,44 @@ av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) } } } + +av_cold void rgb2rgb_init_loongarch(void) +{ + int cpu_flags = av_get_cpu_flags(); + if (have_lasx(cpu_flags)) + interleaveBytes = ff_interleave_bytes_lasx; +} + +av_cold SwsFunc ff_yuv2rgb_init_loongarch(SwsContext *c) +{ + int cpu_flags = av_get_cpu_flags(); + if (have_lasx(cpu_flags)) { + switch (c->dstFormat) { + case AV_PIX_FMT_RGB24: + return yuv420_rgb24_lasx; + case AV_PIX_FMT_BGR24: + return yuv420_bgr24_lasx; + case AV_PIX_FMT_RGBA: + if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { + break; + } else + return yuv420_rgba32_lasx; + case AV_PIX_FMT_ARGB: + if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { + break; + } else + return yuv420_argb32_lasx; + case AV_PIX_FMT_BGRA: + if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { + break; + } else + return yuv420_bgra32_lasx; + case AV_PIX_FMT_ABGR: + if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) { + break; + } else + return yuv420_abgr32_lasx; + } + } + return NULL; +} diff --git a/libswscale/loongarch/swscale_loongarch.h b/libswscale/loongarch/swscale_loongarch.h index 790304a01c..f5afbd7633 100644 --- a/libswscale/loongarch/swscale_loongarch.h +++ b/libswscale/loongarch/swscale_loongarch.h @@ -47,4 +47,26 @@ void planar_rgb_to_uv_lasx(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4] void planar_rgb_to_y_lasx(uint8_t *_dst, const uint8_t *src[4], int width, int32_t *rgb2yuv, void *opq); +int yuv420_rgb24_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], + int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); + +int yuv420_bgr24_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], + int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); + +int yuv420_rgba32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], + int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); + +int yuv420_bgra32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], + int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); + +int yuv420_argb32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], + int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); + +int yuv420_abgr32_lasx(SwsContext *c, const uint8_t *src[], int srcStride[], + int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); + +void ff_interleave_bytes_lasx(const uint8_t *src1, const uint8_t *src2, + uint8_t *dest, int width, int height, + int src1Stride, int src2Stride, int dstStride); + #endif /* SWSCALE_LOONGARCH_SWSCALE_LOONGARCH_H */ diff --git a/libswscale/loongarch/yuv2rgb_lasx.c b/libswscale/loongarch/yuv2rgb_lasx.c new file mode 100644 index 0000000000..64e434f50c --- /dev/null +++ b/libswscale/loongarch/yuv2rgb_lasx.c @@ -0,0 +1,321 @@ +/* + * Copyright (C) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 "swscale_loongarch.h" +#include "libavutil/loongarch/loongson_intrinsics.h" + +#define YUV2RGB_LOAD_COE \ + /* Load x_offset */ \ + __m256i y_offset = __lasx_xvreplgr2vr_d(c->yOffset); \ + __m256i u_offset = __lasx_xvreplgr2vr_d(c->uOffset); \ + __m256i v_offset = __lasx_xvreplgr2vr_d(c->vOffset); \ + /* Load x_coeff */ \ + __m256i ug_coeff = __lasx_xvreplgr2vr_d(c->ugCoeff); \ + __m256i vg_coeff = __lasx_xvreplgr2vr_d(c->vgCoeff); \ + __m256i y_coeff = __lasx_xvreplgr2vr_d(c->yCoeff); \ + __m256i ub_coeff = __lasx_xvreplgr2vr_d(c->ubCoeff); \ + __m256i vr_coeff = __lasx_xvreplgr2vr_d(c->vrCoeff); \ + +#define LOAD_YUV_16 \ + m_y1 = __lasx_xvld(py_1, 0); \ + m_y2 = __lasx_xvld(py_2, 0); \ + m_u = __lasx_xvldrepl_d(pu, 0); \ + m_v = __lasx_xvldrepl_d(pv, 0); \ + m_u = __lasx_xvilvl_b(m_u, m_u); \ + m_v = __lasx_xvilvl_b(m_v, m_v); \ + DUP4_ARG1(__lasx_vext2xv_hu_bu, m_y1, m_y2, m_u, m_v, \ + m_y1, m_y2, m_u, m_v); \ + +/* YUV2RGB method + * The conversion method is as follows: + * R = Y' * y_coeff + V' * vr_coeff + * G = Y' * y_coeff + V' * vg_coeff + U' * ug_coeff + * B = Y' * y_coeff + U' * ub_coeff + * + * where X' = X * 8 - x_offset + * + */ + +#define YUV2RGB \ + m_y1 = __lasx_xvslli_h(m_y1, 3); \ + m_y2 = __lasx_xvslli_h(m_y2, 3); \ + m_u = __lasx_xvslli_h(m_u, 3); \ + m_v = __lasx_xvslli_h(m_v, 3); \ + m_y1 = __lasx_xvsub_h(m_y1, y_offset); \ + m_y2 = __lasx_xvsub_h(m_y2, y_offset); \ + m_u = __lasx_xvsub_h(m_u, u_offset); \ + m_v = __lasx_xvsub_h(m_v, v_offset); \ + y_1 = __lasx_xvmuh_h(m_y1, y_coeff); \ + y_2 = __lasx_xvmuh_h(m_y2, y_coeff); \ + u2g = __lasx_xvmuh_h(m_u, ug_coeff); \ + u2b = __lasx_xvmuh_h(m_u, ub_coeff); \ + v2r = __lasx_xvmuh_h(m_v, vr_coeff); \ + v2g = __lasx_xvmuh_h(m_v, vg_coeff); \ + r1 = __lasx_xvsadd_h(y_1, v2r); \ + v2g = __lasx_xvsadd_h(v2g, u2g); \ + g1 = __lasx_xvsadd_h(y_1, v2g); \ + b1 = __lasx_xvsadd_h(y_1, u2b); \ + r2 = __lasx_xvsadd_h(y_2, v2r); \ + g2 = __lasx_xvsadd_h(y_2, v2g); \ + b2 = __lasx_xvsadd_h(y_2, u2b); \ + DUP4_ARG1(__lasx_xvclip255_h, r1, g1, b1, r2, r1, g1, b1, r2); \ + DUP2_ARG1(__lasx_xvclip255_h, g2, b2, g2, b2); \ + +#define YUV2RGB_RES \ + m_y1 = __lasx_xvldrepl_d(py_1, 0); \ + m_y2 = __lasx_xvldrepl_d(py_2, 0); \ + m_u = __lasx_xvldrepl_d(pu, 0); \ + m_v = __lasx_xvldrepl_d(pv, 0); \ + m_y1 = __lasx_xvilvl_d(m_y2, m_y1); \ + m_u = __lasx_xvilvl_b(m_u, m_u); \ + m_v = __lasx_xvilvl_b(m_v, m_v); \ + m_y1 = __lasx_vext2xv_hu_bu(m_y1); \ + m_u = __lasx_vext2xv_hu_bu(m_u); \ + m_v = __lasx_vext2xv_hu_bu(m_v); \ + m_y1 = __lasx_xvslli_h(m_y1, 3); \ + m_u = __lasx_xvslli_h(m_u, 3); \ + m_v = __lasx_xvslli_h(m_v, 3); \ + m_y1 = __lasx_xvsub_h(m_y1, y_offset); \ + m_u = __lasx_xvsub_h(m_u, u_offset); \ + m_v = __lasx_xvsub_h(m_v, v_offset); \ + y_1 = __lasx_xvmuh_h(m_y1, y_coeff); \ + u2g = __lasx_xvmuh_h(m_u, ug_coeff); \ + u2b = __lasx_xvmuh_h(m_u, ub_coeff); \ + v2r = __lasx_xvmuh_h(m_v, vr_coeff); \ + v2g = __lasx_xvmuh_h(m_v, vg_coeff); \ + r1 = __lasx_xvsadd_h(y_1, v2r); \ + v2g = __lasx_xvsadd_h(v2g, u2g); \ + g1 = __lasx_xvsadd_h(y_1, v2g); \ + b1 = __lasx_xvsadd_h(y_1, u2b); \ + r1 = __lasx_xvclip255_h(r1); \ + g1 = __lasx_xvclip255_h(g1); \ + b1 = __lasx_xvclip255_h(b1); \ + +#define RGB_PACK(r, g, b, rgb_l, rgb_h) \ +{ \ + __m256i rg; \ + rg = __lasx_xvpackev_b(g, r); \ + DUP2_ARG3(__lasx_xvshuf_b, b, rg, shuf2, b, rg, shuf3, rgb_l, rgb_h); \ +} + +#define RGB32_PACK(a, r, g, b, rgb_l, rgb_h) \ +{ \ + __m256i ra, bg, tmp0, tmp1; \ + ra = __lasx_xvpackev_b(r, a); \ + bg = __lasx_xvpackev_b(b, g); \ + tmp0 = __lasx_xvilvl_h(bg, ra); \ + tmp1 = __lasx_xvilvh_h(bg, ra); \ + rgb_l = __lasx_xvpermi_q(tmp1, tmp0, 0x20); \ + rgb_h = __lasx_xvpermi_q(tmp1, tmp0, 0x31); \ +} + +#define RGB_STORE_RES(rgb_l, rgb_h, image_1, image_2) \ +{ \ + __lasx_xvstelm_d(rgb_l, image_1, 0, 0); \ + __lasx_xvstelm_d(rgb_l, image_1, 8, 1); \ + __lasx_xvstelm_d(rgb_h, image_1, 16, 0); \ + __lasx_xvstelm_d(rgb_l, image_2, 0, 2); \ + __lasx_xvstelm_d(rgb_l, image_2, 8, 3); \ + __lasx_xvstelm_d(rgb_h, image_2, 16, 2); \ +} + +#define RGB_STORE(rgb_l, rgb_h, image) \ +{ \ + __lasx_xvstelm_d(rgb_l, image, 0, 0); \ + __lasx_xvstelm_d(rgb_l, image, 8, 1); \ + __lasx_xvstelm_d(rgb_h, image, 16, 0); \ + __lasx_xvstelm_d(rgb_l, image, 24, 2); \ + __lasx_xvstelm_d(rgb_l, image, 32, 3); \ + __lasx_xvstelm_d(rgb_h, image, 40, 2); \ +} + +#define RGB32_STORE(rgb_l, rgb_h, image) \ +{ \ + __lasx_xvst(rgb_l, image, 0); \ + __lasx_xvst(rgb_h, image, 32); \ +} + +#define RGB32_STORE_RES(rgb_l, rgb_h, image_1, image_2) \ +{ \ + __lasx_xvst(rgb_l, image_1, 0); \ + __lasx_xvst(rgb_h, image_2, 0); \ +} + +#define YUV2RGBFUNC(func_name, dst_type, alpha) \ + int func_name(SwsContext *c, const uint8_t *src[], \ + int srcStride[], int srcSliceY, int srcSliceH, \ + uint8_t *dst[], int dstStride[]) \ +{ \ + int x, y, h_size, vshift, res; \ + __m256i m_y1, m_y2, m_u, m_v; \ + __m256i y_1, y_2, u2g, v2g, u2b, v2r, rgb1_l, rgb1_h; \ + __m256i rgb2_l, rgb2_h, r1, g1, b1, r2, g2, b2; \ + __m256i shuf2 = {0x0504120302100100, 0x0A18090816070614, \ + 0x0504120302100100, 0x0A18090816070614}; \ + __m256i shuf3 = {0x1E0F0E1C0D0C1A0B, 0x0101010101010101, \ + 0x1E0F0E1C0D0C1A0B, 0x0101010101010101}; \ + YUV2RGB_LOAD_COE \ + y = (c->dstW + 7) & ~7; \ + h_size = y >> 4; \ + res = y & 15; \ + \ + vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \ + for (y = 0; y < srcSliceH; y += 2) { \ + dst_type *image1 = (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]);\ + dst_type *image2 = (dst_type *)(image1 + dstStride[0]);\ + const uint8_t *py_1 = src[0] + y * srcStride[0]; \ + const uint8_t *py_2 = py_1 + srcStride[0]; \ + const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \ + const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \ + for(x = 0; x < h_size; x++) { \ + +#define YUV2RGBFUNC32(func_name, dst_type, alpha) \ + int func_name(SwsContext *c, const uint8_t *src[], \ + int srcStride[], int srcSliceY, int srcSliceH, \ + uint8_t *dst[], int dstStride[]) \ +{ \ + int x, y, h_size, vshift, res; \ + __m256i m_y1, m_y2, m_u, m_v; \ + __m256i y_1, y_2, u2g, v2g, u2b, v2r, rgb1_l, rgb1_h; \ + __m256i rgb2_l, rgb2_h, r1, g1, b1, r2, g2, b2; \ + __m256i a = __lasx_xvldi(0xFF); \ + \ + YUV2RGB_LOAD_COE \ + y = (c->dstW + 7) & ~7; \ + h_size = y >> 4; \ + res = y & 15; \ + \ + vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \ + for (y = 0; y < srcSliceH; y += 2) { \ + int yd = y + srcSliceY; \ + dst_type av_unused *r, *g, *b; \ + dst_type *image1 = (dst_type *)(dst[0] + (yd) * dstStride[0]); \ + dst_type *image2 = (dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \ + const uint8_t *py_1 = src[0] + y * srcStride[0]; \ + const uint8_t *py_2 = py_1 + srcStride[0]; \ + const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \ + const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \ + for(x = 0; x < h_size; x++) { \ + +#define DEALYUV2RGBREMAIN \ + py_1 += 16; \ + py_2 += 16; \ + pu += 8; \ + pv += 8; \ + image1 += 48; \ + image2 += 48; \ + } \ + if (res) { \ + +#define DEALYUV2RGBREMAIN32 \ + py_1 += 16; \ + py_2 += 16; \ + pu += 8; \ + pv += 8; \ + image1 += 16; \ + image2 += 16; \ + } \ + if (res) { \ + + +#define END_FUNC() \ + } \ + } \ + return srcSliceH; \ +} + +YUV2RGBFUNC(yuv420_rgb24_lasx, uint8_t, 0) + LOAD_YUV_16 + YUV2RGB + RGB_PACK(r1, g1, b1, rgb1_l, rgb1_h); + RGB_PACK(r2, g2, b2, rgb2_l, rgb2_h); + RGB_STORE(rgb1_l, rgb1_h, image1); + RGB_STORE(rgb2_l, rgb2_h, image2); + DEALYUV2RGBREMAIN + YUV2RGB_RES + RGB_PACK(r1, g1, b1, rgb1_l, rgb1_h); + RGB_STORE_RES(rgb1_l, rgb1_h, image1, image2); + END_FUNC() + +YUV2RGBFUNC(yuv420_bgr24_lasx, uint8_t, 0) + LOAD_YUV_16 + YUV2RGB + RGB_PACK(b1, g1, r1, rgb1_l, rgb1_h); + RGB_PACK(b2, g2, r2, rgb2_l, rgb2_h); + RGB_STORE(rgb1_l, rgb1_h, image1); + RGB_STORE(rgb2_l, rgb2_h, image2); + DEALYUV2RGBREMAIN + YUV2RGB_RES + RGB_PACK(b1, g1, r1, rgb1_l, rgb1_h); + RGB_STORE_RES(rgb1_l, rgb1_h, image1, image2); + END_FUNC() + +YUV2RGBFUNC32(yuv420_rgba32_lasx, uint32_t, 0) + LOAD_YUV_16 + YUV2RGB + RGB32_PACK(r1, g1, b1, a, rgb1_l, rgb1_h); + RGB32_PACK(r2, g2, b2, a, rgb2_l, rgb2_h); + RGB32_STORE(rgb1_l, rgb1_h, image1); + RGB32_STORE(rgb2_l, rgb2_h, image2); + DEALYUV2RGBREMAIN32 + YUV2RGB_RES + RGB32_PACK(r1, g1, b1, a, rgb1_l, rgb1_h); + RGB32_STORE_RES(rgb1_l, rgb1_h, image1, image2); + END_FUNC() + +YUV2RGBFUNC32(yuv420_bgra32_lasx, uint32_t, 0) + LOAD_YUV_16 + YUV2RGB + RGB32_PACK(b1, g1, r1, a, rgb1_l, rgb1_h); + RGB32_PACK(b2, g2, r2, a, rgb2_l, rgb2_h); + RGB32_STORE(rgb1_l, rgb1_h, image1); + RGB32_STORE(rgb2_l, rgb2_h, image2); + DEALYUV2RGBREMAIN32 + YUV2RGB_RES + RGB32_PACK(b1, g1, r1, a, rgb1_l, rgb1_h); + RGB32_STORE_RES(rgb1_l, rgb1_h, image1, image2); + END_FUNC() + +YUV2RGBFUNC32(yuv420_argb32_lasx, uint32_t, 0) + LOAD_YUV_16 + YUV2RGB + RGB32_PACK(a, r1, g1, b1, rgb1_l, rgb1_h); + RGB32_PACK(a, r2, g2, b2, rgb2_l, rgb2_h); + RGB32_STORE(rgb1_l, rgb1_h, image1); + RGB32_STORE(rgb2_l, rgb2_h, image2); + DEALYUV2RGBREMAIN32 + YUV2RGB_RES + RGB32_PACK(a, r1, g1, b1, rgb1_l, rgb1_h); + RGB32_STORE_RES(rgb1_l, rgb1_h, image1, image2); + END_FUNC() + +YUV2RGBFUNC32(yuv420_abgr32_lasx, uint32_t, 0) + LOAD_YUV_16 + YUV2RGB + RGB32_PACK(a, b1, g1, r1, rgb1_l, rgb1_h); + RGB32_PACK(a, b2, g2, r2, rgb2_l, rgb2_h); + RGB32_STORE(rgb1_l, rgb1_h, image1); + RGB32_STORE(rgb2_l, rgb2_h, image2); + DEALYUV2RGBREMAIN32 + YUV2RGB_RES + RGB32_PACK(a, b1, g1, r1, rgb1_l, rgb1_h); + RGB32_STORE_RES(rgb1_l, rgb1_h, image1, image2); + END_FUNC() diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 4f1ac9c465..3af775b389 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -141,6 +141,8 @@ av_cold void ff_sws_rgb2rgb_init(void) rgb2rgb_init_aarch64(); #elif ARCH_X86 rgb2rgb_init_x86(); +#elif ARCH_LOONGARCH64 + rgb2rgb_init_loongarch(); #endif } diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h index 7272e98c57..db85bfc42f 100644 --- a/libswscale/rgb2rgb.h +++ b/libswscale/rgb2rgb.h @@ -168,5 +168,6 @@ void ff_sws_rgb2rgb_init(void); void rgb2rgb_init_aarch64(void); void rgb2rgb_init_x86(void); +void rgb2rgb_init_loongarch(void); #endif /* SWSCALE_RGB2RGB_H */ diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 6ee483d12a..9c3f5e23c6 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -683,6 +683,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) t = ff_yuv2rgb_init_ppc(c); #elif ARCH_X86 t = ff_yuv2rgb_init_x86(c); +#elif ARCH_LOONGARCH64 + t = ff_yuv2rgb_init_loongarch(c); #endif if (t) From 925ac0da32697ef5853e90e0be56e106208099e2 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Fri, 9 Sep 2022 17:00:26 +0800 Subject: [PATCH 231/590] swscale/la: Add output_lasx.c file. ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -s 640x480 -pix_fmt rgb24 -y /dev/null -an before: 150fps after: 183fps Signed-off-by: Hao Chen Reviewed-by: yinshiyou-hf@loongson.cn Signed-off-by: Michael Niedermayer --- libswscale/loongarch/Makefile | 3 +- libswscale/loongarch/output_lasx.c | 1982 +++++++++++++++++ libswscale/loongarch/swscale_init_loongarch.c | 3 + libswscale/loongarch/swscale_loongarch.h | 6 + 4 files changed, 1993 insertions(+), 1 deletion(-) create mode 100644 libswscale/loongarch/output_lasx.c diff --git a/libswscale/loongarch/Makefile b/libswscale/loongarch/Makefile index 4345971514..8e665e826c 100644 --- a/libswscale/loongarch/Makefile +++ b/libswscale/loongarch/Makefile @@ -2,4 +2,5 @@ OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_init_loongarch.o LASX-OBJS-$(CONFIG_SWSCALE) += loongarch/swscale_lasx.o \ loongarch/input_lasx.o \ loongarch/yuv2rgb_lasx.o \ - loongarch/rgb2rgb_lasx.o + loongarch/rgb2rgb_lasx.o \ + loongarch/output_lasx.o diff --git a/libswscale/loongarch/output_lasx.c b/libswscale/loongarch/output_lasx.c new file mode 100644 index 0000000000..36a4c4503b --- /dev/null +++ b/libswscale/loongarch/output_lasx.c @@ -0,0 +1,1982 @@ +/* + * Copyright (C) 2022 Loongson Technology Corporation Limited + * Contributed by Hao Chen(chenhao@loongson.cn) + * + * 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 "swscale_loongarch.h" +#include "libavutil/loongarch/loongson_intrinsics.h" + +void ff_yuv2planeX_8_lasx(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + int i; + int len = dstW - 15; + __m256i mask = {0x1C0C180814041000, 0x1C1814100C080400, + 0x1C0C180814041000, 0x1C1814100C080400}; + __m256i val1, val2, val3; + uint8_t dither0 = dither[offset & 7]; + uint8_t dither1 = dither[(offset + 1) & 7]; + uint8_t dither2 = dither[(offset + 2) & 7]; + uint8_t dither3 = dither[(offset + 3) & 7]; + uint8_t dither4 = dither[(offset + 4) & 7]; + uint8_t dither5 = dither[(offset + 5) & 7]; + uint8_t dither6 = dither[(offset + 6) & 7]; + uint8_t dither7 = dither[(offset + 7) & 7]; + int val_1[8] = {dither0, dither2, dither4, dither6, + dither0, dither2, dither4, dither6}; + int val_2[8] = {dither1, dither3, dither5, dither7, + dither1, dither3, dither5, dither7}; + int val_3[8] = {dither0, dither1, dither2, dither3, + dither4, dither5, dither6, dither7}; + + DUP2_ARG2(__lasx_xvld, val_1, 0, val_2, 0, val1, val2); + val3 = __lasx_xvld(val_3, 0); + + for (i = 0; i < len; i += 16) { + int j; + __m256i src0, filter0, val; + __m256i val_ev, val_od; + + val_ev = __lasx_xvslli_w(val1, 12); + val_od = __lasx_xvslli_w(val2, 12); + + for (j = 0; j < filterSize; j++) { + src0 = __lasx_xvld(src[j]+ i, 0); + filter0 = __lasx_xvldrepl_h((filter + j), 0); + val_ev = __lasx_xvmaddwev_w_h(val_ev, src0, filter0); + val_od = __lasx_xvmaddwod_w_h(val_od, src0, filter0); + } + val_ev = __lasx_xvsrai_w(val_ev, 19); + val_od = __lasx_xvsrai_w(val_od, 19); + val_ev = __lasx_xvclip255_w(val_ev); + val_od = __lasx_xvclip255_w(val_od); + val = __lasx_xvshuf_b(val_od, val_ev, mask); + __lasx_xvstelm_d(val, (dest + i), 0, 0); + __lasx_xvstelm_d(val, (dest + i), 8, 2); + } + if (dstW - i >= 8){ + int j; + __m256i src0, filter0, val_h; + __m256i val_l; + + val_l = __lasx_xvslli_w(val3, 12); + + for (j = 0; j < filterSize; j++) { + src0 = __lasx_xvld(src[j] + i, 0); + src0 = __lasx_vext2xv_w_h(src0); + filter0 = __lasx_xvldrepl_h((filter + j), 0); + filter0 = __lasx_vext2xv_w_h(filter0); + val_l = __lasx_xvmadd_w(val_l, src0, filter0); + } + val_l = __lasx_xvsrai_w(val_l, 19); + val_l = __lasx_xvclip255_w(val_l); + val_h = __lasx_xvpermi_d(val_l, 0x4E); + val_l = __lasx_xvshuf_b(val_h, val_l, mask); + __lasx_xvstelm_d(val_l, (dest + i), 0, 1); + i += 8; + } + for (; i < dstW; i++) { + int val = dither[(i + offset) & 7] << 12; + int j; + for (j = 0; j< filterSize; j++) + val += src[j][i] * filter[j]; + + dest[i] = av_clip_uint8(val >> 19); + } +} + +/*Copy from libswscale/output.c*/ +static av_always_inline void +yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2, + unsigned A1, unsigned A2, + const void *_r, const void *_g, const void *_b, int y, + enum AVPixelFormat target, int hasAlpha) +{ + if (target == AV_PIX_FMT_ARGB || target == AV_PIX_FMT_RGBA || + target == AV_PIX_FMT_ABGR || target == AV_PIX_FMT_BGRA) { + uint32_t *dest = (uint32_t *) _dest; + const uint32_t *r = (const uint32_t *) _r; + const uint32_t *g = (const uint32_t *) _g; + const uint32_t *b = (const uint32_t *) _b; + +#if CONFIG_SMALL + dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1]; + dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2]; +#else +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1 + int sh = (target == AV_PIX_FMT_RGB32_1 || + target == AV_PIX_FMT_BGR32_1) ? 0 : 24; + av_assert2((((r[Y1] + g[Y1] + b[Y1]) >> sh) & 0xFF) == 0xFF); +#endif + dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1]; + dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2]; +#endif + } else if (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) { + uint8_t *dest = (uint8_t *) _dest; + const uint8_t *r = (const uint8_t *) _r; + const uint8_t *g = (const uint8_t *) _g; + const uint8_t *b = (const uint8_t *) _b; + +#define r_b ((target == AV_PIX_FMT_RGB24) ? r : b) +#define b_r ((target == AV_PIX_FMT_RGB24) ? b : r) + + dest[i * 6 + 0] = r_b[Y1]; + dest[i * 6 + 1] = g[Y1]; + dest[i * 6 + 2] = b_r[Y1]; + dest[i * 6 + 3] = r_b[Y2]; + dest[i * 6 + 4] = g[Y2]; + dest[i * 6 + 5] = b_r[Y2]; +#undef r_b +#undef b_r + } else if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565 || + target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555 || + target == AV_PIX_FMT_RGB444 || target == AV_PIX_FMT_BGR444) { + uint16_t *dest = (uint16_t *) _dest; + const uint16_t *r = (const uint16_t *) _r; + const uint16_t *g = (const uint16_t *) _g; + const uint16_t *b = (const uint16_t *) _b; + int dr1, dg1, db1, dr2, dg2, db2; + + if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565) { + dr1 = ff_dither_2x2_8[ y & 1 ][0]; + dg1 = ff_dither_2x2_4[ y & 1 ][0]; + db1 = ff_dither_2x2_8[(y & 1) ^ 1][0]; + dr2 = ff_dither_2x2_8[ y & 1 ][1]; + dg2 = ff_dither_2x2_4[ y & 1 ][1]; + db2 = ff_dither_2x2_8[(y & 1) ^ 1][1]; + } else if (target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555) { + dr1 = ff_dither_2x2_8[ y & 1 ][0]; + dg1 = ff_dither_2x2_8[ y & 1 ][1]; + db1 = ff_dither_2x2_8[(y & 1) ^ 1][0]; + dr2 = ff_dither_2x2_8[ y & 1 ][1]; + dg2 = ff_dither_2x2_8[ y & 1 ][0]; + db2 = ff_dither_2x2_8[(y & 1) ^ 1][1]; + } else { + dr1 = ff_dither_4x4_16[ y & 3 ][0]; + dg1 = ff_dither_4x4_16[ y & 3 ][1]; + db1 = ff_dither_4x4_16[(y & 3) ^ 3][0]; + dr2 = ff_dither_4x4_16[ y & 3 ][1]; + dg2 = ff_dither_4x4_16[ y & 3 ][0]; + db2 = ff_dither_4x4_16[(y & 3) ^ 3][1]; + } + + dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; + dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; + } else /* 8/4 bits */ { + uint8_t *dest = (uint8_t *) _dest; + const uint8_t *r = (const uint8_t *) _r; + const uint8_t *g = (const uint8_t *) _g; + const uint8_t *b = (const uint8_t *) _b; + int dr1, dg1, db1, dr2, dg2, db2; + + if (target == AV_PIX_FMT_RGB8 || target == AV_PIX_FMT_BGR8) { + const uint8_t * const d64 = ff_dither_8x8_73[y & 7]; + const uint8_t * const d32 = ff_dither_8x8_32[y & 7]; + dr1 = dg1 = d32[(i * 2 + 0) & 7]; + db1 = d64[(i * 2 + 0) & 7]; + dr2 = dg2 = d32[(i * 2 + 1) & 7]; + db2 = d64[(i * 2 + 1) & 7]; + } else { + const uint8_t * const d64 = ff_dither_8x8_73 [y & 7]; + const uint8_t * const d128 = ff_dither_8x8_220[y & 7]; + dr1 = db1 = d128[(i * 2 + 0) & 7]; + dg1 = d64[(i * 2 + 0) & 7]; + dr2 = db2 = d128[(i * 2 + 1) & 7]; + dg2 = d64[(i * 2 + 1) & 7]; + } + + if (target == AV_PIX_FMT_RGB4 || target == AV_PIX_FMT_BGR4) { + dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] + + ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4); + } else { + dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1]; + dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]; + } + } +} + +#define WRITE_YUV2RGB(vec_y1, vec_y2, vec_u, vec_v, t1, t2, t3, t4) \ +{ \ + Y1 = __lasx_xvpickve2gr_w(vec_y1, t1); \ + Y2 = __lasx_xvpickve2gr_w(vec_y2, t2); \ + U = __lasx_xvpickve2gr_w(vec_u, t3); \ + V = __lasx_xvpickve2gr_w(vec_v, t4); \ + r = c->table_rV[V]; \ + g = (c->table_gU[U] + c->table_gV[V]); \ + b = c->table_bU[U]; \ + yuv2rgb_write(dest, count, Y1, Y2, 0, 0, \ + r, g, b, y, target, 0); \ + count++; \ +} + +static void +yuv2rgb_X_template_lasx(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, + int y, enum AVPixelFormat target, int hasAlpha) +{ + int i, j; + int count = 0; + int t = 1 << 18; + int len = dstW >> 6; + int res = dstW & 63; + int len_count = (dstW + 1) >> 1; + const void *r, *g, *b; + int head = YUVRGB_TABLE_HEADROOM; + __m256i headroom = __lasx_xvreplgr2vr_w(head); + + for (i = 0; i < len; i++) { + int Y1, Y2, U, V, count_lum = count << 1; + __m256i l_src1, l_src2, l_src3, l_src4, u_src1, u_src2, v_src1, v_src2; + __m256i yl1_ev, yl1_od, yh1_ev, yh1_od, yl2_ev, yl2_od, yh2_ev, yh2_od; + __m256i u1_ev, u1_od, v1_ev, v1_od, u2_ev, u2_od, v2_ev, v2_od, temp; + + yl1_ev = __lasx_xvldrepl_w(&t, 0); + yl1_od = yl1_ev; + yh1_ev = yl1_ev; + yh1_od = yl1_ev; + u1_ev = yl1_ev; + v1_ev = yl1_ev; + u1_od = yl1_ev; + v1_od = yl1_ev; + yl2_ev = yl1_ev; + yl2_od = yl1_ev; + yh2_ev = yl1_ev; + yh2_od = yl1_ev; + u2_ev = yl1_ev; + v2_ev = yl1_ev; + u2_od = yl1_ev; + v2_od = yl1_ev; + for (j = 0; j < lumFilterSize; j++) { + const int16_t *src_lum = lumSrc[j] + count_lum; + temp = __lasx_xvldrepl_h((lumFilter + j), 0); + DUP4_ARG2(__lasx_xvld, src_lum, 0, src_lum, 32, src_lum, 64, + src_lum, 96, l_src1, l_src2, l_src3, l_src4); + + yl1_ev = __lasx_xvmaddwev_w_h(yl1_ev, temp, l_src1); + yl1_od = __lasx_xvmaddwod_w_h(yl1_od, temp, l_src1); + yh1_ev = __lasx_xvmaddwev_w_h(yh1_ev, temp, l_src2); + yh1_od = __lasx_xvmaddwod_w_h(yh1_od, temp, l_src2); + yl2_ev = __lasx_xvmaddwev_w_h(yl2_ev, temp, l_src3); + yl2_od = __lasx_xvmaddwod_w_h(yl2_od, temp, l_src3); + yh2_ev = __lasx_xvmaddwev_w_h(yh2_ev, temp, l_src4); + yh2_od = __lasx_xvmaddwod_w_h(yh2_od, temp, l_src4); + } + for (j = 0; j < chrFilterSize; j++) { + DUP2_ARG2(__lasx_xvld, chrUSrc[j] + count, 0, chrUSrc[j] + count, 32, + u_src1, u_src2); + DUP2_ARG2(__lasx_xvld, chrVSrc[j] + count, 0, chrVSrc[j] + count, 32, + v_src1, v_src2); + temp = __lasx_xvldrepl_h((chrFilter + j), 0); + u1_ev = __lasx_xvmaddwev_w_h(u1_ev, temp, u_src1); + u1_od = __lasx_xvmaddwod_w_h(u1_od, temp, u_src1); + v1_ev = __lasx_xvmaddwev_w_h(v1_ev, temp, v_src1); + v1_od = __lasx_xvmaddwod_w_h(v1_od, temp, v_src1); + u2_ev = __lasx_xvmaddwev_w_h(u2_ev, temp, u_src2); + u2_od = __lasx_xvmaddwod_w_h(u2_od, temp, u_src2); + v2_ev = __lasx_xvmaddwev_w_h(v2_ev, temp, v_src2); + v2_od = __lasx_xvmaddwod_w_h(v2_od, temp, v_src2); + } + yl1_ev = __lasx_xvsrai_w(yl1_ev, 19); + yh1_ev = __lasx_xvsrai_w(yh1_ev, 19); + yl1_od = __lasx_xvsrai_w(yl1_od, 19); + yh1_od = __lasx_xvsrai_w(yh1_od, 19); + u1_ev = __lasx_xvsrai_w(u1_ev, 19); + v1_ev = __lasx_xvsrai_w(v1_ev, 19); + u1_od = __lasx_xvsrai_w(u1_od, 19); + v1_od = __lasx_xvsrai_w(v1_od, 19); + yl2_ev = __lasx_xvsrai_w(yl2_ev, 19); + yh2_ev = __lasx_xvsrai_w(yh2_ev, 19); + yl2_od = __lasx_xvsrai_w(yl2_od, 19); + yh2_od = __lasx_xvsrai_w(yh2_od, 19); + u2_ev = __lasx_xvsrai_w(u2_ev, 19); + v2_ev = __lasx_xvsrai_w(v2_ev, 19); + u2_od = __lasx_xvsrai_w(u2_od, 19); + v2_od = __lasx_xvsrai_w(v2_od, 19); + u1_ev = __lasx_xvadd_w(u1_ev, headroom); + v1_ev = __lasx_xvadd_w(v1_ev, headroom); + u1_od = __lasx_xvadd_w(u1_od, headroom); + v1_od = __lasx_xvadd_w(v1_od, headroom); + u2_ev = __lasx_xvadd_w(u2_ev, headroom); + v2_ev = __lasx_xvadd_w(v2_ev, headroom); + u2_od = __lasx_xvadd_w(u2_od, headroom); + v2_od = __lasx_xvadd_w(v2_od, headroom); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_ev, v1_ev, 0, 0, 0, 0); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_od, v1_od, 1, 1, 0, 0); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_ev, v1_ev, 2, 2, 1, 1); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_od, v1_od, 3, 3, 1, 1); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_ev, v1_ev, 4, 4, 2, 2); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_od, v1_od, 5, 5, 2, 2); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_ev, v1_ev, 6, 6, 3, 3); + WRITE_YUV2RGB(yl1_ev, yl1_od, u1_od, v1_od, 7, 7, 3, 3); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_ev, v1_ev, 0, 0, 4, 4); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_od, v1_od, 1, 1, 4, 4); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_ev, v1_ev, 2, 2, 5, 5); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_od, v1_od, 3, 3, 5, 5); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_ev, v1_ev, 4, 4, 6, 6); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_od, v1_od, 5, 5, 6, 6); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_ev, v1_ev, 6, 6, 7, 7); + WRITE_YUV2RGB(yh1_ev, yh1_od, u1_od, v1_od, 7, 7, 7, 7); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_ev, v2_ev, 0, 0, 0, 0); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_od, v2_od, 1, 1, 0, 0); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_ev, v2_ev, 2, 2, 1, 1); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_od, v2_od, 3, 3, 1, 1); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_ev, v2_ev, 4, 4, 2, 2); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_od, v2_od, 5, 5, 2, 2); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_ev, v2_ev, 6, 6, 3, 3); + WRITE_YUV2RGB(yl2_ev, yl2_od, u2_od, v2_od, 7, 7, 3, 3); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_ev, v2_ev, 0, 0, 4, 4); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_od, v2_od, 1, 1, 4, 4); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_ev, v2_ev, 2, 2, 5, 5); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_od, v2_od, 3, 3, 5, 5); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_ev, v2_ev, 4, 4, 6, 6); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_od, v2_od, 5, 5, 6, 6); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_ev, v2_ev, 6, 6, 7, 7); + WRITE_YUV2RGB(yh2_ev, yh2_od, u2_od, v2_od, 7, 7, 7, 7); + } + if (res >= 32) { + int Y1, Y2, U, V, count_lum = count << 1; + __m256i l_src1, l_src2, u_src, v_src; + __m256i yl_ev, yl_od, yh_ev, yh_od; + __m256i u_ev, u_od, v_ev, v_od, temp; + + yl_ev = __lasx_xvldrepl_w(&t, 0); + yl_od = yl_ev; + yh_ev = yl_ev; + yh_od = yl_ev; + u_ev = yl_ev; + v_ev = yl_ev; + u_od = yl_ev; + v_od = yl_ev; + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h((lumFilter + j), 0); + DUP2_ARG2(__lasx_xvld, lumSrc[j] + count_lum, 0, lumSrc[j] + count_lum, + 32, l_src1, l_src2); + yl_ev = __lasx_xvmaddwev_w_h(yl_ev, temp, l_src1); + yl_od = __lasx_xvmaddwod_w_h(yl_od, temp, l_src1); + yh_ev = __lasx_xvmaddwev_w_h(yh_ev, temp, l_src2); + yh_od = __lasx_xvmaddwod_w_h(yh_od, temp, l_src2); + } + for (j = 0; j < chrFilterSize; j++) { + DUP2_ARG2(__lasx_xvld, chrUSrc[j] + count, 0, chrVSrc[j] + count, 0, + u_src, v_src); + temp = __lasx_xvldrepl_h((chrFilter + j), 0); + u_ev = __lasx_xvmaddwev_w_h(u_ev, temp, u_src); + u_od = __lasx_xvmaddwod_w_h(u_od, temp, u_src); + v_ev = __lasx_xvmaddwev_w_h(v_ev, temp, v_src); + v_od = __lasx_xvmaddwod_w_h(v_od, temp, v_src); + } + yl_ev = __lasx_xvsrai_w(yl_ev, 19); + yh_ev = __lasx_xvsrai_w(yh_ev, 19); + yl_od = __lasx_xvsrai_w(yl_od, 19); + yh_od = __lasx_xvsrai_w(yh_od, 19); + u_ev = __lasx_xvsrai_w(u_ev, 19); + v_ev = __lasx_xvsrai_w(v_ev, 19); + u_od = __lasx_xvsrai_w(u_od, 19); + v_od = __lasx_xvsrai_w(v_od, 19); + u_ev = __lasx_xvadd_w(u_ev, headroom); + v_ev = __lasx_xvadd_w(v_ev, headroom); + u_od = __lasx_xvadd_w(u_od, headroom); + v_od = __lasx_xvadd_w(v_od, headroom); + WRITE_YUV2RGB(yl_ev, yl_od, u_ev, v_ev, 0, 0, 0, 0); + WRITE_YUV2RGB(yl_ev, yl_od, u_od, v_od, 1, 1, 0, 0); + WRITE_YUV2RGB(yl_ev, yl_od, u_ev, v_ev, 2, 2, 1, 1); + WRITE_YUV2RGB(yl_ev, yl_od, u_od, v_od, 3, 3, 1, 1); + WRITE_YUV2RGB(yl_ev, yl_od, u_ev, v_ev, 4, 4, 2, 2); + WRITE_YUV2RGB(yl_ev, yl_od, u_od, v_od, 5, 5, 2, 2); + WRITE_YUV2RGB(yl_ev, yl_od, u_ev, v_ev, 6, 6, 3, 3); + WRITE_YUV2RGB(yl_ev, yl_od, u_od, v_od, 7, 7, 3, 3); + WRITE_YUV2RGB(yh_ev, yh_od, u_ev, v_ev, 0, 0, 4, 4); + WRITE_YUV2RGB(yh_ev, yh_od, u_od, v_od, 1, 1, 4, 4); + WRITE_YUV2RGB(yh_ev, yh_od, u_ev, v_ev, 2, 2, 5, 5); + WRITE_YUV2RGB(yh_ev, yh_od, u_od, v_od, 3, 3, 5, 5); + WRITE_YUV2RGB(yh_ev, yh_od, u_ev, v_ev, 4, 4, 6, 6); + WRITE_YUV2RGB(yh_ev, yh_od, u_od, v_od, 5, 5, 6, 6); + WRITE_YUV2RGB(yh_ev, yh_od, u_ev, v_ev, 6, 6, 7, 7); + WRITE_YUV2RGB(yh_ev, yh_od, u_od, v_od, 7, 7, 7, 7); + res -= 32; + } + if (res >= 16) { + int Y1, Y2, U, V; + int count_lum = count << 1; + __m256i l_src, u_src, v_src; + __m256i y_ev, y_od, u, v, temp; + + y_ev = __lasx_xvldrepl_w(&t, 0); + y_od = y_ev; + u = y_ev; + v = y_ev; + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h((lumFilter + j), 0); + l_src = __lasx_xvld(lumSrc[j] + count_lum, 0); + y_ev = __lasx_xvmaddwev_w_h(y_ev, temp, l_src); + y_od = __lasx_xvmaddwod_w_h(y_od, temp, l_src); + } + for (j = 0; j < chrFilterSize; j++) { + DUP2_ARG2(__lasx_xvld, chrUSrc[j] + count, 0, chrVSrc[j] + count, + 0, u_src, v_src); + temp = __lasx_xvldrepl_h((chrFilter + j), 0); + u_src = __lasx_vext2xv_w_h(u_src); + v_src = __lasx_vext2xv_w_h(v_src); + u = __lasx_xvmaddwev_w_h(u, temp, u_src); + v = __lasx_xvmaddwev_w_h(v, temp, v_src); + } + y_ev = __lasx_xvsrai_w(y_ev, 19); + y_od = __lasx_xvsrai_w(y_od, 19); + u = __lasx_xvsrai_w(u, 19); + v = __lasx_xvsrai_w(v, 19); + u = __lasx_xvadd_w(u, headroom); + v = __lasx_xvadd_w(v, headroom); + WRITE_YUV2RGB(y_ev, y_od, u, v, 0, 0, 0, 0); + WRITE_YUV2RGB(y_ev, y_od, u, v, 1, 1, 1, 1); + WRITE_YUV2RGB(y_ev, y_od, u, v, 2, 2, 2, 2); + WRITE_YUV2RGB(y_ev, y_od, u, v, 3, 3, 3, 3); + WRITE_YUV2RGB(y_ev, y_od, u, v, 4, 4, 4, 4); + WRITE_YUV2RGB(y_ev, y_od, u, v, 5, 5, 5, 5); + WRITE_YUV2RGB(y_ev, y_od, u, v, 6, 6, 6, 6); + WRITE_YUV2RGB(y_ev, y_od, u, v, 7, 7, 7, 7); + res -= 16; + } + if (res >= 8) { + int Y1, Y2, U, V; + int count_lum = count << 1; + __m256i l_src, u_src, v_src; + __m256i y_ev, uv, temp; + + y_ev = __lasx_xvldrepl_w(&t, 0); + uv = y_ev; + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h((lumFilter + j), 0); + l_src = __lasx_xvld(lumSrc[j] + count_lum, 0); + l_src = __lasx_vext2xv_w_h(l_src); + y_ev = __lasx_xvmaddwev_w_h(y_ev, temp, l_src); + } + for (j = 0; j < chrFilterSize; j++) { + u_src = __lasx_xvldrepl_d((chrUSrc[j] + count), 0); + v_src = __lasx_xvldrepl_d((chrVSrc[j] + count), 0); + temp = __lasx_xvldrepl_h((chrFilter + j), 0); + u_src = __lasx_xvilvl_d(v_src, u_src); + u_src = __lasx_vext2xv_w_h(u_src); + uv = __lasx_xvmaddwev_w_h(uv, temp, u_src); + } + y_ev = __lasx_xvsrai_w(y_ev, 19); + uv = __lasx_xvsrai_w(uv, 19); + uv = __lasx_xvadd_w(uv, headroom); + WRITE_YUV2RGB(y_ev, y_ev, uv, uv, 0, 1, 0, 4); + WRITE_YUV2RGB(y_ev, y_ev, uv, uv, 2, 3, 1, 5); + WRITE_YUV2RGB(y_ev, y_ev, uv, uv, 4, 5, 2, 6); + WRITE_YUV2RGB(y_ev, y_ev, uv, uv, 6, 7, 3, 7); + } + for (; count < len_count; count++) { + int Y1 = 1 << 18; + int Y2 = Y1; + int U = Y1; + int V = Y1; + + for (j = 0; j < lumFilterSize; j++) { + Y1 += lumSrc[j][count * 2] * lumFilter[j]; + Y2 += lumSrc[j][count * 2 + 1] * lumFilter[j]; + } + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][count] * chrFilter[j]; + V += chrVSrc[j][count] * chrFilter[j]; + } + Y1 >>= 19; + Y2 >>= 19; + U >>= 19; + V >>= 19; + r = c->table_rV[V + YUVRGB_TABLE_HEADROOM]; + g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + + c->table_gV[V + YUVRGB_TABLE_HEADROOM]); + b = c->table_bU[U + YUVRGB_TABLE_HEADROOM]; + + yuv2rgb_write(dest, count, Y1, Y2, 0, 0, + r, g, b, y, target, 0); + } +} + +static void +yuv2rgb_2_template_lasx(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, + int yalpha, int uvalpha, int y, + enum AVPixelFormat target, int hasAlpha) +{ + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1]; + int yalpha1 = 4096 - yalpha; + int uvalpha1 = 4096 - uvalpha; + int i, count = 0; + int len = dstW - 15; + int len_count = (dstW + 1) >> 1; + const void *r, *g, *b; + int head = YUVRGB_TABLE_HEADROOM; + __m256i v_yalpha1 = __lasx_xvreplgr2vr_w(yalpha1); + __m256i v_uvalpha1 = __lasx_xvreplgr2vr_w(uvalpha1); + __m256i v_yalpha = __lasx_xvreplgr2vr_w(yalpha); + __m256i v_uvalpha = __lasx_xvreplgr2vr_w(uvalpha); + __m256i headroom = __lasx_xvreplgr2vr_w(head); + + for (i = 0; i < len; i += 16) { + int Y1, Y2, U, V; + int i_dex = i << 1; + int c_dex = count << 1; + __m256i y0_h, y0_l, y0, u0, v0; + __m256i y1_h, y1_l, y1, u1, v1; + __m256i y_l, y_h, u, v; + + DUP4_ARG2(__lasx_xvldx, buf0, i_dex, ubuf0, c_dex, vbuf0, c_dex, + buf1, i_dex, y0, u0, v0, y1); + DUP2_ARG2(__lasx_xvldx, ubuf1, c_dex, vbuf1, c_dex, u1, v1); + DUP2_ARG2(__lasx_xvsllwil_w_h, y0, 0, y1, 0, y0_l, y1_l); + DUP2_ARG1(__lasx_xvexth_w_h, y0, y1, y0_h, y1_h); + DUP4_ARG1(__lasx_vext2xv_w_h, u0, u1, v0, v1, u0, u1, v0, v1); + y0_l = __lasx_xvmul_w(y0_l, v_yalpha1); + y0_h = __lasx_xvmul_w(y0_h, v_yalpha1); + u0 = __lasx_xvmul_w(u0, v_uvalpha1); + v0 = __lasx_xvmul_w(v0, v_uvalpha1); + y_l = __lasx_xvmadd_w(y0_l, v_yalpha, y1_l); + y_h = __lasx_xvmadd_w(y0_h, v_yalpha, y1_h); + u = __lasx_xvmadd_w(u0, v_uvalpha, u1); + v = __lasx_xvmadd_w(v0, v_uvalpha, v1); + y_l = __lasx_xvsrai_w(y_l, 19); + y_h = __lasx_xvsrai_w(y_h, 19); + u = __lasx_xvsrai_w(u, 19); + v = __lasx_xvsrai_w(v, 19); + u = __lasx_xvadd_w(u, headroom); + v = __lasx_xvadd_w(v, headroom); + WRITE_YUV2RGB(y_l, y_l, u, v, 0, 1, 0, 0); + WRITE_YUV2RGB(y_l, y_l, u, v, 2, 3, 1, 1); + WRITE_YUV2RGB(y_h, y_h, u, v, 0, 1, 2, 2); + WRITE_YUV2RGB(y_h, y_h, u, v, 2, 3, 3, 3); + WRITE_YUV2RGB(y_l, y_l, u, v, 4, 5, 4, 4); + WRITE_YUV2RGB(y_l, y_l, u, v, 6, 7, 5, 5); + WRITE_YUV2RGB(y_h, y_h, u, v, 4, 5, 6, 6); + WRITE_YUV2RGB(y_h, y_h, u, v, 6, 7, 7, 7); + } + if (dstW - i >= 8) { + int Y1, Y2, U, V; + int i_dex = i << 1; + __m256i y0_l, y0, u0, v0; + __m256i y1_l, y1, u1, v1; + __m256i y_l, u, v; + + y0 = __lasx_xvldx(buf0, i_dex); + u0 = __lasx_xvldrepl_d((ubuf0 + count), 0); + v0 = __lasx_xvldrepl_d((vbuf0 + count), 0); + y1 = __lasx_xvldx(buf1, i_dex); + u1 = __lasx_xvldrepl_d((ubuf1 + count), 0); + v1 = __lasx_xvldrepl_d((vbuf1 + count), 0); + DUP2_ARG1(__lasx_vext2xv_w_h, y0, y1, y0_l, y1_l); + DUP4_ARG1(__lasx_vext2xv_w_h, u0, u1, v0, v1, u0, u1, v0, v1); + y0_l = __lasx_xvmul_w(y0_l, v_yalpha1); + u0 = __lasx_xvmul_w(u0, v_uvalpha1); + v0 = __lasx_xvmul_w(v0, v_uvalpha1); + y_l = __lasx_xvmadd_w(y0_l, v_yalpha, y1_l); + u = __lasx_xvmadd_w(u0, v_uvalpha, u1); + v = __lasx_xvmadd_w(v0, v_uvalpha, v1); + y_l = __lasx_xvsrai_w(y_l, 19); + u = __lasx_xvsrai_w(u, 19); + v = __lasx_xvsrai_w(v, 19); + u = __lasx_xvadd_w(u, headroom); + v = __lasx_xvadd_w(v, headroom); + WRITE_YUV2RGB(y_l, y_l, u, v, 0, 1, 0, 0); + WRITE_YUV2RGB(y_l, y_l, u, v, 2, 3, 1, 1); + WRITE_YUV2RGB(y_l, y_l, u, v, 4, 5, 2, 2); + WRITE_YUV2RGB(y_l, y_l, u, v, 6, 7, 3, 3); + i += 8; + } + for (; count < len_count; count++) { + int Y1 = (buf0[count * 2] * yalpha1 + + buf1[count * 2] * yalpha) >> 19; + int Y2 = (buf0[count * 2 + 1] * yalpha1 + + buf1[count * 2 + 1] * yalpha) >> 19; + int U = (ubuf0[count] * uvalpha1 + ubuf1[count] * uvalpha) >> 19; + int V = (vbuf0[count] * uvalpha1 + vbuf1[count] * uvalpha) >> 19; + + r = c->table_rV[V + YUVRGB_TABLE_HEADROOM], + g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + + c->table_gV[V + YUVRGB_TABLE_HEADROOM]), + b = c->table_bU[U + YUVRGB_TABLE_HEADROOM]; + + yuv2rgb_write(dest, count, Y1, Y2, 0, 0, + r, g, b, y, target, 0); + } +} + +static void +yuv2rgb_1_template_lasx(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum AVPixelFormat target, + int hasAlpha) +{ + const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; + int i; + int len = (dstW - 15); + int len_count = (dstW + 1) >> 1; + const void *r, *g, *b; + + if (uvalpha < 2048) { + int count = 0; + int head = YUVRGB_TABLE_HEADROOM; + __m256i headroom = __lasx_xvreplgr2vr_h(head); + + for (i = 0; i < len; i += 16) { + int Y1, Y2, U, V; + int i_dex = i << 1; + int c_dex = count << 1; + __m256i src_y, src_u, src_v; + __m256i u, v, y_l, y_h; + + DUP2_ARG2(__lasx_xvldx, buf0, i_dex, ubuf0, c_dex, src_y, src_u); + src_v = __lasx_xvldx(vbuf0, c_dex); + src_u = __lasx_xvpermi_q(src_u, src_v, 0x02); + src_y = __lasx_xvsrari_h(src_y, 7); + src_u = __lasx_xvsrari_h(src_u, 7); + y_l = __lasx_xvsllwil_w_h(src_y, 0); + y_h = __lasx_xvexth_w_h(src_y); + u = __lasx_xvaddwev_w_h(src_u, headroom); + v = __lasx_xvaddwod_w_h(src_u, headroom); + WRITE_YUV2RGB(y_l, y_l, u, u, 0, 1, 0, 4); + WRITE_YUV2RGB(y_l, y_l, v, v, 2, 3, 0, 4); + WRITE_YUV2RGB(y_h, y_h, u, u, 0, 1, 1, 5); + WRITE_YUV2RGB(y_h, y_h, v, v, 2, 3, 1, 5); + WRITE_YUV2RGB(y_l, y_l, u, u, 4, 5, 2, 6); + WRITE_YUV2RGB(y_l, y_l, v, v, 6, 7, 2, 6); + WRITE_YUV2RGB(y_h, y_h, u, u, 4, 5, 3, 7); + WRITE_YUV2RGB(y_h, y_h, v, v, 6, 7, 3, 7); + } + if (dstW - i >= 8){ + int Y1, Y2, U, V; + int i_dex = i << 1; + __m256i src_y, src_u, src_v; + __m256i y_l, uv; + + src_y = __lasx_xvldx(buf0, i_dex); + src_u = __lasx_xvldrepl_d((ubuf0 + count), 0); + src_v = __lasx_xvldrepl_d((vbuf0 + count), 0); + src_u = __lasx_xvilvl_d(src_v, src_u); + y_l = __lasx_xvsrari_h(src_y, 7); + uv = __lasx_xvsrari_h(src_u, 7); + y_l = __lasx_vext2xv_w_h(y_l); + uv = __lasx_vext2xv_w_h(uv); + uv = __lasx_xvaddwev_w_h(uv, headroom); + WRITE_YUV2RGB(y_l, y_l, uv, uv, 0, 1, 0, 4); + WRITE_YUV2RGB(y_l, y_l, uv, uv, 2, 3, 1, 5); + WRITE_YUV2RGB(y_l, y_l, uv, uv, 4, 5, 2, 6); + WRITE_YUV2RGB(y_l, y_l, uv, uv, 6, 7, 3, 7); + i += 8; + } + for (; count < len_count; count++) { + int Y1 = (buf0[count * 2 ] + 64) >> 7; + int Y2 = (buf0[count * 2 + 1] + 64) >> 7; + int U = (ubuf0[count] + 64) >> 7; + int V = (vbuf0[count] + 64) >> 7; + + r = c->table_rV[V + YUVRGB_TABLE_HEADROOM], + g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + + c->table_gV[V + YUVRGB_TABLE_HEADROOM]), + b = c->table_bU[U + YUVRGB_TABLE_HEADROOM]; + + yuv2rgb_write(dest, count, Y1, Y2, 0, 0, + r, g, b, y, target, 0); + } + } else { + const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; + int count = 0; + int HEADROOM = YUVRGB_TABLE_HEADROOM; + __m256i headroom = __lasx_xvreplgr2vr_w(HEADROOM); + + for (i = 0; i < len; i += 16) { + int Y1, Y2, U, V; + int i_dex = i << 1; + int c_dex = count << 1; + __m256i src_y, src_u0, src_v0, src_u1, src_v1; + __m256i y_l, y_h, u, v; + + DUP4_ARG2(__lasx_xvldx, buf0, i_dex, ubuf0, c_dex, vbuf0, c_dex, + ubuf1, c_dex, src_y, src_u0, src_v0, src_u1); + src_v1 = __lasx_xvldx(vbuf1, c_dex); + src_u0 = __lasx_xvpermi_q(src_u0, src_v0, 0x02); + src_u1 = __lasx_xvpermi_q(src_u1, src_v1, 0x02); + src_y = __lasx_xvsrari_h(src_y, 7); + u = __lasx_xvaddwev_w_h(src_u0, src_u1); + v = __lasx_xvaddwod_w_h(src_u0, src_u1); + y_l = __lasx_xvsllwil_w_h(src_y, 0); + y_h = __lasx_xvexth_w_h(src_y); + u = __lasx_xvsrari_w(u, 8); + v = __lasx_xvsrari_w(v, 8); + u = __lasx_xvadd_w(u, headroom); + v = __lasx_xvadd_w(v, headroom); + WRITE_YUV2RGB(y_l, y_l, u, u, 0, 1, 0, 4); + WRITE_YUV2RGB(y_l, y_l, v, v, 2, 3, 0, 4); + WRITE_YUV2RGB(y_h, y_h, u, u, 0, 1, 1, 5); + WRITE_YUV2RGB(y_h, y_h, v, v, 2, 3, 1, 5); + WRITE_YUV2RGB(y_l, y_l, u, u, 4, 5, 2, 6); + WRITE_YUV2RGB(y_l, y_l, v, v, 6, 7, 2, 6); + WRITE_YUV2RGB(y_h, y_h, u, u, 4, 5, 3, 7); + WRITE_YUV2RGB(y_h, y_h, v, v, 6, 7, 3, 7); + } + if (dstW - i >= 8) { + int Y1, Y2, U, V; + int i_dex = i << 1; + __m256i src_y, src_u0, src_v0, src_u1, src_v1; + __m256i uv; + + src_y = __lasx_xvldx(buf0, i_dex); + src_u0 = __lasx_xvldrepl_d((ubuf0 + count), 0); + src_v0 = __lasx_xvldrepl_d((vbuf0 + count), 0); + src_u1 = __lasx_xvldrepl_d((ubuf1 + count), 0); + src_v1 = __lasx_xvldrepl_d((vbuf1 + count), 0); + + src_u0 = __lasx_xvilvl_h(src_u1, src_u0); + src_v0 = __lasx_xvilvl_h(src_v1, src_v0); + src_u0 = __lasx_xvpermi_q(src_u0, src_v0, 0x02); + src_y = __lasx_xvsrari_h(src_y, 7); + uv = __lasx_xvhaddw_w_h(src_u0, src_u0); + src_y = __lasx_vext2xv_w_h(src_y); + uv = __lasx_xvsrari_w(uv, 8); + uv = __lasx_xvadd_w(uv, headroom); + WRITE_YUV2RGB(src_y, src_y, uv, uv, 0, 1, 0, 4); + WRITE_YUV2RGB(src_y, src_y, uv, uv, 2, 3, 1, 5); + WRITE_YUV2RGB(src_y, src_y, uv, uv, 4, 5, 2, 6); + WRITE_YUV2RGB(src_y, src_y, uv, uv, 6, 7, 3, 7); + i += 8; + } + for (; count < len_count; count++) { + int Y1 = (buf0[count * 2 ] + 64) >> 7; + int Y2 = (buf0[count * 2 + 1] + 64) >> 7; + int U = (ubuf0[count] + ubuf1[count] + 128) >> 8; + int V = (vbuf0[count] + vbuf1[count] + 128) >> 8; + + r = c->table_rV[V + YUVRGB_TABLE_HEADROOM], + g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + + c->table_gV[V + YUVRGB_TABLE_HEADROOM]), + b = c->table_bU[U + YUVRGB_TABLE_HEADROOM]; + + yuv2rgb_write(dest, count, Y1, Y2, 0, 0, + r, g, b, y, target, 0); + } + } +} + +#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \ +static void name ## ext ## _X_lasx(SwsContext *c, const int16_t *lumFilter, \ + const int16_t **lumSrc, int lumFilterSize, \ + const int16_t *chrFilter, const int16_t **chrUSrc, \ + const int16_t **chrVSrc, int chrFilterSize, \ + const int16_t **alpSrc, uint8_t *dest, int dstW, \ + int y) \ +{ \ + name ## base ## _X_template_lasx(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, dest, dstW, y, fmt, hasAlpha); \ +} + +#define YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \ +YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \ +static void name ## ext ## _2_lasx(SwsContext *c, const int16_t *buf[2], \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf[2], uint8_t *dest, int dstW, \ + int yalpha, int uvalpha, int y) \ +{ \ + name ## base ## _2_template_lasx(c, buf, ubuf, vbuf, abuf, dest, \ + dstW, yalpha, uvalpha, y, fmt, hasAlpha); \ +} + +#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \ +YUV2RGBWRAPPERX2(name, base, ext, fmt, hasAlpha) \ +static void name ## ext ## _1_lasx(SwsContext *c, const int16_t *buf0, \ + const int16_t *ubuf[2], const int16_t *vbuf[2], \ + const int16_t *abuf0, uint8_t *dest, int dstW, \ + int uvalpha, int y) \ +{ \ + name ## base ## _1_template_lasx(c, buf0, ubuf, vbuf, abuf0, dest, \ + dstW, uvalpha, y, fmt, hasAlpha); \ +} + + +#if CONFIG_SMALL +#else +#if CONFIG_SWSCALE_ALPHA +#endif +YUV2RGBWRAPPER(yuv2rgb,, x32_1, AV_PIX_FMT_RGB32_1, 0) +YUV2RGBWRAPPER(yuv2rgb,, x32, AV_PIX_FMT_RGB32, 0) +#endif +YUV2RGBWRAPPER(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0) +YUV2RGBWRAPPER(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0) +YUV2RGBWRAPPER(yuv2rgb,, 16, AV_PIX_FMT_RGB565, 0) +YUV2RGBWRAPPER(yuv2rgb,, 15, AV_PIX_FMT_RGB555, 0) +YUV2RGBWRAPPER(yuv2rgb,, 12, AV_PIX_FMT_RGB444, 0) +YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0) +YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0) +YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0) + +// This function is copied from libswscale/output.c +static av_always_inline void yuv2rgb_write_full(SwsContext *c, + uint8_t *dest, int i, int R, int A, int G, int B, + int y, enum AVPixelFormat target, int hasAlpha, int err[4]) +{ + int isrgb8 = target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8; + + if ((R | G | B) & 0xC0000000) { + R = av_clip_uintp2(R, 30); + G = av_clip_uintp2(G, 30); + B = av_clip_uintp2(B, 30); + } + + switch(target) { + case AV_PIX_FMT_ARGB: + dest[0] = hasAlpha ? A : 255; + dest[1] = R >> 22; + dest[2] = G >> 22; + dest[3] = B >> 22; + break; + case AV_PIX_FMT_RGB24: + dest[0] = R >> 22; + dest[1] = G >> 22; + dest[2] = B >> 22; + break; + case AV_PIX_FMT_RGBA: + dest[0] = R >> 22; + dest[1] = G >> 22; + dest[2] = B >> 22; + dest[3] = hasAlpha ? A : 255; + break; + case AV_PIX_FMT_ABGR: + dest[0] = hasAlpha ? A : 255; + dest[1] = B >> 22; + dest[2] = G >> 22; + dest[3] = R >> 22; + break; + case AV_PIX_FMT_BGR24: + dest[0] = B >> 22; + dest[1] = G >> 22; + dest[2] = R >> 22; + break; + case AV_PIX_FMT_BGRA: + dest[0] = B >> 22; + dest[1] = G >> 22; + dest[2] = R >> 22; + dest[3] = hasAlpha ? A : 255; + break; + case AV_PIX_FMT_BGR4_BYTE: + case AV_PIX_FMT_RGB4_BYTE: + case AV_PIX_FMT_BGR8: + case AV_PIX_FMT_RGB8: + { + int r,g,b; + + switch (c->dither) { + default: + case SWS_DITHER_AUTO: + case SWS_DITHER_ED: + R >>= 22; + G >>= 22; + B >>= 22; + R += (7*err[0] + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4; + G += (7*err[1] + 1*c->dither_error[1][i] + 5*c->dither_error[1][i+1] + 3*c->dither_error[1][i+2])>>4; + B += (7*err[2] + 1*c->dither_error[2][i] + 5*c->dither_error[2][i+1] + 3*c->dither_error[2][i+2])>>4; + c->dither_error[0][i] = err[0]; + c->dither_error[1][i] = err[1]; + c->dither_error[2][i] = err[2]; + r = R >> (isrgb8 ? 5 : 7); + g = G >> (isrgb8 ? 5 : 6); + b = B >> (isrgb8 ? 6 : 7); + r = av_clip(r, 0, isrgb8 ? 7 : 1); + g = av_clip(g, 0, isrgb8 ? 7 : 3); + b = av_clip(b, 0, isrgb8 ? 3 : 1); + err[0] = R - r*(isrgb8 ? 36 : 255); + err[1] = G - g*(isrgb8 ? 36 : 85); + err[2] = B - b*(isrgb8 ? 85 : 255); + break; + case SWS_DITHER_A_DITHER: + if (isrgb8) { + /* see http://pippin.gimp.org/a_dither/ for details/origin */ +#define A_DITHER(u,v) (((((u)+((v)*236))*119)&0xff)) + r = (((R >> 19) + A_DITHER(i,y) -96)>>8); + g = (((G >> 19) + A_DITHER(i + 17,y) - 96)>>8); + b = (((B >> 20) + A_DITHER(i + 17*2,y) -96)>>8); + r = av_clip_uintp2(r, 3); + g = av_clip_uintp2(g, 3); + b = av_clip_uintp2(b, 2); + } else { + r = (((R >> 21) + A_DITHER(i,y)-256)>>8); + g = (((G >> 19) + A_DITHER(i + 17,y)-256)>>8); + b = (((B >> 21) + A_DITHER(i + 17*2,y)-256)>>8); + r = av_clip_uintp2(r, 1); + g = av_clip_uintp2(g, 2); + b = av_clip_uintp2(b, 1); + } + break; + case SWS_DITHER_X_DITHER: + if (isrgb8) { + /* see http://pippin.gimp.org/a_dither/ for details/origin */ +#define X_DITHER(u,v) (((((u)^((v)*237))*181)&0x1ff)/2) + r = (((R >> 19) + X_DITHER(i,y) - 96)>>8); + g = (((G >> 19) + X_DITHER(i + 17,y) - 96)>>8); + b = (((B >> 20) + X_DITHER(i + 17*2,y) - 96)>>8); + r = av_clip_uintp2(r, 3); + g = av_clip_uintp2(g, 3); + b = av_clip_uintp2(b, 2); + } else { + r = (((R >> 21) + X_DITHER(i,y)-256)>>8); + g = (((G >> 19) + X_DITHER(i + 17,y)-256)>>8); + b = (((B >> 21) + X_DITHER(i + 17*2,y)-256)>>8); + r = av_clip_uintp2(r, 1); + g = av_clip_uintp2(g, 2); + b = av_clip_uintp2(b, 1); + } + + break; + } + + if(target == AV_PIX_FMT_BGR4_BYTE) { + dest[0] = r + 2*g + 8*b; + } else if(target == AV_PIX_FMT_RGB4_BYTE) { + dest[0] = b + 2*g + 8*r; + } else if(target == AV_PIX_FMT_BGR8) { + dest[0] = r + 8*g + 64*b; + } else if(target == AV_PIX_FMT_RGB8) { + dest[0] = b + 4*g + 32*r; + } else + av_assert2(0); + break; } + } +} + +#define YUV2RGB_SETUP \ + int y_offset = c->yuv2rgb_y_offset; \ + int y_coeff = c->yuv2rgb_y_coeff; \ + int v2r_coe = c->yuv2rgb_v2r_coeff; \ + int v2g_coe = c->yuv2rgb_v2g_coeff; \ + int u2g_coe = c->yuv2rgb_u2g_coeff; \ + int u2b_coe = c->yuv2rgb_u2b_coeff; \ + __m256i offset = __lasx_xvreplgr2vr_w(y_offset); \ + __m256i coeff = __lasx_xvreplgr2vr_w(y_coeff); \ + __m256i v2r = __lasx_xvreplgr2vr_w(v2r_coe); \ + __m256i v2g = __lasx_xvreplgr2vr_w(v2g_coe); \ + __m256i u2g = __lasx_xvreplgr2vr_w(u2g_coe); \ + __m256i u2b = __lasx_xvreplgr2vr_w(u2b_coe); \ + + +#define YUV2RGB(y, u, v, R, G, B, offset, coeff, \ + y_temp, v2r, v2g, u2g, u2b) \ +{ \ + y = __lasx_xvsub_w(y, offset); \ + y = __lasx_xvmul_w(y, coeff); \ + y = __lasx_xvadd_w(y, y_temp); \ + R = __lasx_xvmadd_w(y, v, v2r); \ + v = __lasx_xvmadd_w(y, v, v2g); \ + G = __lasx_xvmadd_w(v, u, u2g); \ + B = __lasx_xvmadd_w(y, u, u2b); \ +} + +#define WRITE_FULL_A(r, g, b, a, t1, s) \ +{ \ + R = __lasx_xvpickve2gr_w(r, t1); \ + G = __lasx_xvpickve2gr_w(g, t1); \ + B = __lasx_xvpickve2gr_w(b, t1); \ + A = __lasx_xvpickve2gr_w(a, t1); \ + if (A & 0x100) \ + A = av_clip_uint8(A); \ + yuv2rgb_write_full(c, dest, i + s, R, A, G, B, y, target, hasAlpha, err);\ + dest += step; \ +} + +#define WRITE_FULL(r, g, b, t1, s) \ +{ \ + R = __lasx_xvpickve2gr_w(r, t1); \ + G = __lasx_xvpickve2gr_w(g, t1); \ + B = __lasx_xvpickve2gr_w(b, t1); \ + yuv2rgb_write_full(c, dest, i + s, R, 0, G, B, y, target, hasAlpha, err); \ + dest += step; \ +} + +static void +yuv2rgb_full_X_template_lasx(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, + int dstW, int y, enum AVPixelFormat target, + int hasAlpha) +{ + int i, j, B, G, R, A; + int step = (target == AV_PIX_FMT_RGB24 || + target == AV_PIX_FMT_BGR24) ? 3 : 4; + int err[4] = {0}; + int a_temp = 1 << 18; + int templ = 1 << 9; + int tempc = templ - (128 << 19); + int ytemp = 1 << 21; + int len = dstW - 15; + __m256i y_temp = __lasx_xvreplgr2vr_w(ytemp); + YUV2RGB_SETUP + + if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE + || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8) + step = 1; + + for (i = 0; i < len; i += 16) { + __m256i l_src, u_src, v_src; + __m256i y_ev, y_od, u_ev, u_od, v_ev, v_od, temp; + __m256i R_ev, R_od, G_ev, G_od, B_ev, B_od; + int n = i << 1; + + y_ev = y_od = __lasx_xvreplgr2vr_w(templ); + u_ev = u_od = v_ev = v_od = __lasx_xvreplgr2vr_w(tempc); + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h((lumFilter + j), 0); + l_src = __lasx_xvldx(lumSrc[j], n); + y_ev = __lasx_xvmaddwev_w_h(y_ev, l_src, temp); + y_od = __lasx_xvmaddwod_w_h(y_od, l_src, temp); + } + for (j = 0; j < chrFilterSize; j++) { + temp = __lasx_xvldrepl_h((chrFilter + j), 0); + DUP2_ARG2(__lasx_xvldx, chrUSrc[j], n, chrVSrc[j], n, + u_src, v_src); + DUP2_ARG3(__lasx_xvmaddwev_w_h, u_ev, u_src, temp, v_ev, + v_src, temp, u_ev, v_ev); + DUP2_ARG3(__lasx_xvmaddwod_w_h, u_od, u_src, temp, v_od, + v_src, temp, u_od, v_od); + } + y_ev = __lasx_xvsrai_w(y_ev, 10); + y_od = __lasx_xvsrai_w(y_od, 10); + u_ev = __lasx_xvsrai_w(u_ev, 10); + u_od = __lasx_xvsrai_w(u_od, 10); + v_ev = __lasx_xvsrai_w(v_ev, 10); + v_od = __lasx_xvsrai_w(v_od, 10); + YUV2RGB(y_ev, u_ev, v_ev, R_ev, G_ev, B_ev, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + YUV2RGB(y_od, u_od, v_od, R_od, G_od, B_od, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if (hasAlpha) { + __m256i a_src, a_ev, a_od; + + a_ev = a_od = __lasx_xvreplgr2vr_w(a_temp); + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h(lumFilter + j, 0); + a_src = __lasx_xvldx(alpSrc[j], n); + a_ev = __lasx_xvmaddwev_w_h(a_ev, a_src, temp); + a_od = __lasx_xvmaddwod_w_h(a_od, a_src, temp); + } + a_ev = __lasx_xvsrai_w(a_ev, 19); + a_od = __lasx_xvsrai_w(a_od, 19); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 0, 0); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 0, 1); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 1, 2); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 1, 3); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 2, 4); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 2, 5); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 3, 6); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 3, 7); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 4, 8); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 4, 9); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 5, 10); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 5, 11); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 6, 12); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 6, 13); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 7, 14); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 7, 15); + } else { + WRITE_FULL(R_ev, G_ev, B_ev, 0, 0); + WRITE_FULL(R_od, G_od, B_od, 0, 1); + WRITE_FULL(R_ev, G_ev, B_ev, 1, 2); + WRITE_FULL(R_od, G_od, B_od, 1, 3); + WRITE_FULL(R_ev, G_ev, B_ev, 2, 4); + WRITE_FULL(R_od, G_od, B_od, 2, 5); + WRITE_FULL(R_ev, G_ev, B_ev, 3, 6); + WRITE_FULL(R_od, G_od, B_od, 3, 7); + WRITE_FULL(R_ev, G_ev, B_ev, 4, 8); + WRITE_FULL(R_od, G_od, B_od, 4, 9); + WRITE_FULL(R_ev, G_ev, B_ev, 5, 10); + WRITE_FULL(R_od, G_od, B_od, 5, 11); + WRITE_FULL(R_ev, G_ev, B_ev, 6, 12); + WRITE_FULL(R_od, G_od, B_od, 6, 13); + WRITE_FULL(R_ev, G_ev, B_ev, 7, 14); + WRITE_FULL(R_od, G_od, B_od, 7, 15); + } + } + if (dstW - i >= 8) { + __m256i l_src, u_src, v_src; + __m256i y_ev, u_ev, v_ev, uv, temp; + __m256i R_ev, G_ev, B_ev; + int n = i << 1; + + y_ev = __lasx_xvreplgr2vr_w(templ); + u_ev = v_ev = __lasx_xvreplgr2vr_w(tempc); + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h((lumFilter + j), 0); + l_src = __lasx_xvldx(lumSrc[j], n); + l_src = __lasx_xvpermi_d(l_src, 0xD8); + l_src = __lasx_xvilvl_h(l_src, l_src); + y_ev = __lasx_xvmaddwev_w_h(y_ev, l_src, temp); + } + for (j = 0; j < chrFilterSize; j++) { + temp = __lasx_xvldrepl_h((chrFilter + j), 0); + DUP2_ARG2(__lasx_xvldx, chrUSrc[j], n, chrVSrc[j], n, u_src, v_src); + u_src = __lasx_xvpermi_d(u_src, 0xD8); + v_src = __lasx_xvpermi_d(v_src, 0xD8); + uv = __lasx_xvilvl_h(v_src, u_src); + u_ev = __lasx_xvmaddwev_w_h(u_ev, uv, temp); + v_ev = __lasx_xvmaddwod_w_h(v_ev, uv, temp); + } + y_ev = __lasx_xvsrai_w(y_ev, 10); + u_ev = __lasx_xvsrai_w(u_ev, 10); + v_ev = __lasx_xvsrai_w(v_ev, 10); + YUV2RGB(y_ev, u_ev, v_ev, R_ev, G_ev, B_ev, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if (hasAlpha) { + __m256i a_src, a_ev; + + a_ev = __lasx_xvreplgr2vr_w(a_temp); + for (j = 0; j < lumFilterSize; j++) { + temp = __lasx_xvldrepl_h(lumFilter + j, 0); + a_src = __lasx_xvldx(alpSrc[j], n); + a_src = __lasx_xvpermi_d(a_src, 0xD8); + a_src = __lasx_xvilvl_h(a_src, a_src); + a_ev = __lasx_xvmaddwev_w_h(a_ev, a_src, temp); + } + a_ev = __lasx_xvsrai_w(a_ev, 19); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 0, 0); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 1, 1); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 2, 2); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 3, 3); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 4, 4); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 5, 5); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 6, 6); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 7, 7); + } else { + WRITE_FULL(R_ev, G_ev, B_ev, 0, 0); + WRITE_FULL(R_ev, G_ev, B_ev, 1, 1); + WRITE_FULL(R_ev, G_ev, B_ev, 2, 2); + WRITE_FULL(R_ev, G_ev, B_ev, 3, 3); + WRITE_FULL(R_ev, G_ev, B_ev, 4, 4); + WRITE_FULL(R_ev, G_ev, B_ev, 5, 5); + WRITE_FULL(R_ev, G_ev, B_ev, 6, 6); + WRITE_FULL(R_ev, G_ev, B_ev, 7, 7); + } + i += 8; + } + for (; i < dstW; i++) { + int Y = templ; + int V, U = V = tempc; + + A = 0; + for (j = 0; j < lumFilterSize; j++) { + Y += lumSrc[j][i] * lumFilter[j]; + } + for (j = 0; j < chrFilterSize; j++) { + U += chrUSrc[j][i] * chrFilter[j]; + V += chrVSrc[j][i] * chrFilter[j]; + + } + Y >>= 10; + U >>= 10; + V >>= 10; + if (hasAlpha) { + A = 1 << 18; + for (j = 0; j < lumFilterSize; j++) { + A += alpSrc[j][i] * lumFilter[j]; + } + A >>= 19; + if (A & 0x100) + A = av_clip_uint8(A); + } + Y -= y_offset; + Y *= y_coeff; + Y += ytemp; + R = (unsigned)Y + V * v2r_coe; + G = (unsigned)Y + V * v2g_coe + U * u2g_coe; + B = (unsigned)Y + U * u2b_coe; + yuv2rgb_write_full(c, dest, i, R, A, G, B, y, target, hasAlpha, err); + dest += step; + } + c->dither_error[0][i] = err[0]; + c->dither_error[1][i] = err[1]; + c->dither_error[2][i] = err[2]; +} + +static void +yuv2rgb_full_2_template_lasx(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, + int yalpha, int uvalpha, int y, + enum AVPixelFormat target, int hasAlpha) +{ + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], + *abuf0 = hasAlpha ? abuf[0] : NULL, + *abuf1 = hasAlpha ? abuf[1] : NULL; + int yalpha1 = 4096 - yalpha; + int uvalpha1 = 4096 - uvalpha; + int uvtemp = 128 << 19; + int atemp = 1 << 18; + int err[4] = {0}; + int ytemp = 1 << 21; + int len = dstW - 15; + int i, R, G, B, A; + int step = (target == AV_PIX_FMT_RGB24 || + target == AV_PIX_FMT_BGR24) ? 3 : 4; + __m256i v_uvalpha1 = __lasx_xvreplgr2vr_w(uvalpha1); + __m256i v_yalpha1 = __lasx_xvreplgr2vr_w(yalpha1); + __m256i v_uvalpha = __lasx_xvreplgr2vr_w(uvalpha); + __m256i v_yalpha = __lasx_xvreplgr2vr_w(yalpha); + __m256i uv = __lasx_xvreplgr2vr_w(uvtemp); + __m256i a_bias = __lasx_xvreplgr2vr_w(atemp); + __m256i y_temp = __lasx_xvreplgr2vr_w(ytemp); + YUV2RGB_SETUP + + av_assert2(yalpha <= 4096U); + av_assert2(uvalpha <= 4096U); + + if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE + || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8) + step = 1; + + for (i = 0; i < len; i += 16) { + __m256i b0, b1, ub0, ub1, vb0, vb1; + __m256i y0_l, y0_h, y1_l, y1_h, u0_l, u0_h; + __m256i v0_l, v0_h, u1_l, u1_h, v1_l, v1_h; + __m256i y_l, y_h, v_l, v_h, u_l, u_h; + __m256i R_l, R_h, G_l, G_h, B_l, B_h; + int n = i << 1; + + DUP4_ARG2(__lasx_xvldx, buf0, n, buf1, n, ubuf0, + n, ubuf1, n, b0, b1, ub0, ub1); + DUP2_ARG2(__lasx_xvldx, vbuf0, n, vbuf1, n, vb0 , vb1); + DUP2_ARG2(__lasx_xvsllwil_w_h, b0, 0, b1, 0, y0_l, y1_l); + DUP4_ARG2(__lasx_xvsllwil_w_h, ub0, 0, ub1, 0, vb0, 0, vb1, 0, + u0_l, u1_l, v0_l, v1_l); + DUP2_ARG1(__lasx_xvexth_w_h, b0, b1, y0_h, y1_h); + DUP4_ARG1(__lasx_xvexth_w_h, ub0, ub1, vb0, vb1, + u0_h, u1_h, v0_h, v1_h); + y0_l = __lasx_xvmul_w(y0_l, v_yalpha1); + y0_h = __lasx_xvmul_w(y0_h, v_yalpha1); + u0_l = __lasx_xvmul_w(u0_l, v_uvalpha1); + u0_h = __lasx_xvmul_w(u0_h, v_uvalpha1); + v0_l = __lasx_xvmul_w(v0_l, v_uvalpha1); + v0_h = __lasx_xvmul_w(v0_h, v_uvalpha1); + y_l = __lasx_xvmadd_w(y0_l, v_yalpha, y1_l); + y_h = __lasx_xvmadd_w(y0_h, v_yalpha, y1_h); + u_l = __lasx_xvmadd_w(u0_l, v_uvalpha, u1_l); + u_h = __lasx_xvmadd_w(u0_h, v_uvalpha, u1_h); + v_l = __lasx_xvmadd_w(v0_l, v_uvalpha, v1_l); + v_h = __lasx_xvmadd_w(v0_h, v_uvalpha, v1_h); + u_l = __lasx_xvsub_w(u_l, uv); + u_h = __lasx_xvsub_w(u_h, uv); + v_l = __lasx_xvsub_w(v_l, uv); + v_h = __lasx_xvsub_w(v_h, uv); + y_l = __lasx_xvsrai_w(y_l, 10); + y_h = __lasx_xvsrai_w(y_h, 10); + u_l = __lasx_xvsrai_w(u_l, 10); + u_h = __lasx_xvsrai_w(u_h, 10); + v_l = __lasx_xvsrai_w(v_l, 10); + v_h = __lasx_xvsrai_w(v_h, 10); + YUV2RGB(y_l, u_l, v_l, R_l, G_l, B_l, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + YUV2RGB(y_h, u_h, v_h, R_h, G_h, B_h, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if (hasAlpha) { + __m256i a0, a1, a0_l, a0_h; + __m256i a_l, a_h, a1_l, a1_h; + + DUP2_ARG2(__lasx_xvldx, abuf0, n, abuf1, n, a0, a1); + DUP2_ARG2(__lasx_xvsllwil_w_h, a0, 0, a1, 0, a0_l, a1_l); + DUP2_ARG1(__lasx_xvexth_w_h, a0, a1, a0_h, a1_h); + a_l = __lasx_xvmadd_w(a_bias, a0_l, v_yalpha1); + a_h = __lasx_xvmadd_w(a_bias, a0_h, v_yalpha1); + a_l = __lasx_xvmadd_w(a_l, v_yalpha, a1_l); + a_h = __lasx_xvmadd_w(a_h, v_yalpha, a1_h); + a_l = __lasx_xvsrai_w(a_l, 19); + a_h = __lasx_xvsrai_w(a_h, 19); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 0, 0); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 1, 1); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 2, 2); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 3, 3); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 0, 4); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 1, 5); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 2, 6); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 3, 7); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 4, 8); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 5, 9); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 6, 10); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 7, 11); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 4, 12); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 5, 13); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 6, 14); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 7, 15); + } else { + WRITE_FULL(R_l, G_l, B_l, 0, 0); + WRITE_FULL(R_l, G_l, B_l, 1, 1); + WRITE_FULL(R_l, G_l, B_l, 2, 2); + WRITE_FULL(R_l, G_l, B_l, 3, 3); + WRITE_FULL(R_h, G_h, B_h, 0, 4); + WRITE_FULL(R_h, G_h, B_h, 1, 5); + WRITE_FULL(R_h, G_h, B_h, 2, 6); + WRITE_FULL(R_h, G_h, B_h, 3, 7); + WRITE_FULL(R_l, G_l, B_l, 4, 8); + WRITE_FULL(R_l, G_l, B_l, 5, 9); + WRITE_FULL(R_l, G_l, B_l, 6, 10); + WRITE_FULL(R_l, G_l, B_l, 7, 11); + WRITE_FULL(R_h, G_h, B_h, 4, 12); + WRITE_FULL(R_h, G_h, B_h, 5, 13); + WRITE_FULL(R_h, G_h, B_h, 6, 14); + WRITE_FULL(R_h, G_h, B_h, 7, 15); + } + } + if (dstW - i >= 8) { + __m256i b0, b1, ub0, ub1, vb0, vb1; + __m256i y0_l, y1_l, u0_l; + __m256i v0_l, u1_l, v1_l; + __m256i y_l, u_l, v_l; + __m256i R_l, G_l, B_l; + int n = i << 1; + + DUP4_ARG2(__lasx_xvldx, buf0, n, buf1, n, ubuf0, n, + ubuf1, n, b0, b1, ub0, ub1); + DUP2_ARG2(__lasx_xvldx, vbuf0, n, vbuf1, n, vb0, vb1); + DUP2_ARG1(__lasx_vext2xv_w_h, b0, b1, y0_l, y1_l); + DUP4_ARG1(__lasx_vext2xv_w_h, ub0, ub1, vb0, vb1, + u0_l, u1_l, v0_l, v1_l); + y0_l = __lasx_xvmul_w(y0_l, v_yalpha1); + u0_l = __lasx_xvmul_w(u0_l, v_uvalpha1); + v0_l = __lasx_xvmul_w(v0_l, v_uvalpha1); + y_l = __lasx_xvmadd_w(y0_l, v_yalpha, y1_l); + u_l = __lasx_xvmadd_w(u0_l, v_uvalpha, u1_l); + v_l = __lasx_xvmadd_w(v0_l, v_uvalpha, v1_l); + u_l = __lasx_xvsub_w(u_l, uv); + v_l = __lasx_xvsub_w(v_l, uv); + y_l = __lasx_xvsrai_w(y_l, 10); + u_l = __lasx_xvsrai_w(u_l, 10); + v_l = __lasx_xvsrai_w(v_l, 10); + YUV2RGB(y_l, u_l, v_l, R_l, G_l, B_l, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if (hasAlpha) { + __m256i a0, a1, a0_l; + __m256i a_l, a1_l; + + DUP2_ARG2(__lasx_xvldx, abuf0, n, abuf1, n, a0, a1); + DUP2_ARG1(__lasx_vext2xv_w_h, a0, a1, a0_l, a1_l); + a_l = __lasx_xvmadd_w(a_bias, a0_l, v_yalpha1); + a_l = __lasx_xvmadd_w(a_l, v_yalpha, a1_l); + a_l = __lasx_xvsrai_w(a_l, 19); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 0, 0); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 1, 1); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 2, 2); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 3, 3); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 4, 4); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 5, 5); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 6, 6); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 7, 7); + } else { + WRITE_FULL(R_l, G_l, B_l, 0, 0); + WRITE_FULL(R_l, G_l, B_l, 1, 1); + WRITE_FULL(R_l, G_l, B_l, 2, 2); + WRITE_FULL(R_l, G_l, B_l, 3, 3); + WRITE_FULL(R_l, G_l, B_l, 4, 4); + WRITE_FULL(R_l, G_l, B_l, 5, 5); + WRITE_FULL(R_l, G_l, B_l, 6, 6); + WRITE_FULL(R_l, G_l, B_l, 7, 7); + } + i += 8; + } + for (; i < dstW; i++){ + int Y = ( buf0[i] * yalpha1 + buf1[i] * yalpha ) >> 10; + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha- uvtemp) >> 10; + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha- uvtemp) >> 10; + + A = 0; + if (hasAlpha){ + A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha + atemp) >> 19; + if (A & 0x100) + A = av_clip_uint8(A); + } + + Y -= y_offset; + Y *= y_coeff; + Y += ytemp; + R = (unsigned)Y + V * v2r_coe; + G = (unsigned)Y + V * v2g_coe + U * u2g_coe; + B = (unsigned)Y + U * u2b_coe; + yuv2rgb_write_full(c, dest, i, R, A, G, B, y, target, hasAlpha, err); + dest += step; + } + c->dither_error[0][i] = err[0]; + c->dither_error[1][i] = err[1]; + c->dither_error[2][i] = err[2]; +} + +static void +yuv2rgb_full_1_template_lasx(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y, enum AVPixelFormat target, + int hasAlpha) +{ + const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; + int i, B, G, R, A; + int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4; + int err[4] = {0}; + int ytemp = 1 << 21; + int bias_int = 64; + int len = dstW - 15; + __m256i y_temp = __lasx_xvreplgr2vr_w(ytemp); + YUV2RGB_SETUP + + if( target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE + || target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8) + step = 1; + if (uvalpha < 2048) { + int uvtemp = 128 << 7; + __m256i uv = __lasx_xvreplgr2vr_w(uvtemp); + __m256i bias = __lasx_xvreplgr2vr_w(bias_int); + + for (i = 0; i < len; i += 16) { + __m256i b, ub, vb, ub_l, ub_h, vb_l, vb_h; + __m256i y_l, y_h, u_l, u_h, v_l, v_h; + __m256i R_l, R_h, G_l, G_h, B_l, B_h; + int n = i << 1; + + DUP2_ARG2(__lasx_xvldx, buf0, n, ubuf0, n, b, ub); + vb = __lasx_xvldx(vbuf0, n); + y_l = __lasx_xvsllwil_w_h(b, 2); + y_h = __lasx_xvexth_w_h(b); + DUP2_ARG2(__lasx_xvsllwil_w_h, ub, 0, vb, 0, ub_l, vb_l); + DUP2_ARG1(__lasx_xvexth_w_h, ub, vb, ub_h, vb_h); + y_h = __lasx_xvslli_w(y_h, 2); + u_l = __lasx_xvsub_w(ub_l, uv); + u_h = __lasx_xvsub_w(ub_h, uv); + v_l = __lasx_xvsub_w(vb_l, uv); + v_h = __lasx_xvsub_w(vb_h, uv); + u_l = __lasx_xvslli_w(u_l, 2); + u_h = __lasx_xvslli_w(u_h, 2); + v_l = __lasx_xvslli_w(v_l, 2); + v_h = __lasx_xvslli_w(v_h, 2); + YUV2RGB(y_l, u_l, v_l, R_l, G_l, B_l, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + YUV2RGB(y_h, u_h, v_h, R_h, G_h, B_h, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if(hasAlpha) { + __m256i a_src; + __m256i a_l, a_h; + + a_src = __lasx_xvld(abuf0 + i, 0); + a_l = __lasx_xvsllwil_w_h(a_src, 0); + a_h = __lasx_xvexth_w_h(a_src); + a_l = __lasx_xvadd_w(a_l, bias); + a_h = __lasx_xvadd_w(a_h, bias); + a_l = __lasx_xvsrai_w(a_l, 7); + a_h = __lasx_xvsrai_w(a_h, 7); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 0, 0); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 1, 1); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 2, 2); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 3, 3); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 0, 4); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 1, 5); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 2, 6); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 3, 7); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 4, 8); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 5, 9); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 6, 10); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 7, 11); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 4, 12); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 5, 13); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 6, 14); + WRITE_FULL_A(R_h, G_h, B_h, a_h, 7, 15); + } else { + WRITE_FULL(R_l, G_l, B_l, 0, 0); + WRITE_FULL(R_l, G_l, B_l, 1, 1); + WRITE_FULL(R_l, G_l, B_l, 2, 2); + WRITE_FULL(R_l, G_l, B_l, 3, 3); + WRITE_FULL(R_h, G_h, B_h, 0, 4); + WRITE_FULL(R_h, G_h, B_h, 1, 5); + WRITE_FULL(R_h, G_h, B_h, 2, 6); + WRITE_FULL(R_h, G_h, B_h, 3, 7); + WRITE_FULL(R_l, G_l, B_l, 4, 8); + WRITE_FULL(R_l, G_l, B_l, 5, 9); + WRITE_FULL(R_l, G_l, B_l, 6, 10); + WRITE_FULL(R_l, G_l, B_l, 7, 11); + WRITE_FULL(R_h, G_h, B_h, 4, 12); + WRITE_FULL(R_h, G_h, B_h, 5, 13); + WRITE_FULL(R_h, G_h, B_h, 6, 14); + WRITE_FULL(R_h, G_h, B_h, 7, 15); + } + } + if (dstW - i >= 8) { + __m256i b, ub, vb, ub_l, vb_l; + __m256i y_l, u_l, v_l; + __m256i R_l, G_l, B_l; + int n = i << 1; + + DUP2_ARG2(__lasx_xvldx, buf0, n, ubuf0, n, b, ub); + vb = __lasx_xvldx(vbuf0, n); + y_l = __lasx_vext2xv_w_h(b); + DUP2_ARG1(__lasx_vext2xv_w_h, ub, vb, ub_l, vb_l); + y_l = __lasx_xvslli_w(y_l, 2); + u_l = __lasx_xvsub_w(ub_l, uv); + v_l = __lasx_xvsub_w(vb_l, uv); + u_l = __lasx_xvslli_w(u_l, 2); + v_l = __lasx_xvslli_w(v_l, 2); + YUV2RGB(y_l, u_l, v_l, R_l, G_l, B_l, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if(hasAlpha) { + __m256i a_src, a_l; + + a_src = __lasx_xvldx(abuf0, n); + a_src = __lasx_vext2xv_w_h(a_src); + a_l = __lasx_xvadd_w(bias, a_src); + a_l = __lasx_xvsrai_w(a_l, 7); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 0, 0); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 1, 1); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 2, 2); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 3, 3); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 4, 4); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 5, 5); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 6, 6); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 7, 7); + } else { + WRITE_FULL(R_l, G_l, B_l, 0, 0); + WRITE_FULL(R_l, G_l, B_l, 1, 1); + WRITE_FULL(R_l, G_l, B_l, 2, 2); + WRITE_FULL(R_l, G_l, B_l, 3, 3); + WRITE_FULL(R_l, G_l, B_l, 4, 4); + WRITE_FULL(R_l, G_l, B_l, 5, 5); + WRITE_FULL(R_l, G_l, B_l, 6, 6); + WRITE_FULL(R_l, G_l, B_l, 7, 7); + } + i += 8; + } + for (; i < dstW; i++) { + int Y = buf0[i] << 2; + int U = (ubuf0[i] - uvtemp) << 2; + int V = (vbuf0[i] - uvtemp) << 2; + + A = 0; + if(hasAlpha) { + A = (abuf0[i] + 64) >> 7; + if (A & 0x100) + A = av_clip_uint8(A); + } + Y -= y_offset; + Y *= y_coeff; + Y += ytemp; + R = (unsigned)Y + V * v2r_coe; + G = (unsigned)Y + V * v2g_coe + U * u2g_coe; + B = (unsigned)Y + U * u2b_coe; + yuv2rgb_write_full(c, dest, i, R, A, G, B, y, target, hasAlpha, err); + dest += step; + } + } else { + const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1]; + int uvtemp = 128 << 8; + __m256i uv = __lasx_xvreplgr2vr_w(uvtemp); + __m256i zero = __lasx_xvldi(0); + __m256i bias = __lasx_xvreplgr2vr_h(bias_int); + + for (i = 0; i < len; i += 16) { + __m256i b, ub0, ub1, vb0, vb1; + __m256i y_ev, y_od, u_ev, u_od, v_ev, v_od; + __m256i R_ev, R_od, G_ev, G_od, B_ev, B_od; + int n = i << 1; + + DUP4_ARG2(__lasx_xvldx, buf0, n, ubuf0, n, vbuf0, n, + ubuf1, n, b, ub0, vb0, ub1); + vb1 = __lasx_xvldx(vbuf, n); + y_ev = __lasx_xvaddwev_w_h(b, zero); + y_od = __lasx_xvaddwod_w_h(b, zero); + DUP2_ARG2(__lasx_xvaddwev_w_h, ub0, vb0, ub1, vb1, u_ev, v_ev); + DUP2_ARG2(__lasx_xvaddwod_w_h, ub0, vb0, ub1, vb1, u_od, v_od); + DUP2_ARG2(__lasx_xvslli_w, y_ev, 2, y_od, 2, y_ev, y_od); + DUP4_ARG2(__lasx_xvsub_w, u_ev, uv, u_od, uv, v_ev, uv, v_od, uv, + u_ev, u_od, v_ev, v_od); + DUP4_ARG2(__lasx_xvslli_w, u_ev, 1, u_od, 1, v_ev, 1, v_od, 1, + u_ev, u_od, v_ev, v_od); + YUV2RGB(y_ev, u_ev, v_ev, R_ev, G_ev, B_ev, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + YUV2RGB(y_od, u_od, v_od, R_od, G_od, B_od, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if(hasAlpha) { + __m256i a_src; + __m256i a_ev, a_od; + + a_src = __lasx_xvld(abuf0 + i, 0); + a_ev = __lasx_xvaddwev_w_h(bias, a_src); + a_od = __lasx_xvaddwod_w_h(bias, a_src); + a_ev = __lasx_xvsrai_w(a_ev, 7); + a_od = __lasx_xvsrai_w(a_od, 7); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 0, 0); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 0, 1); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 1, 2); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 1, 3); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 2, 4); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 2, 5); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 3, 6); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 3, 7); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 4, 8); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 4, 9); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 5, 10); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 5, 11); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 6, 12); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 6, 13); + WRITE_FULL_A(R_ev, G_ev, B_ev, a_ev, 7, 14); + WRITE_FULL_A(R_od, G_od, B_od, a_od, 7, 15); + } else { + WRITE_FULL(R_ev, G_ev, B_ev, 0, 0); + WRITE_FULL(R_od, G_od, B_od, 0, 1); + WRITE_FULL(R_ev, G_ev, B_ev, 1, 2); + WRITE_FULL(R_od, G_od, B_od, 1, 3); + WRITE_FULL(R_ev, G_ev, B_ev, 2, 4); + WRITE_FULL(R_od, G_od, B_od, 2, 5); + WRITE_FULL(R_ev, G_ev, B_ev, 3, 6); + WRITE_FULL(R_od, G_od, B_od, 3, 7); + WRITE_FULL(R_ev, G_ev, B_ev, 4, 8); + WRITE_FULL(R_od, G_od, B_od, 4, 9); + WRITE_FULL(R_ev, G_ev, B_ev, 5, 10); + WRITE_FULL(R_od, G_od, B_od, 5, 11); + WRITE_FULL(R_ev, G_ev, B_ev, 6, 12); + WRITE_FULL(R_od, G_od, B_od, 6, 13); + WRITE_FULL(R_ev, G_ev, B_ev, 7, 14); + WRITE_FULL(R_od, G_od, B_od, 7, 15); + } + } + if (dstW - i >= 8) { + __m256i b, ub0, ub1, vb0, vb1; + __m256i y_l, u_l, v_l; + __m256i R_l, G_l, B_l; + int n = i << 1; + + DUP4_ARG2(__lasx_xvldx, buf0, n, ubuf0, n, vbuf0, n, + ubuf1, n, b, ub0, vb0, ub1); + vb1 = __lasx_xvldx(vbuf1, n); + y_l = __lasx_vext2xv_w_h(b); + y_l = __lasx_xvslli_w(y_l, 2); + DUP4_ARG1(__lasx_vext2xv_w_h, ub0, vb0, ub1, vb1, + ub0, vb0, ub1, vb1); + DUP2_ARG2(__lasx_xvadd_w, ub0, ub1, vb0, vb1, u_l, v_l); + u_l = __lasx_xvsub_w(u_l, uv); + v_l = __lasx_xvsub_w(v_l, uv); + u_l = __lasx_xvslli_w(u_l, 1); + v_l = __lasx_xvslli_w(v_l, 1); + YUV2RGB(y_l, u_l, v_l, R_l, G_l, B_l, offset, coeff, + y_temp, v2r, v2g, u2g, u2b); + + if(hasAlpha) { + __m256i a_src; + __m256i a_l; + + a_src = __lasx_xvld(abuf0 + i, 0); + a_src = __lasx_xvpermi_d(a_src, 0xD8); + a_src = __lasx_xvilvl_h(a_src, a_src); + a_l = __lasx_xvaddwev_w_h(bias, a_src); + a_l = __lasx_xvsrai_w(a_l, 7); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 0, 0); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 1, 1); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 2, 2); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 3, 3); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 4, 4); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 5, 5); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 6, 6); + WRITE_FULL_A(R_l, G_l, B_l, a_l, 7, 7); + } else { + WRITE_FULL(R_l, G_l, B_l, 0, 0); + WRITE_FULL(R_l, G_l, B_l, 1, 1); + WRITE_FULL(R_l, G_l, B_l, 2, 2); + WRITE_FULL(R_l, G_l, B_l, 3, 3); + WRITE_FULL(R_l, G_l, B_l, 4, 4); + WRITE_FULL(R_l, G_l, B_l, 5, 5); + WRITE_FULL(R_l, G_l, B_l, 6, 6); + WRITE_FULL(R_l, G_l, B_l, 7, 7); + } + i += 8; + } + for (; i < dstW; i++) { + int Y = buf0[i] << 2; + int U = (ubuf0[i] + ubuf1[i] - uvtemp) << 1; + int V = (vbuf0[i] + vbuf1[i] - uvtemp) << 1; + + A = 0; + if(hasAlpha) { + A = (abuf0[i] + 64) >> 7; + if (A & 0x100) + A = av_clip_uint8(A); + } + Y -= y_offset; + Y *= y_coeff; + Y += ytemp; + R = (unsigned)Y + V * v2r_coe; + G = (unsigned)Y + V * v2g_coe + U * u2g_coe; + B = (unsigned)Y + U * u2b_coe; + yuv2rgb_write_full(c, dest, i, R, A, G, B, y, target, hasAlpha, err); + dest += step; + } + } + c->dither_error[0][i] = err[0]; + c->dither_error[1][i] = err[1]; + c->dither_error[2][i] = err[2]; +} +#if CONFIG_SMALL +YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, + CONFIG_SWSCALE_ALPHA && c->needAlpha) +YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, + CONFIG_SWSCALE_ALPHA && c->needAlpha) +YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, + CONFIG_SWSCALE_ALPHA && c->needAlpha) +YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, + CONFIG_SWSCALE_ALPHA && c->needAlpha) +#else +#if CONFIG_SWSCALE_ALPHA +YUV2RGBWRAPPER(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1) +YUV2RGBWRAPPER(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, 1) +YUV2RGBWRAPPER(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, 1) +YUV2RGBWRAPPER(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, 1) +#endif +YUV2RGBWRAPPER(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0) +#endif +YUV2RGBWRAPPER(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0) + +YUV2RGBWRAPPER(yuv2, rgb_full, bgr4_byte_full, AV_PIX_FMT_BGR4_BYTE, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, rgb4_byte_full, AV_PIX_FMT_RGB4_BYTE, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, bgr8_full, AV_PIX_FMT_BGR8, 0) +YUV2RGBWRAPPER(yuv2, rgb_full, rgb8_full, AV_PIX_FMT_RGB8, 0) +#undef yuvTorgb +#undef yuvTorgb_setup + + +av_cold void ff_sws_init_output_loongarch(SwsContext *c) +{ + + if(c->flags & SWS_FULL_CHR_H_INT) { + switch (c->dstFormat) { + case AV_PIX_FMT_RGBA: +#if CONFIG_SMALL + c->yuv2packedX = yuv2rgba32_full_X_lasx; + c->yuv2packed2 = yuv2rgba32_full_2_lasx; + c->yuv2packed1 = yuv2rgba32_full_1_lasx; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->needAlpha) { + c->yuv2packedX = yuv2rgba32_full_X_lasx; + c->yuv2packed2 = yuv2rgba32_full_2_lasx; + c->yuv2packed1 = yuv2rgba32_full_1_lasx; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + c->yuv2packedX = yuv2rgbx32_full_X_lasx; + c->yuv2packed2 = yuv2rgbx32_full_2_lasx; + c->yuv2packed1 = yuv2rgbx32_full_1_lasx; + } +#endif /* !CONFIG_SMALL */ + break; + case AV_PIX_FMT_ARGB: +#if CONFIG_SMALL + c->yuv2packedX = yuv2argb32_full_X_lasx; + c->yuv2packed2 = yuv2argb32_full_2_lasx; + c->yuv2packed1 = yuv2argb32_full_1_lasx; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->needAlpha) { + c->yuv2packedX = yuv2argb32_full_X_lasx; + c->yuv2packed2 = yuv2argb32_full_2_lasx; + c->yuv2packed1 = yuv2argb32_full_1_lasx; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + c->yuv2packedX = yuv2xrgb32_full_X_lasx; + c->yuv2packed2 = yuv2xrgb32_full_2_lasx; + c->yuv2packed1 = yuv2xrgb32_full_1_lasx; + } +#endif /* !CONFIG_SMALL */ + break; + case AV_PIX_FMT_BGRA: +#if CONFIG_SMALL + c->yuv2packedX = yuv2bgra32_full_X_lasx; + c->yuv2packed2 = yuv2bgra32_full_2_lasx; + c->yuv2packed1 = yuv2bgra32_full_1_lasx; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->needAlpha) { + c->yuv2packedX = yuv2bgra32_full_X_lasx; + c->yuv2packed2 = yuv2bgra32_full_2_lasx; + c->yuv2packed1 = yuv2bgra32_full_1_lasx; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + c->yuv2packedX = yuv2bgrx32_full_X_lasx; + c->yuv2packed2 = yuv2bgrx32_full_2_lasx; + c->yuv2packed1 = yuv2bgrx32_full_1_lasx; + } +#endif /* !CONFIG_SMALL */ + break; + case AV_PIX_FMT_ABGR: +#if CONFIG_SMALL + c->yuv2packedX = yuv2abgr32_full_X_lasx; + c->yuv2packed2 = yuv2abgr32_full_2_lasx; + c->yuv2packed1 = yuv2abgr32_full_1_lasx; +#else +#if CONFIG_SWSCALE_ALPHA + if (c->needAlpha) { + c->yuv2packedX = yuv2abgr32_full_X_lasx; + c->yuv2packed2 = yuv2abgr32_full_2_lasx; + c->yuv2packed1 = yuv2abgr32_full_1_lasx; + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + c->yuv2packedX = yuv2xbgr32_full_X_lasx; + c->yuv2packed2 = yuv2xbgr32_full_2_lasx; + c->yuv2packed1 = yuv2xbgr32_full_1_lasx; + } +#endif /* !CONFIG_SMALL */ + break; + case AV_PIX_FMT_RGB24: + c->yuv2packedX = yuv2rgb24_full_X_lasx; + c->yuv2packed2 = yuv2rgb24_full_2_lasx; + c->yuv2packed1 = yuv2rgb24_full_1_lasx; + break; + case AV_PIX_FMT_BGR24: + c->yuv2packedX = yuv2bgr24_full_X_lasx; + c->yuv2packed2 = yuv2bgr24_full_2_lasx; + c->yuv2packed1 = yuv2bgr24_full_1_lasx; + break; + case AV_PIX_FMT_BGR4_BYTE: + c->yuv2packedX = yuv2bgr4_byte_full_X_lasx; + c->yuv2packed2 = yuv2bgr4_byte_full_2_lasx; + c->yuv2packed1 = yuv2bgr4_byte_full_1_lasx; + break; + case AV_PIX_FMT_RGB4_BYTE: + c->yuv2packedX = yuv2rgb4_byte_full_X_lasx; + c->yuv2packed2 = yuv2rgb4_byte_full_2_lasx; + c->yuv2packed1 = yuv2rgb4_byte_full_1_lasx; + break; + case AV_PIX_FMT_BGR8: + c->yuv2packedX = yuv2bgr8_full_X_lasx; + c->yuv2packed2 = yuv2bgr8_full_2_lasx; + c->yuv2packed1 = yuv2bgr8_full_1_lasx; + break; + case AV_PIX_FMT_RGB8: + c->yuv2packedX = yuv2rgb8_full_X_lasx; + c->yuv2packed2 = yuv2rgb8_full_2_lasx; + c->yuv2packed1 = yuv2rgb8_full_1_lasx; + break; + } + } else { + switch (c->dstFormat) { + case AV_PIX_FMT_RGB32: + case AV_PIX_FMT_BGR32: +#if CONFIG_SMALL +#else +#if CONFIG_SWSCALE_ALPHA + if (c->needAlpha) { + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + c->yuv2packed1 = yuv2rgbx32_1_lasx; + c->yuv2packed2 = yuv2rgbx32_2_lasx; + c->yuv2packedX = yuv2rgbx32_X_lasx; + } +#endif /* !CONFIG_SMALL */ + break; + case AV_PIX_FMT_RGB32_1: + case AV_PIX_FMT_BGR32_1: +#if CONFIG_SMALL +#else +#if CONFIG_SWSCALE_ALPHA + if (c->needAlpha) { + } else +#endif /* CONFIG_SWSCALE_ALPHA */ + { + c->yuv2packed1 = yuv2rgbx32_1_1_lasx; + c->yuv2packed2 = yuv2rgbx32_1_2_lasx; + c->yuv2packedX = yuv2rgbx32_1_X_lasx; + } +#endif /* !CONFIG_SMALL */ + break; + case AV_PIX_FMT_RGB24: + c->yuv2packed1 = yuv2rgb24_1_lasx; + c->yuv2packed2 = yuv2rgb24_2_lasx; + c->yuv2packedX = yuv2rgb24_X_lasx; + break; + case AV_PIX_FMT_BGR24: + c->yuv2packed1 = yuv2bgr24_1_lasx; + c->yuv2packed2 = yuv2bgr24_2_lasx; + c->yuv2packedX = yuv2bgr24_X_lasx; + break; + case AV_PIX_FMT_RGB565LE: + case AV_PIX_FMT_RGB565BE: + case AV_PIX_FMT_BGR565LE: + case AV_PIX_FMT_BGR565BE: + c->yuv2packed1 = yuv2rgb16_1_lasx; + c->yuv2packed2 = yuv2rgb16_2_lasx; + c->yuv2packedX = yuv2rgb16_X_lasx; + break; + case AV_PIX_FMT_RGB555LE: + case AV_PIX_FMT_RGB555BE: + case AV_PIX_FMT_BGR555LE: + case AV_PIX_FMT_BGR555BE: + c->yuv2packed1 = yuv2rgb15_1_lasx; + c->yuv2packed2 = yuv2rgb15_2_lasx; + c->yuv2packedX = yuv2rgb15_X_lasx; + break; + case AV_PIX_FMT_RGB444LE: + case AV_PIX_FMT_RGB444BE: + case AV_PIX_FMT_BGR444LE: + case AV_PIX_FMT_BGR444BE: + c->yuv2packed1 = yuv2rgb12_1_lasx; + c->yuv2packed2 = yuv2rgb12_2_lasx; + c->yuv2packedX = yuv2rgb12_X_lasx; + break; + case AV_PIX_FMT_RGB8: + case AV_PIX_FMT_BGR8: + c->yuv2packed1 = yuv2rgb8_1_lasx; + c->yuv2packed2 = yuv2rgb8_2_lasx; + c->yuv2packedX = yuv2rgb8_X_lasx; + break; + case AV_PIX_FMT_RGB4: + case AV_PIX_FMT_BGR4: + c->yuv2packed1 = yuv2rgb4_1_lasx; + c->yuv2packed2 = yuv2rgb4_2_lasx; + c->yuv2packedX = yuv2rgb4_X_lasx; + break; + case AV_PIX_FMT_RGB4_BYTE: + case AV_PIX_FMT_BGR4_BYTE: + c->yuv2packed1 = yuv2rgb4b_1_lasx; + c->yuv2packed2 = yuv2rgb4b_2_lasx; + c->yuv2packedX = yuv2rgb4b_X_lasx; + break; + } + } +} diff --git a/libswscale/loongarch/swscale_init_loongarch.c b/libswscale/loongarch/swscale_init_loongarch.c index 1e0bb1b116..97fe947e2e 100644 --- a/libswscale/loongarch/swscale_init_loongarch.c +++ b/libswscale/loongarch/swscale_init_loongarch.c @@ -28,6 +28,7 @@ av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); if (have_lasx(cpu_flags)) { + ff_sws_init_output_loongarch(c); if (c->srcBpc == 8) { if (c->dstBpc <= 14) { c->hyScale = c->hcScale = ff_hscale_8_to_15_lasx; @@ -47,6 +48,8 @@ av_cold void ff_sws_init_swscale_loongarch(SwsContext *c) } break; } + if (c->dstBpc == 8) + c->yuv2planeX = ff_yuv2planeX_8_lasx; } } diff --git a/libswscale/loongarch/swscale_loongarch.h b/libswscale/loongarch/swscale_loongarch.h index f5afbd7633..c52eb1016b 100644 --- a/libswscale/loongarch/swscale_loongarch.h +++ b/libswscale/loongarch/swscale_loongarch.h @@ -69,4 +69,10 @@ void ff_interleave_bytes_lasx(const uint8_t *src1, const uint8_t *src2, uint8_t *dest, int width, int height, int src1Stride, int src2Stride, int dstStride); +av_cold void ff_sws_init_output_loongarch(SwsContext *c); + +void ff_yuv2planeX_8_lasx(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset); + #endif /* SWSCALE_LOONGARCH_SWSCALE_LOONGARCH_H */ From f1b35fc8f01b3882490f626a18fcf0b407d41848 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 11 Sep 2022 03:16:43 +0200 Subject: [PATCH 232/590] lavu/tx: remove av_cold from table definitions How did this get here? --- libavutil/tx_template.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c index 0c7ddd26f6..5e7159bd87 100644 --- a/libavutil/tx_template.c +++ b/libavutil/tx_template.c @@ -104,7 +104,7 @@ static FFSRTabsInitOnce sr_tabs_init_once[] = { { TX_TAB(ff_tx_init_tab_131072), AV_ONCE_INIT }, }; -static av_cold void TX_TAB(ff_tx_init_tab_53)(void) +static void TX_TAB(ff_tx_init_tab_53)(void) { TX_TAB(ff_tx_tab_53)[0] = RESCALE(cos(2 * M_PI / 12)); TX_TAB(ff_tx_tab_53)[1] = RESCALE(cos(2 * M_PI / 12)); @@ -116,7 +116,7 @@ static av_cold void TX_TAB(ff_tx_init_tab_53)(void) TX_TAB(ff_tx_tab_53)[7] = RESCALE(sin(6 * M_PI / 5)); } -static av_cold void TX_TAB(ff_tx_init_tab_7)(void) +static void TX_TAB(ff_tx_init_tab_7)(void) { TX_TAB(ff_tx_tab_7)[0] = RESCALE(cos(2 * M_PI / 7)); TX_TAB(ff_tx_tab_7)[1] = RESCALE(sin(2 * M_PI / 7)); @@ -126,7 +126,7 @@ static av_cold void TX_TAB(ff_tx_init_tab_7)(void) TX_TAB(ff_tx_tab_7)[5] = RESCALE(sin(2 * M_PI / 14)); } -static av_cold void TX_TAB(ff_tx_init_tab_9)(void) +static void TX_TAB(ff_tx_init_tab_9)(void) { TX_TAB(ff_tx_tab_9)[0] = RESCALE(cos(2 * M_PI / 3)); TX_TAB(ff_tx_tab_9)[1] = RESCALE(sin(2 * M_PI / 3)); From 60d8c2019f59fcbeb597c900a56c8c4cd9ec8838 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sat, 10 Sep 2022 00:36:34 -0300 Subject: [PATCH 233/590] avformat/riffdec: don't unconditionally overwrite WAVEFORMATEXTENSIBLE layout Do it only if the value conflicts with the previous channels value. Fixes ticket #9912 Signed-off-by: James Almer --- libavformat/riffdec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 3946ecb72f..c1e4a04550 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -102,6 +102,8 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, return AVERROR_INVALIDDATA; } + av_channel_layout_uninit(&par->ch_layout); + par->codec_type = AVMEDIA_TYPE_AUDIO; if (!big_endian) { id = avio_rl16(pb); @@ -189,9 +191,12 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, if (par->codec_id == AV_CODEC_ID_ADPCM_G726 && par->sample_rate) par->bits_per_coded_sample = par->bit_rate / par->sample_rate; - av_channel_layout_uninit(&par->ch_layout); - par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; - par->ch_layout.nb_channels = channels; + /* ignore WAVEFORMATEXTENSIBLE layout if different from channel count */ + if (channels != par->ch_layout.nb_channels) { + av_channel_layout_uninit(&par->ch_layout); + par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + par->ch_layout.nb_channels = channels; + } return 0; } From 361c8753407cc91b462090e90bd0f78f0c2e2664 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 9 Sep 2022 01:23:21 +0200 Subject: [PATCH 234/590] avcodec/vp8: Remove unused macros Reviewed-by: Peter Ross Signed-off-by: Andreas Rheinhardt --- libavcodec/vp8.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 0e16e75faa..f83a0d66bb 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -44,14 +44,6 @@ # include "arm/vp8.h" #endif -#if CONFIG_VP7_DECODER && CONFIG_VP8_DECODER -#define VPX(vp7, f) (vp7 ? vp7_ ## f : vp8_ ## f) -#elif CONFIG_VP7_DECODER -#define VPX(vp7, f) vp7_ ## f -#else // CONFIG_VP8_DECODER -#define VPX(vp7, f) vp8_ ## f -#endif - // fixme: add 1 bit to all the calls to this? static int vp8_rac_get_sint(VPXRangeCoder *c, int bits) { From b3591ccdf1f364ecea1f0d4b5777d1818e2ec13e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 10 Sep 2022 00:02:46 +0200 Subject: [PATCH 235/590] avcodec/vp8dsp: Remove declarations of inexistent functions Forgotten in d6f8476be4895c620d58e021ab880823d2fe25bf. Reviewed-by: Peter Ross Reviewed-by: Ronald S. Bultje Signed-off-by: Andreas Rheinhardt --- libavcodec/vp8dsp.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libavcodec/vp8dsp.h b/libavcodec/vp8dsp.h index 7c6208df39..bbd7f60a4f 100644 --- a/libavcodec/vp8dsp.h +++ b/libavcodec/vp8dsp.h @@ -81,13 +81,6 @@ typedef struct VP8DSPContext { vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3]; } VP8DSPContext; -void ff_put_vp8_pixels16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride, - int h, int x, int y); -void ff_put_vp8_pixels8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride, - int h, int x, int y); -void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride, - int h, int x, int y); - void ff_vp7dsp_init(VP8DSPContext *c); void ff_vp78dsp_init(VP8DSPContext *c); From 4130789f4f20e67ef44f8c721955c5e3bcbc1b09 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 9 Sep 2022 17:17:15 +0200 Subject: [PATCH 236/590] avcodec/vp8: Move fade_present from context to stack It is only an auxiliary value used for parsing the VP7 frame header. Reviewed-by: Peter Ross Reviewed-by: Ronald S. Bultje Signed-off-by: Andreas Rheinhardt --- libavcodec/vp8.c | 6 +++--- libavcodec/vp8.h | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index f83a0d66bb..07ea3c6dd1 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -580,6 +580,7 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si int height = s->avctx->height; int alpha = 0; int beta = 0; + int fade_present = 1; if (buf_size < 4) { return AVERROR_INVALIDDATA; @@ -681,7 +682,6 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si s->update_last = 1; s->update_probabilities = 1; - s->fade_present = 1; if (s->profile > 0) { s->update_probabilities = vp89_rac_get(c); @@ -689,13 +689,13 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si s->prob[1] = s->prob[0]; if (!s->keyframe) - s->fade_present = vp89_rac_get(c); + fade_present = vp89_rac_get(c); } if (vpx_rac_is_end(c)) return AVERROR_INVALIDDATA; /* E. Fading information for previous frame */ - if (s->fade_present && vp89_rac_get(c)) { + if (fade_present && vp89_rac_get(c)) { alpha = (int8_t) vp89_rac_get_uint(c, 8); beta = (int8_t) vp89_rac_get_uint(c, 8); } diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h index 30aeb4cb06..6f29156b53 100644 --- a/libavcodec/vp8.h +++ b/libavcodec/vp8.h @@ -335,11 +335,6 @@ typedef struct VP8Context { int vp7; - /** - * Fade bit present in bitstream (VP7) - */ - int fade_present; - /** * Interframe DC prediction (VP7) * [0] VP8_FRAME_PREVIOUS From a54e53a1c428299b19c7b4e2b66d01c0482c41dd Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 10 Sep 2022 00:44:22 +0200 Subject: [PATCH 237/590] avcodec/vp8dsp: Constify src in vp8_mc_func Reviewed-by: Peter Ross Reviewed-by: Ronald S. Bultje Signed-off-by: Andreas Rheinhardt --- libavcodec/aarch64/vp8dsp.h | 2 +- libavcodec/arm/vp8dsp.h | 2 +- libavcodec/arm/vp8dsp_armv6.S | 6 +- libavcodec/loongarch/vp8_mc_lsx.c | 31 ++--- libavcodec/loongarch/vp8dsp_loongarch.h | 28 ++--- libavcodec/mips/vp8_mc_msa.c | 110 +++++++++--------- libavcodec/mips/vp8dsp_mips.h | 144 ++++++++++++------------ libavcodec/ppc/vp8dsp_altivec.c | 12 +- libavcodec/vp8dsp.c | 14 +-- libavcodec/vp8dsp.h | 2 +- libavcodec/x86/vp8dsp.asm | 2 +- libavcodec/x86/vp8dsp_init.c | 58 +++++----- 12 files changed, 206 insertions(+), 205 deletions(-) diff --git a/libavcodec/aarch64/vp8dsp.h b/libavcodec/aarch64/vp8dsp.h index 871fed7a95..4e59de28b1 100644 --- a/libavcodec/aarch64/vp8dsp.h +++ b/libavcodec/aarch64/vp8dsp.h @@ -53,7 +53,7 @@ #define VP8_MC(n, opt) \ void ff_put_vp8_##n##_##opt(uint8_t *dst, ptrdiff_t dststride, \ - uint8_t *src, ptrdiff_t srcstride, \ + const uint8_t *src, ptrdiff_t srcstride,\ int h, int x, int y) #define VP8_EPEL(w, opt) \ diff --git a/libavcodec/arm/vp8dsp.h b/libavcodec/arm/vp8dsp.h index 7281d0bfb1..11dcc78d7a 100644 --- a/libavcodec/arm/vp8dsp.h +++ b/libavcodec/arm/vp8dsp.h @@ -58,7 +58,7 @@ void ff_vp8dsp_init_neon(VP8DSPContext *dsp); #define VP8_MC(n, opt) \ void ff_put_vp8_##n##_##opt(uint8_t *dst, ptrdiff_t dststride, \ - uint8_t *src, ptrdiff_t srcstride, \ + const uint8_t *src, ptrdiff_t srcstride,\ int h, int x, int y) #define VP8_EPEL(w, opt) \ diff --git a/libavcodec/arm/vp8dsp_armv6.S b/libavcodec/arm/vp8dsp_armv6.S index 2320bf4d23..395debe866 100644 --- a/libavcodec/arm/vp8dsp_armv6.S +++ b/libavcodec/arm/vp8dsp_armv6.S @@ -1113,7 +1113,7 @@ endfunc @ MC -@ void put_vp8_pixels16(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +@ void put_vp8_pixels16(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, @ ptrdiff_t srcstride, int h, int mx, int my) function ff_put_vp8_pixels16_armv6, export=1 push {r4-r11} @@ -1137,7 +1137,7 @@ function ff_put_vp8_pixels16_armv6, export=1 bx lr endfunc -@ void put_vp8_pixels8(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +@ void put_vp8_pixels8(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, @ ptrdiff_t srcstride, int h, int mx, int my) function ff_put_vp8_pixels8_armv6, export=1 push {r4-r11} @@ -1161,7 +1161,7 @@ function ff_put_vp8_pixels8_armv6, export=1 bx lr endfunc -@ void put_vp8_pixels4(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +@ void put_vp8_pixels4(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, @ ptrdiff_t srcstride, int h, int mx, int my) function ff_put_vp8_pixels4_armv6, export=1 ldr r12, [sp, #0] @ h diff --git a/libavcodec/loongarch/vp8_mc_lsx.c b/libavcodec/loongarch/vp8_mc_lsx.c index 80c4f87e80..034d84cc5d 100644 --- a/libavcodec/loongarch/vp8_mc_lsx.c +++ b/libavcodec/loongarch/vp8_mc_lsx.c @@ -122,7 +122,7 @@ static const int8_t subpel_filters_lsx[7][8] = { } ) void ff_put_vp8_epel8_h6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -187,7 +187,7 @@ void ff_put_vp8_epel8_h6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -241,7 +241,7 @@ void ff_put_vp8_epel16_h6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -308,7 +308,7 @@ void ff_put_vp8_epel8_v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -389,7 +389,7 @@ void ff_put_vp8_epel16_v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h6v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -491,7 +491,7 @@ void ff_put_vp8_epel8_h6v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h6v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -504,7 +504,7 @@ void ff_put_vp8_epel16_h6v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -561,7 +561,7 @@ void ff_put_vp8_epel8_v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -631,7 +631,7 @@ void ff_put_vp8_epel16_v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h6v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -714,7 +714,7 @@ void ff_put_vp8_epel8_h6v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h6v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -728,7 +728,7 @@ void ff_put_vp8_epel16_h6v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h4v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -818,7 +818,7 @@ void ff_put_vp8_epel8_h4v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h4v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -832,7 +832,7 @@ void ff_put_vp8_epel16_h4v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_pixels8_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t cnt; @@ -889,12 +889,13 @@ void ff_put_vp8_pixels8_lsx(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_pixels16_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t width = 16; int32_t cnt, loop_cnt; - uint8_t *src_tmp, *dst_tmp; + const uint8_t *src_tmp; + uint8_t *dst_tmp; __m128i src0, src1, src2, src3, src4, src5, src6, src7; ptrdiff_t src_stride2 = src_stride << 1; diff --git a/libavcodec/loongarch/vp8dsp_loongarch.h b/libavcodec/loongarch/vp8dsp_loongarch.h index 87e9509db9..09c7e1f91d 100644 --- a/libavcodec/loongarch/vp8dsp_loongarch.h +++ b/libavcodec/loongarch/vp8dsp_loongarch.h @@ -25,49 +25,49 @@ #include "libavcodec/vp8dsp.h" void ff_put_vp8_pixels8_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int x, int y); void ff_put_vp8_pixels16_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int x, int y); void ff_put_vp8_epel16_h6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel16_v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel16_v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel16_h6v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel16_h4v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel16_h6v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel8_v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel8_v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel8_h6v4_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel8_h4v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel8_h6v6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); void ff_put_vp8_epel8_h6_lsx(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my); /* loop filter */ diff --git a/libavcodec/mips/vp8_mc_msa.c b/libavcodec/mips/vp8_mc_msa.c index a61320625a..be1997f7dd 100644 --- a/libavcodec/mips/vp8_mc_msa.c +++ b/libavcodec/mips/vp8_mc_msa.c @@ -156,7 +156,7 @@ static const int8_t bilinear_filters_msa[7][2] = { out0, out1, out2, out3); \ } -static void common_hz_6t_4x4_msa(uint8_t *src, int32_t src_stride, +static void common_hz_6t_4x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -184,7 +184,7 @@ static void common_hz_6t_4x4_msa(uint8_t *src, int32_t src_stride, ST_W4(out, 0, 1, 2, 3, dst, dst_stride); } -static void common_hz_6t_4x8_msa(uint8_t *src, int32_t src_stride, +static void common_hz_6t_4x8_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -220,7 +220,7 @@ static void common_hz_6t_4x8_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_epel4_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter = subpel_filters_msa[mx - 1]; @@ -233,7 +233,7 @@ void ff_put_vp8_epel4_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -281,7 +281,7 @@ void ff_put_vp8_epel8_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -330,7 +330,7 @@ void ff_put_vp8_epel16_h6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel4_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -377,7 +377,7 @@ void ff_put_vp8_epel4_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -427,7 +427,7 @@ void ff_put_vp8_epel8_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -501,7 +501,7 @@ void ff_put_vp8_epel16_v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel4_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -576,7 +576,7 @@ void ff_put_vp8_epel4_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -663,7 +663,7 @@ void ff_put_vp8_epel8_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, void ff_put_vp8_epel16_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -677,7 +677,7 @@ void ff_put_vp8_epel16_h6v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_hz_4t_4x4_msa(uint8_t *src, int32_t src_stride, +static void common_hz_4t_4x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -704,7 +704,7 @@ static void common_hz_4t_4x4_msa(uint8_t *src, int32_t src_stride, ST_W4(out, 0, 1, 2, 3, dst, dst_stride); } -static void common_hz_4t_4x8_msa(uint8_t *src, int32_t src_stride, +static void common_hz_4t_4x8_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -739,7 +739,7 @@ static void common_hz_4t_4x8_msa(uint8_t *src, int32_t src_stride, ST_W4(out, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride); } -static void common_hz_4t_4x16_msa(uint8_t *src, int32_t src_stride, +static void common_hz_4t_4x16_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -790,7 +790,7 @@ static void common_hz_4t_4x16_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_epel4_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter = subpel_filters_msa[mx - 1]; @@ -805,7 +805,7 @@ void ff_put_vp8_epel4_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -840,7 +840,7 @@ void ff_put_vp8_epel8_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -889,7 +889,7 @@ void ff_put_vp8_epel16_h4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel4_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -936,7 +936,7 @@ void ff_put_vp8_epel4_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -982,7 +982,7 @@ void ff_put_vp8_epel8_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1041,7 +1041,7 @@ void ff_put_vp8_epel16_v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel4_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1100,7 +1100,7 @@ void ff_put_vp8_epel4_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1167,7 +1167,7 @@ void ff_put_vp8_epel8_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -1182,7 +1182,7 @@ void ff_put_vp8_epel16_h4v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel4_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1248,7 +1248,7 @@ void ff_put_vp8_epel4_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1321,7 +1321,7 @@ void ff_put_vp8_epel8_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -1336,7 +1336,7 @@ void ff_put_vp8_epel16_h6v4_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel4_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1400,7 +1400,7 @@ void ff_put_vp8_epel4_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel8_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1475,7 +1475,7 @@ void ff_put_vp8_epel8_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_epel16_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t multiple8_cnt; @@ -1489,7 +1489,7 @@ void ff_put_vp8_epel16_h4v6_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_hz_2t_4x4_msa(uint8_t *src, int32_t src_stride, +static void common_hz_2t_4x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -1512,7 +1512,7 @@ static void common_hz_2t_4x4_msa(uint8_t *src, int32_t src_stride, ST_W2(res1, 0, 1, dst + 2 * dst_stride, dst_stride); } -static void common_hz_2t_4x8_msa(uint8_t *src, int32_t src_stride, +static void common_hz_2t_4x8_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -1542,7 +1542,7 @@ static void common_hz_2t_4x8_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_bilinear4_h_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter = bilinear_filters_msa[mx - 1]; @@ -1554,7 +1554,7 @@ void ff_put_vp8_bilinear4_h_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_hz_2t_8x4_msa(uint8_t *src, int32_t src_stride, +static void common_hz_2t_8x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -1578,7 +1578,7 @@ static void common_hz_2t_8x4_msa(uint8_t *src, int32_t src_stride, ST_D4(src0, src1, 0, 1, 0, 1, dst, dst_stride); } -static void common_hz_2t_8x8mult_msa(uint8_t *src, int32_t src_stride, +static void common_hz_2t_8x8mult_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter, int32_t height) { @@ -1642,7 +1642,7 @@ static void common_hz_2t_8x8mult_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_bilinear8_h_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter = bilinear_filters_msa[mx - 1]; @@ -1656,7 +1656,7 @@ void ff_put_vp8_bilinear8_h_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_bilinear16_h_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1722,7 +1722,7 @@ void ff_put_vp8_bilinear16_h_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_vt_2t_4x4_msa(uint8_t *src, int32_t src_stride, +static void common_vt_2t_4x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -1748,7 +1748,7 @@ static void common_vt_2t_4x4_msa(uint8_t *src, int32_t src_stride, ST_W4(src2110, 0, 1, 2, 3, dst, dst_stride); } -static void common_vt_2t_4x8_msa(uint8_t *src, int32_t src_stride, +static void common_vt_2t_4x8_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -1783,7 +1783,7 @@ static void common_vt_2t_4x8_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_bilinear4_v_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter = bilinear_filters_msa[my - 1]; @@ -1795,7 +1795,7 @@ void ff_put_vp8_bilinear4_v_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_vt_2t_8x4_msa(uint8_t *src, int32_t src_stride, +static void common_vt_2t_8x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter) { @@ -1819,7 +1819,7 @@ static void common_vt_2t_8x4_msa(uint8_t *src, int32_t src_stride, ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); } -static void common_vt_2t_8x8mult_msa(uint8_t *src, int32_t src_stride, +static void common_vt_2t_8x8mult_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter, int32_t height) { @@ -1865,7 +1865,7 @@ static void common_vt_2t_8x8mult_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_bilinear8_v_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter = bilinear_filters_msa[my - 1]; @@ -1879,7 +1879,7 @@ void ff_put_vp8_bilinear8_v_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_bilinear16_v_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -1932,7 +1932,7 @@ void ff_put_vp8_bilinear16_v_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_hv_2ht_2vt_4x4_msa(uint8_t *src, int32_t src_stride, +static void common_hv_2ht_2vt_4x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter_horiz, const int8_t *filter_vert) @@ -1966,7 +1966,7 @@ static void common_hv_2ht_2vt_4x4_msa(uint8_t *src, int32_t src_stride, ST_W2(res1, 0, 1, dst + 2 * dst_stride, dst_stride); } -static void common_hv_2ht_2vt_4x8_msa(uint8_t *src, int32_t src_stride, +static void common_hv_2ht_2vt_4x8_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter_horiz, const int8_t *filter_vert) @@ -2014,7 +2014,7 @@ static void common_hv_2ht_2vt_4x8_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_bilinear4_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter_horiz = bilinear_filters_msa[mx - 1]; @@ -2029,7 +2029,7 @@ void ff_put_vp8_bilinear4_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void common_hv_2ht_2vt_8x4_msa(uint8_t *src, int32_t src_stride, +static void common_hv_2ht_2vt_8x4_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter_horiz, const int8_t *filter_vert) @@ -2073,7 +2073,7 @@ static void common_hv_2ht_2vt_8x4_msa(uint8_t *src, int32_t src_stride, ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); } -static void common_hv_2ht_2vt_8x8mult_msa(uint8_t *src, int32_t src_stride, +static void common_hv_2ht_2vt_8x8mult_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, const int8_t *filter_horiz, const int8_t *filter_vert, @@ -2154,7 +2154,7 @@ static void common_hv_2ht_2vt_8x8mult_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_bilinear8_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { const int8_t *filter_horiz = bilinear_filters_msa[mx - 1]; @@ -2170,7 +2170,7 @@ void ff_put_vp8_bilinear8_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_bilinear16_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { uint32_t loop_cnt; @@ -2241,7 +2241,7 @@ void ff_put_vp8_bilinear16_hv_msa(uint8_t *dst, ptrdiff_t dst_stride, } void ff_put_vp8_pixels8_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t cnt; @@ -2283,16 +2283,16 @@ void ff_put_vp8_pixels8_msa(uint8_t *dst, ptrdiff_t dst_stride, } } -static void copy_16multx8mult_msa(uint8_t *src, int32_t src_stride, +static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride, int32_t height, int32_t width) { int32_t cnt, loop_cnt; - uint8_t *src_tmp, *dst_tmp; + uint8_t *dst_tmp; v16u8 src0, src1, src2, src3, src4, src5, src6, src7; for (cnt = (width >> 4); cnt--;) { - src_tmp = src; + const uint8_t *src_tmp = src; dst_tmp = dst; for (loop_cnt = (height >> 3); loop_cnt--;) { @@ -2311,7 +2311,7 @@ static void copy_16multx8mult_msa(uint8_t *src, int32_t src_stride, } void ff_put_vp8_pixels16_msa(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int height, int mx, int my) { int32_t cnt; diff --git a/libavcodec/mips/vp8dsp_mips.h b/libavcodec/mips/vp8dsp_mips.h index 07666ab7a0..3d88db897a 100644 --- a/libavcodec/mips/vp8dsp_mips.h +++ b/libavcodec/mips/vp8dsp_mips.h @@ -28,118 +28,118 @@ #include "constants.h" void ff_put_vp8_pixels4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int x, int y); void ff_put_vp8_pixels8_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int x, int y); void ff_put_vp8_pixels16_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int x, int y); void ff_put_vp8_epel16_h4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h4v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h6v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h4v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h6v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h4v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h6v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h4v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h6v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h4v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h6v4_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h4v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h6v6_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear16_h_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear16_v_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear16_hv_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear8_h_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear8_v_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear8_hv_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear4_h_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear4_v_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear4_hv_msa(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); /* loop filter */ @@ -184,84 +184,84 @@ void ff_vp8_idct_dc_add4y_mmi(uint8_t *dst, int16_t block[4][16], void ff_vp8_idct_dc_add4uv_mmi(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride); -void ff_put_vp8_pixels4_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_pixels4_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int x, int y); -void ff_put_vp8_pixels8_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_pixels8_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int x, int y); -void ff_put_vp8_pixels16_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_pixels16_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int x, int y); -void ff_put_vp8_epel16_h4_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_epel16_h4_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); -void ff_put_vp8_epel16_h6_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_epel16_h6_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); -void ff_put_vp8_epel16_v4_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_epel16_v4_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); -void ff_put_vp8_epel16_v6_mmi(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, +void ff_put_vp8_epel16_v6_mmi(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h4v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h6v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h4v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel16_h6v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h4v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h6v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h4v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel8_h6v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h4v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h6v4_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h4v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_epel4_h6v6_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear16_h_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear16_v_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear16_hv_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear8_h_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear8_v_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear8_hv_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear4_h_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear4_v_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); void ff_put_vp8_bilinear4_hv_mmi(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); + const uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my); // loop filter applied to edges between macroblocks void ff_vp8_v_loop_filter16_mmi(uint8_t *dst, ptrdiff_t stride, int flim_E, diff --git a/libavcodec/ppc/vp8dsp_altivec.c b/libavcodec/ppc/vp8dsp_altivec.c index 273de84778..12dac8b0a8 100644 --- a/libavcodec/ppc/vp8dsp_altivec.c +++ b/libavcodec/ppc/vp8dsp_altivec.c @@ -96,7 +96,7 @@ static const vec_s8 h_subpel_filters_outer[3] = static av_always_inline void put_vp8_epel_h_altivec_core(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int w, int is6tap) { LOAD_H_SUBPEL_FILTER(mx-1); @@ -193,7 +193,7 @@ static const vec_u8 v_subpel_filters[7] = static av_always_inline void put_vp8_epel_v_altivec_core(uint8_t *dst, ptrdiff_t dst_stride, - uint8_t *src, ptrdiff_t src_stride, + const uint8_t *src, ptrdiff_t src_stride, int h, int my, int w, int is6tap) { LOAD_V_SUBPEL_FILTER(my-1); @@ -259,19 +259,19 @@ void put_vp8_epel_v_altivec_core(uint8_t *dst, ptrdiff_t dst_stride, #define EPEL_FUNCS(WIDTH, TAPS) \ static av_noinline \ -void put_vp8_epel ## WIDTH ## _h ## TAPS ## _altivec(uint8_t *dst, ptrdiff_t dst_stride, uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my) \ +void put_vp8_epel ## WIDTH ## _h ## TAPS ## _altivec(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my) \ { \ put_vp8_epel_h_altivec_core(dst, dst_stride, src, src_stride, h, mx, WIDTH, TAPS == 6); \ } \ \ static av_noinline \ -void put_vp8_epel ## WIDTH ## _v ## TAPS ## _altivec(uint8_t *dst, ptrdiff_t dst_stride, uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my) \ +void put_vp8_epel ## WIDTH ## _v ## TAPS ## _altivec(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, int h, int mx, int my) \ { \ put_vp8_epel_v_altivec_core(dst, dst_stride, src, src_stride, h, my, WIDTH, TAPS == 6); \ } #define EPEL_HV(WIDTH, HTAPS, VTAPS) \ -static void put_vp8_epel ## WIDTH ## _h ## HTAPS ## v ## VTAPS ## _altivec(uint8_t *dst, ptrdiff_t dstride, uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) \ +static void put_vp8_epel ## WIDTH ## _h ## HTAPS ## v ## VTAPS ## _altivec(uint8_t *dst, ptrdiff_t dstride, const uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) \ { \ DECLARE_ALIGNED(16, uint8_t, tmp)[(2*WIDTH+5)*16]; \ if (VTAPS == 6) { \ @@ -299,7 +299,7 @@ EPEL_HV(4, 4,6) EPEL_HV(4, 6,4) EPEL_HV(4, 4,4) -static void put_vp8_pixels16_altivec(uint8_t *dst, ptrdiff_t dstride, uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) +static void put_vp8_pixels16_altivec(uint8_t *dst, ptrdiff_t dstride, const uint8_t *src, ptrdiff_t sstride, int h, int mx, int my) { register vector unsigned char perm; int i; diff --git a/libavcodec/vp8dsp.c b/libavcodec/vp8dsp.c index a92774ed5e..7a85e9f4ca 100644 --- a/libavcodec/vp8dsp.c +++ b/libavcodec/vp8dsp.c @@ -468,7 +468,7 @@ static const uint8_t subpel_filters[7][6] = { #define PUT_PIXELS(WIDTH) \ static void put_vp8_pixels ## WIDTH ## _c(uint8_t *dst, ptrdiff_t dststride, \ - uint8_t *src, ptrdiff_t srcstride, \ + const uint8_t *src, ptrdiff_t srcstride, \ int h, int x, int y) \ { \ int i; \ @@ -492,7 +492,7 @@ PUT_PIXELS(4) #define VP8_EPEL_H(SIZE, TAPS) \ static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, \ ptrdiff_t dststride, \ - uint8_t *src, \ + const uint8_t *src, \ ptrdiff_t srcstride, \ int h, int mx, int my) \ { \ @@ -510,7 +510,7 @@ static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, \ #define VP8_EPEL_V(SIZE, TAPS) \ static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, \ ptrdiff_t dststride, \ - uint8_t *src, \ + const uint8_t *src, \ ptrdiff_t srcstride, \ int h, int mx, int my) \ { \ @@ -529,7 +529,7 @@ static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, \ static void \ put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst, \ ptrdiff_t dststride, \ - uint8_t *src, \ + const uint8_t *src, \ ptrdiff_t srcstride, \ int h, int mx, \ int my) \ @@ -586,7 +586,7 @@ VP8_EPEL_HV(4, 6, 6) #define VP8_BILINEAR(SIZE) \ static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, ptrdiff_t dstride, \ - uint8_t *src, ptrdiff_t sstride, \ + const uint8_t *src, ptrdiff_t sstride, \ int h, int mx, int my) \ { \ int a = 8 - mx, b = mx; \ @@ -600,7 +600,7 @@ static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, ptrdiff_t dstride, \ } \ \ static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t dstride, \ - uint8_t *src, ptrdiff_t sstride, \ + const uint8_t *src, ptrdiff_t sstride, \ int h, int mx, int my) \ { \ int c = 8 - my, d = my; \ @@ -615,7 +615,7 @@ static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t dstride, \ \ static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, \ ptrdiff_t dstride, \ - uint8_t *src, \ + const uint8_t *src, \ ptrdiff_t sstride, \ int h, int mx, int my) \ { \ diff --git a/libavcodec/vp8dsp.h b/libavcodec/vp8dsp.h index bbd7f60a4f..16b5e9c35b 100644 --- a/libavcodec/vp8dsp.h +++ b/libavcodec/vp8dsp.h @@ -31,7 +31,7 @@ #include typedef void (*vp8_mc_func)(uint8_t *dst /* align 8 */, ptrdiff_t dstStride, - uint8_t *src /* align 1 */, ptrdiff_t srcStride, + const uint8_t *src /* align 1 */, ptrdiff_t srcStride, int h, int x, int y); typedef struct VP8DSPContext { diff --git a/libavcodec/x86/vp8dsp.asm b/libavcodec/x86/vp8dsp.asm index 1c59e884ed..33d488bf6f 100644 --- a/libavcodec/x86/vp8dsp.asm +++ b/libavcodec/x86/vp8dsp.asm @@ -157,7 +157,7 @@ SECTION .text ; subpel MC functions: ; ; void ff_put_vp8_epel_hv_(uint8_t *dst, ptrdiff_t deststride, -; uint8_t *src, ptrdiff_t srcstride, +; const uint8_t *src, ptrdiff_t srcstride, ; int height, int mx, int my); ;------------------------------------------------------------------------------- diff --git a/libavcodec/x86/vp8dsp_init.c b/libavcodec/x86/vp8dsp_init.c index cceb346ced..bd20da1fc9 100644 --- a/libavcodec/x86/vp8dsp_init.c +++ b/libavcodec/x86/vp8dsp_init.c @@ -32,93 +32,93 @@ * MC functions */ void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel4_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear4_h_mmxext(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear8_h_sse2 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear4_h_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear4_v_mmxext(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear8_v_sse2 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear4_v_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_pixels8_mmx (uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); void ff_put_vp8_pixels16_sse(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, + const uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); #define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \ static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \ - uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \ + uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \ ptrdiff_t srcstride, int height, int mx, int my) \ { \ ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ @@ -149,7 +149,7 @@ TAP_W16(ssse3, bilinear, v) #define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \ static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \ - uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \ + uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \ ptrdiff_t srcstride, int height, int mx, int my) \ { \ LOCAL_ALIGNED(ALIGN, uint8_t, tmp, [SIZE * (MAXHEIGHT + TAPNUMY - 1)]); \ @@ -186,7 +186,7 @@ HVTAP(ssse3, 16, 6, 6, 4, 8) #define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \ static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \ - uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \ + uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \ ptrdiff_t srcstride, int height, int mx, int my) \ { \ LOCAL_ALIGNED(ALIGN, uint8_t, tmp, [SIZE * (MAXHEIGHT + 2)]); \ From 29c4c0886d143790fcbeddbe40a23dfc6f56345c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 8 Sep 2022 15:00:06 +0200 Subject: [PATCH 238/590] avutil/x86/intreadwrite: Add ability to detect whether MMX code is used It can be used to call emms_c() only when needed. Signed-off-by: Andreas Rheinhardt --- libavutil/x86/intreadwrite.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavutil/x86/intreadwrite.h b/libavutil/x86/intreadwrite.h index 4061d19231..40f375b013 100644 --- a/libavutil/x86/intreadwrite.h +++ b/libavutil/x86/intreadwrite.h @@ -29,6 +29,8 @@ #if !HAVE_FAST_64BIT && defined(__MMX__) +#define FF_COPY_SWAP_ZERO_USES_MMX + #define AV_COPY64 AV_COPY64 static av_always_inline void AV_COPY64(void *d, const void *s) { From df215e575850e41b19aeb1fd99e53372a6b3d537 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 8 Sep 2022 15:09:26 +0200 Subject: [PATCH 239/590] avcodec/dca_core: Only call emms_c() if needed It is not needed on x64, because the AV_COPY* and AV_ZERO* macros never use MMX on x64. Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 1655116eed..bbf36ea678 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -767,7 +767,9 @@ static void erase_adpcm_history(DCACoreDecoder *s) for (band = 0; band < DCA_SUBBANDS; band++) AV_ZERO128(s->subband_samples[ch][band] - DCA_ADPCM_COEFFS); +#ifdef FF_COPY_SWAP_ZERO_USES_MMX emms_c(); +#endif } static int alloc_sample_buffer(DCACoreDecoder *s) @@ -831,7 +833,9 @@ static int parse_frame_data(DCACoreDecoder *s, enum HeaderType header, int xch_b } } +#ifdef FF_COPY_SWAP_ZERO_USES_MMX emms_c(); +#endif return 0; } @@ -1276,7 +1280,9 @@ static void erase_x96_adpcm_history(DCACoreDecoder *s) for (band = 0; band < DCA_SUBBANDS_X96; band++) AV_ZERO128(s->x96_subband_samples[ch][band] - DCA_ADPCM_COEFFS); +#ifdef FF_COPY_SWAP_ZERO_USES_MMX emms_c(); +#endif } static int alloc_x96_sample_buffer(DCACoreDecoder *s) @@ -1506,7 +1512,9 @@ static int parse_x96_frame_data(DCACoreDecoder *s, int exss, int xch_base) } } +#ifdef FF_COPY_SWAP_ZERO_USES_MMX emms_c(); +#endif return 0; } From dcbb7e8a303b4a97b1ff3945277fa1db868ef121 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 7 Sep 2022 01:55:23 +0200 Subject: [PATCH 240/590] avcodec/ralf: Move frame allocation after error checks Signed-off-by: Andreas Rheinhardt --- libavcodec/ralf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 20c5f060d0..8f8e49f535 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -451,12 +451,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, src_size = avpkt->size; } - frame->nb_samples = ctx->max_frame_size; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) - return ret; - samples0 = (int16_t *)frame->data[0]; - samples1 = (int16_t *)frame->data[1]; - if (src_size < 5) { av_log(avctx, AV_LOG_ERROR, "too short packets are too short!\n"); return AVERROR_INVALIDDATA; @@ -481,6 +475,11 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, ctx->num_blocks++; } + frame->nb_samples = ctx->max_frame_size; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + samples0 = (int16_t *)frame->data[0]; + samples1 = (int16_t *)frame->data[1]; block_pointer = src + table_bytes + 2; bytes_left = src_size - table_bytes - 2; ctx->sample_offset = 0; From 5c19cb3f924c8afafcae08916a4167e36842adcd Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 7 Sep 2022 02:02:54 +0200 Subject: [PATCH 241/590] avcodec/ralf: Move variable from context to stack Signed-off-by: Andreas Rheinhardt --- libavcodec/ralf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/ralf.c b/libavcodec/ralf.c index 8f8e49f535..591598d8fc 100644 --- a/libavcodec/ralf.c +++ b/libavcodec/ralf.c @@ -63,7 +63,6 @@ typedef struct RALFContext { unsigned bias[2]; ///< a constant value added to channel data after filtering - int num_blocks; ///< number of blocks inside the frame int sample_offset; int block_size[1 << 12]; ///< size of the blocks int block_pts[1 << 12]; ///< block start time (in milliseconds) @@ -418,7 +417,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int16_t *samples1; int ret; GetBitContext gb; - int table_size, table_bytes, i; + int table_size, table_bytes, num_blocks; const uint8_t *src, *block_pointer; int src_size; int bytes_left; @@ -462,17 +461,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR_INVALIDDATA; } init_get_bits(&gb, src + 2, table_size); - ctx->num_blocks = 0; + num_blocks = 0; while (get_bits_left(&gb) > 0) { - if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size)) + if (num_blocks >= FF_ARRAY_ELEMS(ctx->block_size)) return AVERROR_INVALIDDATA; - ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->ch_layout.nb_channels); + ctx->block_size[num_blocks] = get_bits(&gb, 13 + avctx->ch_layout.nb_channels); if (get_bits1(&gb)) { - ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9); + ctx->block_pts[num_blocks] = get_bits(&gb, 9); } else { - ctx->block_pts[ctx->num_blocks] = 0; + ctx->block_pts[num_blocks] = 0; } - ctx->num_blocks++; + num_blocks++; } frame->nb_samples = ctx->max_frame_size; @@ -483,7 +482,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, block_pointer = src + table_bytes + 2; bytes_left = src_size - table_bytes - 2; ctx->sample_offset = 0; - for (i = 0; i < ctx->num_blocks; i++) { + for (int i = 0; i < num_blocks; i++) { if (bytes_left < ctx->block_size[i]) { av_log(avctx, AV_LOG_ERROR, "I'm pedaling backwards\n"); break; From 88170070c4036530b79690c70e603fdddbb021c4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 7 Sep 2022 13:58:53 +0200 Subject: [PATCH 242/590] avcodec: add bonk audio decoder --- Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/bonk.c | 433 ++++++++++++++++++++++++++++++++++++++++ libavcodec/codec_desc.c | 7 + libavcodec/codec_id.h | 1 + libavcodec/version.h | 4 +- 7 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 libavcodec/bonk.c diff --git a/Changelog b/Changelog index f34e8e5d42..66756a73e2 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,7 @@ version : - VAAPI decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9 - WBMP (Wireless Application Protocol Bitmap) image format - a3dscope filter +- bonk decoder version 5.1: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 945908e3b8..0b46bc0173 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -263,6 +263,7 @@ OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmvaudio.o OBJS-$(CONFIG_BMV_VIDEO_DECODER) += bmvvideo.o +OBJS-$(CONFIG_BONK_DECODER) += bonk.o OBJS-$(CONFIG_BRENDER_PIX_DECODER) += brenderpix.o OBJS-$(CONFIG_C93_DECODER) += c93.o OBJS-$(CONFIG_CAVS_DECODER) += cavs.o cavsdec.o cavsdsp.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 6939a4e25f..5d58a5d9f0 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -446,6 +446,7 @@ extern const FFCodec ff_atrac9_decoder; extern const FFCodec ff_binkaudio_dct_decoder; extern const FFCodec ff_binkaudio_rdft_decoder; extern const FFCodec ff_bmv_audio_decoder; +extern const FFCodec ff_bonk_decoder; extern const FFCodec ff_cook_decoder; extern const FFCodec ff_dca_encoder; extern const FFCodec ff_dca_decoder; diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c new file mode 100644 index 0000000000..f3d797d588 --- /dev/null +++ b/libavcodec/bonk.c @@ -0,0 +1,433 @@ +/* + * Bonk audio decoder + * + * 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 "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "avcodec.h" +#include "codec_internal.h" +#include "decode.h" +#define BITSTREAM_READER_LE +#include "get_bits.h" +#include "bytestream.h" + +typedef struct BitCount { + uint8_t bit; + unsigned count; +} BitCount; + +typedef struct BonkContext { + GetBitContext gb; + int skip; + + uint8_t *bitstream; + int64_t max_framesize; + int bitstream_size; + int bitstream_index; + + uint64_t nb_samples; + int lossless; + int mid_side; + int n_taps; + int down_sampling; + int samples_per_packet; + + int state[2][2048], k[2048]; + int *samples[2]; + int *input_samples; + uint8_t quant[2048]; + BitCount *bits; +} BonkContext; + +static av_cold int bonk_close(AVCodecContext *avctx) +{ + BonkContext *s = avctx->priv_data; + + av_freep(&s->bitstream); + av_freep(&s->input_samples); + av_freep(&s->samples[0]); + av_freep(&s->samples[1]); + av_freep(&s->bits); + s->bitstream_size = 0; + + return 0; +} + +static av_cold int bonk_init(AVCodecContext *avctx) +{ + BonkContext *s = avctx->priv_data; + + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; + if (avctx->extradata_size < 17) + return AVERROR(EINVAL); + + if (avctx->extradata[0]) { + av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n"); + return AVERROR_INVALIDDATA; + } + + if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2) + return AVERROR_INVALIDDATA; + + s->nb_samples = AV_RL32(avctx->extradata + 1) / avctx->ch_layout.nb_channels; + if (!s->nb_samples) + s->nb_samples = UINT64_MAX; + s->lossless = avctx->extradata[10] != 0; + s->mid_side = avctx->extradata[11] != 0; + s->n_taps = AV_RL16(avctx->extradata + 12); + if (!s->n_taps || s->n_taps > 2048) + return AVERROR(EINVAL); + + s->down_sampling = avctx->extradata[14]; + if (!s->down_sampling) + return AVERROR(EINVAL); + + s->samples_per_packet = AV_RL16(avctx->extradata + 15); + if (!s->samples_per_packet) + return AVERROR(EINVAL); + s->max_framesize = s->samples_per_packet * avctx->ch_layout.nb_channels * s->down_sampling * 16LL; + if (s->max_framesize > (INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) / 8) + return AVERROR_INVALIDDATA; + + s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream)); + if (!s->bitstream) + return AVERROR(ENOMEM); + + s->input_samples = av_calloc(s->samples_per_packet, sizeof(*s->input_samples)); + if (!s->input_samples) + return AVERROR(ENOMEM); + + s->samples[0] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0])); + s->samples[1] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0])); + if (!s->samples[0] || !s->samples[1]) + return AVERROR(ENOMEM); + + s->bits = av_calloc(s->max_framesize * 8, sizeof(*s->bits)); + if (!s->bits) + return AVERROR(ENOMEM); + + for (int i = 0; i < 512; i++) { + s->quant[i] = sqrt(i + 1); + } + + return 0; +} + +static unsigned read_uint_max(BonkContext *s, uint32_t max) +{ + unsigned value = 0; + int i, bits; + + if (max == 0) + return 0; + + if (max >> 31) + return 32; + + bits = 32 - ff_clz(max); + + for (i = 0; i < bits - 1; i++) + if (get_bits1(&s->gb)) + value += 1 << i; + + if ((value | (1 << (bits - 1))) <= max) + if (get_bits1(&s->gb)) + value += 1 << (bits - 1); + + return value; +} + +static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part) +{ + int i, low_bits = 0, x = 0, max_x; + int n_zeros = 0, step = 256, dominant = 0; + int pos = 0, level = 0; + BitCount *bits = s->bits; + + memset(buf, 0, entries * sizeof(*buf)); + if (base_2_part) { + low_bits = get_bits(&s->gb, 4); + + if (low_bits) + for (i = 0; i < entries; i++) + buf[i] = get_bits(&s->gb, low_bits); + } + + while (n_zeros < entries) { + int steplet = step >> 8; + + if (get_bits_left(&s->gb) <= 0) + return AVERROR_INVALIDDATA; + + if (!get_bits1(&s->gb)) { + if (steplet < 0) + break; + + if (steplet > 0) { + bits[x ].bit = dominant; + bits[x++].count = steplet; + } + + if (!dominant) + n_zeros += steplet; + + step += step / 8; + } else if (steplet > 0) { + int actual_run = read_uint_max(s, steplet - 1); + + if (actual_run < 0) + break; + + if (actual_run > 0) { + bits[x ].bit = dominant; + bits[x++].count = actual_run; + } + + bits[x ].bit = !dominant; + bits[x++].count = 1; + + if (!dominant) + n_zeros += actual_run; + else + n_zeros++; + + step -= step / 8; + } + + if (step < 256) { + if (step == 0) + return AVERROR_INVALIDDATA; + step = 65536 / step; + dominant = !dominant; + } + } + + max_x = x; + x = 0; + n_zeros = 0; + for (i = 0; n_zeros < entries; i++) { + if (pos >= entries) { + pos = 0; + level += 1 << low_bits; + } + + if (x >= max_x) + return AVERROR_INVALIDDATA; + + if (buf[pos] >= level) { + if (bits[x].bit) + buf[pos] += 1 << low_bits; + else + n_zeros++; + + bits[x].count--; + x += bits[x].count == 0; + } + + pos++; + } + + for (i = 0; i < entries; i++) { + if (buf[i] && get_bits1(&s->gb)) { + buf[i] = -buf[i]; + } + } + + return 0; +} + +static inline int shift_down(int a, int b) +{ + return (a >> b) + (a < 0); +} + +static inline int shift(int a, int b) +{ + return a + (1 << b - 1) >> b; +} + +#define LATTICE_SHIFT 10 +#define SAMPLE_SHIFT 4 +#define SAMPLE_FACTOR (1 << SAMPLE_SHIFT) + +static int predictor_calc_error(int *k, int *state, int order, int error) +{ + int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT); + int *k_ptr = &(k[order-2]), + *state_ptr = &(state[order-2]); + + for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) { + int k_value = *k_ptr, state_value = *state_ptr; + + x -= shift_down(k_value * state_value, LATTICE_SHIFT); + state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT); + } + + // don't drift too far, to avoid overflows + av_clip(x, -(SAMPLE_FACTOR << 16), SAMPLE_FACTOR << 16); + + state[0] = x; + + return x; +} + +static void predictor_init_state(int *k, int *state, int order) +{ + for (int i = order - 2; i >= 0; i--) { + int x = state[i]; + + for (int j = 0, p = i + 1; p < order; j++, p++) { + int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT); + + state[p] += shift_down(k[j] * x, LATTICE_SHIFT); + x = tmp; + } + } +} + +static int bonk_decode(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *pkt) +{ + BonkContext *s = avctx->priv_data; + GetBitContext *gb = &s->gb; + const uint8_t *buf; + int quant, n, buf_size, input_buf_size; + int ret = AVERROR_INVALIDDATA; + + if ((!pkt->size && !s->bitstream_size) || s->nb_samples == 0) { + *got_frame_ptr = 0; + return pkt->size; + } + + buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size); + input_buf_size = buf_size; + if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE > s->max_framesize) { + memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); + s->bitstream_index = 0; + } + if (pkt->data) + memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], pkt->data, buf_size); + buf = &s->bitstream[s->bitstream_index]; + buf_size += s->bitstream_size; + s->bitstream_size = buf_size; + if (buf_size < s->max_framesize && pkt->data) { + *got_frame_ptr = 0; + return input_buf_size; + } + + frame->nb_samples = FFMIN(s->samples_per_packet * s->down_sampling, s->nb_samples); + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + if ((ret = init_get_bits8(gb, buf, buf_size)) < 0) + return ret; + + skip_bits(gb, s->skip); + if ((ret = intlist_read(s, s->k, s->n_taps, 0)) < 0) + return ret; + + for (int i = 0; i < s->n_taps; i++) + s->k[i] *= s->quant[i]; + quant = s->lossless ? 1 : get_bits(&s->gb, 16) * SAMPLE_FACTOR; + + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { + const int samples_per_packet = s->samples_per_packet; + const int down_sampling = s->down_sampling; + const int offset = samples_per_packet * down_sampling - 1; + int *state = s->state[ch]; + int *sample = s->samples[ch]; + + predictor_init_state(s->k, state, s->n_taps); + if ((ret = intlist_read(s, s->input_samples, samples_per_packet, 1)) < 0) + return ret; + + for (int i = 0; i < samples_per_packet; i++) { + for (int j = 0; j < s->down_sampling - 1; j++) { + sample[0] = predictor_calc_error(s->k, state, s->n_taps, 0); + sample++; + } + + sample[0] = predictor_calc_error(s->k, state, s->n_taps, s->input_samples[i] * quant); + sample++; + } + + sample = s->samples[ch]; + for (int i = 0; i < s->n_taps; i++) + state[i] = sample[offset - i]; + } + + if (s->mid_side && avctx->ch_layout.nb_channels == 2) { + for (int i = 0; i < frame->nb_samples; i++) { + s->samples[1][i] += shift(s->samples[0][i], 1); + s->samples[0][i] -= s->samples[1][i]; + } + } + + if (!s->lossless) { + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { + int *samples = s->samples[ch]; + for (int i = 0; i < frame->nb_samples; i++) + samples[i] = shift(samples[i], 4); + } + } + + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { + int16_t *osamples = (int16_t *)frame->extended_data[ch]; + int *samples = s->samples[ch]; + for (int i = 0; i < frame->nb_samples; i++) + osamples[i] = av_clip_int16(samples[i]); + } + + s->nb_samples -= frame->nb_samples; + + s->skip = get_bits_count(gb) - 8 * (get_bits_count(gb) / 8); + n = get_bits_count(gb) / 8; + + if (n > buf_size) { + s->bitstream_size = 0; + s->bitstream_index = 0; + return AVERROR_INVALIDDATA; + } + + *got_frame_ptr = 1; + + if (s->bitstream_size) { + s->bitstream_index += n; + s->bitstream_size -= n; + return input_buf_size; + } + return n; +} + +const FFCodec ff_bonk_decoder = { + .p.name = "bonk", + CODEC_LONG_NAME("Bonk audio"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_BONK, + .priv_data_size = sizeof(BonkContext), + .init = bonk_init, + FF_CODEC_DECODE_CB(bonk_decode), + .close = bonk_close, + .p.capabilities = AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_SUBFRAMES, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_NONE }, +}; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 06dfe55d0f..c002480d39 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3290,6 +3290,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("DFPWM (Dynamic Filter Pulse Width Modulation)"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_BONK, + .type = AVMEDIA_TYPE_AUDIO, + .name = "bonk", + .long_name = NULL_IF_CONFIG_SMALL("Bonk audio"), + .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, /* subtitle codecs */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 2247bc0309..858b5c3a75 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -527,6 +527,7 @@ enum AVCodecID { AV_CODEC_ID_FASTAUDIO, AV_CODEC_ID_MSNSIREN, AV_CODEC_ID_DFPWM, + AV_CODEC_ID_BONK, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/version.h b/libavcodec/version.h index d251ae2eff..2328be4b26 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 42 -#define LIBAVCODEC_VERSION_MICRO 104 +#define LIBAVCODEC_VERSION_MINOR 43 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From 3ce6fa6b6d099dcad43bb0178334441ab72df4cc Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 7 Sep 2022 14:01:42 +0200 Subject: [PATCH 243/590] avformat: add bonk demuxer --- Changelog | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/bonk.c | 98 ++++++++++++++++++++++++++++++++++++++++ libavformat/version.h | 4 +- 5 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 libavformat/bonk.c diff --git a/Changelog b/Changelog index 66756a73e2..f76fce36b8 100644 --- a/Changelog +++ b/Changelog @@ -11,7 +11,7 @@ version : - VAAPI decoding and encoding for 10/12bit 422, 10/12bit 444 HEVC and VP9 - WBMP (Wireless Application Protocol Bitmap) image format - a3dscope filter -- bonk decoder +- bonk decoder and demuxer version 5.1: diff --git a/libavformat/Makefile b/libavformat/Makefile index 684bad0eb4..5cdcda3239 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -147,6 +147,7 @@ OBJS-$(CONFIG_BIT_MUXER) += bit.o OBJS-$(CONFIG_BITPACKED_DEMUXER) += rawvideodec.o OBJS-$(CONFIG_BMV_DEMUXER) += bmv.o OBJS-$(CONFIG_BOA_DEMUXER) += boadec.o +OBJS-$(CONFIG_BONK_DEMUXER) += bonk.o rawdec.o OBJS-$(CONFIG_BFSTM_DEMUXER) += brstm.o OBJS-$(CONFIG_BRSTM_DEMUXER) += brstm.o OBJS-$(CONFIG_C93_DEMUXER) += c93.o voc_packet.o voc.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index ae4479fb7a..cebd5e0c67 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -102,6 +102,7 @@ extern const AVInputFormat ff_bmv_demuxer; extern const AVInputFormat ff_bfstm_demuxer; extern const AVInputFormat ff_brstm_demuxer; extern const AVInputFormat ff_boa_demuxer; +extern const AVInputFormat ff_bonk_demuxer; extern const AVInputFormat ff_c93_demuxer; extern const AVInputFormat ff_caf_demuxer; extern const AVOutputFormat ff_caf_muxer; diff --git a/libavformat/bonk.c b/libavformat/bonk.c new file mode 100644 index 0000000000..fc400979b3 --- /dev/null +++ b/libavformat/bonk.c @@ -0,0 +1,98 @@ +/* + * Bonk demuxer + * Copyright (c) 2016 Paul B Mahol + * + * 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 "libavutil/intreadwrite.h" +#include "avformat.h" +#include "demux.h" +#include "internal.h" +#include "rawdec.h" + +static int bonk_probe(const AVProbeData *p) +{ + for (int i = 0; i < p->buf_size - 22; i++) { + if (!p->buf[i] && AV_RL32(p->buf + i + 1) == MKTAG('B','O','N','K')) { + if (p->buf[i + 5]) + return 0; + if (AV_RL32(p->buf + i + 6) == 0) + return 0; + if (AV_RL32(p->buf + i + 10) == 0) + return 0; + if (p->buf[i + 14] == 0) + return 0; + if (AV_RL16(p->buf + i + 17) == 0 || + AV_RL16(p->buf + i + 17) > 2048) + return 0; + if (p->buf[i + 19] == 0) + return 0; + if (AV_RL16(p->buf + i + 20) == 0) + return 0; + return AVPROBE_SCORE_MAX; + } else if (!p->buf[i]) { + break; + } + } + + return 0; +} + +static int bonk_read_header(AVFormatContext *s) +{ + AVStream *st; + int ret; + + for (int i = 0; !avio_feof(s->pb); i++) { + int b = avio_r8(s->pb); + if (!b && avio_rl32(s->pb) == MKTAG('B','O','N','K')) + break; + else if (!b) + return AVERROR_INVALIDDATA; + } + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + if ((ret = ff_get_extradata(s, st->codecpar, s->pb, 17)) < 0) + return ret; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_BONK; + st->codecpar->sample_rate = AV_RL32(st->codecpar->extradata + 5); + st->codecpar->ch_layout.nb_channels = st->codecpar->extradata[9]; + if (st->codecpar->ch_layout.nb_channels == 0) + return AVERROR_INVALIDDATA; + st->duration = AV_RL32(st->codecpar->extradata + 1) / st->codecpar->ch_layout.nb_channels; + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + ffformatcontext(s)->data_offset = avio_tell(s->pb); + + return 0; +} + +const AVInputFormat ff_bonk_demuxer = { + .name = "bonk", + .long_name = NULL_IF_CONFIG_SMALL("raw Bonk"), + .read_probe = bonk_probe, + .read_header = bonk_read_header, + .read_packet = ff_raw_read_partial_packet, + .extensions = "bonk", + .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS, + .raw_codec_id = AV_CODEC_ID_BONK, + .priv_data_size = sizeof(FFRawDemuxerContext), + .priv_class = &ff_raw_demuxer_class, +}; diff --git a/libavformat/version.h b/libavformat/version.h index a54ffd6c0e..36f22982d8 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 30 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 31 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From 3a783fc8cb7e65b98d4689f278df071f37d70a55 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 10 Sep 2022 21:16:41 +0200 Subject: [PATCH 244/590] fate/id3v2: Add test for reading and writing UTF-16 BOM tags Signed-off-by: Andreas Rheinhardt --- tests/fate/id3v2.mak | 5 ++++ tests/ref/fate/id3v2-utf16-bom | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/ref/fate/id3v2-utf16-bom diff --git a/tests/fate/id3v2.mak b/tests/fate/id3v2.mak index 4dca681e38..7ad4d877a4 100644 --- a/tests/fate/id3v2.mak +++ b/tests/fate/id3v2.mak @@ -7,6 +7,11 @@ fate-id3v2-priv-remux: CMD = transcode mp3 $(TARGET_SAMPLES)/id3v2/id3v2_priv.mp FATE_ID3V2_FFMPEG_FFPROBE-$(call REMUX, AIFF, WAV_DEMUXER) += fate-id3v2-chapters fate-id3v2-chapters: CMD = transcode wav $(TARGET_SAMPLES)/wav/200828-005.wav aiff "-c copy -metadata:c:0 description=foo -metadata:c:0 date=2021 -metadata:c copyright=none -metadata:c:1 genre=nonsense -write_id3v2 1" "-c copy -t 0.05" "-show_entries format_tags:chapters" +# Tests reading and writing UTF-16 BOM strings; also tests +# the AIFF muxer's and demuxer's ability to preserve channel layouts. +FATE_ID3V2_FFMPEG_FFPROBE-$(call REMUX, AIFF, WAV_DEMUXER FLAC_DEMUXER PCM_S16LE_DECODER MJPEG_DECODER ARESAMPLE_FILTER CHANNELMAP_FILTER PCM_S24BE_ENCODER) += fate-id3v2-utf16-bom +fate-id3v2-utf16-bom: CMD = transcode wav $(TARGET_SAMPLES)/audio-reference/yo.raw-short.wav aiff "-map 0:a -map 1:v -af aresample,channelmap=channel_layout=hexagonal,aresample -c:a pcm_s24be -c:v copy -write_id3v2 1 -id3v2_version 3 -map_metadata:g:0 1:g -map_metadata:s:v 1:g" "-c copy -t 0.05" "-show_entries stream=channel_layout:stream_tags:format_tags" "-i $(TARGET_SAMPLES)/cover_art/cover_art.flac" + FATE_SAMPLES_FFPROBE += $(FATE_ID3V2_FFPROBE-yes) FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_ID3V2_FFMPEG_FFPROBE-yes) fate-id3v2: $(FATE_ID3V2_FFPROBE-yes) $(FATE_ID3V2_FFMPEG_FFPROBE-yes) diff --git a/tests/ref/fate/id3v2-utf16-bom b/tests/ref/fate/id3v2-utf16-bom new file mode 100644 index 0000000000..dd2566de2b --- /dev/null +++ b/tests/ref/fate/id3v2-utf16-bom @@ -0,0 +1,42 @@ +9b8bfdf87a8d3d089819ef9f6f264ec4 *tests/data/fate/id3v2-utf16-bom.aiff +885482 tests/data/fate/id3v2-utf16-bom.aiff +#tb 0: 1/90000 +#media_type 0: video +#codec_id 0: mjpeg +#dimensions 0: 350x350 +#sar 0: 1/1 +#tb 1: 1/48000 +#media_type 1: audio +#codec_id 1: pcm_s24be +#sample_rate 1: 48000 +#channel_layout_name 1: hexagonal +0, 0, 0, 0, 19650, 0xd5662610 +1, 0, 0, 227, 4086, 0x00000000 +1, 227, 227, 227, 4086, 0x00000000 +1, 454, 454, 227, 4086, 0x00000000 +1, 681, 681, 227, 4086, 0x667b2643 +1, 908, 908, 227, 4086, 0x9a09957d +1, 1135, 1135, 227, 4086, 0x763e27c5 +1, 1362, 1362, 227, 4086, 0x2a47f536 +1, 1589, 1589, 227, 4086, 0xed32e5f2 +1, 1816, 1816, 227, 4086, 0x2e96c720 +1, 2043, 2043, 227, 4086, 0x84c5b5f0 +1, 2270, 2270, 227, 4086, 0xe3dfeefc +[STREAM] +channel_layout=hexagonal +[/STREAM] +[STREAM] +TAG:title=Дороги +TAG:comment=Other +[/STREAM] +[FORMAT] +TAG:artist=Мельница +TAG:RATING=0 +TAG:album=Ангелофрения +TAG:title=Дороги +TAG:tracktotal=11 +TAG:totaltracks=11 +TAG:genre=Folk +TAG:track=2 +TAG:date=2012 +[/FORMAT] From f6448133e72e0e74ed5dec18e8a4134dfc79babe Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 10 Sep 2022 21:43:33 +0200 Subject: [PATCH 245/590] fate/subtitles: Add PGS remux test Signed-off-by: Andreas Rheinhardt --- tests/fate/subtitles.mak | 5 +++++ tests/ref/fate/sub-pgs-remux | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/ref/fate/sub-pgs-remux diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak index bc464edce6..e6684a814b 100644 --- a/tests/fate/subtitles.mak +++ b/tests/fate/subtitles.mak @@ -50,6 +50,11 @@ fate-sub-mpsub: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/MPSub_capability_te FATE_SUBTITLES_ASS-$(call DEMDEC, MPSUB, TEXT) += fate-sub-mpsub-frames fate-sub-mpsub-frames: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/MPSub_capability_tester_frames.sub +# FIXME?: The dts in the input file are not monotonous and so the +# timestamps of the remuxed file have been fixed up. +FATE_SUBTITLES-$(call REMUX, SUP) += fate-sub-pgs-remux +fate-sub-pgs-remux: CMD = transcode sup $(TARGET_SAMPLES)/sub/pgs_sub.sup sup "-copyts -c:s copy" "-copyts -c:s copy" + FATE_SUBTITLES_ASS-$(call DEMDEC, PJS, PJS) += fate-sub-pjs fate-sub-pjs: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/PJS_capability_tester.pjs diff --git a/tests/ref/fate/sub-pgs-remux b/tests/ref/fate/sub-pgs-remux new file mode 100644 index 0000000000..e965d93bec --- /dev/null +++ b/tests/ref/fate/sub-pgs-remux @@ -0,0 +1,15 @@ +cf306b7bc30122effc6429e35364f640 *tests/data/fate/sub-pgs-remux.sup +49382 tests/data/fate/sub-pgs-remux.sup +#tb 0: 1/90000 +#media_type 0: subtitle +#codec_id 0: hdmv_pgs_subtitle +0, 6072, 6072, 0, 30, 0x32b303ec +0, 6072, 6072, 0, 22, 0x27510416 +0, 6072, 6072, 0, 160, 0xe2024133 +0, 6072, 6072, 0, 22943, 0xc011fe0e +0, 6072, 6072, 0, 2969, 0x35604c6f +0, 6072, 6072, 0, 3, 0x01800080 +0, 35426, 36102, 0, 30, 0x2db303ac +0, 35426, 35862, 0, 22, 0x27510416 +0, 35426, 35426, 0, 160, 0xe2024133 +0, 35426, 35862, 0, 22943, 0xc011fe0e From 8d12f3de1401f10d93319ffdc46b01de9eba4285 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 12 Sep 2022 14:17:32 +0200 Subject: [PATCH 246/590] avcodec/bonk: Actually clip when using av_clip() Also fixes a "statement with no effect [-Wunused-value]" warning from GCC. Reviewed-by: James Almer Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/bonk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/bonk.c b/libavcodec/bonk.c index f3d797d588..409694f710 100644 --- a/libavcodec/bonk.c +++ b/libavcodec/bonk.c @@ -280,7 +280,7 @@ static int predictor_calc_error(int *k, int *state, int order, int error) } // don't drift too far, to avoid overflows - av_clip(x, -(SAMPLE_FACTOR << 16), SAMPLE_FACTOR << 16); + x = av_clip(x, -(SAMPLE_FACTOR << 16), SAMPLE_FACTOR << 16); state[0] = x; From 50a4dff69f6477b06f00eae1cac2a53ae22fe9a5 Mon Sep 17 00:00:00 2001 From: James Cowgill Date: Sun, 25 Aug 2019 09:18:00 +0100 Subject: [PATCH 247/590] avcodec/arm/sbcenc: avoid callee preserved vfp registers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling FFmpeg with GCC-9, some very random segfaults were observed in code which had previously called down into the SBC encoder NEON assembly routines. This was caused by these functions clobbering some of the vfp callee saved registers (d8 - d15 aka q4 - q7). GCC was using these registers to save local variables, but after these functions returned, they would contain garbage. Fix by reallocating the registers in the two affected functions in the following way: ff_sbc_analyze_4_neon: q2-q5 => q8-q11, then q1-q4 => q8-q11 ff_sbc_analyze_8_neon: q2-q9 => q8-q15 The reason for using these replacements is to keep closely related sets of registers consecutively numbered which hopefully makes the code more easy to follow. Since this commit only reallocates registers, it should have no performance impact. Signed-off-by: James Cowgill Signed-off-by: Martin Storsjö --- libavcodec/arm/sbcdsp_neon.S | 220 +++++++++++++++++------------------ 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/libavcodec/arm/sbcdsp_neon.S b/libavcodec/arm/sbcdsp_neon.S index d83d21d202..914abfb6cc 100644 --- a/libavcodec/arm/sbcdsp_neon.S +++ b/libavcodec/arm/sbcdsp_neon.S @@ -38,49 +38,49 @@ function ff_sbc_analyze_4_neon, export=1 /* TODO: merge even and odd cases (or even merge all four calls to this * function) in order to have only aligned reads from 'in' array * and reduce number of load instructions */ - vld1.16 {d4, d5}, [r0, :64]! - vld1.16 {d8, d9}, [r2, :128]! + vld1.16 {d16, d17}, [r0, :64]! + vld1.16 {d20, d21}, [r2, :128]! - vmull.s16 q0, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmull.s16 q1, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! + vmull.s16 q0, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmull.s16 q1, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! - vmlal.s16 q0, d6, d10 - vld1.16 {d4, d5}, [r0, :64]! - vmlal.s16 q1, d7, d11 - vld1.16 {d8, d9}, [r2, :128]! + vmlal.s16 q0, d18, d22 + vld1.16 {d16, d17}, [r0, :64]! + vmlal.s16 q1, d19, d23 + vld1.16 {d20, d21}, [r2, :128]! - vmlal.s16 q0, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmlal.s16 q1, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! + vmlal.s16 q0, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmlal.s16 q1, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! - vmlal.s16 q0, d6, d10 - vld1.16 {d4, d5}, [r0, :64]! - vmlal.s16 q1, d7, d11 - vld1.16 {d8, d9}, [r2, :128]! + vmlal.s16 q0, d18, d22 + vld1.16 {d16, d17}, [r0, :64]! + vmlal.s16 q1, d19, d23 + vld1.16 {d20, d21}, [r2, :128]! - vmlal.s16 q0, d4, d8 - vmlal.s16 q1, d5, d9 + vmlal.s16 q0, d16, d20 + vmlal.s16 q1, d17, d21 vpadd.s32 d0, d0, d1 vpadd.s32 d1, d2, d3 vrshrn.s32 d0, q0, SBC_PROTO_FIXED_SCALE - vld1.16 {d2, d3, d4, d5}, [r2, :128]! + vld1.16 {d16, d17, d18, d19}, [r2, :128]! vdup.i32 d1, d0[1] /* TODO: can be eliminated */ vdup.i32 d0, d0[0] /* TODO: can be eliminated */ - vmull.s16 q3, d2, d0 - vmull.s16 q4, d3, d0 - vmlal.s16 q3, d4, d1 - vmlal.s16 q4, d5, d1 + vmull.s16 q10, d16, d0 + vmull.s16 q11, d17, d0 + vmlal.s16 q10, d18, d1 + vmlal.s16 q11, d19, d1 - vpadd.s32 d0, d6, d7 /* TODO: can be eliminated */ - vpadd.s32 d1, d8, d9 /* TODO: can be eliminated */ + vpadd.s32 d0, d20, d21 /* TODO: can be eliminated */ + vpadd.s32 d1, d22, d23 /* TODO: can be eliminated */ vst1.32 {d0, d1}, [r1, :128] @@ -91,57 +91,57 @@ function ff_sbc_analyze_8_neon, export=1 /* TODO: merge even and odd cases (or even merge all four calls to this * function) in order to have only aligned reads from 'in' array * and reduce number of load instructions */ - vld1.16 {d4, d5}, [r0, :64]! - vld1.16 {d8, d9}, [r2, :128]! - - vmull.s16 q6, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmull.s16 q7, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! - vmull.s16 q8, d6, d10 - vld1.16 {d4, d5}, [r0, :64]! - vmull.s16 q9, d7, d11 - vld1.16 {d8, d9}, [r2, :128]! - - vmlal.s16 q6, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmlal.s16 q7, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! - vmlal.s16 q8, d6, d10 - vld1.16 {d4, d5}, [r0, :64]! - vmlal.s16 q9, d7, d11 - vld1.16 {d8, d9}, [r2, :128]! - - vmlal.s16 q6, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmlal.s16 q7, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! - vmlal.s16 q8, d6, d10 - vld1.16 {d4, d5}, [r0, :64]! - vmlal.s16 q9, d7, d11 - vld1.16 {d8, d9}, [r2, :128]! - - vmlal.s16 q6, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmlal.s16 q7, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! - vmlal.s16 q8, d6, d10 - vld1.16 {d4, d5}, [r0, :64]! - vmlal.s16 q9, d7, d11 - vld1.16 {d8, d9}, [r2, :128]! - - vmlal.s16 q6, d4, d8 - vld1.16 {d6, d7}, [r0, :64]! - vmlal.s16 q7, d5, d9 - vld1.16 {d10, d11}, [r2, :128]! - - vmlal.s16 q8, d6, d10 - vmlal.s16 q9, d7, d11 - - vpadd.s32 d0, d12, d13 - vpadd.s32 d1, d14, d15 - vpadd.s32 d2, d16, d17 - vpadd.s32 d3, d18, d19 + vld1.16 {d16, d17}, [r0, :64]! + vld1.16 {d20, d21}, [r2, :128]! + + vmull.s16 q12, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmull.s16 q13, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! + vmull.s16 q14, d18, d22 + vld1.16 {d16, d17}, [r0, :64]! + vmull.s16 q15, d19, d23 + vld1.16 {d20, d21}, [r2, :128]! + + vmlal.s16 q12, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmlal.s16 q13, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! + vmlal.s16 q14, d18, d22 + vld1.16 {d16, d17}, [r0, :64]! + vmlal.s16 q15, d19, d23 + vld1.16 {d20, d21}, [r2, :128]! + + vmlal.s16 q12, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmlal.s16 q13, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! + vmlal.s16 q14, d18, d22 + vld1.16 {d16, d17}, [r0, :64]! + vmlal.s16 q15, d19, d23 + vld1.16 {d20, d21}, [r2, :128]! + + vmlal.s16 q12, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmlal.s16 q13, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! + vmlal.s16 q14, d18, d22 + vld1.16 {d16, d17}, [r0, :64]! + vmlal.s16 q15, d19, d23 + vld1.16 {d20, d21}, [r2, :128]! + + vmlal.s16 q12, d16, d20 + vld1.16 {d18, d19}, [r0, :64]! + vmlal.s16 q13, d17, d21 + vld1.16 {d22, d23}, [r2, :128]! + + vmlal.s16 q14, d18, d22 + vmlal.s16 q15, d19, d23 + + vpadd.s32 d0, d24, d25 + vpadd.s32 d1, d26, d27 + vpadd.s32 d2, d28, d29 + vpadd.s32 d3, d30, d31 vrshr.s32 q0, q0, SBC_PROTO_FIXED_SCALE vrshr.s32 q1, q1, SBC_PROTO_FIXED_SCALE @@ -153,38 +153,38 @@ function ff_sbc_analyze_8_neon, export=1 vdup.i32 d1, d0[1] /* TODO: can be eliminated */ vdup.i32 d0, d0[0] /* TODO: can be eliminated */ - vld1.16 {d4, d5}, [r2, :128]! - vmull.s16 q6, d4, d0 - vld1.16 {d6, d7}, [r2, :128]! - vmull.s16 q7, d5, d0 - vmull.s16 q8, d6, d0 - vmull.s16 q9, d7, d0 - - vld1.16 {d4, d5}, [r2, :128]! - vmlal.s16 q6, d4, d1 - vld1.16 {d6, d7}, [r2, :128]! - vmlal.s16 q7, d5, d1 - vmlal.s16 q8, d6, d1 - vmlal.s16 q9, d7, d1 - - vld1.16 {d4, d5}, [r2, :128]! - vmlal.s16 q6, d4, d2 - vld1.16 {d6, d7}, [r2, :128]! - vmlal.s16 q7, d5, d2 - vmlal.s16 q8, d6, d2 - vmlal.s16 q9, d7, d2 - - vld1.16 {d4, d5}, [r2, :128]! - vmlal.s16 q6, d4, d3 - vld1.16 {d6, d7}, [r2, :128]! - vmlal.s16 q7, d5, d3 - vmlal.s16 q8, d6, d3 - vmlal.s16 q9, d7, d3 - - vpadd.s32 d0, d12, d13 /* TODO: can be eliminated */ - vpadd.s32 d1, d14, d15 /* TODO: can be eliminated */ - vpadd.s32 d2, d16, d17 /* TODO: can be eliminated */ - vpadd.s32 d3, d18, d19 /* TODO: can be eliminated */ + vld1.16 {d16, d17}, [r2, :128]! + vmull.s16 q12, d16, d0 + vld1.16 {d18, d19}, [r2, :128]! + vmull.s16 q13, d17, d0 + vmull.s16 q14, d18, d0 + vmull.s16 q15, d19, d0 + + vld1.16 {d16, d17}, [r2, :128]! + vmlal.s16 q12, d16, d1 + vld1.16 {d18, d19}, [r2, :128]! + vmlal.s16 q13, d17, d1 + vmlal.s16 q14, d18, d1 + vmlal.s16 q15, d19, d1 + + vld1.16 {d16, d17}, [r2, :128]! + vmlal.s16 q12, d16, d2 + vld1.16 {d18, d19}, [r2, :128]! + vmlal.s16 q13, d17, d2 + vmlal.s16 q14, d18, d2 + vmlal.s16 q15, d19, d2 + + vld1.16 {d16, d17}, [r2, :128]! + vmlal.s16 q12, d16, d3 + vld1.16 {d18, d19}, [r2, :128]! + vmlal.s16 q13, d17, d3 + vmlal.s16 q14, d18, d3 + vmlal.s16 q15, d19, d3 + + vpadd.s32 d0, d24, d25 /* TODO: can be eliminated */ + vpadd.s32 d1, d26, d27 /* TODO: can be eliminated */ + vpadd.s32 d2, d28, d29 /* TODO: can be eliminated */ + vpadd.s32 d3, d30, d31 /* TODO: can be eliminated */ vst1.32 {d0, d1, d2, d3}, [r1, :128] From 9ad3db3ad932d484708194f419544c33cb3c71e6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 11 Sep 2022 18:34:47 +0200 Subject: [PATCH 248/590] fate/spdif: Add spdif tests These tests test both the demuxer as well as the muxer wherever possible. It is not always possible due to the fact that the muxer supports more codecs than the demuxer. The spdif demuxer does currently not set the need_parsing flag. If one were to set this to AVSTREAM_PARSE_FULL, the test results would change as follows: - For spdif-aac-remux, the packets are currently padded to 16bits, i.e. if the actual packet size is odd, there is a padding byte. The parser splits this byte away into a one byte packet of its own. Insanely, these one byte packets get the same duration as normal packets, i.e. timing is ruined. - The DCA-remux tests get proper duration/timestamps. - In the spdif-mp2-remux test the demuxer marks the stream as being MP2; the parser sets it to MP3 and this triggers the "Codec change in IEC 61937" codepath; this test therefore returns only two packets with the parser. - For spdif-mp3-remux some bytes end up in different packets: Some input packets of this file have an odd length (417B instead of 418B like all the other packets) and are padded to 418B. Without a parser, all returned packets from the spdif-demuxer are 418B. With a parser, the packets that were originally 417B are 417B again, but the padding byte has not been discarded, but added to the next packet which is now 419B. This fixes "Multiple frames in a packet" warning and avoids an "Invalid data found when processing input" error when decoding. Signed-off-by: Andreas Rheinhardt --- tests/Makefile | 1 + tests/fate/spdif.mak | 44 + tests/ref/fate/spdif-aac-remux | 93 ++ tests/ref/fate/spdif-ac3-remux | 63 ++ tests/ref/fate/spdif-dca-core-bswap | 1 + tests/ref/fate/spdif-dca-core-remux | 14 + tests/ref/fate/spdif-dca-master | 1 + tests/ref/fate/spdif-dca-master-core | 1 + tests/ref/fate/spdif-dca-master-core-remux | 1179 ++++++++++++++++++++ tests/ref/fate/spdif-eac3 | 1 + tests/ref/fate/spdif-mlp | 1 + tests/ref/fate/spdif-mp2-remux | 49 + tests/ref/fate/spdif-mp3-remux | 47 + tests/ref/fate/spdif-truehd | 1 + 14 files changed, 1496 insertions(+) create mode 100644 tests/fate/spdif.mak create mode 100644 tests/ref/fate/spdif-aac-remux create mode 100644 tests/ref/fate/spdif-ac3-remux create mode 100644 tests/ref/fate/spdif-dca-core-bswap create mode 100644 tests/ref/fate/spdif-dca-core-remux create mode 100644 tests/ref/fate/spdif-dca-master create mode 100644 tests/ref/fate/spdif-dca-master-core create mode 100644 tests/ref/fate/spdif-dca-master-core-remux create mode 100644 tests/ref/fate/spdif-eac3 create mode 100644 tests/ref/fate/spdif-mlp create mode 100644 tests/ref/fate/spdif-mp2-remux create mode 100644 tests/ref/fate/spdif-mp3-remux create mode 100644 tests/ref/fate/spdif-truehd diff --git a/tests/Makefile b/tests/Makefile index d9c509a415..06494a9cc4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -231,6 +231,7 @@ include $(SRC_PATH)/tests/fate/real.mak include $(SRC_PATH)/tests/fate/screen.mak include $(SRC_PATH)/tests/fate/segment.mak include $(SRC_PATH)/tests/fate/source.mak +include $(SRC_PATH)/tests/fate/spdif.mak include $(SRC_PATH)/tests/fate/speedhq.mak include $(SRC_PATH)/tests/fate/subtitles.mak include $(SRC_PATH)/tests/fate/truehd.mak diff --git a/tests/fate/spdif.mak b/tests/fate/spdif.mak new file mode 100644 index 0000000000..093b8138e8 --- /dev/null +++ b/tests/fate/spdif.mak @@ -0,0 +1,44 @@ +# This padds the AAC frames to 16 bit words (the actual size is +# still available in the ADTS headers). +FATE_SPDIF_REMUX-$(call ALLYES, AAC_DEMUXER AAC_DECODER) += fate-spdif-aac-remux +fate-spdif-aac-remux: CMD = transcode aac $(TARGET_SAMPLES)/aac/foo.aac spdif "-c copy" "-c copy" + +FATE_SPDIF_REMUX-$(call ALLYES, AC3_DEMUXER AC3_DECODER) += fate-spdif-ac3-remux +fate-spdif-ac3-remux: CMD = transcode ac3 $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 spdif "-c copy" "-c copy" + +FATE_SPDIF_REMUX-$(call ALLYES, DTS_DEMUXER DCA_DECODER) += fate-spdif-dca-core-remux +fate-spdif-dca-core-remux: CMD = transcode dts $(TARGET_SAMPLES)/dts/dcadec-suite/core_51_24_48_768_0.dtshd spdif "-c copy" "-c copy" + +FATE_SPDIF-$(call DEMMUX, DTSHD, SPDIF) += fate-spdif-dca-core-bswap +fate-spdif-dca-core-bswap: CMD = md5 -i $(TARGET_SAMPLES)/dts/dcadec-suite/core_51_24_48_768_0.dtshd -c copy -spdif_flags +be -f spdif + +# Only the core will be transferred, extensions are discarded. +FATE_SPDIF_REMUX-$(call ALLYES, DTS_DEMUXER DCA_DECODER) += fate-spdif-dca-master-core-remux +fate-spdif-dca-master-core-remux: CMD = transcode dts $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts spdif "-c copy" "-c copy" + +FATE_SPDIF-$(call DEMMUX, DTS, SPDIF) += fate-spdif-dca-master fate-spdif-dca-master-core +fate-spdif-dca-master: CMD = md5 -i $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts -c copy -dtshd_rate 192000 -f spdif +# This test uses a too low bitrate and therefore switches to only transmit the core. +fate-spdif-dca-master-core: CMD = md5 -i $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts -c copy -dtshd_rate 96000 -f spdif + +FATE_SPDIF-$(call DEMMUX, EAC3, SPDIF) += fate-spdif-eac3 +fate-spdif-eac3: CMD = md5 -i $(TARGET_SAMPLES)/eac3/csi_miami_stereo_128_spx.eac3 -c copy -f spdif + +FATE_SPDIF-$(call DEMMUX, MLP, SPDIF) += fate-spdif-mlp +fate-spdif-mlp: CMD = md5 -i $(TARGET_SAMPLES)/lossless-audio/luckynight-partial.mlp -c copy -f spdif + +# Note: The spdif demuxer marks the generated file as containing MP3. +FATE_SPDIF_REMUX-$(call ALLYES, MPEGTS_DEMUXER MPEGAUDIO_PARSER MP3_DECODER) += fate-spdif-mp2-remux +fate-spdif-mp2-remux: CMD = transcode mpegts $(TARGET_SAMPLES)/mpeg2/xdcam8mp2-1s_small.ts spdif "-map 0:a -c copy" "-c copy" + +FATE_SPDIF_REMUX-$(call ALLYES, MP3_DEMUXER MP3_DECODER) += fate-spdif-mp3-remux +fate-spdif-mp3-remux: CMD = transcode mp3 $(TARGET_SAMPLES)/audiomatch/square3.mp3 spdif "-c copy" "-c copy" + +FATE_SPDIF-$(call DEMMUX, TRUEHD, SPDIF) += fate-spdif-truehd +fate-spdif-truehd: CMD = md5 -i $(TARGET_SAMPLES)/truehd/atmos.thd -c copy -f spdif + +# Make the demuxer support all the formats supported by the muxer +# and switch the md5 tests to remux tests? +FATE_SPDIF-$(call REMUX, SPDIF) += $(FATE_SPDIF_REMUX-yes) +FATE_SAMPLES_FFMPEG += $(FATE_SPDIF-yes) +fate-spdif: $(FATE_SPDIF-yes) diff --git a/tests/ref/fate/spdif-aac-remux b/tests/ref/fate/spdif-aac-remux new file mode 100644 index 0000000000..92d99093f9 --- /dev/null +++ b/tests/ref/fate/spdif-aac-remux @@ -0,0 +1,93 @@ +1a324961354902555e25d30f67300f51 *tests/data/fate/spdif-aac-remux.spdif +352256 tests/data/fate/spdif-aac-remux.spdif +#tb 0: 1/90000 +#media_type 0: audio +#codec_id 0: aac +#sample_rate 0: 44100 +#channel_layout_name 0: stereo +0, 0, 0, 2089, 378, 0x5ebf1e99 +0, 2089, 2089, 2089, 410, 0x9a9cc8b5 +0, 4179, 4179, 2089, 410, 0xf2ffc522 +0, 6268, 6268, 2089, 404, 0x4a1dc5a1 +0, 8358, 8358, 2089, 412, 0x38c5cd55 +0, 10448, 10448, 2089, 440, 0x363fdb80 +0, 12538, 12538, 2089, 376, 0x269ec08b +0, 14628, 14628, 2089, 378, 0xd627be91 +0, 16717, 16717, 2089, 434, 0x7f68d7ba +0, 18807, 18807, 2089, 354, 0x52b5b11f +0, 20897, 20897, 2089, 368, 0x4458a8c2 +0, 22987, 22987, 2089, 378, 0x789ab43a +0, 25077, 25077, 2089, 378, 0x476ec1f4 +0, 27166, 27166, 2089, 366, 0xe13fb37a +0, 29256, 29256, 2089, 370, 0x3772b685 +0, 31346, 31346, 2089, 366, 0x54bbb52b +0, 33436, 33436, 2089, 380, 0x28a9bc19 +0, 35526, 35526, 2089, 496, 0x761efc09 +0, 37615, 37615, 2089, 354, 0xb524bb1f +0, 39705, 39705, 2089, 348, 0xcef9b075 +0, 41795, 41795, 2089, 360, 0x5a50bc48 +0, 43885, 43885, 2089, 362, 0xb454b67c +0, 45975, 45975, 2089, 362, 0x2502aab4 +0, 48064, 48064, 2089, 378, 0x9336b10f +0, 50154, 50154, 2089, 376, 0x2dcbb1e6 +0, 52244, 52244, 2089, 370, 0x8064ac7f +0, 54334, 54334, 2089, 368, 0x300ebac3 +0, 56424, 56424, 2089, 372, 0x88ccba7c +0, 58513, 58513, 2089, 370, 0x1ad6b67b +0, 60603, 60603, 2089, 374, 0x1969bafe +0, 62693, 62693, 2089, 378, 0x1d55b287 +0, 64783, 64783, 2089, 370, 0xffc7b1e0 +0, 66873, 66873, 2089, 392, 0x1ab2c1af +0, 68962, 68962, 2089, 382, 0xc98bbd75 +0, 71052, 71052, 2089, 394, 0xbf2ac43b +0, 73142, 73142, 2089, 370, 0xcd31bbef +0, 75232, 75232, 2089, 394, 0x579eca77 +0, 77322, 77322, 2089, 386, 0xdeebc55a +0, 79411, 79411, 2089, 384, 0xc125c2b8 +0, 81501, 81501, 2089, 366, 0x0ce6bf87 +0, 83591, 83591, 2089, 380, 0x202fbd37 +0, 85681, 85681, 2089, 454, 0x6997e64d +0, 87771, 87771, 2089, 356, 0x41f9b837 +0, 89860, 89860, 2089, 362, 0x3f9bb026 +0, 91950, 91950, 2089, 368, 0xe511af25 +0, 94040, 94040, 2089, 418, 0x42f7d1d5 +0, 96130, 96130, 2089, 410, 0x657dd072 +0, 98220, 98220, 2089, 490, 0x1476f7f6 +0, 100309, 100309, 2089, 350, 0x44fbb45f +0, 102399, 102399, 2089, 350, 0xfd52aef1 +0, 104489, 104489, 2089, 350, 0xd354aa2f +0, 106579, 106579, 2089, 352, 0xbaaaad58 +0, 108668, 108668, 2089, 354, 0x591baa8c +0, 110758, 110758, 2089, 362, 0xf053b0e1 +0, 112848, 112848, 2089, 376, 0x8fafbbf8 +0, 114938, 114938, 2089, 444, 0xde95eef0 +0, 117028, 117028, 2089, 342, 0x5869a95e +0, 119117, 119117, 2089, 402, 0x6d2eca68 +0, 121207, 121207, 2089, 380, 0xe1c1b4ee +0, 123297, 123297, 2089, 358, 0x3807ad6f +0, 125387, 125387, 2089, 350, 0xaa47aa0f +0, 127477, 127477, 2089, 358, 0xf8dbabbf +0, 129566, 129566, 2089, 368, 0x701fae8c +0, 131656, 131656, 2089, 368, 0x60c1b34e +0, 133746, 133746, 2089, 392, 0x749ac181 +0, 135836, 135836, 2089, 478, 0xce58f5ab +0, 137926, 137926, 2089, 346, 0x5767a88b +0, 140015, 140015, 2089, 362, 0x7998b479 +0, 142105, 142105, 2089, 356, 0x300bb3eb +0, 144195, 144195, 2089, 362, 0xa783b13f +0, 146285, 146285, 2089, 356, 0x8ce5b0bd +0, 148375, 148375, 2089, 402, 0x684fc5d8 +0, 150464, 150464, 2089, 434, 0x83d8e111 +0, 152554, 152554, 2089, 352, 0x5e3ab34f +0, 154644, 154644, 2089, 364, 0xa2a5ab60 +0, 156734, 156734, 2089, 380, 0x0c90bbfd +0, 158824, 158824, 2089, 378, 0x1ee7bf81 +0, 160913, 160913, 2089, 378, 0xb3d1b08e +0, 163003, 163003, 2089, 372, 0x7480b657 +0, 165093, 165093, 2089, 376, 0x9e31bfd0 +0, 167183, 167183, 2089, 424, 0x963bdd40 +0, 169273, 169273, 2089, 468, 0x6016f010 +0, 171362, 171362, 2089, 472, 0x69c4e4c5 +0, 173452, 173452, 2089, 334, 0x2354ab0b +0, 175542, 175542, 2089, 346, 0xe85bab65 +0, 177632, 177632, 2089, 266, 0x93bb7efa diff --git a/tests/ref/fate/spdif-ac3-remux b/tests/ref/fate/spdif-ac3-remux new file mode 100644 index 0000000000..176aa4d69b --- /dev/null +++ b/tests/ref/fate/spdif-ac3-remux @@ -0,0 +1,63 @@ +d2c51a1156406cd8895122998efa66ec *tests/data/fate/spdif-ac3-remux.spdif +344064 tests/data/fate/spdif-ac3-remux.spdif +#tb 0: 1/90000 +#media_type 0: audio +#codec_id 0: ac3 +#sample_rate 0: 48000 +#channel_layout_name 0: 5.1(side) +0, 0, 0, 2880, 1792, 0xc6250823 +0, 2880, 2880, 2880, 1792, 0xb76a1098 +0, 5760, 5760, 2880, 1792, 0xfe6e1038 +0, 8640, 8640, 2880, 1792, 0x102f060a +0, 11520, 11520, 2880, 1792, 0xfd881629 +0, 14400, 14400, 2880, 1792, 0x950505f6 +0, 17280, 17280, 2880, 1792, 0x3d9a143f +0, 20160, 20160, 2880, 1792, 0xa2261142 +0, 23040, 23040, 2880, 1792, 0x9cc9053d +0, 25920, 25920, 2880, 1792, 0xaaeb109b +0, 28800, 28800, 2880, 1792, 0xd36308f6 +0, 31680, 31680, 2880, 1792, 0xb08a125d +0, 34560, 34560, 2880, 1792, 0xd8d31026 +0, 37440, 37440, 2880, 1792, 0x9b87a34d +0, 40320, 40320, 2880, 1792, 0x51ed77f6 +0, 43200, 43200, 2880, 1792, 0x29c16ed2 +0, 46080, 46080, 2880, 1792, 0x8c9662d6 +0, 48960, 48960, 2880, 1792, 0x32c85025 +0, 51840, 51840, 2880, 1792, 0x32914d88 +0, 54720, 54720, 2880, 1792, 0x84b9382b +0, 57600, 57600, 2880, 1792, 0x003e4890 +0, 60480, 60480, 2880, 1792, 0x70325b4e +0, 63360, 63360, 2880, 1792, 0x80e04a58 +0, 66240, 66240, 2880, 1792, 0x2c46323a +0, 69120, 69120, 2880, 1792, 0x7be152a5 +0, 72000, 72000, 2880, 1792, 0x08615466 +0, 74880, 74880, 2880, 1792, 0x55364eaf +0, 77760, 77760, 2880, 1792, 0x46595d56 +0, 80640, 80640, 2880, 1792, 0xdf476ace +0, 83520, 83520, 2880, 1792, 0x9ff767dc +0, 86400, 86400, 2880, 1792, 0xb4d450a7 +0, 89280, 89280, 2880, 1792, 0x032c7506 +0, 92160, 92160, 2880, 1792, 0x50e35426 +0, 95040, 95040, 2880, 1792, 0xe5575597 +0, 97920, 97920, 2880, 1792, 0x86565611 +0, 100800, 100800, 2880, 1792, 0xed6f54aa +0, 103680, 103680, 2880, 1792, 0x4cee4aab +0, 106560, 106560, 2880, 1792, 0x8aa33ac7 +0, 109440, 109440, 2880, 1792, 0xb665442c +0, 112320, 112320, 2880, 1792, 0x9a4b647d +0, 115200, 115200, 2880, 1792, 0xf40d582d +0, 118080, 118080, 2880, 1792, 0xf22e5d98 +0, 120960, 120960, 2880, 1792, 0x2f7745be +0, 123840, 123840, 2880, 1792, 0xa918561a +0, 126720, 126720, 2880, 1792, 0x59cc56fb +0, 129600, 129600, 2880, 1792, 0xaefe5dca +0, 132480, 132480, 2880, 1792, 0x80ba657d +0, 135360, 135360, 2880, 1792, 0x09137032 +0, 138240, 138240, 2880, 1792, 0xf51b5d34 +0, 141120, 141120, 2880, 1792, 0x1d695fb1 +0, 144000, 144000, 2880, 1792, 0xf6f56509 +0, 146880, 146880, 2880, 1792, 0xd1f658d5 +0, 149760, 149760, 2880, 1792, 0xb8614f64 +0, 152640, 152640, 2880, 1792, 0x8dd55743 +0, 155520, 155520, 2880, 1792, 0xcb1f50df +0, 158400, 158400, 2880, 1440, 0xa129aa95 diff --git a/tests/ref/fate/spdif-dca-core-bswap b/tests/ref/fate/spdif-dca-core-bswap new file mode 100644 index 0000000000..c2ca7b7b44 --- /dev/null +++ b/tests/ref/fate/spdif-dca-core-bswap @@ -0,0 +1 @@ +45ff602f64887babf37f4ee14e5d5072 diff --git a/tests/ref/fate/spdif-dca-core-remux b/tests/ref/fate/spdif-dca-core-remux new file mode 100644 index 0000000000..a74b8a41a9 --- /dev/null +++ b/tests/ref/fate/spdif-dca-core-remux @@ -0,0 +1,14 @@ +a4e739ebe07c75dd569156d5038696a9 *tests/data/fate/spdif-dca-core-remux.spdif +14336 tests/data/fate/spdif-dca-core-remux.spdif +#tb 0: 1/90000 +#media_type 0: audio +#codec_id 0: dts +#sample_rate 0: 48000 +#channel_layout_name 0: 5.1(side) +0, 0, 0, 0, 1024, 0x07b79d2a +0, 0, 0, 0, 1024, 0x7eaaba77 +0, 0, 0, 0, 1024, 0xbed65c1d +0, 0, 0, 0, 1024, 0x10bc6792 +0, 0, 0, 0, 1024, 0xf8436f6e +0, 0, 0, 0, 1024, 0x4454a681 +0, 0, 0, 0, 1024, 0xda3ba189 diff --git a/tests/ref/fate/spdif-dca-master b/tests/ref/fate/spdif-dca-master new file mode 100644 index 0000000000..bf725f373e --- /dev/null +++ b/tests/ref/fate/spdif-dca-master @@ -0,0 +1 @@ +00d1ec506aa862a0c17c197c3773a82b diff --git a/tests/ref/fate/spdif-dca-master-core b/tests/ref/fate/spdif-dca-master-core new file mode 100644 index 0000000000..f54c9cfa3c --- /dev/null +++ b/tests/ref/fate/spdif-dca-master-core @@ -0,0 +1 @@ +43fc10a0a8360931f946f80b9941c9c5 diff --git a/tests/ref/fate/spdif-dca-master-core-remux b/tests/ref/fate/spdif-dca-master-core-remux new file mode 100644 index 0000000000..de6f128186 --- /dev/null +++ b/tests/ref/fate/spdif-dca-master-core-remux @@ -0,0 +1,1179 @@ +c4f3f3c6ca73fcb7beac137105dadab4 *tests/data/fate/spdif-dca-master-core-remux.spdif +2400256 tests/data/fate/spdif-dca-master-core-remux.spdif +#tb 0: 1/90000 +#media_type 0: audio +#codec_id 0: dts +#sample_rate 0: 48000 +#channel_layout_name 0: 5.1(side) +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xbe7b9e5e +0, 0, 0, 0, 2012, 0x671dc73a +0, 0, 0, 0, 2012, 0x7fd5b1d2 +0, 0, 0, 0, 2012, 0xa9259df1 +0, 0, 0, 0, 2012, 0x3e8c2b92 +0, 0, 0, 0, 2012, 0x4876a9ff +0, 0, 0, 0, 2012, 0x7e469182 +0, 0, 0, 0, 2012, 0x10eba401 +0, 0, 0, 0, 2012, 0x51c68ed3 +0, 0, 0, 0, 2012, 0x3f52901b +0, 0, 0, 0, 2012, 0x7bebacce +0, 0, 0, 0, 2012, 0xcb94898d +0, 0, 0, 0, 2012, 0x14e3ae70 +0, 0, 0, 0, 2012, 0x016893cb +0, 0, 0, 0, 2012, 0x00739f0a +0, 0, 0, 0, 2012, 0x834aba41 +0, 0, 0, 0, 2012, 0x6a92ac08 +0, 0, 0, 0, 2012, 0x09eda257 +0, 0, 0, 0, 2012, 0x81449e3f +0, 0, 0, 0, 2012, 0xe6eb91d4 +0, 0, 0, 0, 2012, 0x51158c0e +0, 0, 0, 0, 2012, 0x84e4a013 +0, 0, 0, 0, 2012, 0x4c48a0e6 +0, 0, 0, 0, 2012, 0xf54c9811 +0, 0, 0, 0, 2012, 0x62778edb +0, 0, 0, 0, 2012, 0x7226a51b +0, 0, 0, 0, 2012, 0x44b9aad8 +0, 0, 0, 0, 2012, 0x8aa6b380 +0, 0, 0, 0, 2012, 0xc88c99e6 +0, 0, 0, 0, 2012, 0xed5e93e2 +0, 0, 0, 0, 2012, 0xeb0b9755 +0, 0, 0, 0, 2012, 0xe5ba8ca9 +0, 0, 0, 0, 2012, 0x2fef9bcf +0, 0, 0, 0, 2012, 0xf19c8749 +0, 0, 0, 0, 2012, 0x0feb94d0 +0, 0, 0, 0, 2012, 0x1f9194d1 +0, 0, 0, 0, 2012, 0x0cad9822 +0, 0, 0, 0, 2012, 0xe6f79152 +0, 0, 0, 0, 2012, 0x69e78955 +0, 0, 0, 0, 2012, 0x91dd8a1b +0, 0, 0, 0, 2012, 0x63fe8eea +0, 0, 0, 0, 2012, 0x8f6d90a2 +0, 0, 0, 0, 2012, 0xe3bf8626 +0, 0, 0, 0, 2012, 0xd08599db +0, 0, 0, 0, 2012, 0xf556a282 +0, 0, 0, 0, 2012, 0x7f8c8f90 +0, 0, 0, 0, 2012, 0xa04493b9 +0, 0, 0, 0, 2012, 0x21a19b3a +0, 0, 0, 0, 2012, 0x6ead9244 +0, 0, 0, 0, 2012, 0xe65290d7 +0, 0, 0, 0, 2012, 0x8ff58a8e +0, 0, 0, 0, 2012, 0x24ada603 +0, 0, 0, 0, 2012, 0x79cb85c7 +0, 0, 0, 0, 2012, 0x63c0ac54 +0, 0, 0, 0, 2012, 0x7f719f83 +0, 0, 0, 0, 2012, 0x2eb69654 +0, 0, 0, 0, 2012, 0xf5149bc0 +0, 0, 0, 0, 2012, 0xd0d6a414 +0, 0, 0, 0, 2012, 0x4f4a8ed3 +0, 0, 0, 0, 2012, 0x20888cb5 +0, 0, 0, 0, 2012, 0x13439c86 +0, 0, 0, 0, 2012, 0xc8fc98e1 +0, 0, 0, 0, 2012, 0x14689766 +0, 0, 0, 0, 2012, 0x830293e4 +0, 0, 0, 0, 2012, 0xdd5bb8ce +0, 0, 0, 0, 2012, 0x005ea280 +0, 0, 0, 0, 2012, 0x9b0581e2 +0, 0, 0, 0, 2012, 0x210f89b8 +0, 0, 0, 0, 2012, 0xb7c180bd +0, 0, 0, 0, 2012, 0xe53c85e4 +0, 0, 0, 0, 2012, 0x1f689207 +0, 0, 0, 0, 2012, 0x5653813b +0, 0, 0, 0, 2012, 0x1d278d66 +0, 0, 0, 0, 2012, 0xd94c9a83 +0, 0, 0, 0, 2012, 0x7af48548 +0, 0, 0, 0, 2012, 0x86209c99 +0, 0, 0, 0, 2012, 0x6e3b7fc9 +0, 0, 0, 0, 2012, 0x41c289e7 +0, 0, 0, 0, 2012, 0x8bea85db +0, 0, 0, 0, 2012, 0x45c98c39 +0, 0, 0, 0, 2012, 0xee098755 +0, 0, 0, 0, 2012, 0x485d9ec1 +0, 0, 0, 0, 2012, 0x78819023 +0, 0, 0, 0, 2012, 0xf43377bd +0, 0, 0, 0, 2012, 0x43fc9439 +0, 0, 0, 0, 2012, 0x045e9bf3 +0, 0, 0, 0, 2012, 0x0fc09f0c +0, 0, 0, 0, 2012, 0x7ba69bf5 +0, 0, 0, 0, 2012, 0x4aa7aaf0 +0, 0, 0, 0, 2012, 0x620c85bf +0, 0, 0, 0, 2012, 0xa6bb8a30 +0, 0, 0, 0, 2012, 0xfd10883c +0, 0, 0, 0, 2012, 0x32037e17 +0, 0, 0, 0, 2012, 0xb18c9e01 +0, 0, 0, 0, 2012, 0xd8206ee5 +0, 0, 0, 0, 2012, 0xdbc49136 +0, 0, 0, 0, 2012, 0x650a785d +0, 0, 0, 0, 2012, 0x9e107d61 +0, 0, 0, 0, 2012, 0xbf4eac50 +0, 0, 0, 0, 2012, 0x9d8f79b2 +0, 0, 0, 0, 2012, 0x252d8e8a +0, 0, 0, 0, 2012, 0x00af8fd6 +0, 0, 0, 0, 2012, 0x9e388d3b +0, 0, 0, 0, 2012, 0x75de7f56 +0, 0, 0, 0, 2012, 0xd502839c +0, 0, 0, 0, 2012, 0x66709e03 +0, 0, 0, 0, 2012, 0x3e0a96ba +0, 0, 0, 0, 2012, 0x0813ad4e +0, 0, 0, 0, 2012, 0x799c90c5 +0, 0, 0, 0, 2012, 0x98a18bed +0, 0, 0, 0, 2012, 0x8cd197d7 +0, 0, 0, 0, 2012, 0xf9ea8b22 +0, 0, 0, 0, 2012, 0x674f7cd2 +0, 0, 0, 0, 2012, 0xa5c39136 +0, 0, 0, 0, 2012, 0xe064ac30 +0, 0, 0, 0, 2012, 0x2af78c75 +0, 0, 0, 0, 2012, 0x43df9b19 +0, 0, 0, 0, 2012, 0x8d1a87d5 +0, 0, 0, 0, 2012, 0xd5be8d29 +0, 0, 0, 0, 2012, 0x43448bd4 +0, 0, 0, 0, 2012, 0xa128a30b +0, 0, 0, 0, 2012, 0x6fc29902 +0, 0, 0, 0, 2012, 0x5854a24b +0, 0, 0, 0, 2012, 0xb222958a +0, 0, 0, 0, 2012, 0xfca39cce +0, 0, 0, 0, 2012, 0xee0087f0 +0, 0, 0, 0, 2012, 0xd2d69b8c +0, 0, 0, 0, 2012, 0xe2308f8d +0, 0, 0, 0, 2012, 0x8dc4b09a +0, 0, 0, 0, 2012, 0x14489aef +0, 0, 0, 0, 2012, 0x900f9835 +0, 0, 0, 0, 2012, 0x0092a95f +0, 0, 0, 0, 2012, 0xfd90b1bf +0, 0, 0, 0, 2012, 0xb11ab5d5 +0, 0, 0, 0, 2012, 0xc802b908 +0, 0, 0, 0, 2012, 0xb12aa91e +0, 0, 0, 0, 2012, 0xd173c2a9 +0, 0, 0, 0, 2012, 0xaeafb887 +0, 0, 0, 0, 2012, 0xeb7eb0d7 +0, 0, 0, 0, 2012, 0x9afbc56a +0, 0, 0, 0, 2012, 0x2d78bc34 +0, 0, 0, 0, 2012, 0x6550aed1 +0, 0, 0, 0, 2012, 0xd514a55d +0, 0, 0, 0, 2012, 0x9058c263 +0, 0, 0, 0, 2012, 0xf819b66a +0, 0, 0, 0, 2012, 0x16a5c902 +0, 0, 0, 0, 2012, 0x602fc11b +0, 0, 0, 0, 2012, 0xe3c6b177 +0, 0, 0, 0, 2012, 0xacc4cd06 +0, 0, 0, 0, 2012, 0xeb96addb +0, 0, 0, 0, 2012, 0x1195cad3 +0, 0, 0, 0, 2012, 0x8e96ad7f +0, 0, 0, 0, 2012, 0x31e592b7 +0, 0, 0, 0, 2012, 0xa0c5ccf0 +0, 0, 0, 0, 2012, 0x6e77c92b +0, 0, 0, 0, 2012, 0xe87fa928 +0, 0, 0, 0, 2012, 0x4923bcdb +0, 0, 0, 0, 2012, 0x3260b452 +0, 0, 0, 0, 2012, 0x62beafa0 +0, 0, 0, 0, 2012, 0x5a6fc18a +0, 0, 0, 0, 2012, 0x9d05ae87 +0, 0, 0, 0, 2012, 0xb577a54e +0, 0, 0, 0, 2012, 0xd66bc5ef +0, 0, 0, 0, 2012, 0x40bec7bb +0, 0, 0, 0, 2012, 0xedd3a1b9 +0, 0, 0, 0, 2012, 0xf6f49f83 +0, 0, 0, 0, 2012, 0x316fb06d +0, 0, 0, 0, 2012, 0xc3f3a874 +0, 0, 0, 0, 2012, 0x3a96b3bd +0, 0, 0, 0, 2012, 0x825aba30 +0, 0, 0, 0, 2012, 0x5b58ce66 +0, 0, 0, 0, 2012, 0x412dc092 +0, 0, 0, 0, 2012, 0xcb47bfa3 +0, 0, 0, 0, 2012, 0xe025bb79 +0, 0, 0, 0, 2012, 0x0042ba53 +0, 0, 0, 0, 2012, 0x7e9bba1d +0, 0, 0, 0, 2012, 0x0058c99d +0, 0, 0, 0, 2012, 0x47d2b590 +0, 0, 0, 0, 2012, 0xdf4ba9c6 +0, 0, 0, 0, 2012, 0xe671987c +0, 0, 0, 0, 2012, 0x90dccc89 +0, 0, 0, 0, 2012, 0x012ccae9 +0, 0, 0, 0, 2012, 0x2eb5b83e +0, 0, 0, 0, 2012, 0x3fecb7f4 +0, 0, 0, 0, 2012, 0x7955a464 +0, 0, 0, 0, 2012, 0xfe9eb3c3 +0, 0, 0, 0, 2012, 0x7457c904 +0, 0, 0, 0, 2012, 0xd23ea69d +0, 0, 0, 0, 2012, 0xc497bf82 +0, 0, 0, 0, 2012, 0x15e5c241 +0, 0, 0, 0, 2012, 0x3dfea71f +0, 0, 0, 0, 2012, 0x1e59c9c0 +0, 0, 0, 0, 2012, 0x1a34b927 +0, 0, 0, 0, 2012, 0xbf42b430 +0, 0, 0, 0, 2012, 0xf084c29f +0, 0, 0, 0, 2012, 0x6443c44a +0, 0, 0, 0, 2012, 0x7985a4a5 +0, 0, 0, 0, 2012, 0x27add059 +0, 0, 0, 0, 2012, 0x7f1faea4 +0, 0, 0, 0, 2012, 0x8d9dc732 +0, 0, 0, 0, 2012, 0xf272c32e +0, 0, 0, 0, 2012, 0x4fa3ab11 +0, 0, 0, 0, 2012, 0x512e9887 +0, 0, 0, 0, 2012, 0xd478d55b +0, 0, 0, 0, 2012, 0xa94a9d93 +0, 0, 0, 0, 2012, 0xff73d812 +0, 0, 0, 0, 2012, 0xd3a6b9ef +0, 0, 0, 0, 2012, 0x7b4ebc1e +0, 0, 0, 0, 2012, 0xcc7bba1a +0, 0, 0, 0, 2012, 0x1aa7cd1a +0, 0, 0, 0, 2012, 0xd707c202 +0, 0, 0, 0, 2012, 0xcb6ac18b +0, 0, 0, 0, 2012, 0x1ccdcbd6 +0, 0, 0, 0, 2012, 0x700cb51e +0, 0, 0, 0, 2012, 0x27b6a3e7 +0, 0, 0, 0, 2012, 0x8570b8cd +0, 0, 0, 0, 2012, 0x22f2b2ed +0, 0, 0, 0, 2012, 0x75edb63e +0, 0, 0, 0, 2012, 0x8145b53f +0, 0, 0, 0, 2012, 0x15efb8bc +0, 0, 0, 0, 2012, 0x200bb5e6 +0, 0, 0, 0, 2012, 0xfa79b178 +0, 0, 0, 0, 2012, 0xbd39cdf4 +0, 0, 0, 0, 2012, 0x0970b0b2 +0, 0, 0, 0, 2012, 0x1acebe72 +0, 0, 0, 0, 2012, 0x1a26aa71 +0, 0, 0, 0, 2012, 0x8f71aa54 +0, 0, 0, 0, 2012, 0x0265c523 +0, 0, 0, 0, 2012, 0x2df0a53b +0, 0, 0, 0, 2012, 0x59a7a37a +0, 0, 0, 0, 2012, 0x9ad9acda +0, 0, 0, 0, 2012, 0x738cbc6f +0, 0, 0, 0, 2012, 0xc646a7ad +0, 0, 0, 0, 2012, 0x7f25c19b +0, 0, 0, 0, 2012, 0x1439bdb0 +0, 0, 0, 0, 2012, 0xa40cbef0 +0, 0, 0, 0, 2012, 0x9b09b99a +0, 0, 0, 0, 2012, 0x5ff0bbde +0, 0, 0, 0, 2012, 0x3981c2d6 +0, 0, 0, 0, 2012, 0xfa89b40d +0, 0, 0, 0, 2012, 0x12e9a7b9 +0, 0, 0, 0, 2012, 0xc5faaac3 +0, 0, 0, 0, 2012, 0xe12bc3a9 +0, 0, 0, 0, 2012, 0x9c57b8f3 +0, 0, 0, 0, 2012, 0x4fd4b6c0 +0, 0, 0, 0, 2012, 0xb72cca50 +0, 0, 0, 0, 2012, 0xb4d4cbbb +0, 0, 0, 0, 2012, 0x9399bfa1 +0, 0, 0, 0, 2012, 0x0abfb708 +0, 0, 0, 0, 2012, 0xd1d9acc0 +0, 0, 0, 0, 2012, 0x079ab5b2 +0, 0, 0, 0, 2012, 0x05a0be32 +0, 0, 0, 0, 2012, 0x445cc8db +0, 0, 0, 0, 2012, 0xf9a3aa71 +0, 0, 0, 0, 2012, 0xd2e29eac +0, 0, 0, 0, 2012, 0x391a9f20 +0, 0, 0, 0, 2012, 0x571eab4e +0, 0, 0, 0, 2012, 0x6962bc96 +0, 0, 0, 0, 2012, 0x2f04b495 +0, 0, 0, 0, 2012, 0x7b66bab7 +0, 0, 0, 0, 2012, 0xa718b8c9 +0, 0, 0, 0, 2012, 0xb069a54e +0, 0, 0, 0, 2012, 0xc052a1d2 +0, 0, 0, 0, 2012, 0x661ac62e +0, 0, 0, 0, 2012, 0xc4ebb529 +0, 0, 0, 0, 2012, 0xf998b251 +0, 0, 0, 0, 2012, 0x0ee8bffa +0, 0, 0, 0, 2012, 0x6e3fd984 +0, 0, 0, 0, 2012, 0x5825b63f +0, 0, 0, 0, 2012, 0x9c79c561 +0, 0, 0, 0, 2012, 0x3470beb7 +0, 0, 0, 0, 2012, 0x9135bd9d +0, 0, 0, 0, 2012, 0xd8e8bb7f +0, 0, 0, 0, 2012, 0x322ea448 +0, 0, 0, 0, 2012, 0xe974b3ab +0, 0, 0, 0, 2012, 0x4151c32d +0, 0, 0, 0, 2012, 0x2b05bf7d +0, 0, 0, 0, 2012, 0x4111c0d8 +0, 0, 0, 0, 2012, 0xff9ad574 +0, 0, 0, 0, 2012, 0xa55dced2 +0, 0, 0, 0, 2012, 0x11e6c0cb +0, 0, 0, 0, 2012, 0x2478b998 +0, 0, 0, 0, 2012, 0xdc8abb54 +0, 0, 0, 0, 2012, 0xe16da510 +0, 0, 0, 0, 2012, 0xfc18b3db +0, 0, 0, 0, 2012, 0x1426cd42 +0, 0, 0, 0, 2012, 0xb560a661 +0, 0, 0, 0, 2012, 0xc200aa4b +0, 0, 0, 0, 2012, 0xea00af2a +0, 0, 0, 0, 2012, 0x32bcbf84 +0, 0, 0, 0, 2012, 0x4c29cb2a +0, 0, 0, 0, 2012, 0xe8a2aabc +0, 0, 0, 0, 2012, 0x64bdb6cd +0, 0, 0, 0, 2012, 0x3a80adbc +0, 0, 0, 0, 2012, 0xa012b2c4 +0, 0, 0, 0, 2012, 0xac3ebce7 +0, 0, 0, 0, 2012, 0xfae1b2a7 +0, 0, 0, 0, 2012, 0x37b4ddae +0, 0, 0, 0, 2012, 0x8ff9bd55 +0, 0, 0, 0, 2012, 0x16f6abeb +0, 0, 0, 0, 2012, 0x5820badf +0, 0, 0, 0, 2012, 0x7183b45e +0, 0, 0, 0, 2012, 0xc0a6c826 +0, 0, 0, 0, 2012, 0x4c36bb02 +0, 0, 0, 0, 2012, 0xda46b854 +0, 0, 0, 0, 2012, 0xcc8accb6 +0, 0, 0, 0, 2012, 0xa6b2c3a2 +0, 0, 0, 0, 2012, 0x1c91cc00 +0, 0, 0, 0, 2012, 0xf33cd721 +0, 0, 0, 0, 2012, 0x7f86d2ed +0, 0, 0, 0, 2012, 0x9fdabb1d +0, 0, 0, 0, 2012, 0x33ebbbc4 +0, 0, 0, 0, 2012, 0x2741ba4f +0, 0, 0, 0, 2012, 0x0d0dd107 +0, 0, 0, 0, 2012, 0xf1d5b551 +0, 0, 0, 0, 2012, 0xf47dbebc +0, 0, 0, 0, 2012, 0xa955cea3 +0, 0, 0, 0, 2012, 0x51d6b407 +0, 0, 0, 0, 2012, 0xb7d3c2c0 +0, 0, 0, 0, 2012, 0xce3cc6ae +0, 0, 0, 0, 2012, 0x782cc184 +0, 0, 0, 0, 2012, 0xf4cec2af +0, 0, 0, 0, 2012, 0xa43eb295 +0, 0, 0, 0, 2012, 0xc74aa62d +0, 0, 0, 0, 2012, 0xf9dfc11f +0, 0, 0, 0, 2012, 0x3da1a319 +0, 0, 0, 0, 2012, 0xf613bd75 +0, 0, 0, 0, 2012, 0x10d9cda4 +0, 0, 0, 0, 2012, 0x08c9bcb3 +0, 0, 0, 0, 2012, 0x43b9d170 +0, 0, 0, 0, 2012, 0x1f0db940 +0, 0, 0, 0, 2012, 0x3c4ec614 +0, 0, 0, 0, 2012, 0xa94abaaa +0, 0, 0, 0, 2012, 0x2557a922 +0, 0, 0, 0, 2012, 0x4245c4b4 +0, 0, 0, 0, 2012, 0x0cb1b06f +0, 0, 0, 0, 2012, 0x778bbeab +0, 0, 0, 0, 2012, 0x5ce4ca3b +0, 0, 0, 0, 2012, 0xe70e9fd3 +0, 0, 0, 0, 2012, 0x28afbcbf +0, 0, 0, 0, 2012, 0xc41fb9b2 +0, 0, 0, 0, 2012, 0xd60cbfae +0, 0, 0, 0, 2012, 0x1087cb26 +0, 0, 0, 0, 2012, 0xc9face3b +0, 0, 0, 0, 2012, 0x7403b314 +0, 0, 0, 0, 2012, 0xe034ba97 +0, 0, 0, 0, 2012, 0x15dcbc67 +0, 0, 0, 0, 2012, 0x20d3bcff +0, 0, 0, 0, 2012, 0xc136a2ce +0, 0, 0, 0, 2012, 0x038bb025 +0, 0, 0, 0, 2012, 0xd655cf84 +0, 0, 0, 0, 2012, 0xcf54c656 +0, 0, 0, 0, 2012, 0x3c77bb0d +0, 0, 0, 0, 2012, 0xd765d7a7 +0, 0, 0, 0, 2012, 0x1a60b020 +0, 0, 0, 0, 2012, 0x83c8c2e9 +0, 0, 0, 0, 2012, 0x9b97c6e7 +0, 0, 0, 0, 2012, 0x3870ad63 +0, 0, 0, 0, 2012, 0x0e3ac67d +0, 0, 0, 0, 2012, 0xeb53c935 +0, 0, 0, 0, 2012, 0xeeb0c3e1 +0, 0, 0, 0, 2012, 0x9cb5bdb9 +0, 0, 0, 0, 2012, 0x64b1afec +0, 0, 0, 0, 2012, 0x57dcadbc +0, 0, 0, 0, 2012, 0xed76c5fd +0, 0, 0, 0, 2012, 0x0cb4cac5 +0, 0, 0, 0, 2012, 0xd30bbd06 +0, 0, 0, 0, 2012, 0xaee9c6c3 +0, 0, 0, 0, 2012, 0xe845c9b3 +0, 0, 0, 0, 2012, 0xc09cc7fc +0, 0, 0, 0, 2012, 0xfdebaacb +0, 0, 0, 0, 2012, 0x6f2db89f +0, 0, 0, 0, 2012, 0x7d89bee7 +0, 0, 0, 0, 2012, 0x8699b8be +0, 0, 0, 0, 2012, 0x57d6cc8a +0, 0, 0, 0, 2012, 0xcdbcd246 +0, 0, 0, 0, 2012, 0x9057b285 +0, 0, 0, 0, 2012, 0x2ac9cc87 +0, 0, 0, 0, 2012, 0xeb20c421 +0, 0, 0, 0, 2012, 0x4789d11f +0, 0, 0, 0, 2012, 0x55e7c9fe +0, 0, 0, 0, 2012, 0xd81cb4c6 +0, 0, 0, 0, 2012, 0x2af0a88e +0, 0, 0, 0, 2012, 0x7d96a4ee +0, 0, 0, 0, 2012, 0xff7cc3ea +0, 0, 0, 0, 2012, 0x2514d2a8 +0, 0, 0, 0, 2012, 0x7d2cccc3 +0, 0, 0, 0, 2012, 0x98dccbbf +0, 0, 0, 0, 2012, 0x55f2bd3e +0, 0, 0, 0, 2012, 0x0e58bbd7 +0, 0, 0, 0, 2012, 0x1520c45d +0, 0, 0, 0, 2012, 0x3c60cede +0, 0, 0, 0, 2012, 0xbfb2be6b +0, 0, 0, 0, 2012, 0xa839c2d5 +0, 0, 0, 0, 2012, 0x7713bdba +0, 0, 0, 0, 2012, 0xf16c9e95 +0, 0, 0, 0, 2012, 0x8e94caf1 +0, 0, 0, 0, 2012, 0x3915c673 +0, 0, 0, 0, 2012, 0x69afc76f +0, 0, 0, 0, 2012, 0x3ebec514 +0, 0, 0, 0, 2012, 0x70c5dd9b +0, 0, 0, 0, 2012, 0x6868b7d9 +0, 0, 0, 0, 2012, 0x9a31c801 +0, 0, 0, 0, 2012, 0x93c4b6ac +0, 0, 0, 0, 2012, 0xb1aaca39 +0, 0, 0, 0, 2012, 0x8f67b9ed +0, 0, 0, 0, 2012, 0x09adcf1f +0, 0, 0, 0, 2012, 0xe172cb3c +0, 0, 0, 0, 2012, 0x044bbdc5 +0, 0, 0, 0, 2012, 0x391cb3d9 +0, 0, 0, 0, 2012, 0x3bd1bc29 +0, 0, 0, 0, 2012, 0x8a78c5d2 +0, 0, 0, 0, 2012, 0xa46fce11 +0, 0, 0, 0, 2012, 0x4c13d9bc +0, 0, 0, 0, 2012, 0x7f47ce4f +0, 0, 0, 0, 2012, 0xa03ebcae +0, 0, 0, 0, 2012, 0xf6f2b2c8 +0, 0, 0, 0, 2012, 0x7995be2a +0, 0, 0, 0, 2012, 0x22d7b94a +0, 0, 0, 0, 2012, 0x07bcc06a +0, 0, 0, 0, 2012, 0x04adcb6d +0, 0, 0, 0, 2012, 0x4aecc135 +0, 0, 0, 0, 2012, 0x8442dc6a +0, 0, 0, 0, 2012, 0x9e67b826 +0, 0, 0, 0, 2012, 0xb1c4b235 +0, 0, 0, 0, 2012, 0x565ecaae +0, 0, 0, 0, 2012, 0x34a2c877 +0, 0, 0, 0, 2012, 0x815eb148 +0, 0, 0, 0, 2012, 0x354eb4ce +0, 0, 0, 0, 2012, 0xf74db8b1 +0, 0, 0, 0, 2012, 0x56f3b430 +0, 0, 0, 0, 2012, 0x39f9c72f +0, 0, 0, 0, 2012, 0x83d1bfde +0, 0, 0, 0, 2012, 0x2da1bf57 +0, 0, 0, 0, 2012, 0xd97fc933 +0, 0, 0, 0, 2012, 0x4b3edbfe +0, 0, 0, 0, 2012, 0xb975d346 +0, 0, 0, 0, 2012, 0x856ac304 +0, 0, 0, 0, 2012, 0xb38dba2e +0, 0, 0, 0, 2012, 0xbe14c822 +0, 0, 0, 0, 2012, 0xb848c927 +0, 0, 0, 0, 2012, 0x0a89c0e6 +0, 0, 0, 0, 2012, 0x44a3c3d5 +0, 0, 0, 0, 2012, 0x7af1c30c +0, 0, 0, 0, 2012, 0xe928b619 +0, 0, 0, 0, 2012, 0xc9aeb012 +0, 0, 0, 0, 2012, 0xae02cfde +0, 0, 0, 0, 2012, 0x0b42c3d9 +0, 0, 0, 0, 2012, 0xa5b7c1ed +0, 0, 0, 0, 2012, 0xd2dcbcdc +0, 0, 0, 0, 2012, 0x18cfbf55 +0, 0, 0, 0, 2012, 0x34f0c800 +0, 0, 0, 0, 2012, 0x2a80bdba +0, 0, 0, 0, 2012, 0x5ef2b3a7 +0, 0, 0, 0, 2012, 0x35a6ba33 +0, 0, 0, 0, 2012, 0x1088bbf5 +0, 0, 0, 0, 2012, 0xaec0bedf +0, 0, 0, 0, 2012, 0x769fb535 +0, 0, 0, 0, 2012, 0xfe11b979 +0, 0, 0, 0, 2012, 0xe856b37e +0, 0, 0, 0, 2012, 0x36c3cffd +0, 0, 0, 0, 2012, 0x4771db58 +0, 0, 0, 0, 2012, 0x5467d13e +0, 0, 0, 0, 2012, 0xb405c1b5 +0, 0, 0, 0, 2012, 0x3cbdc145 +0, 0, 0, 0, 2012, 0xbb9ccdd7 +0, 0, 0, 0, 2012, 0xac25ce9e +0, 0, 0, 0, 2012, 0x6d2ac82a +0, 0, 0, 0, 2012, 0x1661ba50 +0, 0, 0, 0, 2012, 0xbc7ac82a +0, 0, 0, 0, 2012, 0x020bb4de +0, 0, 0, 0, 2012, 0x4e10cb93 +0, 0, 0, 0, 2012, 0x3dabc15f +0, 0, 0, 0, 2012, 0x12acc64b +0, 0, 0, 0, 2012, 0x9cecb51a +0, 0, 0, 0, 2012, 0x959acb39 +0, 0, 0, 0, 2012, 0x3ee7c0e8 +0, 0, 0, 0, 2012, 0xde18c1df +0, 0, 0, 0, 2012, 0x3c72c3cd +0, 0, 0, 0, 2012, 0x1ac4bb5d +0, 0, 0, 0, 2012, 0xb155c741 +0, 0, 0, 0, 2012, 0x5069c8aa +0, 0, 0, 0, 2012, 0x610db0bc +0, 0, 0, 0, 2012, 0xb82bc329 +0, 0, 0, 0, 2012, 0x8bd4c522 +0, 0, 0, 0, 2012, 0xd44bb865 +0, 0, 0, 0, 2012, 0xb51ac7dc +0, 0, 0, 0, 2012, 0xfe2bc799 +0, 0, 0, 0, 2012, 0x8cd1bb53 +0, 0, 0, 0, 2012, 0xba13ca97 +0, 0, 0, 0, 2012, 0xf107bd51 +0, 0, 0, 0, 2012, 0xa04ece95 +0, 0, 0, 0, 2012, 0x4f4faa54 +0, 0, 0, 0, 2012, 0x5a74bfe1 +0, 0, 0, 0, 2012, 0xdafade5b +0, 0, 0, 0, 2012, 0x738fba51 +0, 0, 0, 0, 2012, 0xe7b2b78e +0, 0, 0, 0, 2012, 0x7685b6ce +0, 0, 0, 0, 2012, 0xae45bd8a +0, 0, 0, 0, 2012, 0xd52cc84e +0, 0, 0, 0, 2012, 0x04abd773 +0, 0, 0, 0, 2012, 0x2badb0ff +0, 0, 0, 0, 2012, 0x0eaec6b2 +0, 0, 0, 0, 2012, 0x7c1ec33f +0, 0, 0, 0, 2012, 0x8773b925 +0, 0, 0, 0, 2012, 0x40bbc36d +0, 0, 0, 0, 2012, 0x330bc288 +0, 0, 0, 0, 2012, 0x1659b6f5 +0, 0, 0, 0, 2012, 0x66eac162 +0, 0, 0, 0, 2012, 0xf3acdb3d +0, 0, 0, 0, 2012, 0x465abb87 +0, 0, 0, 0, 2012, 0xe8e9bc16 +0, 0, 0, 0, 2012, 0x71eebbd9 +0, 0, 0, 0, 2012, 0x1f59cb2a +0, 0, 0, 0, 2012, 0x53e3c9e7 +0, 0, 0, 0, 2012, 0xf410b939 +0, 0, 0, 0, 2012, 0xdb13d1b3 +0, 0, 0, 0, 2012, 0xcd26bf27 +0, 0, 0, 0, 2012, 0x707ecc9c +0, 0, 0, 0, 2012, 0x3483b6bf +0, 0, 0, 0, 2012, 0x4184d451 +0, 0, 0, 0, 2012, 0xcf6abfae +0, 0, 0, 0, 2012, 0x5c9eb4ca +0, 0, 0, 0, 2012, 0xf396be01 +0, 0, 0, 0, 2012, 0x06bfda38 +0, 0, 0, 0, 2012, 0x0e92bcf4 +0, 0, 0, 0, 2012, 0xaaa2b99d +0, 0, 0, 0, 2012, 0xf112a9a9 +0, 0, 0, 0, 2012, 0x2844bdf1 +0, 0, 0, 0, 2012, 0xb96baf39 +0, 0, 0, 0, 2012, 0xd4f2d157 +0, 0, 0, 0, 2012, 0x7c74b149 +0, 0, 0, 0, 2012, 0xbd43d5f2 +0, 0, 0, 0, 2012, 0xaa10b2ba +0, 0, 0, 0, 2012, 0x66e9b95f +0, 0, 0, 0, 2012, 0x6f01abef +0, 0, 0, 0, 2012, 0x1cb5c664 +0, 0, 0, 0, 2012, 0x5ee2afc5 +0, 0, 0, 0, 2012, 0xeb39d213 +0, 0, 0, 0, 2012, 0x1ffeaafc +0, 0, 0, 0, 2012, 0x6bb4d548 +0, 0, 0, 0, 2012, 0xa045b23a +0, 0, 0, 0, 2012, 0x17c3aa49 +0, 0, 0, 0, 2012, 0x2d47db7c +0, 0, 0, 0, 2012, 0x07ddc9ac +0, 0, 0, 0, 2012, 0xa386c99e +0, 0, 0, 0, 2012, 0x0e0bae8a +0, 0, 0, 0, 2012, 0x7d6fc419 +0, 0, 0, 0, 2012, 0x34a3c5a2 +0, 0, 0, 0, 2012, 0xda81c8e9 +0, 0, 0, 0, 2012, 0xde53bcd8 +0, 0, 0, 0, 2012, 0x372ac065 +0, 0, 0, 0, 2012, 0x6d07a95c +0, 0, 0, 0, 2012, 0x296eb47f +0, 0, 0, 0, 2012, 0x0f47be2a +0, 0, 0, 0, 2012, 0x389ebaf6 +0, 0, 0, 0, 2012, 0x9746ba3b +0, 0, 0, 0, 2012, 0x070e9aed +0, 0, 0, 0, 2012, 0xa4abc798 +0, 0, 0, 0, 2012, 0xe55cac7b +0, 0, 0, 0, 2012, 0x0c71ba45 +0, 0, 0, 0, 2012, 0x70fbb3c5 +0, 0, 0, 0, 2012, 0xa35ec30a +0, 0, 0, 0, 2012, 0xf30ab935 +0, 0, 0, 0, 2012, 0x2cbb9b99 +0, 0, 0, 0, 2012, 0x6606c1bf +0, 0, 0, 0, 2012, 0x41ccad5c +0, 0, 0, 0, 2012, 0x352fc002 +0, 0, 0, 0, 2012, 0x1763bd10 +0, 0, 0, 0, 2012, 0xb54bcae6 +0, 0, 0, 0, 2012, 0x7374ab92 +0, 0, 0, 0, 2012, 0x2895a99a +0, 0, 0, 0, 2012, 0x9f68b02f +0, 0, 0, 0, 2012, 0xdfabbb76 +0, 0, 0, 0, 2012, 0x764ea6c5 +0, 0, 0, 0, 2012, 0x4e83c5a5 +0, 0, 0, 0, 2012, 0xf0e8c76a +0, 0, 0, 0, 2012, 0xdc80b4ea +0, 0, 0, 0, 2012, 0xcc53b0a5 +0, 0, 0, 0, 2012, 0x7893bc7f +0, 0, 0, 0, 2012, 0x6965b355 +0, 0, 0, 0, 2012, 0x7f8fac00 +0, 0, 0, 0, 2012, 0x6c71c7b8 +0, 0, 0, 0, 2012, 0xa00ec367 +0, 0, 0, 0, 2012, 0x5f0fc50e +0, 0, 0, 0, 2012, 0x1bd2ad87 +0, 0, 0, 0, 2012, 0xd054ba2d +0, 0, 0, 0, 2012, 0xaf80a0d5 +0, 0, 0, 0, 2012, 0x2acac873 +0, 0, 0, 0, 2012, 0x260ca584 +0, 0, 0, 0, 2012, 0x4f98aa7c +0, 0, 0, 0, 2012, 0x0254aa36 +0, 0, 0, 0, 2012, 0xe3c7c33a +0, 0, 0, 0, 2012, 0x3b9ea70f +0, 0, 0, 0, 2012, 0xe829b7e6 +0, 0, 0, 0, 2012, 0x9317a8d1 +0, 0, 0, 0, 2012, 0x88b3a98f +0, 0, 0, 0, 2012, 0xa4a8c3bc +0, 0, 0, 0, 2012, 0x95c9a869 +0, 0, 0, 0, 2012, 0x7f889fed +0, 0, 0, 0, 2012, 0x5438c408 +0, 0, 0, 0, 2012, 0x3455a366 +0, 0, 0, 0, 2012, 0x5319b33d +0, 0, 0, 0, 2012, 0xb19dc4f0 +0, 0, 0, 0, 2012, 0xf080b109 +0, 0, 0, 0, 2012, 0xef83d8e7 +0, 0, 0, 0, 2012, 0x237ac69c +0, 0, 0, 0, 2012, 0xbb30b714 +0, 0, 0, 0, 2012, 0x8745ba54 +0, 0, 0, 0, 2012, 0x8588bd6c +0, 0, 0, 0, 2012, 0xc580bdde +0, 0, 0, 0, 2012, 0xb062baf1 +0, 0, 0, 0, 2012, 0xe014b082 +0, 0, 0, 0, 2012, 0x148bcb87 +0, 0, 0, 0, 2012, 0x554bc13d +0, 0, 0, 0, 2012, 0xc410c270 +0, 0, 0, 0, 2012, 0xb2c8b65b +0, 0, 0, 0, 2012, 0xa412b3f4 +0, 0, 0, 0, 2012, 0xbb52aa9a +0, 0, 0, 0, 2012, 0x4005b527 +0, 0, 0, 0, 2012, 0x8c5eb055 +0, 0, 0, 0, 2012, 0x8622c142 +0, 0, 0, 0, 2012, 0x05a3b861 +0, 0, 0, 0, 2012, 0x9f6dbb4d +0, 0, 0, 0, 2012, 0x033fb867 +0, 0, 0, 0, 2012, 0x243babd5 +0, 0, 0, 0, 2012, 0x8d6db83c +0, 0, 0, 0, 2012, 0x3923b829 +0, 0, 0, 0, 2012, 0x69b6b587 +0, 0, 0, 0, 2012, 0xdda8d018 +0, 0, 0, 0, 2012, 0x54b1b2a4 +0, 0, 0, 0, 2012, 0x380eb1af +0, 0, 0, 0, 2012, 0xec3cbdb4 +0, 0, 0, 0, 2012, 0x7ce9b4cf +0, 0, 0, 0, 2012, 0xcf6cb99b +0, 0, 0, 0, 2012, 0x7383ab97 +0, 0, 0, 0, 2012, 0xaa4cc068 +0, 0, 0, 0, 2012, 0x96d4c3db +0, 0, 0, 0, 2012, 0xab8cb84f +0, 0, 0, 0, 2012, 0x73dcacf9 +0, 0, 0, 0, 2012, 0xf61ca122 +0, 0, 0, 0, 2012, 0x9f1cbd5b +0, 0, 0, 0, 2012, 0x1f84aa3f +0, 0, 0, 0, 2012, 0xa003ad43 +0, 0, 0, 0, 2012, 0x6cffa4ef +0, 0, 0, 0, 2012, 0x29559e1e +0, 0, 0, 0, 2012, 0x7a79b059 +0, 0, 0, 0, 2012, 0xa1929c42 +0, 0, 0, 0, 2012, 0x52dead1c +0, 0, 0, 0, 2012, 0x8f31b9f5 +0, 0, 0, 0, 2012, 0xb8a899ec +0, 0, 0, 0, 2012, 0x7ca4b02d +0, 0, 0, 0, 2012, 0x2c92ae1b +0, 0, 0, 0, 2012, 0xe683a92f +0, 0, 0, 0, 2012, 0xe9d5abcf +0, 0, 0, 0, 2012, 0x757db377 +0, 0, 0, 0, 2012, 0xd4a8bbae +0, 0, 0, 0, 2012, 0xeea5c4ee +0, 0, 0, 0, 2012, 0xc37ca9a9 +0, 0, 0, 0, 2012, 0x8871bb51 +0, 0, 0, 0, 2012, 0x5dd8b3a2 +0, 0, 0, 0, 2012, 0xef0fae7f +0, 0, 0, 0, 2012, 0xe7ecb23e +0, 0, 0, 0, 2012, 0xc4f6d437 +0, 0, 0, 0, 2012, 0x0c74b81d +0, 0, 0, 0, 2012, 0xee68b1ee +0, 0, 0, 0, 2012, 0x46b4b4a8 +0, 0, 0, 0, 2012, 0x0526abca +0, 0, 0, 0, 2012, 0x7695ba55 +0, 0, 0, 0, 2012, 0xc7f5ad90 +0, 0, 0, 0, 2012, 0x0522b9bc +0, 0, 0, 0, 2012, 0x0eefc6ad +0, 0, 0, 0, 2012, 0x340dae16 +0, 0, 0, 0, 2012, 0xea42bdc0 +0, 0, 0, 0, 2012, 0xe047abb6 +0, 0, 0, 0, 2012, 0x6da5c14f +0, 0, 0, 0, 2012, 0x46d8c11d +0, 0, 0, 0, 2012, 0x8f4d9f2f +0, 0, 0, 0, 2012, 0x6d00d26c +0, 0, 0, 0, 2012, 0x87fc9d1b +0, 0, 0, 0, 2012, 0xbba5b763 +0, 0, 0, 0, 2012, 0xab58b853 +0, 0, 0, 0, 2012, 0x8180b863 +0, 0, 0, 0, 2012, 0x3684b3ba +0, 0, 0, 0, 2012, 0xf1a4a806 +0, 0, 0, 0, 2012, 0x2826b48c +0, 0, 0, 0, 2012, 0x1883af7f +0, 0, 0, 0, 2012, 0x44c5c37a +0, 0, 0, 0, 2012, 0xec33c3f1 +0, 0, 0, 0, 2012, 0xd67fb767 +0, 0, 0, 0, 2012, 0x03c2c219 +0, 0, 0, 0, 2012, 0x75a9b389 +0, 0, 0, 0, 2012, 0xe041ad88 +0, 0, 0, 0, 2012, 0x6bccb005 +0, 0, 0, 0, 2012, 0xd881c24a +0, 0, 0, 0, 2012, 0x7dd0c302 +0, 0, 0, 0, 2012, 0x2ba8a649 +0, 0, 0, 0, 2012, 0x63e19eab +0, 0, 0, 0, 2012, 0x1c0dafce +0, 0, 0, 0, 2012, 0xf266bf47 +0, 0, 0, 0, 2012, 0x11beb4b1 +0, 0, 0, 0, 2012, 0xc6f6b2b5 +0, 0, 0, 0, 2012, 0x15d4b4d0 +0, 0, 0, 0, 2012, 0x08bfa1e7 +0, 0, 0, 0, 2012, 0x18dbb7b5 +0, 0, 0, 0, 2012, 0xc279cc67 +0, 0, 0, 0, 2012, 0xd236bf28 +0, 0, 0, 0, 2012, 0xc9d1b196 +0, 0, 0, 0, 2012, 0xb605983e +0, 0, 0, 0, 2012, 0x8132c566 +0, 0, 0, 0, 2012, 0x6be4cd39 +0, 0, 0, 0, 2012, 0xce53c1f9 +0, 0, 0, 0, 2012, 0xe1efac0f +0, 0, 0, 0, 2012, 0x3d60a57a +0, 0, 0, 0, 2012, 0x1beda4b7 +0, 0, 0, 0, 2012, 0x34a4ac81 +0, 0, 0, 0, 2012, 0x30b0be4b +0, 0, 0, 0, 2012, 0xc7ceaf45 +0, 0, 0, 0, 2012, 0xade0b6ec +0, 0, 0, 0, 2012, 0xe00daf06 +0, 0, 0, 0, 2012, 0x04f79fe4 +0, 0, 0, 0, 2012, 0x8c59b7d9 +0, 0, 0, 0, 2012, 0x6f66b92a +0, 0, 0, 0, 2012, 0x9b08b2c0 +0, 0, 0, 0, 2012, 0xa8c1b5c1 +0, 0, 0, 0, 2012, 0xe3aac0b0 +0, 0, 0, 0, 2012, 0x1622bdaf +0, 0, 0, 0, 2012, 0x25e1a9ff +0, 0, 0, 0, 2012, 0x5577ad82 +0, 0, 0, 0, 2012, 0xfe16a49b +0, 0, 0, 0, 2012, 0xef7fc32a +0, 0, 0, 0, 2012, 0xfe30c35d +0, 0, 0, 0, 2012, 0x3adc9610 +0, 0, 0, 0, 2012, 0x36eeabdc +0, 0, 0, 0, 2012, 0xde3fb56c +0, 0, 0, 0, 2012, 0x5629bd82 +0, 0, 0, 0, 2012, 0xb099a61d +0, 0, 0, 0, 2012, 0x3013b106 +0, 0, 0, 0, 2012, 0xc359aef3 +0, 0, 0, 0, 2012, 0xec01b3e1 +0, 0, 0, 0, 2012, 0x6e8ac0b1 +0, 0, 0, 0, 2012, 0x41e8b82d +0, 0, 0, 0, 2012, 0x3a2fb38b +0, 0, 0, 0, 2012, 0x7025aac9 +0, 0, 0, 0, 2012, 0xbb0eb094 +0, 0, 0, 0, 2012, 0xdc06c156 +0, 0, 0, 0, 2012, 0x4007cea4 +0, 0, 0, 0, 2012, 0x102ebe03 +0, 0, 0, 0, 2012, 0x6e8faae7 +0, 0, 0, 0, 2012, 0xa357aa0c +0, 0, 0, 0, 2012, 0x07d2bf4d +0, 0, 0, 0, 2012, 0xfb71b338 +0, 0, 0, 0, 2012, 0xd5f1be84 +0, 0, 0, 0, 2012, 0x2a7cb554 +0, 0, 0, 0, 2012, 0xfb03b8c3 +0, 0, 0, 0, 2012, 0x2ff1ca87 +0, 0, 0, 0, 2012, 0xeef2b7f3 +0, 0, 0, 0, 2012, 0x9377b15f +0, 0, 0, 0, 2012, 0x370cb0c2 +0, 0, 0, 0, 2012, 0x5f78b118 +0, 0, 0, 0, 2012, 0x19afa87a +0, 0, 0, 0, 2012, 0xc717ab0d +0, 0, 0, 0, 2012, 0x3ca499f4 +0, 0, 0, 0, 2012, 0x9612b8e4 +0, 0, 0, 0, 2012, 0x32c0bb29 +0, 0, 0, 0, 2012, 0x7727beba +0, 0, 0, 0, 2012, 0x8b60a4cb +0, 0, 0, 0, 2012, 0xe899a9c8 +0, 0, 0, 0, 2012, 0x60f4b7fe +0, 0, 0, 0, 2012, 0x544f9ecb +0, 0, 0, 0, 2012, 0x34afcd71 +0, 0, 0, 0, 2012, 0x470eab55 +0, 0, 0, 0, 2012, 0xe4959f93 +0, 0, 0, 0, 2012, 0x69eeaf97 +0, 0, 0, 0, 2012, 0x0ec9aca3 +0, 0, 0, 0, 2012, 0x51e4b7f6 +0, 0, 0, 0, 2012, 0xf6c0a837 +0, 0, 0, 0, 2012, 0x3bdca59b +0, 0, 0, 0, 2012, 0x14c59dfc +0, 0, 0, 0, 2012, 0xa50ab23a +0, 0, 0, 0, 2012, 0x8832b6e2 +0, 0, 0, 0, 2012, 0x3d699d1b +0, 0, 0, 0, 2012, 0x751aa4b8 +0, 0, 0, 0, 2012, 0x59a9b98c +0, 0, 0, 0, 2012, 0xb67c98cb +0, 0, 0, 0, 2012, 0x0fd39ccd +0, 0, 0, 0, 2012, 0x9980d1e1 +0, 0, 0, 0, 2012, 0xffd9a716 +0, 0, 0, 0, 2012, 0x7d2fbed1 +0, 0, 0, 0, 2012, 0x76e6b042 +0, 0, 0, 0, 2012, 0xe027a232 +0, 0, 0, 0, 2012, 0x7c6ca5ce +0, 0, 0, 0, 2012, 0x5cf6bda4 +0, 0, 0, 0, 2012, 0x6075bd0d +0, 0, 0, 0, 2012, 0xedc4abe9 +0, 0, 0, 0, 2012, 0xb8f7cc26 +0, 0, 0, 0, 2012, 0x2cbbb500 +0, 0, 0, 0, 2012, 0x1c34b04d +0, 0, 0, 0, 2012, 0x5f18bea2 +0, 0, 0, 0, 2012, 0x94d0bb2b +0, 0, 0, 0, 2012, 0x6899b78e +0, 0, 0, 0, 2012, 0xc9aaa7a2 +0, 0, 0, 0, 2012, 0x298cbafa +0, 0, 0, 0, 2012, 0x89d9ac80 +0, 0, 0, 0, 2012, 0xc6ffa7e6 +0, 0, 0, 0, 2012, 0xdcf7caf9 +0, 0, 0, 0, 2012, 0x26cfb4ee +0, 0, 0, 0, 2012, 0xec70b09d +0, 0, 0, 0, 2012, 0x65dca50f +0, 0, 0, 0, 2012, 0xcdebc0b6 +0, 0, 0, 0, 2012, 0x9393a262 +0, 0, 0, 0, 2012, 0x34aab06d +0, 0, 0, 0, 2012, 0x4800a550 +0, 0, 0, 0, 2012, 0x4d9aadec +0, 0, 0, 0, 2012, 0x2cddabb6 +0, 0, 0, 0, 2012, 0x91a0c5b2 +0, 0, 0, 0, 2012, 0xd326bee1 +0, 0, 0, 0, 2012, 0xf76ab2d5 +0, 0, 0, 0, 2012, 0xcef99ade +0, 0, 0, 0, 2012, 0x950dc76f +0, 0, 0, 0, 2012, 0xb6aca7ad +0, 0, 0, 0, 2012, 0x1aacb71c +0, 0, 0, 0, 2012, 0x32389da0 +0, 0, 0, 0, 2012, 0x030cbcce +0, 0, 0, 0, 2012, 0x0ec4b0cb +0, 0, 0, 0, 2012, 0x6c0bb62e +0, 0, 0, 0, 2012, 0xfadbb20d +0, 0, 0, 0, 2012, 0x99c9c848 +0, 0, 0, 0, 2012, 0xe3e3b21a +0, 0, 0, 0, 2012, 0x88d9a50b +0, 0, 0, 0, 2012, 0xf4bbaf17 +0, 0, 0, 0, 2012, 0x49fea706 +0, 0, 0, 0, 2012, 0xafd0babf +0, 0, 0, 0, 2012, 0x8970a8f3 +0, 0, 0, 0, 2012, 0x9223a553 +0, 0, 0, 0, 2012, 0x6ec2b2f9 +0, 0, 0, 0, 2012, 0x7960b759 +0, 0, 0, 0, 2012, 0x852891bf +0, 0, 0, 0, 2012, 0x094ebbeb +0, 0, 0, 0, 2012, 0xf9bab418 +0, 0, 0, 0, 2012, 0x010eae8c +0, 0, 0, 0, 2012, 0x10baab3d +0, 0, 0, 0, 2012, 0x2564b13f +0, 0, 0, 0, 2012, 0xaec8ac22 +0, 0, 0, 0, 2012, 0xda0cbd4f +0, 0, 0, 0, 2012, 0x97e1c075 +0, 0, 0, 0, 2012, 0x6731aca5 +0, 0, 0, 0, 2012, 0x2c1db696 +0, 0, 0, 0, 2012, 0x8ff7abbf +0, 0, 0, 0, 2012, 0xf75ab3a2 +0, 0, 0, 0, 2012, 0x8683b824 +0, 0, 0, 0, 2012, 0x9668b354 +0, 0, 0, 0, 2012, 0x6e9aae04 +0, 0, 0, 0, 2012, 0xd8e9acd7 +0, 0, 0, 0, 2012, 0xa326c298 +0, 0, 0, 0, 2012, 0x6abcb409 +0, 0, 0, 0, 2012, 0x7eb3b549 +0, 0, 0, 0, 2012, 0xfc72ba6a +0, 0, 0, 0, 2012, 0xed73b2e6 +0, 0, 0, 0, 2012, 0x07a6b0a9 +0, 0, 0, 0, 2012, 0x10a4aec4 +0, 0, 0, 0, 2012, 0xaac9a650 +0, 0, 0, 0, 2012, 0x848b9869 +0, 0, 0, 0, 2012, 0x1ddaafd6 +0, 0, 0, 0, 2012, 0xe291aaec +0, 0, 0, 0, 2012, 0x8aa1aa4d +0, 0, 0, 0, 2012, 0x9b69b94c +0, 0, 0, 0, 2012, 0xe784bec0 +0, 0, 0, 0, 2012, 0x9305ba2d +0, 0, 0, 0, 2012, 0x5616bb81 +0, 0, 0, 0, 2012, 0xea0facca +0, 0, 0, 0, 2012, 0xe1b9991e +0, 0, 0, 0, 2012, 0xded8bd59 +0, 0, 0, 0, 2012, 0xe79fb0ee +0, 0, 0, 0, 2012, 0x1b8595a6 +0, 0, 0, 0, 2012, 0xb55ba336 +0, 0, 0, 0, 2012, 0xc552bc98 +0, 0, 0, 0, 2012, 0x2fe2c5ba +0, 0, 0, 0, 2012, 0xe18aa5a6 +0, 0, 0, 0, 2012, 0xaa9bae1c +0, 0, 0, 0, 2012, 0xd1ddb68d +0, 0, 0, 0, 2012, 0x95bfb203 +0, 0, 0, 0, 2012, 0xeacab8b9 +0, 0, 0, 0, 2012, 0x5bfcb117 +0, 0, 0, 0, 2012, 0x1a9fa91c +0, 0, 0, 0, 2012, 0xa285b180 +0, 0, 0, 0, 2012, 0xfd58a6e2 +0, 0, 0, 0, 2012, 0x394fc325 +0, 0, 0, 0, 2012, 0x0415a6aa +0, 0, 0, 0, 2012, 0xf75fa5e0 +0, 0, 0, 0, 2012, 0x115cd11b +0, 0, 0, 0, 2012, 0x6587b9e3 +0, 0, 0, 0, 2012, 0xce6bb7e6 +0, 0, 0, 0, 2012, 0xbaa2b409 +0, 0, 0, 0, 2012, 0x271bbb14 +0, 0, 0, 0, 2012, 0x4516c223 +0, 0, 0, 0, 2012, 0x4f6ab266 +0, 0, 0, 0, 2012, 0x244ba6fc +0, 0, 0, 0, 2012, 0x60e0ae4e +0, 0, 0, 0, 2012, 0xfc3cac80 +0, 0, 0, 0, 2012, 0x8465b287 +0, 0, 0, 0, 2012, 0xc683b070 +0, 0, 0, 0, 2012, 0x2901c8e7 +0, 0, 0, 0, 2012, 0x0622b1a1 +0, 0, 0, 0, 2012, 0xe002b34c +0, 0, 0, 0, 2012, 0xf4969e79 +0, 0, 0, 0, 2012, 0x871cc453 +0, 0, 0, 0, 2012, 0x9a7daaf3 +0, 0, 0, 0, 2012, 0xba92a60a +0, 0, 0, 0, 2012, 0xf464a0c4 +0, 0, 0, 0, 2012, 0x53bbb6cd +0, 0, 0, 0, 2012, 0xb58a9d2a +0, 0, 0, 0, 2012, 0x1e1fb830 +0, 0, 0, 0, 2012, 0xdc7eb93e +0, 0, 0, 0, 2012, 0xe6ceaaf9 +0, 0, 0, 0, 2012, 0x8c7ea35d +0, 0, 0, 0, 2012, 0x0b87ba04 +0, 0, 0, 0, 2012, 0xf516a700 +0, 0, 0, 0, 2012, 0xfaf19e13 +0, 0, 0, 0, 2012, 0x53cf9ed0 +0, 0, 0, 0, 2012, 0x2e25c2f9 +0, 0, 0, 0, 2012, 0x959aa1b8 +0, 0, 0, 0, 2012, 0x2a49a572 +0, 0, 0, 0, 2012, 0xf7a9b809 +0, 0, 0, 0, 2012, 0x44a9b879 +0, 0, 0, 0, 2012, 0xe428c0d4 +0, 0, 0, 0, 2012, 0xc258c2c6 +0, 0, 0, 0, 2012, 0xf7f3b794 +0, 0, 0, 0, 2012, 0xa8adbad9 +0, 0, 0, 0, 2012, 0xc2508e79 +0, 0, 0, 0, 2012, 0x1418ac76 +0, 0, 0, 0, 2012, 0xb28aadef +0, 0, 0, 0, 2012, 0xda17bd03 +0, 0, 0, 0, 2012, 0xa92ab852 +0, 0, 0, 0, 2012, 0xc3cbcfa4 +0, 0, 0, 0, 2012, 0xf716bb5e +0, 0, 0, 0, 2012, 0x6009a8af +0, 0, 0, 0, 2012, 0x9e69bc81 +0, 0, 0, 0, 2012, 0x3aafc8cf +0, 0, 0, 0, 2012, 0x03bccdab +0, 0, 0, 0, 2012, 0xfdceb2d9 +0, 0, 0, 0, 2012, 0x68f7afb8 +0, 0, 0, 0, 2012, 0xb7bab330 +0, 0, 0, 0, 2012, 0x4976b125 +0, 0, 0, 0, 2012, 0x7c86ae12 +0, 0, 0, 0, 2012, 0x4ce4ca54 +0, 0, 0, 0, 2012, 0xf1f7b892 +0, 0, 0, 0, 2012, 0xf958abb1 +0, 0, 0, 0, 2012, 0x047accd0 +0, 0, 0, 0, 2012, 0x34a1c49c +0, 0, 0, 0, 2012, 0x4b24a4ed +0, 0, 0, 0, 2012, 0xea31b1bc +0, 0, 0, 0, 2012, 0x8beaa3e3 +0, 0, 0, 0, 2012, 0x064caaf9 +0, 0, 0, 0, 2012, 0x56babf15 +0, 0, 0, 0, 2012, 0xd16fc6f4 +0, 0, 0, 0, 2012, 0x4ac2b78a +0, 0, 0, 0, 2012, 0xba3aa509 +0, 0, 0, 0, 2012, 0xc103b074 +0, 0, 0, 0, 2012, 0x464aba98 +0, 0, 0, 0, 2012, 0xaacac5a3 +0, 0, 0, 0, 2012, 0x9cecbcfa +0, 0, 0, 0, 2012, 0x8da0ab79 +0, 0, 0, 0, 2012, 0x85b2b023 +0, 0, 0, 0, 2012, 0x598abc91 +0, 0, 0, 0, 2012, 0x08c0a35c +0, 0, 0, 0, 2012, 0x30e4a7cf +0, 0, 0, 0, 2012, 0xf1e4a931 +0, 0, 0, 0, 2012, 0x8a4fb6c1 +0, 0, 0, 0, 2012, 0x126aac08 +0, 0, 0, 0, 2012, 0x537fa51b +0, 0, 0, 0, 2012, 0x1e54ac5a +0, 0, 0, 0, 2012, 0x7274bbd0 +0, 0, 0, 0, 2012, 0xd16bc2c2 +0, 0, 0, 0, 2012, 0x9236c1e3 +0, 0, 0, 0, 2012, 0x348aa7af +0, 0, 0, 0, 2012, 0xa020be5e +0, 0, 0, 0, 2012, 0x3cc5a4b8 +0, 0, 0, 0, 2012, 0x8b19b649 +0, 0, 0, 0, 2012, 0x554aa5ab +0, 0, 0, 0, 2012, 0x35d6ac35 +0, 0, 0, 0, 2012, 0x64dba435 +0, 0, 0, 0, 2012, 0x6001bae2 +0, 0, 0, 0, 2012, 0x9220b599 +0, 0, 0, 0, 2012, 0xa3fdb899 +0, 0, 0, 0, 2012, 0x19a5abf4 +0, 0, 0, 0, 2012, 0xd857b8cf +0, 0, 0, 0, 2012, 0x38d1b234 +0, 0, 0, 0, 2012, 0x69f4bfb8 +0, 0, 0, 0, 2012, 0xcc87a375 +0, 0, 0, 0, 2012, 0xc1cdd0c5 +0, 0, 0, 0, 2012, 0xba0ca3ee +0, 0, 0, 0, 2012, 0x4d20c397 +0, 0, 0, 0, 2012, 0x825c9636 +0, 0, 0, 0, 2012, 0x7aa4ae53 +0, 0, 0, 0, 2012, 0xe970ae78 +0, 0, 0, 0, 2012, 0x5fb2ba59 +0, 0, 0, 0, 2012, 0xcd90a953 +0, 0, 0, 0, 2012, 0xf573ac40 +0, 0, 0, 0, 2012, 0x324cbd77 +0, 0, 0, 0, 2012, 0xece0a73d +0, 0, 0, 0, 2012, 0x0dd1aefa +0, 0, 0, 0, 2012, 0xe338c866 +0, 0, 0, 0, 2012, 0xfe71bffc +0, 0, 0, 0, 2012, 0x61a5a810 +0, 0, 0, 0, 2012, 0x7c3ba074 +0, 0, 0, 0, 2012, 0x492f9d91 +0, 0, 0, 0, 2012, 0xa126a7b9 +0, 0, 0, 0, 2012, 0x7cf19a40 +0, 0, 0, 0, 2012, 0x1c2fbae6 +0, 0, 0, 0, 2012, 0x540accdf +0, 0, 0, 0, 2012, 0x5908a938 +0, 0, 0, 0, 2012, 0xe7f8b501 +0, 0, 0, 0, 2012, 0x03a8b53e +0, 0, 0, 0, 2012, 0xb4e3bdda +0, 0, 0, 0, 2012, 0x9e86abe1 +0, 0, 0, 0, 2012, 0x3234b98d +0, 0, 0, 0, 2012, 0x5caec781 +0, 0, 0, 0, 2012, 0x5c21a32e +0, 0, 0, 0, 2012, 0x8b72c112 +0, 0, 0, 0, 2012, 0x2ec2bac3 +0, 0, 0, 0, 2012, 0xd9c4adaa +0, 0, 0, 0, 2012, 0x2da1b496 +0, 0, 0, 0, 2012, 0x0a51b21e +0, 0, 0, 0, 2012, 0x6414ab0d +0, 0, 0, 0, 2012, 0x95c4b203 +0, 0, 0, 0, 2012, 0x98e0b4a2 +0, 0, 0, 0, 2012, 0x34369f5f +0, 0, 0, 0, 2012, 0x9dffa40c +0, 0, 0, 0, 2012, 0xf345b0e5 +0, 0, 0, 0, 2012, 0x6714bdbf +0, 0, 0, 0, 2012, 0xc276c3d1 +0, 0, 0, 0, 2012, 0xf199b475 +0, 0, 0, 0, 2012, 0x3395cf3b +0, 0, 0, 0, 2012, 0x4b52afb0 +0, 0, 0, 0, 2012, 0x3f74b217 +0, 0, 0, 0, 2012, 0xa25cad38 +0, 0, 0, 0, 2012, 0x3290a5b4 +0, 0, 0, 0, 2012, 0x2917b750 +0, 0, 0, 0, 2012, 0xeb3ec739 +0, 0, 0, 0, 2012, 0xbf9ea51d +0, 0, 0, 0, 2012, 0x98e2a0c1 +0, 0, 0, 0, 2012, 0xa39ba7f2 +0, 0, 0, 0, 2012, 0x6df7a05c +0, 0, 0, 0, 2012, 0x2c1bba28 +0, 0, 0, 0, 2012, 0x6099b1cd +0, 0, 0, 0, 2012, 0x9366b9f2 +0, 0, 0, 0, 2012, 0x95899570 +0, 0, 0, 0, 2012, 0x6234a0c8 +0, 0, 0, 0, 2012, 0xec2cbcfc +0, 0, 0, 0, 2012, 0x3ff7a9db +0, 0, 0, 0, 2012, 0x4e44bad7 +0, 0, 0, 0, 2012, 0x1dbbbc39 +0, 0, 0, 0, 2012, 0xf9df99be +0, 0, 0, 0, 2012, 0xa713b313 +0, 0, 0, 0, 2012, 0x8bbdbe51 +0, 0, 0, 0, 2012, 0x0d5bc786 +0, 0, 0, 0, 2012, 0x75d293f2 +0, 0, 0, 0, 2012, 0x4832b688 +0, 0, 0, 0, 2012, 0x71aba74c +0, 0, 0, 0, 2012, 0x04d5abf2 +0, 0, 0, 0, 2012, 0xaa8fbd98 +0, 0, 0, 0, 2012, 0xd93eb6d4 +0, 0, 0, 0, 2012, 0x8fb6b5a8 +0, 0, 0, 0, 2012, 0x779a92f5 +0, 0, 0, 0, 2012, 0x35c8ab3d +0, 0, 0, 0, 2012, 0x0017aaa5 +0, 0, 0, 0, 2012, 0xd6e7bafe +0, 0, 0, 0, 2012, 0xe358b423 +0, 0, 0, 0, 2012, 0x3f74bfba +0, 0, 0, 0, 2012, 0x0a5eb707 +0, 0, 0, 0, 2012, 0xedbfb0df +0, 0, 0, 0, 2012, 0x2e71a26f +0, 0, 0, 0, 2012, 0x214db1a8 +0, 0, 0, 0, 2012, 0xb632c275 +0, 0, 0, 0, 2012, 0xb597cf92 +0, 0, 0, 0, 2012, 0x18a8b508 +0, 0, 0, 0, 2012, 0x8267b4ff +0, 0, 0, 0, 2012, 0x5a9ab8d6 +0, 0, 0, 0, 2012, 0x2037a2b6 diff --git a/tests/ref/fate/spdif-eac3 b/tests/ref/fate/spdif-eac3 new file mode 100644 index 0000000000..a186efe12b --- /dev/null +++ b/tests/ref/fate/spdif-eac3 @@ -0,0 +1 @@ +b881db03eb6370e057645396d1880260 diff --git a/tests/ref/fate/spdif-mlp b/tests/ref/fate/spdif-mlp new file mode 100644 index 0000000000..20dfcb1bb8 --- /dev/null +++ b/tests/ref/fate/spdif-mlp @@ -0,0 +1 @@ +6deb20b45c83b0edce9b91a44a76137c diff --git a/tests/ref/fate/spdif-mp2-remux b/tests/ref/fate/spdif-mp2-remux new file mode 100644 index 0000000000..cf976d6b49 --- /dev/null +++ b/tests/ref/fate/spdif-mp2-remux @@ -0,0 +1,49 @@ +1ca2b4cb48fd0f14b8a53d9330152d33 *tests/data/fate/spdif-mp2-remux.spdif +193536 tests/data/fate/spdif-mp2-remux.spdif +#tb 0: 1/90000 +#media_type 0: audio +#codec_id 0: mp3 +#sample_rate 0: 48000 +#channel_layout_name 0: stereo +0, 0, 0, 2160, 1152, 0x6f926334 +0, 2160, 2160, 2160, 1152, 0xa1ca68b3 +0, 4320, 4320, 2160, 1152, 0xefa54d9e +0, 6480, 6480, 2160, 1152, 0xd224482c +0, 8640, 8640, 2160, 1152, 0xa1003b3d +0, 10800, 10800, 2160, 1152, 0x196d2d8d +0, 12960, 12960, 2160, 1152, 0x76616814 +0, 15120, 15120, 2160, 1152, 0x7de26bc5 +0, 17280, 17280, 2160, 1152, 0xaf093a77 +0, 19440, 19440, 2160, 1152, 0xa128456e +0, 21600, 21600, 2160, 1152, 0xb4152c91 +0, 23760, 23760, 2160, 1152, 0xe14e51c0 +0, 25920, 25920, 2160, 1152, 0x9ec060bb +0, 28080, 28080, 2160, 1152, 0x8fc34ee7 +0, 30240, 30240, 2160, 1152, 0xa6194f4e +0, 32400, 32400, 2160, 1152, 0x7612307a +0, 34560, 34560, 2160, 1152, 0x2ad2523f +0, 36720, 36720, 2160, 1152, 0xd7686d66 +0, 38880, 38880, 2160, 1152, 0x47af67e7 +0, 41040, 41040, 2160, 1152, 0x25a357d4 +0, 43200, 43200, 2160, 1152, 0x94a66533 +0, 45360, 45360, 2160, 1152, 0xcd646915 +0, 47520, 47520, 2160, 1152, 0xc3614dc2 +0, 49680, 49680, 2160, 1152, 0x17da5f3e +0, 51840, 51840, 2160, 1152, 0x11194069 +0, 54000, 54000, 2160, 1152, 0x29af3e5b +0, 56160, 56160, 2160, 1152, 0x37c83b1b +0, 58320, 58320, 2160, 1152, 0xaba73200 +0, 60480, 60480, 2160, 1152, 0x743a482d +0, 62640, 62640, 2160, 1152, 0xab435176 +0, 64800, 64800, 2160, 1152, 0x3f363c6a +0, 66960, 66960, 2160, 1152, 0xbbaf35ad +0, 69120, 69120, 2160, 1152, 0xc7783d29 +0, 71280, 71280, 2160, 1152, 0x28963a4e +0, 73440, 73440, 2160, 1152, 0xdda343dd +0, 75600, 75600, 2160, 1152, 0x1e4857e3 +0, 77760, 77760, 2160, 1152, 0x0bfd43bf +0, 79920, 79920, 2160, 1152, 0x1bee45f5 +0, 82080, 82080, 2160, 1152, 0xf816371b +0, 84240, 84240, 2160, 1152, 0x70eb4605 +0, 86400, 86400, 2160, 1152, 0x3dea4608 +0, 88560, 88560, 2160, 1152, 0x709d5317 diff --git a/tests/ref/fate/spdif-mp3-remux b/tests/ref/fate/spdif-mp3-remux new file mode 100644 index 0000000000..fd9635f9ed --- /dev/null +++ b/tests/ref/fate/spdif-mp3-remux @@ -0,0 +1,47 @@ +a7c7fb1e53b1758096f11974ca93cdf7 *tests/data/fate/spdif-mp3-remux.spdif +184320 tests/data/fate/spdif-mp3-remux.spdif +#tb 0: 1/90000 +#media_type 0: audio +#codec_id 0: mp3 +#sample_rate 0: 44100 +#channel_layout_name 0: mono +0, 0, 0, 2351, 418, 0x64d1b620 +0, 2351, 2351, 2351, 418, 0x04edc6dd +0, 4702, 4702, 2351, 418, 0x2f1ac32b +0, 7053, 7053, 2351, 418, 0xa5ebce7b +0, 9404, 9404, 2351, 418, 0xa4e1d8b5 +0, 11755, 11755, 2351, 418, 0xf927d670 +0, 14106, 14106, 2351, 418, 0x4e8ccae5 +0, 16457, 16457, 2351, 418, 0x2b0ad5c2 +0, 18808, 18808, 2351, 418, 0x4a2fcc63 +0, 21159, 21159, 2351, 418, 0xe945dbc7 +0, 23510, 23510, 2351, 418, 0x601cd144 +0, 25861, 25861, 2351, 418, 0x052dc6a9 +0, 28212, 28212, 2351, 418, 0x348bd06b +0, 30563, 30563, 2351, 418, 0x2996d2bd +0, 32914, 32914, 2351, 418, 0xf658cc71 +0, 35265, 35265, 2351, 418, 0xeb19d2bf +0, 37616, 37616, 2351, 418, 0xd547d84e +0, 39967, 39967, 2351, 418, 0x4a59d73f +0, 42318, 42318, 2351, 418, 0xedbcd9bf +0, 44669, 44669, 2351, 418, 0x36c1d5fb +0, 47020, 47020, 2351, 418, 0x30ddcf11 +0, 49371, 49371, 2351, 418, 0xc1c6d2de +0, 51722, 51722, 2351, 418, 0xeed0cfc8 +0, 54073, 54073, 2351, 418, 0xe7bfde05 +0, 56424, 56424, 2351, 418, 0x3bbec91f +0, 58775, 58775, 2351, 418, 0x4f76cc86 +0, 61126, 61126, 2351, 418, 0x9819cdd2 +0, 63477, 63477, 2351, 418, 0x2cddd971 +0, 65828, 65828, 2351, 418, 0x2b84d6f8 +0, 68179, 68179, 2351, 418, 0xe483ce32 +0, 70530, 70530, 2351, 418, 0x68add0b0 +0, 72881, 72881, 2351, 418, 0xddd6d0bf +0, 75232, 75232, 2351, 418, 0x00c7d8aa +0, 77583, 77583, 2351, 418, 0x915fd36c +0, 79934, 79934, 2351, 418, 0x28d2d73c +0, 82285, 82285, 2351, 418, 0xaa7ad8b4 +0, 84636, 84636, 2351, 418, 0xe4e6d680 +0, 86987, 86987, 2351, 418, 0x4084d578 +0, 89338, 89338, 2351, 418, 0x3ab4b6e7 +0, 91689, 91689, 2351, 418, 0x951b66f9 diff --git a/tests/ref/fate/spdif-truehd b/tests/ref/fate/spdif-truehd new file mode 100644 index 0000000000..5bb0f0ed5b --- /dev/null +++ b/tests/ref/fate/spdif-truehd @@ -0,0 +1 @@ +ed9617614478a05b3f94a74d3f1061d9 From cf2cf31805448dd11692313440a21821773a6128 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 8 Sep 2022 09:59:09 +0200 Subject: [PATCH 249/590] avcodec/flac_parser: avoid returning too negative number If return value is very small parser code will assert. --- libavcodec/flac_parser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 5b3a4e6e67..bd91cc1a05 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -663,8 +663,11 @@ static int get_best_header(FLACParseContext *fpc, const uint8_t **poutbuf, /* Return the negative overread index so the client can compute pos. This should be the amount overread to the beginning of the child */ - if (child) - return child->offset - flac_fifo_size(&fpc->fifo_buf); + if (child) { + int64_t offset = child->offset - flac_fifo_size(&fpc->fifo_buf); + if (offset > -(1 << 28)) + return offset; + } return 0; } From 72acff9f593f977944a62652fc9dd346ec53225a Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 20 Jan 2021 16:58:31 +0100 Subject: [PATCH 250/590] avutil/x86/float_dsp: add fma3 for scalarproduct --- libavutil/x86/float_dsp.asm | 127 +++++++++++++++++++++++++++++++++ libavutil/x86/float_dsp_init.c | 2 + 2 files changed, 129 insertions(+) diff --git a/libavutil/x86/float_dsp.asm b/libavutil/x86/float_dsp.asm index cca4d019c7..8f8e6dddf5 100644 --- a/libavutil/x86/float_dsp.asm +++ b/libavutil/x86/float_dsp.asm @@ -440,6 +440,133 @@ cglobal scalarproduct_float, 3,3,2, v1, v2, offset %endif RET +INIT_YMM fma3 +cglobal scalarproduct_float, 3,5,8, v1, v2, size, len, offset + xor offsetq, offsetq + xorps m0, m0 + shl sized, 2 + mov lenq, sizeq + cmp lenq, 32 + jl .l16 + cmp lenq, 64 + jl .l32 + xorps m1, m1 + cmp lenq, 128 + jl .l64 + and lenq, ~127 + xorps m2, m2 + xorps m3, m3 +.loop128: + movups m4, [v1q+offsetq] + movups m5, [v1q+offsetq + 32] + movups m6, [v1q+offsetq + 64] + movups m7, [v1q+offsetq + 96] + fmaddps m0, m4, [v2q+offsetq ], m0 + fmaddps m1, m5, [v2q+offsetq + 32], m1 + fmaddps m2, m6, [v2q+offsetq + 64], m2 + fmaddps m3, m7, [v2q+offsetq + 96], m3 + add offsetq, 128 + cmp offsetq, lenq + jl .loop128 + addps m0, m2 + addps m1, m3 + mov lenq, sizeq + and lenq, 127 + cmp lenq, 64 + jge .l64 + addps m0, m1 + cmp lenq, 32 + jge .l32 + vextractf128 xmm2, m0, 1 + addps xmm0, xmm2 + cmp lenq, 16 + jge .l16 + movhlps xmm1, xmm0 + addps xmm0, xmm1 + movss xmm1, xmm0 + shufps xmm0, xmm0, 1 + addss xmm0, xmm1 +%if ARCH_X86_64 == 0 + movss r0m, xm0 + fld dword r0m +%endif + RET +.l64: + and lenq, ~63 + add lenq, offsetq +.loop64: + movups m4, [v1q+offsetq] + movups m5, [v1q+offsetq + 32] + fmaddps m0, m4, [v2q+offsetq], m0 + fmaddps m1, m5, [v2q+offsetq + 32], m1 + add offsetq, 64 + cmp offsetq, lenq + jl .loop64 + addps m0, m1 + mov lenq, sizeq + and lenq, 63 + cmp lenq, 32 + jge .l32 + vextractf128 xmm2, m0, 1 + addps xmm0, xmm2 + cmp lenq, 16 + jge .l16 + movhlps xmm1, xmm0 + addps xmm0, xmm1 + movss xmm1, xmm0 + shufps xmm0, xmm0, 1 + addss xmm0, xmm1 +%if ARCH_X86_64 == 0 + movss r0m, xm0 + fld dword r0m +%endif + RET +.l32: + and lenq, ~31 + add lenq, offsetq +.loop32: + movups m4, [v1q+offsetq] + fmaddps m0, m4, [v2q+offsetq], m0 + add offsetq, 32 + cmp offsetq, lenq + jl .loop32 + vextractf128 xmm2, m0, 1 + addps xmm0, xmm2 + mov lenq, sizeq + and lenq, 31 + cmp lenq, 16 + jge .l16 + movhlps xmm1, xmm0 + addps xmm0, xmm1 + movss xmm1, xmm0 + shufps xmm0, xmm0, 1 + addss xmm0, xmm1 +%if ARCH_X86_64 == 0 + movss r0m, xm0 + fld dword r0m +%endif + RET +.l16: + and lenq, ~15 + add lenq, offsetq +.loop16: + movaps xmm1, [v1q+offsetq] + mulps xmm1, [v2q+offsetq] + addps xmm0, xmm1 + add offsetq, 16 + cmp offsetq, lenq + jl .loop16 + movhlps xmm1, xmm0 + addps xmm0, xmm1 + movss xmm1, xmm0 + shufps xmm0, xmm0, 1 + addss xmm0, xmm1 +%if ARCH_X86_64 == 0 + movss r0m, xm0 + fld dword r0m +%endif + RET + ;----------------------------------------------------------------------------- ; void ff_butterflies_float(float *src0, float *src1, int len); ;----------------------------------------------------------------------------- diff --git a/libavutil/x86/float_dsp_init.c b/libavutil/x86/float_dsp_init.c index ad17bc2044..ad6b506259 100644 --- a/libavutil/x86/float_dsp_init.c +++ b/libavutil/x86/float_dsp_init.c @@ -74,6 +74,7 @@ void ff_vector_fmul_reverse_avx2(float *dst, const float *src0, const float *src1, int len); float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); +float ff_scalarproduct_float_fma3(const float *v1, const float *v2, int order); void ff_butterflies_float_sse(float *av_restrict src0, float *av_restrict src1, int len); @@ -112,5 +113,6 @@ av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_fma3; fdsp->vector_fmul_add = ff_vector_fmul_add_fma3; fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_fma3; + fdsp->scalarproduct_float = ff_scalarproduct_float_fma3; } } From 37a503ac879ca7677beb7423c33a6c5d24dd6396 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 12 Sep 2022 18:53:31 +0200 Subject: [PATCH 251/590] avcodec/x86/audiodsp: add scalarproduct avx2 --- libavcodec/x86/audiodsp.asm | 18 ++++++++++++++++++ libavcodec/x86/audiodsp_init.c | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/libavcodec/x86/audiodsp.asm b/libavcodec/x86/audiodsp.asm index b604b0443c..f64077cb13 100644 --- a/libavcodec/x86/audiodsp.asm +++ b/libavcodec/x86/audiodsp.asm @@ -44,6 +44,24 @@ cglobal scalarproduct_int16, 3,3,3, v1, v2, order movd eax, m2 RET +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +cglobal scalarproduct_int16, 3,3,2, v1, v2, order + add orderd, orderd + add v1q, orderq + add v2q, orderq + neg orderq + pxor m1, m1 +.loop: + movu m0, [v1q + orderq] + pmaddwd m0, [v2q + orderq] + paddd m1, m0 + add orderq, mmsize + jl .loop + HADDD m1, m0 + movd eax, xm1 + RET +%endif ;----------------------------------------------------------------------------- ; void ff_vector_clip_int32(int32_t *dst, const int32_t *src, int32_t min, diff --git a/libavcodec/x86/audiodsp_init.c b/libavcodec/x86/audiodsp_init.c index aa5e43e570..68aa3b2129 100644 --- a/libavcodec/x86/audiodsp_init.c +++ b/libavcodec/x86/audiodsp_init.c @@ -24,6 +24,9 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/audiodsp.h" +int32_t ff_scalarproduct_int16_avx2(const int16_t *v1, const int16_t *v2, + int order); + int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2, int order); @@ -53,4 +56,7 @@ av_cold void ff_audiodsp_init_x86(AudioDSPContext *c) if (EXTERNAL_SSE4(cpu_flags)) c->vector_clip_int32 = ff_vector_clip_int32_sse4; + + if (EXTERNAL_AVX2_FAST(cpu_flags)) + c->scalarproduct_int16 = ff_scalarproduct_int16_avx2; } From bda3a9faf4a2f201b24fb38a04da86410c9205ae Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 13 Sep 2022 13:50:09 -0300 Subject: [PATCH 252/590] x86/float_dsp: use three operand form for some instructions Fixes compilation with old yasm Signed-off-by: James Almer --- libavutil/x86/float_dsp.asm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavutil/x86/float_dsp.asm b/libavutil/x86/float_dsp.asm index 8f8e6dddf5..ff608f5f5a 100644 --- a/libavutil/x86/float_dsp.asm +++ b/libavutil/x86/float_dsp.asm @@ -443,19 +443,19 @@ cglobal scalarproduct_float, 3,3,2, v1, v2, offset INIT_YMM fma3 cglobal scalarproduct_float, 3,5,8, v1, v2, size, len, offset xor offsetq, offsetq - xorps m0, m0 + xorps m0, m0, m0 shl sized, 2 mov lenq, sizeq cmp lenq, 32 jl .l16 cmp lenq, 64 jl .l32 - xorps m1, m1 + xorps m1, m1, m1 cmp lenq, 128 jl .l64 and lenq, ~127 - xorps m2, m2 - xorps m3, m3 + xorps m2, m2, m2 + xorps m3, m3, m3 .loop128: movups m4, [v1q+offsetq] movups m5, [v1q+offsetq + 32] @@ -468,13 +468,13 @@ cglobal scalarproduct_float, 3,5,8, v1, v2, size, len, offset add offsetq, 128 cmp offsetq, lenq jl .loop128 - addps m0, m2 - addps m1, m3 + addps m0, m0, m2 + addps m1, m1, m3 mov lenq, sizeq and lenq, 127 cmp lenq, 64 jge .l64 - addps m0, m1 + addps m0, m0, m1 cmp lenq, 32 jge .l32 vextractf128 xmm2, m0, 1 @@ -502,7 +502,7 @@ cglobal scalarproduct_float, 3,5,8, v1, v2, size, len, offset add offsetq, 64 cmp offsetq, lenq jl .loop64 - addps m0, m1 + addps m0, m0, m1 mov lenq, sizeq and lenq, 63 cmp lenq, 32 From 092ce9712f63fc2641ec831d09c8ca0731083ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 12 Sep 2022 18:53:16 +0300 Subject: [PATCH 253/590] doc: reference the RISC-V specification --- doc/optimization.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/optimization.txt b/doc/optimization.txt index 974e2f9af2..3ed29fe38c 100644 --- a/doc/optimization.txt +++ b/doc/optimization.txt @@ -267,6 +267,11 @@ CELL/SPU: http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/30B3520C93F437AB87257060006FFE5E/$file/Language_Extensions_for_CBEA_2.4.pdf http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/9F820A5FFA3ECE8C8725716A0062585F/$file/CBE_Handbook_v1.1_24APR2007_pub.pdf +RISC-V-specific: +---------------- +The RISC-V Instruction Set Manual, Volume 1, Unprivileged ISA: +https://riscv.org/technical/specifications/ + GCC asm links: -------------- official doc but quite ugly From d808070547a867a8f3f7b97fdff3574576213c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 12 Sep 2022 18:53:17 +0300 Subject: [PATCH 254/590] lavu/riscv: AV_READ_TIME cycle counter This uses the architected RISC-V 64-bit cycle counter from the RISC-V unprivileged instruction set. In 64-bit and 128-bit, this is a straightforward CSR read. In 32-bit mode, the 64-bit value is exposed as two CSRs, which cannot be read atomically, so a loop is necessary to detect and fix up the race condition where the bottom half wraps exactly between the two reads. --- libavutil/riscv/timer.h | 53 +++++++++++++++++++++++++++++++++++++++++ libavutil/timer.h | 2 ++ 2 files changed, 55 insertions(+) create mode 100644 libavutil/riscv/timer.h diff --git a/libavutil/riscv/timer.h b/libavutil/riscv/timer.h new file mode 100644 index 0000000000..a34157a566 --- /dev/null +++ b/libavutil/riscv/timer.h @@ -0,0 +1,53 @@ +/* + * 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 AVUTIL_RISCV_TIMER_H +#define AVUTIL_RISCV_TIMER_H + +#include "config.h" + +#if HAVE_INLINE_ASM +#include + +static inline uint64_t rdcycle64(void) +{ +#if (__riscv_xlen >= 64) + uintptr_t cycles; + + __asm__ volatile ("rdcycle %0" : "=r"(cycles)); + +#else + uint64_t cycles; + uint32_t hi, lo, check; + + __asm__ volatile ( + "1: rdcycleh %0\n" + " rdcycle %1\n" + " rdcycleh %2\n" + " bne %0, %2, 1b\n" : "=r" (hi), "=r" (lo), "=r" (check)); + + cycles = (((uint64_t)hi) << 32) | lo; + +#endif + return cycles; +} + +#define AV_READ_TIME rdcycle64 + +#endif +#endif /* AVUTIL_RISCV_TIMER_H */ diff --git a/libavutil/timer.h b/libavutil/timer.h index 48e576739f..d3db5a27ef 100644 --- a/libavutil/timer.h +++ b/libavutil/timer.h @@ -57,6 +57,8 @@ # include "arm/timer.h" #elif ARCH_PPC # include "ppc/timer.h" +#elif ARCH_RISCV +# include "riscv/timer.h" #elif ARCH_X86 # include "x86/timer.h" #endif From ff14e3739393147b4596245ea511ec43a4ce6448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 12 Sep 2022 18:53:18 +0300 Subject: [PATCH 255/590] configure/riscv: detect fast CLZ RISC-V defines the CLZ instruction as part of the ratified Zbb subset of the (not yet ratified) bit mapulation extension (B). We can detect it from the __riscv_zbb predefined constant. At least GCC 12 already supports this correctly. Note that the macro will be non-zero if supported, zero if enabled in the compiler flags (e.g. -march=rv64gzbb) but not known to the compiler, and undefined otherwise. --- configure | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure b/configure index 9e51abd0d3..b7dc1d8656 100755 --- a/configure +++ b/configure @@ -5334,6 +5334,12 @@ elif enabled ppc; then ;; esac +elif enabled riscv; then + + if test_cpp_condition stddef.h "__riscv_zbb"; then + enable fast_clz + fi + elif enabled sparc; then case $cpu in From df2057041b6079bea2fc5e6b31b00756f3da7d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 12 Sep 2022 18:53:19 +0300 Subject: [PATCH 256/590] lavu/riscv: byte-swap operations If the target supports the Basic bit-manipulation (Zbb) extension, then the REV8 instruction is available to reverse byte order. Note that this instruction only exists at the "XLEN" register size, so we need to right shift the result down to the data width. If Zbb is not supported, then this patchset does nothing. Support for run-time detection is left for the future. Currently, there are no bits in auxv/ELF HWCAP for Z-extensions, so there are no clean ways to do this. --- libavutil/bswap.h | 2 ++ libavutil/riscv/bswap.h | 74 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 libavutil/riscv/bswap.h diff --git a/libavutil/bswap.h b/libavutil/bswap.h index 91cb79538d..4840ab433f 100644 --- a/libavutil/bswap.h +++ b/libavutil/bswap.h @@ -40,6 +40,8 @@ # include "arm/bswap.h" #elif ARCH_AVR32 # include "avr32/bswap.h" +#elif ARCH_RISCV +# include "riscv/bswap.h" #elif ARCH_SH4 # include "sh4/bswap.h" #elif ARCH_X86 diff --git a/libavutil/riscv/bswap.h b/libavutil/riscv/bswap.h new file mode 100644 index 0000000000..de1429c0f7 --- /dev/null +++ b/libavutil/riscv/bswap.h @@ -0,0 +1,74 @@ +/* + * 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 AVUTIL_RISCV_BSWAP_H +#define AVUTIL_RISCV_BSWAP_H + +#include +#include "config.h" +#include "libavutil/attributes.h" + +#if defined (__riscv_zbb) && (__riscv_zbb > 0) && HAVE_INLINE_ASM + +static av_always_inline av_const uintptr_t av_bswap_xlen(uintptr_t x) +{ + uintptr_t y; + + __asm__("rev8 %0, %1" : "=r" (y) : "r" (x)); + return y; +} + +#define av_bswap16 av_bswap16 + +static av_always_inline av_const uint_fast16_t av_bswap16(uint_fast16_t x) +{ + return av_bswap_xlen(x) >> (__riscv_xlen - 16); +} + +#if (__riscv_xlen == 32) +#define av_bswap32 av_bswap_xlen +#define av_bswap64 av_bswap64 + +static av_always_inline av_const uint64_t av_bswap64(uint64_t x) +{ + return (((uint64_t)av_bswap32(x)) << 32) | av_bswap32(x >> 32); +} + +#else +#define av_bswap32 av_bswap32 + +static av_always_inline av_const uint_fast32_t av_bswap32(uint_fast32_t x) +{ + return av_bswap_xlen(x) >> (__riscv_xlen - 32); +} + +#if (__riscv_xlen == 64) +#define av_bswap64 av_bswap_xlen + +#else +#define av_bswap64 av_bswap64 + +static av_always_inline av_const uint_fast64_t av_bswap64(uint_fast64_t x) +{ + return av_bswap_xlen(x) >> (__riscv_xlen - 64); +} + +#endif /* __riscv_xlen > 64 */ +#endif /* __riscv_xlen > 32 */ +#endif /* __riscv_zbb */ +#endif /* AVUTIL_RISCV_BSWAP_H */ From c177108ae1144fd4e6cedb4a702260dbaa179825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 12 Sep 2022 18:53:20 +0300 Subject: [PATCH 257/590] lavu/riscv: add optimisations This provides some micro-optimisations for signed integer clipping, and support for bit weight with the Zbb extension. --- libavutil/intmath.h | 5 +- libavutil/riscv/intmath.h | 103 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 libavutil/riscv/intmath.h diff --git a/libavutil/intmath.h b/libavutil/intmath.h index 9573109e9d..c54d23b7bf 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -28,8 +28,9 @@ #if ARCH_ARM # include "arm/intmath.h" -#endif -#if ARCH_X86 +#elif ARCH_RISCV +# include "riscv/intmath.h" +#elif ARCH_X86 # include "x86/intmath.h" #endif diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h new file mode 100644 index 0000000000..78f7ba930a --- /dev/null +++ b/libavutil/riscv/intmath.h @@ -0,0 +1,103 @@ +/* + * 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 AVUTIL_RISCV_INTMATH_H +#define AVUTIL_RISCV_INTMATH_H + +#include + +#include "config.h" +#include "libavutil/attributes.h" + +/* + * The compiler is forced to sign-extend the result anyhow, so it is faster to + * compute it explicitly and use it. + */ +#define av_clip_int8 av_clip_int8_rvi +static av_always_inline av_const int8_t av_clip_int8_rvi(int a) +{ + union { uint8_t u; int8_t s; } u = { .u = a }; + + if (a != u.s) + a = ((a >> 31) ^ 0x7F); + return a; +} + +#define av_clip_int16 av_clip_int16_rvi +static av_always_inline av_const int16_t av_clip_int16_rvi(int a) +{ + union { uint8_t u; int8_t s; } u = { .u = a }; + + if (a != u.s) + a = ((a >> 31) ^ 0x7F); + return a; +} + +#define av_clipl_int32 av_clipl_int32_rvi +static av_always_inline av_const int32_t av_clipl_int32_rvi(int64_t a) +{ + union { uint32_t u; int32_t s; } u = { .u = a }; + + if (a != u.s) + a = ((a >> 63) ^ 0x7FFFFFFF); + return a; +} + +#define av_clip_intp2 av_clip_intp2_rvi +static av_always_inline av_const int av_clip_intp2_rvi(int a, int p) +{ + const int shift = 32 - p; + int b = (a << shift) >> shift; + + if (a != b) + b = (a >> 31) ^ ((1 << p) - 1); + return b; +} + +#if defined (__riscv_zbb) && (__riscv_zbb > 0) && HAVE_INLINE_ASM + +#define av_popcount av_popcount_rvb +static av_always_inline av_const int av_popcount_rvb(uint32_t x) +{ + int ret; + +#if (__riscv_xlen >= 64) + __asm__ ("cpopw %0, %1\n" : "=r" (ret) : "r" (x)); +#else + __asm__ ("cpop %0, %1\n" : "=r" (ret) : "r" (x)); +#endif + return ret; +} + +#if (__riscv_xlen >= 64) +#define av_popcount64 av_popcount64_rvb +static av_always_inline av_const int av_popcount64_rvb(uint64_t x) +{ + int ret; + +#if (__riscv_xlen >= 128) + __asm__ ("cpopd %0, %1\n" : "=r" (ret) : "r" (x)); +#else + __asm__ ("cpop %0, %1\n" : "=r" (ret) : "r" (x)); +#endif + return ret; +} +#endif /* __riscv_xlen >= 64 */ +#endif /* __riscv_zbb */ + +#endif /* AVUTIL_RISCV_INTMATH_H */ From cc81ab283c72921a23f7dc149c6a2b386eaf77c6 Mon Sep 17 00:00:00 2001 From: Roman Arzumanyan Date: Sat, 10 Sep 2022 11:05:56 +0300 Subject: [PATCH 258/590] libavfilter: add vf_colorrange_cuda, CUDA-accelerated color conversion filter Signed-off-by: Timo Rothenpieler --- configure | 6 +- doc/filters.texi | 32 +++ libavfilter/Makefile | 3 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 2 +- libavfilter/vf_colorspace_cuda.c | 435 ++++++++++++++++++++++++++++++ libavfilter/vf_colorspace_cuda.cu | 94 +++++++ 7 files changed, 570 insertions(+), 3 deletions(-) create mode 100644 libavfilter/vf_colorspace_cuda.c create mode 100644 libavfilter/vf_colorspace_cuda.cu diff --git a/configure b/configure index b7dc1d8656..240ae942d1 100755 --- a/configure +++ b/configure @@ -3149,10 +3149,12 @@ qsvvpp_select="qsv" vaapi_encode_deps="vaapi" v4l2_m2m_deps="linux_videodev2_h sem_timedwait" -chromakey_cuda_filter_deps="ffnvcodec" -chromakey_cuda_filter_deps_any="cuda_nvcc cuda_llvm" bilateral_cuda_filter_deps="ffnvcodec" bilateral_cuda_filter_deps_any="cuda_nvcc cuda_llvm" +chromakey_cuda_filter_deps="ffnvcodec" +chromakey_cuda_filter_deps_any="cuda_nvcc cuda_llvm" +colorspace_cuda_filter_deps="ffnvcodec" +colorspace_cuda_filter_deps_any="cuda_nvcc cuda_llvm" hwupload_cuda_filter_deps="ffnvcodec" scale_npp_filter_deps="ffnvcodec libnpp" scale2ref_npp_filter_deps="ffnvcodec libnpp" diff --git a/doc/filters.texi b/doc/filters.texi index dbc08163d8..6aa350a63c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -9725,6 +9725,38 @@ For example to convert the input to SMPTE-240M, use the command: colorspace=smpte240m @end example +@section colorspace_cuda + +CUDA accelerated implementation of the colorspace filter. + +It is by no means feature complete compared to the software colorspace filter, +and at the current time only supports color range conversion between jpeg/full +and mpeg/limited range. + +The filter accepts the following options: + +@table @option +@item range +Specify output color range. + +The accepted values are: +@table @samp +@item tv +TV (restricted) range + +@item mpeg +MPEG (restricted) range + +@item pc +PC (full) range + +@item jpeg +JPEG (full) range + +@end table + +@end table + @section colortemperature Adjust color temperature in video to simulate variations in ambient color temperature. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 841ec47141..ff2a06c262 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -230,6 +230,9 @@ OBJS-$(CONFIG_COLORLEVELS_FILTER) += vf_colorlevels.o OBJS-$(CONFIG_COLORMAP_FILTER) += vf_colormap.o OBJS-$(CONFIG_COLORMATRIX_FILTER) += vf_colormatrix.o OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspacedsp.o +OBJS-$(CONFIG_COLORSPACE_CUDA_FILTER) += vf_colorspace_cuda.o \ + vf_colorspace_cuda.ptx.o \ + cuda/load_helper.o OBJS-$(CONFIG_COLORTEMPERATURE_FILTER) += vf_colortemperature.o OBJS-$(CONFIG_CONVOLUTION_FILTER) += vf_convolution.o OBJS-$(CONFIG_CONVOLUTION_OPENCL_FILTER) += vf_convolution_opencl.o opencl.o \ diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 79e8a16bbc..119de40b25 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -213,6 +213,7 @@ extern const AVFilter ff_vf_colorlevels; extern const AVFilter ff_vf_colormap; extern const AVFilter ff_vf_colormatrix; extern const AVFilter ff_vf_colorspace; +extern const AVFilter ff_vf_colorspace_cuda; extern const AVFilter ff_vf_colortemperature; extern const AVFilter ff_vf_convolution; extern const AVFilter ff_vf_convolution_opencl; diff --git a/libavfilter/version.h b/libavfilter/version.h index fc0df70dee..5aac9c513a 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFILTER_VERSION_MINOR 48 +#define LIBAVFILTER_VERSION_MINOR 49 #define LIBAVFILTER_VERSION_MICRO 100 diff --git a/libavfilter/vf_colorspace_cuda.c b/libavfilter/vf_colorspace_cuda.c new file mode 100644 index 0000000000..131c4ad72b --- /dev/null +++ b/libavfilter/vf_colorspace_cuda.c @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include + +#include "libavutil/avstring.h" +#include "libavutil/common.h" +#include "libavutil/cuda_check.h" +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/internal.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "scale_eval.h" +#include "video.h" + +#include "cuda/load_helper.h" + +static const enum AVPixelFormat supported_formats[] = { + AV_PIX_FMT_NV12, + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_YUV444P, +}; + +#define DIV_UP(a, b) (((a) + (b)-1) / (b)) +#define BLOCKX 32 +#define BLOCKY 16 + +#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x) + +typedef struct CUDAColorspaceContext { + const AVClass* class; + + AVCUDADeviceContext* hwctx; + AVBufferRef* frames_ctx; + AVFrame* own_frame; + AVFrame* tmp_frame; + + CUcontext cu_ctx; + CUstream cu_stream; + CUmodule cu_module; + CUfunction cu_convert[AVCOL_RANGE_NB]; + + enum AVPixelFormat pix_fmt; + enum AVColorRange range; + + int num_planes; +} CUDAColorspaceContext; + +static av_cold int cudacolorspace_init(AVFilterContext* ctx) +{ + CUDAColorspaceContext* s = ctx->priv; + + s->own_frame = av_frame_alloc(); + if (!s->own_frame) + return AVERROR(ENOMEM); + + s->tmp_frame = av_frame_alloc(); + if (!s->tmp_frame) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold void cudacolorspace_uninit(AVFilterContext* ctx) +{ + CUDAColorspaceContext* s = ctx->priv; + + if (s->hwctx && s->cu_module) { + CudaFunctions* cu = s->hwctx->internal->cuda_dl; + CUcontext dummy; + + CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx)); + CHECK_CU(cu->cuModuleUnload(s->cu_module)); + s->cu_module = NULL; + CHECK_CU(cu->cuCtxPopCurrent(&dummy)); + } + + av_frame_free(&s->own_frame); + av_buffer_unref(&s->frames_ctx); + av_frame_free(&s->tmp_frame); +} + +static av_cold int init_hwframe_ctx(CUDAColorspaceContext* s, AVBufferRef* device_ctx, + int width, int height) +{ + AVBufferRef* out_ref = NULL; + AVHWFramesContext* out_ctx; + int ret; + + out_ref = av_hwframe_ctx_alloc(device_ctx); + if (!out_ref) + return AVERROR(ENOMEM); + + out_ctx = (AVHWFramesContext*)out_ref->data; + + out_ctx->format = AV_PIX_FMT_CUDA; + out_ctx->sw_format = s->pix_fmt; + out_ctx->width = FFALIGN(width, 32); + out_ctx->height = FFALIGN(height, 32); + + ret = av_hwframe_ctx_init(out_ref); + if (ret < 0) + goto fail; + + av_frame_unref(s->own_frame); + ret = av_hwframe_get_buffer(out_ref, s->own_frame, 0); + if (ret < 0) + goto fail; + + s->own_frame->width = width; + s->own_frame->height = height; + + av_buffer_unref(&s->frames_ctx); + s->frames_ctx = out_ref; + + return 0; +fail: + av_buffer_unref(&out_ref); + return ret; +} + +static int format_is_supported(enum AVPixelFormat fmt) +{ + for (int i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) + if (fmt == supported_formats[i]) + return 1; + + return 0; +} + +static av_cold int init_processing_chain(AVFilterContext* ctx, int width, + int height) +{ + CUDAColorspaceContext* s = ctx->priv; + AVHWFramesContext* in_frames_ctx; + + int ret; + + if (!ctx->inputs[0]->hw_frames_ctx) { + av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n"); + return AVERROR(EINVAL); + } + + in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data; + s->pix_fmt = in_frames_ctx->sw_format; + + if (!format_is_supported(s->pix_fmt)) { + av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", + av_get_pix_fmt_name(s->pix_fmt)); + return AVERROR(EINVAL); + } + + if ((AVCOL_RANGE_MPEG != s->range) && (AVCOL_RANGE_JPEG != s->range)) { + av_log(ctx, AV_LOG_ERROR, "Unsupported color range\n"); + return AVERROR(EINVAL); + } + + s->num_planes = av_pix_fmt_count_planes(s->pix_fmt); + + ret = init_hwframe_ctx(s, in_frames_ctx->device_ref, width, height); + if (ret < 0) + return ret; + + ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->frames_ctx); + if (!ctx->outputs[0]->hw_frames_ctx) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold int cudacolorspace_load_functions(AVFilterContext* ctx) +{ + CUDAColorspaceContext* s = ctx->priv; + CUcontext dummy, cuda_ctx = s->hwctx->cuda_ctx; + CudaFunctions* cu = s->hwctx->internal->cuda_dl; + int ret; + + extern const unsigned char ff_vf_colorspace_cuda_ptx_data[]; + extern const unsigned int ff_vf_colorspace_cuda_ptx_len; + + ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx)); + if (ret < 0) + return ret; + + ret = ff_cuda_load_module(ctx, s->hwctx, &s->cu_module, + ff_vf_colorspace_cuda_ptx_data, + ff_vf_colorspace_cuda_ptx_len); + if (ret < 0) + goto fail; + + ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_convert[AVCOL_RANGE_MPEG], s->cu_module, "to_mpeg_cuda")); + if (ret < 0) + goto fail; + + ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_convert[AVCOL_RANGE_JPEG], s->cu_module, "to_jpeg_cuda")); + if (ret < 0) + goto fail; + +fail: + CHECK_CU(cu->cuCtxPopCurrent(&dummy)); + return ret; +} + +static av_cold int cudacolorspace_config_props(AVFilterLink* outlink) +{ + AVFilterContext* ctx = outlink->src; + AVFilterLink* inlink = outlink->src->inputs[0]; + CUDAColorspaceContext* s = ctx->priv; + AVHWFramesContext* frames_ctx = + (AVHWFramesContext*)inlink->hw_frames_ctx->data; + AVCUDADeviceContext* device_hwctx = frames_ctx->device_ctx->hwctx; + int ret; + + s->hwctx = device_hwctx; + s->cu_stream = s->hwctx->stream; + + outlink->w = inlink->w; + outlink->h = inlink->h; + + ret = init_processing_chain(ctx, inlink->w, inlink->h); + if (ret < 0) + return ret; + + if (inlink->sample_aspect_ratio.num) { + outlink->sample_aspect_ratio = av_mul_q( + (AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, + inlink->sample_aspect_ratio); + } else { + outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; + } + + ret = cudacolorspace_load_functions(ctx); + if (ret < 0) + return ret; + + return ret; +} + +static int conv_cuda_convert(AVFilterContext* ctx, AVFrame* out, AVFrame* in) +{ + CUDAColorspaceContext* s = ctx->priv; + CudaFunctions* cu = s->hwctx->internal->cuda_dl; + CUcontext dummy, cuda_ctx = s->hwctx->cuda_ctx; + int ret; + + ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx)); + if (ret < 0) + return ret; + + out->color_range = s->range; + + for (int i = 0; i < s->num_planes; i++) { + int width = in->width, height = in->height, comp_id = (i > 0); + + switch (s->pix_fmt) { + case AV_PIX_FMT_YUV444P: + break; + case AV_PIX_FMT_YUV420P: + width = comp_id ? in->width / 2 : in->width; + case AV_PIX_FMT_NV12: + height = comp_id ? in->height / 2 : in->height; + break; + default: + av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", + av_get_pix_fmt_name(s->pix_fmt)); + return AVERROR(EINVAL); + } + + if (!s->cu_convert[out->color_range]) { + av_log(ctx, AV_LOG_ERROR, "Unsupported color range\n"); + return AVERROR(EINVAL); + } + + if (in->color_range != out->color_range) { + void* args[] = {&in->data[i], &out->data[i], &in->linesize[i], + &comp_id}; + ret = CHECK_CU(cu->cuLaunchKernel( + s->cu_convert[out->color_range], DIV_UP(width, BLOCKX), + DIV_UP(height, BLOCKY), 1, BLOCKX, BLOCKY, 1, 0, s->cu_stream, + args, NULL)); + } else { + ret = av_hwframe_transfer_data(out, in, 0); + if (ret < 0) + return ret; + } + } + + CHECK_CU(cu->cuCtxPopCurrent(&dummy)); + return ret; +} + +static int cudacolorspace_conv(AVFilterContext* ctx, AVFrame* out, AVFrame* in) +{ + CUDAColorspaceContext* s = ctx->priv; + AVFilterLink* outlink = ctx->outputs[0]; + AVFrame* src = in; + int ret; + + ret = conv_cuda_convert(ctx, s->own_frame, src); + if (ret < 0) + return ret; + + src = s->own_frame; + ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0); + if (ret < 0) + return ret; + + av_frame_move_ref(out, s->own_frame); + av_frame_move_ref(s->own_frame, s->tmp_frame); + + s->own_frame->width = outlink->w; + s->own_frame->height = outlink->h; + + ret = av_frame_copy_props(out, in); + if (ret < 0) + return ret; + + return 0; +} + +static int cudacolorspace_filter_frame(AVFilterLink* link, AVFrame* in) +{ + AVFilterContext* ctx = link->dst; + CUDAColorspaceContext* s = ctx->priv; + AVFilterLink* outlink = ctx->outputs[0]; + CudaFunctions* cu = s->hwctx->internal->cuda_dl; + + AVFrame* out = NULL; + CUcontext dummy; + int ret = 0; + + out = av_frame_alloc(); + if (!out) { + ret = AVERROR(ENOMEM); + goto fail; + } + + ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx)); + if (ret < 0) + goto fail; + + ret = cudacolorspace_conv(ctx, out, in); + + CHECK_CU(cu->cuCtxPopCurrent(&dummy)); + if (ret < 0) + goto fail; + + av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den, + (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w, + (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, + INT_MAX); + + av_frame_free(&in); + return ff_filter_frame(outlink, out); +fail: + av_frame_free(&in); + av_frame_free(&out); + return ret; +} + +#define OFFSET(x) offsetof(CUDAColorspaceContext, x) +#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM) +static const AVOption options[] = { + {"range", "Output video range", OFFSET(range), AV_OPT_TYPE_INT, { .i64 = AVCOL_RANGE_UNSPECIFIED }, AVCOL_RANGE_UNSPECIFIED, AVCOL_RANGE_NB - 1, FLAGS, "range"}, + {"tv", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range"}, + {"mpeg", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range"}, + {"pc", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range"}, + {"jpeg", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range"}, + {NULL}, +}; + +static const AVClass cudacolorspace_class = { + .class_name = "colorspace_cuda", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVFilterPad cudacolorspace_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .filter_frame = cudacolorspace_filter_frame, + }, +}; + +static const AVFilterPad cudacolorspace_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .config_props = cudacolorspace_config_props, + }, +}; + +const AVFilter ff_vf_colorspace_cuda = { + .name = "colorspace_cuda", + .description = NULL_IF_CONFIG_SMALL("CUDA accelerated video color converter"), + + .init = cudacolorspace_init, + .uninit = cudacolorspace_uninit, + + .priv_size = sizeof(CUDAColorspaceContext), + .priv_class = &cudacolorspace_class, + + FILTER_INPUTS(cudacolorspace_inputs), + FILTER_OUTPUTS(cudacolorspace_outputs), + + FILTER_SINGLE_PIXFMT(AV_PIX_FMT_CUDA), + + .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, +}; diff --git a/libavfilter/vf_colorspace_cuda.cu b/libavfilter/vf_colorspace_cuda.cu new file mode 100644 index 0000000000..59db9f69f3 --- /dev/null +++ b/libavfilter/vf_colorspace_cuda.cu @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +extern "C" { +#define MPEG_LUMA_MIN (16) +#define MPEG_CHROMA_MIN (16) +#define MPEG_LUMA_MAX (235) +#define MPEG_CHROMA_MAX (240) + +#define JPEG_LUMA_MIN (0) +#define JPEG_CHROMA_MIN (1) +#define JPEG_LUMA_MAX (255) +#define JPEG_CHROMA_MAX (255) + +__device__ int mpeg_min[] = {MPEG_LUMA_MIN, MPEG_CHROMA_MIN}; +__device__ int mpeg_max[] = {MPEG_LUMA_MAX, MPEG_CHROMA_MAX}; + +__device__ int jpeg_min[] = {JPEG_LUMA_MIN, JPEG_CHROMA_MIN}; +__device__ int jpeg_max[] = {JPEG_LUMA_MAX, JPEG_CHROMA_MAX}; + +__device__ int clamp(int val, int min, int max) +{ + if (val < min) + return min; + else if (val > max) + return max; + else + return val; +} + +__global__ void to_jpeg_cuda(const unsigned char* src, unsigned char* dst, + int pitch, int comp_id) +{ + int x = blockIdx.x * blockDim.x + threadIdx.x; + int y = blockIdx.y * blockDim.y + threadIdx.y; + int src_, dst_; + + // 8 bit -> 15 bit for better precision + src_ = static_cast(src[x + y * pitch]) << 7; + + // Conversion + dst_ = comp_id ? (min(src_, 30775) * 4663 - 9289992) >> 12 // chroma + : (min(src_, 30189) * 19077 - 39057361) >> 14; // luma + + // Dither replacement + dst_ = dst_ + 64; + + // Back to 8 bit + dst_ = clamp(dst_ >> 7, jpeg_min[comp_id], jpeg_max[comp_id]); + dst[x + y * pitch] = static_cast(dst_); +} + +__global__ void to_mpeg_cuda(const unsigned char* src, unsigned char* dst, + int pitch, int comp_id) +{ + int x = blockIdx.x * blockDim.x + threadIdx.x; + int y = blockIdx.y * blockDim.y + threadIdx.y; + int src_, dst_; + + // 8 bit -> 15 bit for better precision + src_ = static_cast(src[x + y * pitch]) << 7; + + // Conversion + dst_ = comp_id ? (src_ * 1799 + 4081085) >> 11 // chroma + : (src_ * 14071 + 33561947) >> 14; // luma + + // Dither replacement + dst_ = dst_ + 64; + + // Back to 8 bit + dst_ = clamp(dst_ >> 7, mpeg_min[comp_id], mpeg_max[comp_id]); + dst[x + y * pitch] = static_cast(dst_); +} + +} From 1234df7501d1f5a7812057978cee8eb3237b9f9e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 9 Sep 2022 14:31:54 +0200 Subject: [PATCH 259/590] Revert "avcodec/loongarch: Add wrapper for __lsx_vldx" This reverts commit 6c9a60ada4256cf5c388d8dc48860e24c15396c0. The loongarch headers have been fixed, so that this workaround is no longer necessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/loongarch/hevc_lpf_sao_lsx.c | 52 +++--- libavcodec/loongarch/hevc_mc_bi_lsx.c | 140 +++++++------- libavcodec/loongarch/hevc_mc_uni_lsx.c | 76 ++++---- libavcodec/loongarch/hevc_mc_uniw_lsx.c | 8 +- libavcodec/loongarch/hevcdsp_lsx.c | 218 +++++++++++----------- libavutil/loongarch/loongson_intrinsics.h | 5 - 6 files changed, 247 insertions(+), 252 deletions(-) diff --git a/libavcodec/loongarch/hevc_lpf_sao_lsx.c b/libavcodec/loongarch/hevc_lpf_sao_lsx.c index 1944336876..b5822afd94 100644 --- a/libavcodec/loongarch/hevc_lpf_sao_lsx.c +++ b/libavcodec/loongarch/hevc_lpf_sao_lsx.c @@ -1202,17 +1202,17 @@ static void hevc_sao_edge_filter_0degree_16multiple_lsx(uint8_t *dst, for (; height; height -= 4) { src_minus1 = src - 1; src_minus10 = __lsx_vld(src_minus1, 0); - DUP2_ARG2(LSX_VLDX, src_minus1, src_stride, src_minus1, + DUP2_ARG2(__lsx_vldx, src_minus1, src_stride, src_minus1, src_stride_2x, src_minus11, src_minus12); - src_minus13 = LSX_VLDX(src_minus1, src_stride_3x); + src_minus13 = __lsx_vldx(src_minus1, src_stride_3x); for (v_cnt = 0; v_cnt < width; v_cnt += 16) { src_minus1 += 16; dst_ptr = dst + v_cnt; src10 = __lsx_vld(src_minus1, 0); - DUP2_ARG2(LSX_VLDX, src_minus1, src_stride, src_minus1, + DUP2_ARG2(__lsx_vldx, src_minus1, src_stride, src_minus1, src_stride_2x, src11, src12); - src13 = LSX_VLDX(src_minus1, src_stride_3x); + src13 = __lsx_vldx(src_minus1, src_stride_3x); DUP4_ARG3(__lsx_vshuf_b, src10, src_minus10, shuf1, src11, src_minus11, shuf1, src12, src_minus12, shuf1, src13, src_minus13, shuf1, src_zero0, src_zero1, @@ -1359,7 +1359,7 @@ static void hevc_sao_edge_filter_90degree_4width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src10, src11); __lsx_vstelm_w(dst0, dst, 0, 0); @@ -1418,7 +1418,7 @@ static void hevc_sao_edge_filter_90degree_8width_lsx(uint8_t *dst, /* load in advance */ DUP2_ARG2(__lsx_vld, src - src_stride, 0, src, 0, src_minus10, src_minus11); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src10, src11); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src10, src11); for (height -= 2; height; height -= 2) { src += src_stride_2x; @@ -1452,7 +1452,7 @@ static void hevc_sao_edge_filter_90degree_8width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src10, src11); __lsx_vstelm_d(dst0, dst, 0, 0); @@ -1529,7 +1529,7 @@ static void hevc_sao_edge_filter_90degree_16multiple_lsx(uint8_t *dst, src_minus10, src_minus11); for (h_cnt = (height >> 2); h_cnt--;) { - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src, src_stride_3x, src, src_stride_4x, src10, src11, src12, src13); DUP4_ARG2(__lsx_vseq_b, src_minus11, src_minus10, src_minus11, @@ -1636,7 +1636,7 @@ static void hevc_sao_edge_filter_45degree_4width_lsx(uint8_t *dst, /* load in advance */ DUP2_ARG2(__lsx_vld, src_orig - src_stride, 0, src_orig, 0, src_minus10, src_minus11); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); for (height -= 2; height; height -= 2) { @@ -1678,7 +1678,7 @@ static void hevc_sao_edge_filter_45degree_4width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); __lsx_vstelm_w(dst0, dst, 0, 0); @@ -1749,7 +1749,7 @@ static void hevc_sao_edge_filter_45degree_8width_lsx(uint8_t *dst, /* load in advance */ DUP2_ARG2(__lsx_vld, src_orig - src_stride, 0, src_orig, 0, src_minus10, src_minus11); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); for (height -= 2; height; height -= 2) { @@ -1791,7 +1791,7 @@ static void hevc_sao_edge_filter_45degree_8width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11) __lsx_vstelm_d(dst0, dst, 0, 0); __lsx_vstelm_d(dst0, dst + dst_stride, 0, 1); @@ -1834,7 +1834,7 @@ static void hevc_sao_edge_filter_45degree_8width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); __lsx_vstelm_d(dst0, dst, 0, 0); @@ -1881,17 +1881,17 @@ static void hevc_sao_edge_filter_45degree_16multiple_lsx(uint8_t *dst, src_orig = src - 1; dst_orig = dst; src_minus11 = __lsx_vld(src_orig, 0); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src_minus12, src_minus13); - src_minus14 = LSX_VLDX(src_orig, src_stride_3x); + src_minus14 = __lsx_vldx(src_orig, src_stride_3x); for (v_cnt = 0; v_cnt < width; v_cnt += 16) { src_minus10 = __lsx_vld(src_orig - src_stride, 0); src_orig += 16; src10 = __lsx_vld(src_orig, 0); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src11, src12); - src13 = LSX_VLDX(src_orig, src_stride_3x); + src13 = __lsx_vldx(src_orig, src_stride_3x); src_plus13 = __lsx_vld(src + v_cnt + src_stride_4x, 1); DUP4_ARG3(__lsx_vshuf_b, src10, src_minus11, shuf1, src11, @@ -2017,7 +2017,7 @@ static void hevc_sao_edge_filter_135degree_4width_lsx(uint8_t *dst, /* load in advance */ DUP2_ARG2(__lsx_vld, src_orig - src_stride, 0, src_orig, 0, src_minus10, src_minus11); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); for (height -= 2; height; height -= 2) { @@ -2059,7 +2059,7 @@ static void hevc_sao_edge_filter_135degree_4width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); __lsx_vstelm_w(dst0, dst, 0, 0); @@ -2132,7 +2132,7 @@ static void hevc_sao_edge_filter_135degree_8width_lsx(uint8_t *dst, /* load in advance */ DUP2_ARG2(__lsx_vld, src_orig - src_stride, 0, src_orig, 0, src_minus10, src_minus11); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); for (height -= 2; height; height -= 2) { @@ -2174,7 +2174,7 @@ static void hevc_sao_edge_filter_135degree_8width_lsx(uint8_t *dst, src_minus11 = src11; /* load in advance */ - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src10, src11); __lsx_vstelm_d(dst0, dst, 0, 0); @@ -2257,18 +2257,18 @@ static void hevc_sao_edge_filter_135degree_16multiple_lsx(uint8_t *dst, dst_orig = dst; src_minus11 = __lsx_vld(src_orig, 0); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src_plus10, src_plus11); - src_plus12 = LSX_VLDX(src_orig, src_stride_3x); + src_plus12 = __lsx_vldx(src_orig, src_stride_3x); for (v_cnt = 0; v_cnt < width; v_cnt += 16) { src_minus10 = __lsx_vld(src_orig - src_stride, 2); - src_plus13 = LSX_VLDX(src_orig, src_stride_4x); + src_plus13 = __lsx_vldx(src_orig, src_stride_4x); src_orig += 16; src10 = __lsx_vld(src_orig, 0); - DUP2_ARG2(LSX_VLDX, src_orig, src_stride, src_orig, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_orig, src_stride, src_orig, src_stride_2x, src11, src12); - src13 =LSX_VLDX(src_orig, src_stride_3x); + src13 =__lsx_vldx(src_orig, src_stride_3x); DUP4_ARG3(__lsx_vshuf_b, src10, src_minus11, shuf1, src11, src_plus10, shuf1, src12, src_plus11, shuf1, src13, diff --git a/libavcodec/loongarch/hevc_mc_bi_lsx.c b/libavcodec/loongarch/hevc_mc_bi_lsx.c index 4e10a8a440..48441c107b 100644 --- a/libavcodec/loongarch/hevc_mc_bi_lsx.c +++ b/libavcodec/loongarch/hevc_mc_bi_lsx.c @@ -163,14 +163,14 @@ void hevc_bi_copy_6w_lsx(const uint8_t *src0_ptr, int32_t src_stride, DUP2_ARG2(__lsx_vilvl_d, reg1, reg0, reg3, reg2, src2, src3); src0_ptr += src_stride_4x; in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; in4 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in5, in6); - in7 = LSX_VLDX(src1_ptr, src2_stride_3x); + in7 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; DUP4_ARG2(__lsx_vsllwil_hu_bu, src0, 6, src1, 6, src2, 6, src3, 6, dst0, dst2, dst4, dst6); @@ -207,7 +207,7 @@ void hevc_bi_copy_6w_lsx(const uint8_t *src0_ptr, int32_t src_stride, src0 = __lsx_vilvl_d(reg1, reg0); src0_ptr += src_stride_2x; in0 = __lsx_vld(src1_ptr, 0); - in1 = LSX_VLDX(src1_ptr, src2_stride_x); + in1 = __lsx_vldx(src1_ptr, src2_stride_x); src1_ptr += src2_stride_x; dst0 = __lsx_vsllwil_hu_bu(src0, 6); dst1 = __lsx_vilvh_b(zero, src0); @@ -265,14 +265,14 @@ void hevc_bi_copy_8w_lsx(const uint8_t *src0_ptr, int32_t src_stride, DUP4_ARG2(__lsx_vslli_h, dst1, 6, dst3, 6, dst5, 6, dst7, 6, dst1, dst3, dst5, dst7); in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; in4 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in5, in6); - in7 = LSX_VLDX(src1_ptr, src2_stride_3x); + in7 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; out0 = hevc_bi_rnd_clip(in0, dst0, in1, dst1); out1 = hevc_bi_rnd_clip(in2, dst2, in3, dst3); @@ -294,7 +294,7 @@ void hevc_bi_copy_8w_lsx(const uint8_t *src0_ptr, int32_t src_stride, reg1 = __lsx_vldrepl_d(src0_ptr + src_stride, 0); src0 = __lsx_vilvl_d(reg1, reg0); in0 = __lsx_vld(src1_ptr, 0); - in1 = LSX_VLDX(src1_ptr, src2_stride_x); + in1 = __lsx_vldx(src1_ptr, src2_stride_x); dst0 = __lsx_vsllwil_hu_bu(src0, 6); dst1 = __lsx_vilvh_b(zero, src0); dst1 = __lsx_vslli_h(dst1, 6); @@ -330,19 +330,19 @@ void hevc_bi_copy_12w_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (loop_cnt = 4; loop_cnt--;) { src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr, src_stride_3x); + src3 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; in4 = __lsx_vld(_src1, 0); - DUP2_ARG2(LSX_VLDX, _src1, src2_stride_x, _src1, src2_stride_2x, + DUP2_ARG2(__lsx_vldx, _src1, src2_stride_x, _src1, src2_stride_2x, in5, in6); - in7 = LSX_VLDX(_src1, src2_stride_3x); + in7 = __lsx_vldx(_src1, src2_stride_3x); _src1 += src2_stride_2x; DUP2_ARG2(__lsx_vilvl_d, in5, in4, in7, in6, in4, in5); @@ -389,19 +389,19 @@ void hevc_bi_copy_16w_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr, src_stride_3x); + src3 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; in4 = __lsx_vld(_src1, 0); - DUP2_ARG2(LSX_VLDX, _src1, src2_stride_x, _src1, src2_stride_2x, + DUP2_ARG2(__lsx_vldx, _src1, src2_stride_x, _src1, src2_stride_2x, in5, in6); - in7 = LSX_VLDX(_src1, src2_stride_3x); + in7 = __lsx_vldx(_src1, src2_stride_3x); _src1 += src2_stride_2x; DUP4_ARG2(__lsx_vsllwil_hu_bu, src0, 6, src1, 6, src2, 6, src3, 6, dst0_r, dst1_r, dst2_r, dst3_r) @@ -647,12 +647,12 @@ void hevc_vt_8t_8w_lsx(const uint8_t *src0_ptr, int32_t src_stride, const int16_ filt0, filt1, filt2, filt3); src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr, src_stride_3x); + src3 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; src4 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src5, src6); src0_ptr += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, @@ -661,14 +661,14 @@ void hevc_vt_8t_8w_lsx(const uint8_t *src0_ptr, int32_t src_stride, const int16_ for (loop_cnt = (height >> 2); loop_cnt--;) { src7 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src0_ptr, src_stride_3x); + src10 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); @@ -741,12 +741,12 @@ void hevc_vt_8t_16multx2mult_lsx(const uint8_t *src0_ptr, int32_t src_stride, dst_tmp = dst; src0 = __lsx_vld(src0_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr_tmp, src_stride, src0_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src0_ptr_tmp, src_stride, src0_ptr_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr_tmp, src_stride_3x); + src3 = __lsx_vldx(src0_ptr_tmp, src_stride_3x); src0_ptr_tmp += src_stride_4x; src4 = __lsx_vld(src0_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr_tmp, src_stride, src0_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src0_ptr_tmp, src_stride, src0_ptr_tmp, src_stride_2x, src5, src6); src0_ptr_tmp += src_stride_3x; @@ -759,7 +759,7 @@ void hevc_vt_8t_16multx2mult_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (loop_cnt = (height >> 1); loop_cnt--;) { src7 = __lsx_vld(src0_ptr_tmp, 0); - src8 = LSX_VLDX(src0_ptr_tmp, src_stride); + src8 = __lsx_vldx(src0_ptr_tmp, src_stride); src0_ptr_tmp += src_stride_2x; DUP2_ARG2(__lsx_vld, src1_ptr_tmp, 0, src1_ptr_tmp, 16, in0, in2); src1_ptr_tmp += src2_stride; @@ -903,12 +903,12 @@ void hevc_hv_8t_8multx1mult_lsx(const uint8_t *src0_ptr, int32_t src_stride, src1_ptr_tmp = src1_ptr; src0 = __lsx_vld(src0_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr_tmp, src_stride, src0_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src0_ptr_tmp, src_stride, src0_ptr_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr_tmp, src_stride_3x); + src3 = __lsx_vldx(src0_ptr_tmp, src_stride_3x); src0_ptr_tmp += src_stride_4x; src4 = __lsx_vld(src0_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr_tmp, src_stride, src0_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src0_ptr_tmp, src_stride, src0_ptr_tmp, src_stride_2x, src5, src6); src0_ptr_tmp += src_stride_3x; @@ -1134,9 +1134,9 @@ static void hevc_hz_4t_24w_lsx(const uint8_t *src0_ptr, int32_t src_stride, dst += dst_stride_4x; in0 = __lsx_vld(src1_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr_tmp, src2_stride_x, src1_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src1_ptr_tmp, src2_stride_x, src1_ptr_tmp, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr_tmp, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr_tmp, src2_stride_3x); src1_ptr_tmp += src2_stride_2x; DUP4_ARG3(__lsx_vshuf_b, src1, src1, mask0, src3, src3, mask0, src5, @@ -1229,7 +1229,7 @@ static void hevc_vt_4t_12w_lsx(const uint8_t *src0_ptr, int32_t src_stride, DUP2_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filt0, filt1); src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); src0_ptr += src_stride_3x; DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); @@ -1238,19 +1238,19 @@ static void hevc_vt_4t_12w_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src3 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src0_ptr, src_stride_3x); + src6 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; in4 = __lsx_vld(_src1, 0); - DUP2_ARG2(LSX_VLDX, _src1, src2_stride_x, _src1, src2_stride_2x, + DUP2_ARG2(__lsx_vldx, _src1, src2_stride_x, _src1, src2_stride_2x, in5, in6); - in7 = LSX_VLDX(_src1, src2_stride_3x); + in7 = __lsx_vldx(_src1, src2_stride_3x); _src1 += src2_stride_2x; DUP2_ARG2(__lsx_vilvl_d, in5, in4, in7, in6, in4, in5); @@ -1310,7 +1310,7 @@ static void hevc_vt_4t_16w_lsx(const uint8_t *src0_ptr, int32_t src_stride, DUP2_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filt0, filt1); src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); src0_ptr += src_stride_3x; DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); @@ -1318,7 +1318,7 @@ static void hevc_vt_4t_16w_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src3 = __lsx_vld(src0_ptr, 0); - src4 = LSX_VLDX(src0_ptr, src_stride); + src4 = __lsx_vldx(src0_ptr, src_stride); src0_ptr += src_stride_2x; DUP2_ARG2(__lsx_vld, src1_ptr, 0, src1_ptr, 16, in0, in2); src1_ptr += src2_stride; @@ -1340,7 +1340,7 @@ static void hevc_vt_4t_16w_lsx(const uint8_t *src0_ptr, int32_t src_stride, dst += dst_stride_2x; src5 = __lsx_vld(src0_ptr, 0); - src2 = LSX_VLDX(src0_ptr, src_stride); + src2 = __lsx_vldx(src0_ptr, src_stride); src0_ptr += src_stride_2x; DUP2_ARG2(__lsx_vld, src1_ptr, 0, src1_ptr, 16, in0, in2); src1_ptr += src2_stride; @@ -1517,7 +1517,7 @@ static void hevc_hv_4t_6w_lsx(const uint8_t *src0_ptr, int32_t src_stride, mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); src0_ptr += src_stride_3x; @@ -1535,9 +1535,9 @@ static void hevc_hv_4t_6w_lsx(const uint8_t *src0_ptr, int32_t src_stride, DUP2_ARG2(__lsx_vilvh_h, dsth1, dsth0, dsth2, dsth1, tmp1, tmp3); src3 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src0_ptr, src_stride_3x); + src6 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; DUP2_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, vec0, vec1); DUP2_ARG3(__lsx_vshuf_b, src4, src4, mask0, src4, src4, mask1, vec2, vec3); @@ -1550,9 +1550,9 @@ static void hevc_hv_4t_6w_lsx(const uint8_t *src0_ptr, int32_t src_stride, vec5, filt1, dsth6, vec7, filt1, dsth3, dsth4, dsth5, dsth6); src3 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src0_ptr, src_stride_3x); + src6 = __lsx_vldx(src0_ptr, src_stride_3x); DUP2_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, vec0, vec1); DUP2_ARG3(__lsx_vshuf_b, src4, src4, mask0, src4, src4, mask1, vec2, vec3); @@ -1700,7 +1700,7 @@ void hevc_hv_4t_8x2_lsx(const uint8_t *src0_ptr, int32_t src_stride, const int16 mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src0_ptr, 0); - DUP4_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP4_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src0_ptr, src_stride_3x, src0_ptr, src_stride_4x, src1, src2, src3, src4); @@ -1777,19 +1777,19 @@ void hevc_hv_4t_8multx4_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (cnt = width8mult; cnt--;) { src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr, src_stride_3x); + src3 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; src4 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src5, src6); src0_ptr += (8 - src_stride_4x); in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += 8; DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, @@ -1900,22 +1900,22 @@ void hevc_hv_4t_8x6_lsx(const uint8_t *src0_ptr, int32_t src_stride, const int16 mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src0_ptr, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src0_ptr, src_stride_3x); + src3 = __lsx_vldx(src0_ptr, src_stride_3x); src0_ptr += src_stride_4x; src4 = __lsx_vld(src0_ptr, 0); - DUP4_ARG2(LSX_VLDX, src0_ptr, src_stride, src0_ptr, src_stride_2x, + DUP4_ARG2(__lsx_vldx, src0_ptr, src_stride, src0_ptr, src_stride_2x, src0_ptr, src_stride_3x, src0_ptr, src_stride_4x, src5, src6, src7, src8); in0 = __lsx_vld(src1_ptr, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, + DUP2_ARG2(__lsx_vldx, src1_ptr, src2_stride_x, src1_ptr, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr, src2_stride_3x); src1_ptr += src2_stride_2x; in4 = __lsx_vld(src1_ptr, 0); - in5 = LSX_VLDX(src1_ptr, src2_stride_x); + in5 = __lsx_vldx(src1_ptr, src2_stride_x); DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, vec0, vec1); DUP2_ARG3(__lsx_vshuf_b, src1, src1, mask0, src1, src1, mask1, vec2, vec3); @@ -2041,7 +2041,7 @@ void hevc_hv_4t_8multx4mult_lsx(const uint8_t *src0_ptr, int32_t src_stride, src1_ptr_tmp = src1_ptr; src0 = __lsx_vld(src0_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr_tmp, src_stride, src0_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src0_ptr_tmp, src_stride, src0_ptr_tmp, src_stride_2x, src1, src2); src0_ptr_tmp += src_stride_3x; @@ -2063,14 +2063,14 @@ void hevc_hv_4t_8multx4mult_lsx(const uint8_t *src0_ptr, int32_t src_stride, for (loop_cnt = height >> 2; loop_cnt--;) { src3 = __lsx_vld(src0_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src0_ptr_tmp, src_stride, src0_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src0_ptr_tmp, src_stride, src0_ptr_tmp, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src0_ptr_tmp, src_stride_3x); + src6 = __lsx_vldx(src0_ptr_tmp, src_stride_3x); src0_ptr_tmp += src_stride_4x; in0 = __lsx_vld(src1_ptr_tmp, 0); - DUP2_ARG2(LSX_VLDX, src1_ptr_tmp, src2_stride_x, src1_ptr_tmp, + DUP2_ARG2(__lsx_vldx, src1_ptr_tmp, src2_stride_x, src1_ptr_tmp, src2_stride_2x, in1, in2); - in3 = LSX_VLDX(src1_ptr_tmp, src2_stride_3x); + in3 = __lsx_vldx(src1_ptr_tmp, src2_stride_3x); src1_ptr_tmp += src2_stride_2x; DUP4_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, src4, diff --git a/libavcodec/loongarch/hevc_mc_uni_lsx.c b/libavcodec/loongarch/hevc_mc_uni_lsx.c index de8e79f502..5437dce0e0 100644 --- a/libavcodec/loongarch/hevc_mc_uni_lsx.c +++ b/libavcodec/loongarch/hevc_mc_uni_lsx.c @@ -148,11 +148,11 @@ void common_vt_8t_8w_lsx(const uint8_t *src, int32_t src_stride, filt0, filt1, filt2, filt3); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -160,8 +160,8 @@ void common_vt_8t_8w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, @@ -228,12 +228,12 @@ void common_vt_8t_16w_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src_tmp, src_stride_3x); + src3 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; src4 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src5, src6); src_tmp += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, @@ -245,9 +245,9 @@ void common_vt_8t_16w_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, for (loop_cnt = (height >> 2); loop_cnt--;) { src7 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src_tmp, src_stride_3x); + src10 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); @@ -380,12 +380,12 @@ void hevc_hv_8t_8x2_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src_tmp, src_stride_3x); + src3 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; src4 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src5, src6); src_tmp += src_stride_3x; @@ -429,7 +429,7 @@ void hevc_hv_8t_8x2_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, for (loop_cnt = height >> 1; loop_cnt--;) { src7 = __lsx_vld(src_tmp, 0); - src8 = LSX_VLDX(src_tmp, src_stride); + src8 = __lsx_vldx(src_tmp, src_stride); src_tmp += src_stride_2x; DUP4_ARG3(__lsx_vshuf_b, src7, src7, mask0, src7, src7, mask1, src7, @@ -567,13 +567,13 @@ void common_vt_4t_24w_lsx(const uint8_t *src, int32_t src_stride, /* 16 width */ src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src1, src0, src2, src1, src10_l, src21_l); /* 8 width */ src6 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, src7, src8); + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src7, src8); src += src_stride_3x; _src += src_stride_3x; DUP2_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src76_r, src87_r); @@ -581,7 +581,7 @@ void common_vt_4t_24w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = 8; loop_cnt--;) { /* 16 width */ DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src3, src9); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src4, src10); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src4, src10); DUP2_ARG2(__lsx_vilvl_b, src3, src2, src4, src3, src32_r, src43_r); DUP2_ARG2(__lsx_vilvh_b, src3, src2, src4, src3, src32_l, src43_l); @@ -615,7 +615,7 @@ void common_vt_4t_24w_lsx(const uint8_t *src, int32_t src_stride, /* 16 width */ DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src5, src11); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src2, src8); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src2, src8); DUP2_ARG2(__lsx_vilvl_b, src5, src4, src2, src5, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src5, src4, src2, src5, src10_l, src21_l); @@ -676,14 +676,14 @@ void common_vt_4t_32w_lsx(const uint8_t *src, int32_t src_stride, /* 16 width */ src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src1, src0, src2, src1, src10_l, src21_l); /* next 16 width */ src6 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, src7, src8); + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src7, src8); src += src_stride_3x; _src += src_stride_3x; @@ -693,7 +693,7 @@ void common_vt_4t_32w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 1); loop_cnt--;) { /* 16 width */ DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src3, src9); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src4, src10); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src4, src10); DUP2_ARG2(__lsx_vilvl_b, src3, src2, src4, src3, src32_r, src43_r); DUP2_ARG2(__lsx_vilvh_b, src3, src2, src4, src3, src32_l, src43_l); @@ -774,7 +774,7 @@ void hevc_hv_4t_8x2_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src, 0); - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src, src_stride_3x, src, src_stride_4x, src1, src2, src3, src4); DUP4_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, src1, src1, @@ -838,11 +838,11 @@ void hevc_hv_4t_8multx4_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst for (cnt = width8mult; cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += (8 - src_stride_4x); DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, vec0, vec1); @@ -939,10 +939,10 @@ void hevc_hv_4t_8x6_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src, 0); - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x,src, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x,src, src_stride_3x, src, src_stride_4x, src1, src2, src3, src4); src += src_stride_4x; - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x,src, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x,src, src_stride_3x, src, src_stride_4x, src5, src6, src7, src8); DUP4_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, src1, src1, @@ -1051,7 +1051,7 @@ void hevc_hv_4t_8multx4mult_lsx(const uint8_t *src, int32_t src_stride, uint8_t dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); src_tmp += src_stride_3x; @@ -1073,9 +1073,9 @@ void hevc_hv_4t_8multx4mult_lsx(const uint8_t *src, int32_t src_stride, uint8_t for (loop_cnt = (height >> 2); loop_cnt--;) { src3 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src_tmp, src_stride_3x); + src6 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, src4, @@ -1186,7 +1186,7 @@ void hevc_hv_4t_12w_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); src_tmp += src_stride_3x; @@ -1205,9 +1205,9 @@ void hevc_hv_4t_12w_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, for (loop_cnt = 4; loop_cnt--;) { src3 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src_tmp, src_stride_3x); + src6 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, src4, @@ -1261,7 +1261,7 @@ void hevc_hv_4t_12w_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, mask3 = __lsx_vaddi_bu(mask2, 2); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); src += src_stride_3x; DUP2_ARG3(__lsx_vshuf_b, src1, src0, mask2, src1, src0, mask3, vec0, vec1); DUP2_ARG3(__lsx_vshuf_b, src2, src1, mask2, src2, src1, mask3, vec2, vec3); @@ -1276,12 +1276,12 @@ void hevc_hv_4t_12w_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, for (loop_cnt = 2; loop_cnt--;) { src3 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src4, src5); + src6 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src7, src3, mask2, src7, src3, mask3, src8, src4, mask2, src8, src4, mask3, vec0, vec1, vec2, vec3); diff --git a/libavcodec/loongarch/hevc_mc_uniw_lsx.c b/libavcodec/loongarch/hevc_mc_uniw_lsx.c index 502bf24e71..c4e79225d3 100644 --- a/libavcodec/loongarch/hevc_mc_uniw_lsx.c +++ b/libavcodec/loongarch/hevc_mc_uniw_lsx.c @@ -79,12 +79,12 @@ void hevc_hv_8t_8x2_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src_tmp, src_stride_3x); + src3 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; src4 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src5, src6); src_tmp += src_stride_3x; @@ -127,7 +127,7 @@ void hevc_hv_8t_8x2_lsx(const uint8_t *src, int32_t src_stride, uint8_t *dst, for (loop_cnt = height >> 1; loop_cnt--;) { src7 = __lsx_vld(src_tmp, 0); - src8 = LSX_VLDX(src_tmp, src_stride); + src8 = __lsx_vldx(src_tmp, src_stride); src_tmp += src_stride_2x; DUP4_ARG3(__lsx_vshuf_b, src7, src7, mask0, src7, src7, mask1, src7, src7, mask2, src7, src7, mask3, vec0, vec1, vec2, vec3); diff --git a/libavcodec/loongarch/hevcdsp_lsx.c b/libavcodec/loongarch/hevcdsp_lsx.c index 86fc5f06c0..85843dd111 100644 --- a/libavcodec/loongarch/hevcdsp_lsx.c +++ b/libavcodec/loongarch/hevcdsp_lsx.c @@ -48,14 +48,14 @@ static void hevc_copy_4w_lsx(const uint8_t *src, int32_t src_stride, __m128i in0, in1, in2, in3; for (; loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(src, src_stride_3x); + src7 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vilvl_w, src1, src0, src3, src2, src5, src4, src7, src6, @@ -98,12 +98,12 @@ static void hevc_copy_6w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 3); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); + src7 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vsllwil_hu_bu, src0, 6, src1, 6, src2, 6, src3, 6, @@ -163,14 +163,14 @@ static void hevc_copy_8w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 3); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(src, src_stride_3x); + src7 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vsllwil_hu_bu, src0, 6, src1, 6, src2, 6, src3, 6, @@ -215,12 +215,12 @@ static void hevc_copy_12w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 3); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); + src7 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vsllwil_hu_bu, src0, 6, src1, 6, src2, 6, src3, 6, @@ -288,14 +288,14 @@ static void hevc_copy_16w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 3); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(src, src_stride_3x); + src7 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vilvh_b, zero, src0, zero, src1, zero, src2, zero, src3, in0_l, in1_l, in2_l, in3_l); @@ -333,8 +333,8 @@ static void hevc_copy_16w_lsx(const uint8_t *src, int32_t src_stride, } if (res) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); DUP4_ARG2(__lsx_vilvh_b, zero, src0, zero, src1, zero, src2, zero, src3, in0_l, in1_l, in2_l, in3_l); @@ -373,13 +373,13 @@ static void hevc_copy_24w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(_src, src_stride_3x); + src7 = __lsx_vldx(_src, src_stride_3x); _src += src_stride_4x; DUP4_ARG2(__lsx_vilvh_b, zero, src0, zero, src1, zero, src2, zero, @@ -423,13 +423,13 @@ static void hevc_copy_32w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src2, src4); - src6 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src2, src4); + src6 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src1 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src3, src5); - src7 = LSX_VLDX(_src, src_stride_3x); + src7 = __lsx_vldx(_src, src_stride_3x); _src += src_stride_4x; DUP4_ARG2(__lsx_vilvh_b, zero, src0, zero, src1, zero, src2, zero, @@ -623,12 +623,12 @@ static void hevc_hz_8t_4w_lsx(const uint8_t *src, int32_t src_stride, for (;loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); + src7 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src1, src0, mask0, src1, src0, mask1, src1, src0, mask2, src1, src0, mask3, vec0, vec1, vec2, vec3); @@ -668,7 +668,7 @@ static void hevc_hz_8t_4w_lsx(const uint8_t *src, int32_t src_stride, } for (;res--;) { src0 = __lsx_vld(src, 0); - src1 = LSX_VLDX(src, src_stride); + src1 = __lsx_vldx(src, src_stride); DUP4_ARG3(__lsx_vshuf_b, src1, src0, mask0, src1, src0, mask1, src1, src0, mask2, src1, src0, mask3, vec0, vec1, vec2, vec3); dst0 = __lsx_vdp2_h_bu_b(vec0, filt0); @@ -709,8 +709,8 @@ static void hevc_hz_8t_8w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, src0, @@ -774,12 +774,12 @@ static void hevc_hz_8t_12w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = 4; loop_cnt--;) { src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src4 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src5, src6); - src7 = LSX_VLDX(_src, src_stride_3x); + src7 = __lsx_vldx(_src, src_stride_3x); src += src_stride_4x; _src += src_stride_4x; @@ -1216,11 +1216,11 @@ static void hevc_vt_8t_4w_lsx(const uint8_t *src, int32_t src_stride, filt0, filt1, filt2, filt3); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -1231,13 +1231,13 @@ static void hevc_vt_8t_4w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 3); loop_cnt--;) { src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src11 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src12, src13); - src14 = LSX_VLDX(src, src_stride_3x); + src14 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, src9, @@ -1289,7 +1289,7 @@ static void hevc_vt_8t_4w_lsx(const uint8_t *src, int32_t src_stride, } for (;res--;) { src7 = __lsx_vld(src, 0); - src8 = LSX_VLDX(src, src_stride); + src8 = __lsx_vldx(src, src_stride); DUP2_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src76_r, src87_r); src += src_stride_2x; src8776 = __lsx_vilvl_d(src87_r, src76_r); @@ -1334,11 +1334,11 @@ static void hevc_vt_8t_8w_lsx(const uint8_t *src, int32_t src_stride, filt0, filt1, filt2, filt3); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -1346,8 +1346,8 @@ static void hevc_vt_8t_8w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); @@ -1408,11 +1408,11 @@ static void hevc_vt_8t_12w_lsx(const uint8_t *src, int32_t src_stride, DUP4_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filter, 4, filter, 6, filt0, filt1, filt2, filt3); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -1426,8 +1426,8 @@ static void hevc_vt_8t_12w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = (height >> 2); loop_cnt--;) { src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); @@ -1520,12 +1520,12 @@ static void hevc_vt_8t_16multx4mult_lsx(const uint8_t *src, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src_tmp, src_stride_3x); + src3 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; src4 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src5, src6); src_tmp += src_stride_3x; DUP4_ARG2(__lsx_vilvl_b, src1, src0, src3, src2, src5, src4, src2, src1, @@ -1537,9 +1537,9 @@ static void hevc_vt_8t_16multx4mult_lsx(const uint8_t *src, for (loop_cnt = (height >> 2); loop_cnt--;) { src7 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src_tmp, src_stride_3x); + src10 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; DUP4_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); @@ -1689,11 +1689,11 @@ static void hevc_hv_8t_4w_lsx(const uint8_t *src, int32_t src_stride, mask3 = __lsx_vaddi_bu(mask0, 6); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += src_stride_3x; DUP4_ARG3(__lsx_vshuf_b, src3, src0, mask0, src3, src0, mask1, src3, src0, @@ -1729,8 +1729,8 @@ static void hevc_hv_8t_4w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = height >> 2; loop_cnt--;) { src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src9, src7, mask0, src9, src7, mask1, src9, src7, @@ -1830,12 +1830,12 @@ static void hevc_hv_8t_8multx1mult_lsx(const uint8_t *src, src_tmp = src; dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src_tmp, src_stride_3x); + src3 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; src4 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src5, src6); src_tmp += src_stride_3x; @@ -1978,12 +1978,12 @@ static void hevc_hv_8t_12w_lsx(const uint8_t *src, int32_t src_stride, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src_tmp, src_stride_3x); + src3 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; src4 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src5, src6); src_tmp += src_stride_3x; @@ -2077,11 +2077,11 @@ static void hevc_hv_8t_12w_lsx(const uint8_t *src, int32_t src_stride, mask7 = __lsx_vaddi_bu(mask4, 6); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src4 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += src_stride_3x; DUP4_ARG3(__lsx_vshuf_b, src3, src0, mask4, src3, src0, mask5, src3, src0, @@ -2118,8 +2118,8 @@ static void hevc_hv_8t_12w_lsx(const uint8_t *src, int32_t src_stride, for (loop_cnt = height >> 2; loop_cnt--;) { src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP4_ARG3(__lsx_vshuf_b, src9, src7, mask4, src9, src7, mask5, src9, @@ -2285,14 +2285,14 @@ static void hevc_vt_4t_16w_lsx(const uint8_t *src, DUP2_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filt0, filt1); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); src += src_stride_3x; DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src1, src0, src2, src1, src10_l, src21_l); for (loop_cnt = (height >> 2); loop_cnt--;) { src3 = __lsx_vld(src, 0); - src4 = LSX_VLDX(src, src_stride); + src4 = __lsx_vldx(src, src_stride); src += src_stride_2x; DUP2_ARG2(__lsx_vilvl_b, src3, src2, src4, src3, src32_r, src43_r); DUP2_ARG2(__lsx_vilvh_b, src3, src2, src4, src3, src32_l, src43_l); @@ -2309,7 +2309,7 @@ static void hevc_vt_4t_16w_lsx(const uint8_t *src, dst += dst_stride; src5 = __lsx_vld(src, 0); - src2 = LSX_VLDX(src, src_stride); + src2 = __lsx_vldx(src, src_stride); src += src_stride_2x; DUP2_ARG2(__lsx_vilvl_b, src5, src4, src2, src5, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src5, src4, src2, src5, src10_l, src21_l); @@ -2353,19 +2353,19 @@ static void hevc_vt_4t_24w_lsx(const uint8_t *src, DUP2_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filt0, filt1); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src1, src0, src2, src1, src10_l, src21_l); src6 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, src7, src8); + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src7, src8); src += src_stride_3x; _src += src_stride_3x; DUP2_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src76_r, src87_r); for (loop_cnt = (height >> 2); loop_cnt--;) { DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src3, src9); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src4, src10); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src4, src10); src += src_stride_2x; _src += src_stride_2x; DUP2_ARG2(__lsx_vilvl_b, src3, src2, src4, src3, src32_r, src43_r); @@ -2392,7 +2392,7 @@ static void hevc_vt_4t_24w_lsx(const uint8_t *src, dst += dst_stride; DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src5, src11); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src2, src8); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src2, src8); src += src_stride_2x; _src += src_stride_2x; DUP2_ARG2(__lsx_vilvl_b, src5, src4, src2, src5, src10_r, src21_r); @@ -2448,12 +2448,12 @@ static void hevc_vt_4t_32w_lsx(const uint8_t *src, DUP2_ARG2(__lsx_vldrepl_h, filter, 0, filter, 2, filt0, filt1); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); DUP2_ARG2(__lsx_vilvl_b, src1, src0, src2, src1, src10_r, src21_r); DUP2_ARG2(__lsx_vilvh_b, src1, src0, src2, src1, src10_l, src21_l); src6 = __lsx_vld(_src, 0); - DUP2_ARG2(LSX_VLDX, _src, src_stride, _src, src_stride_2x, src7, src8); + DUP2_ARG2(__lsx_vldx, _src, src_stride, _src, src_stride_2x, src7, src8); src += src_stride_3x; _src += src_stride_3x; DUP2_ARG2(__lsx_vilvl_b, src7, src6, src8, src7, src76_r, src87_r); @@ -2461,7 +2461,7 @@ static void hevc_vt_4t_32w_lsx(const uint8_t *src, for (loop_cnt = (height >> 2); loop_cnt--;) { DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src3, src9); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src4, src10); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src4, src10); src += src_stride_2x; _src += src_stride_2x; DUP2_ARG2(__lsx_vilvl_b, src3, src2, src4, src3, src32_r, src43_r); @@ -2493,7 +2493,7 @@ static void hevc_vt_4t_32w_lsx(const uint8_t *src, dst += dst_stride; DUP2_ARG2(__lsx_vld, src, 0, _src, 0, src5, src11); - DUP2_ARG2(LSX_VLDX, src, src_stride, _src, src_stride, src2, src8); + DUP2_ARG2(__lsx_vldx, src, src_stride, _src, src_stride, src2, src8); src += src_stride_2x; _src += src_stride_2x; DUP2_ARG2(__lsx_vilvl_b, src5, src4, src2, src5, src10_r, src21_r); @@ -2560,9 +2560,9 @@ static void hevc_hv_4t_8x2_lsx(const uint8_t *src, mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); - src3 = LSX_VLDX(src, src_stride_3x); - src4 = LSX_VLDX(src, src_stride_4x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); + src3 = __lsx_vldx(src, src_stride_3x); + src4 = __lsx_vldx(src, src_stride_4x); DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, vec0, vec1); DUP2_ARG3(__lsx_vshuf_b, src1, src1, mask0, src1, src1, mask1, vec2, vec3); @@ -2627,10 +2627,10 @@ static void hevc_hv_4t_8multx4_lsx(const uint8_t *src, int32_t src_stride, for (cnt = width8mult; cnt--;) { src0 = __lsx_vld(src, 0); - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src, src_stride_3x, src, src_stride_4x, src1, src2, src3, src4); src += src_stride_4x; - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src5, src6); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src5, src6); src += (8 - src_stride_4x); DUP2_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, @@ -2730,10 +2730,10 @@ static void hevc_hv_4t_8x6_lsx(const uint8_t *src, mask1 = __lsx_vaddi_bu(mask0, 2); src0 = __lsx_vld(src, 0); - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src, src_stride_3x, src, src_stride_4x, src1, src2, src3, src4); src += src_stride_4x; - DUP4_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src, + DUP4_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src, src_stride_3x, src, src_stride_4x, src5, src6, src7, src8); DUP4_ARG3(__lsx_vshuf_b, src0, src0, mask0, src0, src0, mask1, src1, src1, @@ -2847,7 +2847,7 @@ static void hevc_hv_4t_8multx4mult_lsx(const uint8_t *src, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); src_tmp += src_stride_3x; @@ -2869,9 +2869,9 @@ static void hevc_hv_4t_8multx4mult_lsx(const uint8_t *src, for (loop_cnt = height >> 2; loop_cnt--;) { src3 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src_tmp, src_stride_3x); + src6 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; DUP2_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, @@ -2997,7 +2997,7 @@ static void hevc_hv_4t_12w_lsx(const uint8_t *src, dst_tmp = dst; src0 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src1, src2); src_tmp += src_stride_3x; @@ -3016,9 +3016,9 @@ static void hevc_hv_4t_12w_lsx(const uint8_t *src, for (loop_cnt = 4; loop_cnt--;) { src3 = __lsx_vld(src_tmp, 0); - DUP2_ARG2(LSX_VLDX, src_tmp, src_stride, src_tmp, src_stride_2x, + DUP2_ARG2(__lsx_vldx, src_tmp, src_stride, src_tmp, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src_tmp, src_stride_3x); + src6 = __lsx_vldx(src_tmp, src_stride_3x); src_tmp += src_stride_4x; DUP2_ARG3(__lsx_vshuf_b, src3, src3, mask0, src3, src3, mask1, @@ -3077,7 +3077,7 @@ static void hevc_hv_4t_12w_lsx(const uint8_t *src, mask3 = __lsx_vaddi_bu(mask2, 2); src0 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src1, src2); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src1, src2); src += src_stride_3x; DUP2_ARG3(__lsx_vshuf_b, src1, src0, mask2, src1, src0, mask3, vec0, vec1); DUP2_ARG3(__lsx_vshuf_b, src2, src1, mask2, src2, src1, mask3, vec2, vec3); @@ -3090,12 +3090,12 @@ static void hevc_hv_4t_12w_lsx(const uint8_t *src, for (loop_cnt = 2; loop_cnt--;) { src3 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src4, src5); - src6 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src4, src5); + src6 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; src7 = __lsx_vld(src, 0); - DUP2_ARG2(LSX_VLDX, src, src_stride, src, src_stride_2x, src8, src9); - src10 = LSX_VLDX(src, src_stride_3x); + DUP2_ARG2(__lsx_vldx, src, src_stride, src, src_stride_2x, src8, src9); + src10 = __lsx_vldx(src, src_stride_3x); src += src_stride_4x; DUP2_ARG3(__lsx_vshuf_b, src7, src3, mask2, src7, src3, mask3, vec0, vec1); diff --git a/libavutil/loongarch/loongson_intrinsics.h b/libavutil/loongarch/loongson_intrinsics.h index 6425551255..090adab266 100644 --- a/libavutil/loongarch/loongson_intrinsics.h +++ b/libavutil/loongarch/loongson_intrinsics.h @@ -89,11 +89,6 @@ #ifdef __loongarch_sx #include - -/* __lsx_vldx() from lsxintrin.h does not accept a const void*; - * remove the following once it does. */ -#define LSX_VLDX(cptr, stride) __lsx_vldx((void*)(cptr), (stride)) - /* * ============================================================================= * Description : Dot product & addition of byte vector elements From e402bd65b1be9125a85bc4f3d56aed214cbfce51 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 9 Sep 2022 14:32:36 +0200 Subject: [PATCH 260/590] Revert "avcodec/loongarch/h264chroma, vc1dsp_lasx: Add wrapper for __lasx_xvldx" This reverts commit 2c8dc7e953e532752500e8145aa1ceee908bda2f. The loongarch headers have been fixed, so that this wrapper is no longer necessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/loongarch/h264chroma_lasx.c | 90 +++++++++++------------ libavcodec/loongarch/vc1dsp_lasx.c | 16 ++-- libavutil/loongarch/loongson_intrinsics.h | 5 -- 3 files changed, 53 insertions(+), 58 deletions(-) diff --git a/libavcodec/loongarch/h264chroma_lasx.c b/libavcodec/loongarch/h264chroma_lasx.c index 5e611997f4..1c0e002bdf 100644 --- a/libavcodec/loongarch/h264chroma_lasx.c +++ b/libavcodec/loongarch/h264chroma_lasx.c @@ -51,7 +51,7 @@ static av_always_inline void avc_chroma_hv_8x4_lasx(const uint8_t *src, uint8_t __m256i coeff_vt_vec1 = __lasx_xvreplgr2vr_h(coef_ver1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 0, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, src1, src2, src3, src4); DUP2_ARG3(__lasx_xvpermi_q, src2, src1, 0x20, src4, src3, 0x20, src1, src3); src0 = __lasx_xvshuf_b(src0, src0, mask); @@ -91,10 +91,10 @@ static av_always_inline void avc_chroma_hv_8x8_lasx(const uint8_t *src, uint8_t __m256i coeff_vt_vec1 = __lasx_xvreplgr2vr_h(coef_ver1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 0, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, src1, src2, src3, src4); src += stride_4x; - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, src5, src6, src7, src8); DUP4_ARG3(__lasx_xvpermi_q, src2, src1, 0x20, src4, src3, 0x20, src6, src5, 0x20, src8, src7, 0x20, src1, src3, src5, src7); @@ -141,8 +141,8 @@ static av_always_inline void avc_chroma_hz_8x4_lasx(const uint8_t *src, uint8_t coeff_vec = __lasx_xvslli_b(coeff_vec, 3); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 0, src, 0, mask, src0); - DUP2_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src1, src2); - src3 = LASX_XVLDX(src, stride_3x); + DUP2_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src1, src2); + src3 = __lasx_xvldx(src, stride_3x); DUP2_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src3, src2, 0x20, src0, src2); DUP2_ARG3(__lasx_xvshuf_b, src0, src0, mask, src2, src2, mask, src0, src2); DUP2_ARG2(__lasx_xvdp2_h_bu, src0, coeff_vec, src2, coeff_vec, res0, res1); @@ -170,11 +170,11 @@ static av_always_inline void avc_chroma_hz_8x8_lasx(const uint8_t *src, uint8_t coeff_vec = __lasx_xvslli_b(coeff_vec, 3); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 0, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, src1, src2, src3, src4); src += stride_4x; - DUP2_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src5, src6); - src7 = LASX_XVLDX(src, stride_3x); + DUP2_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src5, src6); + src7 = __lasx_xvldx(src, stride_3x); DUP4_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src3, src2, 0x20, src5, src4, 0x20, src7, src6, 0x20, src0, src2, src4, src6); DUP4_ARG3(__lasx_xvshuf_b, src0, src0, mask, src2, src2, mask, src4, src4, mask, @@ -212,7 +212,7 @@ static av_always_inline void avc_chroma_hz_nonmult_lasx(const uint8_t *src, coeff_vec = __lasx_xvslli_b(coeff_vec, 3); for (row = height >> 2; row--;) { - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src0, src1, src2, src3); src += stride_4x; DUP2_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src3, src2, 0x20, src0, src2); @@ -228,7 +228,7 @@ static av_always_inline void avc_chroma_hz_nonmult_lasx(const uint8_t *src, if ((height & 3)) { src0 = __lasx_xvld(src, 0); - src1 = LASX_XVLDX(src, stride); + src1 = __lasx_xvldx(src, stride); src1 = __lasx_xvpermi_q(src1, src0, 0x20); src0 = __lasx_xvshuf_b(src1, src1, mask); res0 = __lasx_xvdp2_h_bu(src0, coeff_vec); @@ -253,7 +253,7 @@ static av_always_inline void avc_chroma_vt_8x4_lasx(const uint8_t *src, uint8_t coeff_vec = __lasx_xvslli_b(coeff_vec, 3); src0 = __lasx_xvld(src, 0); src += stride; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src1, src2, src3, src4); DUP4_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src2, src1, 0x20, src3, src2, 0x20, src4, src3, 0x20, src0, src1, src2, src3); @@ -282,10 +282,10 @@ static av_always_inline void avc_chroma_vt_8x8_lasx(const uint8_t *src, uint8_t coeff_vec = __lasx_xvslli_b(coeff_vec, 3); src0 = __lasx_xvld(src, 0); src += stride; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src1, src2, src3, src4); src += stride_4x; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src5, src6, src7, src8); DUP4_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src2, src1, 0x20, src3, src2, 0x20, src4, src3, 0x20, src0, src1, src2, src3); @@ -402,7 +402,7 @@ static void avc_chroma_hv_4x2_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s __m256i coeff_vt_vec = __lasx_xvpermi_q(coeff_vt_vec1, coeff_vt_vec0, 0x02); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 32, src, 0, mask, src0); - DUP2_ARG2(LASX_XVLDX, src, stride, src, stride_2, src1, src2); + DUP2_ARG2(__lasx_xvldx, src, stride, src, stride_2, src1, src2); DUP2_ARG3(__lasx_xvshuf_b, src1, src0, mask, src2, src1, mask, src0, src1); src0 = __lasx_xvpermi_q(src0, src1, 0x02); res_hz = __lasx_xvdp2_h_bu(src0, coeff_hz_vec); @@ -431,7 +431,7 @@ static void avc_chroma_hv_4x4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s __m256i coeff_vt_vec1 = __lasx_xvreplgr2vr_h(coef_ver1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 32, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src1, src2, src3, src4); DUP4_ARG3(__lasx_xvshuf_b, src1, src0, mask, src2, src1, mask, src3, src2, mask, src4, src3, mask, src0, src1, src2, src3); @@ -464,10 +464,10 @@ static void avc_chroma_hv_4x8_lasx(const uint8_t *src, uint8_t * dst, ptrdiff_t __m256i coeff_vt_vec1 = __lasx_xvreplgr2vr_h(coef_ver1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 32, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src1, src2, src3, src4); src += stride_4; - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src5, src6, src7, src8); DUP4_ARG3(__lasx_xvshuf_b, src1, src0, mask, src2, src1, mask, src3, src2, mask, src4, src3, mask, src0, src1, src2, src3); @@ -519,7 +519,7 @@ static void avc_chroma_hz_4x2_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s __m256i coeff_vec = __lasx_xvilvl_b(coeff_vec0, coeff_vec1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 32, src, 0, mask, src0); - src1 = LASX_XVLDX(src, stride); + src1 = __lasx_xvldx(src, stride); src0 = __lasx_xvshuf_b(src1, src0, mask); res = __lasx_xvdp2_h_bu(src0, coeff_vec); res = __lasx_xvslli_h(res, 3); @@ -540,8 +540,8 @@ static void avc_chroma_hz_4x4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s __m256i coeff_vec = __lasx_xvilvl_b(coeff_vec0, coeff_vec1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 32, src, 0, mask, src0); - DUP2_ARG2(LASX_XVLDX, src, stride, src, stride_2, src1, src2); - src3 = LASX_XVLDX(src, stride_3); + DUP2_ARG2(__lasx_xvldx, src, stride, src, stride_2, src1, src2); + src3 = __lasx_xvldx(src, stride_3); DUP2_ARG3(__lasx_xvshuf_b, src1, src0, mask, src3, src2, mask, src0, src2); src0 = __lasx_xvpermi_q(src0, src2, 0x02); res = __lasx_xvdp2_h_bu(src0, coeff_vec); @@ -567,11 +567,11 @@ static void avc_chroma_hz_4x8_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s coeff_vec = __lasx_xvslli_b(coeff_vec, 3); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 32, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src1, src2, src3, src4); src += stride_4; - DUP2_ARG2(LASX_XVLDX, src, stride, src, stride_2, src5, src6); - src7 = LASX_XVLDX(src, stride_3); + DUP2_ARG2(__lasx_xvldx, src, stride, src, stride_2, src5, src6); + src7 = __lasx_xvldx(src, stride_3); DUP4_ARG3(__lasx_xvshuf_b, src1, src0, mask, src3, src2, mask, src5, src4, mask, src7, src6, mask, src0, src2, src4, src6); DUP2_ARG3(__lasx_xvpermi_q, src0, src2, 0x02, src4, src6, 0x02, src0, src4); @@ -625,7 +625,7 @@ static void avc_chroma_vt_4x2_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s __m256i coeff_vec = __lasx_xvilvl_b(coeff_vec0, coeff_vec1); src0 = __lasx_xvld(src, 0); - DUP2_ARG2(LASX_XVLDX, src, stride, src, stride << 1, src1, src2); + DUP2_ARG2(__lasx_xvldx, src, stride, src, stride << 1, src1, src2); DUP2_ARG2(__lasx_xvilvl_b, src1, src0, src2, src1, tmp0, tmp1); tmp0 = __lasx_xvilvl_d(tmp1, tmp0); res = __lasx_xvdp2_h_bu(tmp0, coeff_vec); @@ -649,7 +649,7 @@ static void avc_chroma_vt_4x4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s __m256i coeff_vec = __lasx_xvilvl_b(coeff_vec0, coeff_vec1); src0 = __lasx_xvld(src, 0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src1, src2, src3, src4); DUP4_ARG2(__lasx_xvilvl_b, src1, src0, src2, src1, src3, src2, src4, src3, tmp0, tmp1, tmp2, tmp3); @@ -679,10 +679,10 @@ static void avc_chroma_vt_4x8_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t s coeff_vec = __lasx_xvslli_b(coeff_vec, 3); src0 = __lasx_xvld(src, 0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src1, src2, src3, src4); src += stride_4; - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2, src, stride_3, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2, src, stride_3, src, stride_4, src5, src6, src7, src8); DUP4_ARG2(__lasx_xvilvl_b, src1, src0, src2, src1, src3, src2, src4, src3, tmp0, tmp1, tmp2, tmp3); @@ -860,7 +860,7 @@ static av_always_inline void avc_chroma_hv_and_aver_dst_8x4_lasx(const uint8_t * __m256i coeff_vt_vec1 = __lasx_xvreplgr2vr_h(coef_ver1); DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 0, src, 0, mask, src0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, src1, src2, src3, src4); DUP2_ARG3(__lasx_xvpermi_q, src2, src1, 0x20, src4, src3, 0x20, src1, src3); src0 = __lasx_xvshuf_b(src0, src0, mask); @@ -874,7 +874,7 @@ static av_always_inline void avc_chroma_hv_and_aver_dst_8x4_lasx(const uint8_t * res_vt0 = __lasx_xvmadd_h(res_vt0, res_hz0, coeff_vt_vec1); res_vt1 = __lasx_xvmadd_h(res_vt1, res_hz1, coeff_vt_vec1); out = __lasx_xvssrarni_bu_h(res_vt1, res_vt0, 6); - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); tp0 = __lasx_xvpermi_q(tp2, tp0, 0x20); @@ -907,10 +907,10 @@ static av_always_inline void avc_chroma_hv_and_aver_dst_8x8_lasx(const uint8_t * DUP2_ARG2(__lasx_xvld, chroma_mask_arr, 0, src, 0, mask, src0); src += stride; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src1, src2, src3, src4); src += stride_4x; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src5, src6, src7, src8); DUP4_ARG3(__lasx_xvpermi_q, src2, src1, 0x20, src4, src3, 0x20, src6, src5, 0x20, src8, src7, 0x20, src1, src3, src5, src7); @@ -934,12 +934,12 @@ static av_always_inline void avc_chroma_hv_and_aver_dst_8x8_lasx(const uint8_t * res_vt3 = __lasx_xvmadd_h(res_vt3, res_hz3, coeff_vt_vec1); DUP2_ARG3(__lasx_xvssrarni_bu_h, res_vt1, res_vt0, 6, res_vt3, res_vt2, 6, out0, out1); - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); dst0 = __lasx_xvpermi_q(tp2, tp0, 0x20); dst += stride_4x; - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); dst -= stride_4x; DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); @@ -973,13 +973,13 @@ static av_always_inline void avc_chroma_hz_and_aver_dst_8x4_lasx(const uint8_t * coeff_vec = __lasx_xvslli_b(coeff_vec, 3); mask = __lasx_xvld(chroma_mask_arr, 0); - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src0, src1, src2, src3); DUP2_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src3, src2, 0x20, src0, src2); DUP2_ARG3(__lasx_xvshuf_b, src0, src0, mask, src2, src2, mask, src0, src2); DUP2_ARG2(__lasx_xvdp2_h_bu, src0, coeff_vec, src2, coeff_vec, res0, res1); out = __lasx_xvssrarni_bu_h(res1, res0, 6); - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); tp0 = __lasx_xvpermi_q(tp2, tp0, 0x20); @@ -1008,10 +1008,10 @@ static av_always_inline void avc_chroma_hz_and_aver_dst_8x8_lasx(const uint8_t * coeff_vec = __lasx_xvslli_b(coeff_vec, 3); mask = __lasx_xvld(chroma_mask_arr, 0); - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src0, src1, src2, src3); src += stride_4x; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src4, src5, src6, src7); DUP4_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src3, src2, 0x20, src5, src4, 0x20, src7, src6, 0x20, src0, src2, src4, src6); @@ -1020,12 +1020,12 @@ static av_always_inline void avc_chroma_hz_and_aver_dst_8x8_lasx(const uint8_t * DUP4_ARG2(__lasx_xvdp2_h_bu, src0, coeff_vec, src2, coeff_vec, src4, coeff_vec, src6, coeff_vec, res0, res1, res2, res3); DUP2_ARG3(__lasx_xvssrarni_bu_h, res1, res0, 6, res3, res2, 6, out0, out1); - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); dst0 = __lasx_xvpermi_q(tp2, tp0, 0x20); dst += stride_4x; - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); dst -= stride_4x; DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); @@ -1059,14 +1059,14 @@ static av_always_inline void avc_chroma_vt_and_aver_dst_8x4_lasx(const uint8_t * coeff_vec = __lasx_xvslli_b(coeff_vec, 3); src0 = __lasx_xvld(src, 0); - DUP4_ARG2(LASX_XVLDX, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, + DUP4_ARG2(__lasx_xvldx, src, stride, src, stride_2x, src, stride_3x, src, stride_4x, src1, src2, src3, src4); DUP4_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src2, src1, 0x20, src3, src2, 0x20, src4, src3, 0x20, src0, src1, src2, src3); DUP2_ARG2(__lasx_xvilvl_b, src1, src0, src3, src2, src0, src2); DUP2_ARG2(__lasx_xvdp2_h_bu, src0, coeff_vec, src2, coeff_vec, res0, res1); out = __lasx_xvssrarni_bu_h(res1, res0, 6); - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); tp0 = __lasx_xvpermi_q(tp2, tp0, 0x20); @@ -1095,10 +1095,10 @@ static av_always_inline void avc_chroma_vt_and_aver_dst_8x8_lasx(const uint8_t * coeff_vec = __lasx_xvslli_b(coeff_vec, 3); src0 = __lasx_xvld(src, 0); src += stride; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src1, src2, src3, src4); src += stride_4x; - DUP4_ARG2(LASX_XVLDX, src, 0, src, stride, src, stride_2x, src, stride_3x, + DUP4_ARG2(__lasx_xvldx, src, 0, src, stride, src, stride_2x, src, stride_3x, src5, src6, src7, src8); DUP4_ARG3(__lasx_xvpermi_q, src1, src0, 0x20, src2, src1, 0x20, src3, src2, 0x20, src4, src3, 0x20, src0, src1, src2, src3); @@ -1109,12 +1109,12 @@ static av_always_inline void avc_chroma_vt_and_aver_dst_8x8_lasx(const uint8_t * DUP4_ARG2(__lasx_xvdp2_h_bu, src0, coeff_vec, src2, coeff_vec, src4, coeff_vec, src6, coeff_vec, res0, res1, res2, res3); DUP2_ARG3(__lasx_xvssrarni_bu_h, res1, res0, 6, res3, res2, 6, out0, out1); - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); dst0 = __lasx_xvpermi_q(tp2, tp0, 0x20); dst += stride_4x; - DUP4_ARG2(LASX_XVLDX, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, + DUP4_ARG2(__lasx_xvldx, dst, 0, dst, stride, dst, stride_2x, dst, stride_3x, tp0, tp1, tp2, tp3); dst -= stride_4x; DUP2_ARG2(__lasx_xvilvl_d, tp2, tp0, tp3, tp1, tp0, tp2); diff --git a/libavcodec/loongarch/vc1dsp_lasx.c b/libavcodec/loongarch/vc1dsp_lasx.c index 12f68ee028..848fe4afb3 100644 --- a/libavcodec/loongarch/vc1dsp_lasx.c +++ b/libavcodec/loongarch/vc1dsp_lasx.c @@ -831,20 +831,20 @@ static void put_vc1_mspel_mc_h_lasx(uint8_t *dst, const uint8_t *src, const_para1_2 = __lasx_xvreplgr2vr_h(*(para_v + 1)); in0 = __lasx_xvld(_src, 0); - DUP2_ARG2(LASX_XVLDX, _src, stride, _src, stride2, in1, in2); - in3 = LASX_XVLDX(_src, stride3); + DUP2_ARG2(__lasx_xvldx, _src, stride, _src, stride2, in1, in2); + in3 = __lasx_xvldx(_src, stride3); _src += stride4; in4 = __lasx_xvld(_src, 0); - DUP2_ARG2(LASX_XVLDX, _src, stride, _src, stride2, in5, in6); - in7 = LASX_XVLDX(_src, stride3); + DUP2_ARG2(__lasx_xvldx, _src, stride, _src, stride2, in5, in6); + in7 = __lasx_xvldx(_src, stride3); _src += stride4; in8 = __lasx_xvld(_src, 0); - DUP2_ARG2(LASX_XVLDX, _src, stride, _src, stride2, in9, in10); - in11 = LASX_XVLDX(_src, stride3); + DUP2_ARG2(__lasx_xvldx, _src, stride, _src, stride2, in9, in10); + in11 = __lasx_xvldx(_src, stride3); _src += stride4; in12 = __lasx_xvld(_src, 0); - DUP2_ARG2(LASX_XVLDX, _src, stride, _src, stride2, in13, in14); - in15 = LASX_XVLDX(_src, stride3); + DUP2_ARG2(__lasx_xvldx, _src, stride, _src, stride2, in13, in14); + in15 = __lasx_xvldx(_src, stride3); DUP4_ARG2(__lasx_xvilvl_b, in2, in0, in3, in1, in6, in4, in7, in5, tmp0_m, tmp1_m, tmp2_m, tmp3_m); DUP4_ARG2(__lasx_xvilvl_b, in10, in8, in11, in9, in14, in12, in15, in13, diff --git a/libavutil/loongarch/loongson_intrinsics.h b/libavutil/loongarch/loongson_intrinsics.h index 090adab266..eb256863c8 100644 --- a/libavutil/loongarch/loongson_intrinsics.h +++ b/libavutil/loongarch/loongson_intrinsics.h @@ -716,11 +716,6 @@ static inline __m128i __lsx_vclip255_w(__m128i _in) { #ifdef __loongarch_asx #include - -/* __lasx_xvldx() in lasxintrin.h does not accept a const void*; - * remove the following once it does. */ -#define LASX_XVLDX(ptr, stride) __lasx_xvldx((void*)ptr, stride) - /* * ============================================================================= * Description : Dot product of byte vector elements From 9903ba28c28ab18dc7b7b6fb8571cc8b5caae1a6 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 8 Sep 2022 19:43:03 -0300 Subject: [PATCH 261/590] swsresample/swresample: error out on invalid layouts If it's unsupported or invalid, then there's no point trying to rebuild it using a value that may have been derived from the same layout to begin with. Move the checks before the attempts at copying the layout while at it. Fixes ticket #9908. Signed-off-by: James Almer --- libswresample/swresample.c | 48 +++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 6f04d130d3..5884f8d533 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -227,7 +227,7 @@ av_cold int swr_init(struct SwrContext *s){ s->in_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; s->in_ch_layout.nb_channels = s->user_in_ch_count; } - } else + } else if (av_channel_layout_check(&s->user_in_chlayout)) av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout); if ((s->user_out_ch_count && s->user_out_ch_count != s->user_out_chlayout.nb_channels) || @@ -240,17 +240,45 @@ av_cold int swr_init(struct SwrContext *s){ s->out_ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; s->out_ch_layout.nb_channels = s->user_out_ch_count; } - } else + } else if (av_channel_layout_check(&s->user_out_chlayout)) av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout); if (!s->out.ch_count && !s->user_out_ch_layout) s->out.ch_count = s->out_ch_layout.nb_channels; if (!s-> in.ch_count && !s-> user_in_ch_layout) s-> in.ch_count = s->in_ch_layout.nb_channels; + + if (!(ret = av_channel_layout_check(&s->in_ch_layout)) || s->in_ch_layout.nb_channels > SWR_CH_MAX) { + if (ret) + av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1)); + av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", ret ? l1 : ""); + return AVERROR(EINVAL); + } + + if (!(ret = av_channel_layout_check(&s->out_ch_layout)) || s->out_ch_layout.nb_channels > SWR_CH_MAX) { + if (ret) + av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2)); + av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", ret ? l2 : ""); + return AVERROR(EINVAL); + } #else s->out.ch_count = s-> user_out_chlayout.nb_channels; s-> in.ch_count = s-> user_in_chlayout.nb_channels; + if (!(ret = av_channel_layout_check(&s->user_in_chlayout)) || s->user_in_chlayout.nb_channels > SWR_CH_MAX) { + if (ret) + av_channel_layout_describe(&s->user_in_chlayout, l1, sizeof(l1)); + av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", ret ? l1 : ""); + return AVERROR(EINVAL); + } + + if (!(ret = av_channel_layout_check(&s->user_out_chlayout)) || s->user_out_chlayout.nb_channels > SWR_CH_MAX) { + if (ret) + av_channel_layout_describe(&s->user_out_chlayout, l2, sizeof(l2)); + av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", ret ? l2 : ""); + return AVERROR(EINVAL); + } + ret = av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout); ret |= av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout); if (ret < 0) @@ -261,18 +289,6 @@ av_cold int swr_init(struct SwrContext *s){ s->dither.method = s->user_dither_method; - if (!av_channel_layout_check(&s->in_ch_layout) || s->in_ch_layout.nb_channels > SWR_CH_MAX) { - av_channel_layout_describe(&s->in_ch_layout, l1, sizeof(l1)); - av_log(s, AV_LOG_WARNING, "Input channel layout \"%s\" is invalid or unsupported.\n", l1); - av_channel_layout_uninit(&s->in_ch_layout); - } - - if (!av_channel_layout_check(&s->out_ch_layout) || s->out_ch_layout.nb_channels > SWR_CH_MAX) { - av_channel_layout_describe(&s->out_ch_layout, l2, sizeof(l2)); - av_log(s, AV_LOG_WARNING, "Output channel layout \"%s\" is invalid or unsupported.\n", l2); - av_channel_layout_uninit(&s->out_ch_layout); - } - switch(s->engine){ #if CONFIG_LIBSOXR case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break; @@ -291,9 +307,9 @@ av_cold int swr_init(struct SwrContext *s){ av_channel_layout_uninit(&s->in_ch_layout); } - if (!s->in_ch_layout.nb_channels || s->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) + if (s->in_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) av_channel_layout_default(&s->in_ch_layout, s->used_ch_count); - if (!s->out_ch_layout.nb_channels || s->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) + if (s->out_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) av_channel_layout_default(&s->out_ch_layout, s->out.ch_count); s->rematrix = av_channel_layout_compare(&s->out_ch_layout, &s->in_ch_layout) || From 130483449ebec8fd8d9080d564f7ec5d46e18d39 Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 12 Sep 2022 09:57:56 -0300 Subject: [PATCH 262/590] fftools/opt_common: check the return value of av_hwdevice_get_type_name before printing it It may be NULL, as is the case for D3D11VA_VLD. Running "ffmpeg -h decoder=h264" on a Windows build Before: Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]: Supported hardware devices: dxva2 (null) d3d11va cuda After: Decoder h264 [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]: Supported hardware devices: dxva2 d3d11va cuda Signed-off-by: James Almer --- fftools/opt_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fftools/opt_common.c b/fftools/opt_common.c index 7cd8b1c66e..8a06df82df 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -335,9 +335,12 @@ static void print_codec(const AVCodec *c) printf(" Supported hardware devices: "); for (int i = 0;; i++) { const AVCodecHWConfig *config = avcodec_get_hw_config(c, i); + const char *name; if (!config) break; - printf("%s ", av_hwdevice_get_type_name(config->device_type)); + name = av_hwdevice_get_type_name(config->device_type); + if (name) + printf("%s ", name); } printf("\n"); } From 62af385b917f2474498abeabd6057e6c60e2b9a9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 14 Sep 2022 02:21:41 +0200 Subject: [PATCH 263/590] avformat/dump: Avoid unnecessary implicit calculation of strlen av_strlcpy() returns the length of the src string to enable the caller to check for truncation. It is currently used in the following way in dump_metadata(): Every metadata value is searched for \b, \n, \v, \f, \r and then the data up to the first of these characters found is copied to a small temporary buffer via av_strlcpy() (but of course not more than fits into said buffer) and then printed; all characters up to the character found earlier are then treated as consumed. But this is bad performance-wise if the while string is big and contains many of these characters, because av_strlcpy() will unnecessarily calculate the length of the whole remaining string. (dump_metadata() actually ignored the return value of av_strlcpy().) Fix this by not copying the data to a temporary buffer at all. Instead just use %.*s to bound the number of characters output. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavformat/dump.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/dump.c b/libavformat/dump.c index e3f0056c20..cafcef36c6 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -145,10 +145,8 @@ static void dump_metadata(void *ctx, const AVDictionary *m, const char *indent) av_log(ctx, AV_LOG_INFO, "%s %-16s: ", indent, tag->key); while (*p) { - char tmp[256]; size_t len = strcspn(p, "\x8\xa\xb\xc\xd"); - av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1)); - av_log(ctx, AV_LOG_INFO, "%s", tmp); + av_log(ctx, AV_LOG_INFO, "%.*s", (int)(FFMIN(255, len)), p); p += len; if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " "); if (*p == 0xa) av_log(ctx, AV_LOG_INFO, "\n%s %-16s: ", indent, ""); From f976ed7fcf61324451e73876840c9473125f371b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 13 Sep 2022 21:20:11 +0200 Subject: [PATCH 264/590] avutil/dict: Avoid check whose result is known in advance We know that an AVDictionary is not empty if we have just added an entry to it, so only check for it being empty on the branch that does not do so. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavutil/dict.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index a4f638a1fc..d127bb90aa 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -126,12 +126,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, } m->count++; } else { + if (!m->count) { + av_freep(&m->elems); + av_freep(pm); + } av_freep(©_key); } - if (!m->count) { - av_freep(&m->elems); - av_freep(pm); - } return 0; From c15dd31d2a9067b3aa7a575f585f44d62e9d5454 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 13 Sep 2022 20:57:05 +0200 Subject: [PATCH 265/590] avutil/dict: Fix memleak when using AV_DICT_APPEND If a key already exists in an AVDictionary and the AV_DICT_APPEND flag is set, the old entry is at first discarded from the dictionary, but a pointer to the value is kept. Lateron enough memory to store the appended string is allocated; should this allocation fail, the old string is not freed and hence leaks. This commit changes this by moving creating the combined value to an earlier point in the function, which also ensures that the AVDictionary is unchanged in case of errors. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavutil/dict.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index d127bb90aa..aa64fb990c 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -73,7 +73,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, { AVDictionary *m = *pm; AVDictionaryEntry *tag = NULL; - char *oldval = NULL, *copy_key = NULL, *copy_value = NULL; + char *copy_key = NULL, *copy_value = NULL; if (!(flags & AV_DICT_MULTIKEY)) { tag = av_dict_get(m, key, NULL, flags); @@ -97,10 +97,17 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, av_free(copy_value); return 0; } - if (flags & AV_DICT_APPEND) - oldval = tag->value; - else - av_free(tag->value); + if (copy_value && flags & AV_DICT_APPEND) { + size_t len = strlen(tag->value) + strlen(copy_value) + 1; + char *newval = av_mallocz(len); + if (!newval) + goto err_out; + av_strlcat(newval, tag->value, len); + av_strlcat(newval, copy_value, len); + av_freep(©_value); + copy_value = newval; + } + av_free(tag->value); av_free(tag->key); *tag = m->elems[--m->count]; } else if (copy_value) { @@ -113,17 +120,6 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, if (copy_value) { m->elems[m->count].key = copy_key; m->elems[m->count].value = copy_value; - if (oldval && flags & AV_DICT_APPEND) { - size_t len = strlen(oldval) + strlen(copy_value) + 1; - char *newval = av_mallocz(len); - if (!newval) - goto err_out; - av_strlcat(newval, oldval, len); - av_freep(&oldval); - av_strlcat(newval, copy_value, len); - m->elems[m->count].value = newval; - av_freep(©_value); - } m->count++; } else { if (!m->count) { From e867a29ec1eb71a5841e452a4f2bf946c096282a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 13 Sep 2022 21:07:19 +0200 Subject: [PATCH 266/590] avutil/dict: Improve appending values When appending two values (due to AV_DICT_APPEND), the earlier code would first zero-allocate a buffer of the required size and then copy both parts into it via av_strlcat(). This is problematic, as it leads to quadratic performance in case of frequent enlargements. Fix this by using av_realloc() (which is hopefully designed to handle such cases in a better way than simply throwing the buffer we already have away) and by copying the string via memcpy() (after all, we already calculated the strlen of both strings). Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavutil/dict.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index aa64fb990c..4bba041d0a 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -98,16 +98,17 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, return 0; } if (copy_value && flags & AV_DICT_APPEND) { - size_t len = strlen(tag->value) + strlen(copy_value) + 1; - char *newval = av_mallocz(len); + size_t oldlen = strlen(tag->value); + size_t new_part_len = strlen(copy_value); + size_t len = oldlen + new_part_len + 1; + char *newval = av_realloc(tag->value, len); if (!newval) goto err_out; - av_strlcat(newval, tag->value, len); - av_strlcat(newval, copy_value, len); + memcpy(newval + oldlen, copy_value, new_part_len + 1); av_freep(©_value); copy_value = newval; - } - av_free(tag->value); + } else + av_free(tag->value); av_free(tag->key); *tag = m->elems[--m->count]; } else if (copy_value) { From a5ce44f30108a0683a123354e52210a20026fb5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 14 Sep 2022 20:34:19 +0300 Subject: [PATCH 267/590] lavu/riscv: fix av_clip_int16 Some serious copy-paste / squash / rebase mismanipulation here. Signed-off-by: James Almer --- libavutil/riscv/intmath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h index 78f7ba930a..3263a79dc4 100644 --- a/libavutil/riscv/intmath.h +++ b/libavutil/riscv/intmath.h @@ -41,10 +41,10 @@ static av_always_inline av_const int8_t av_clip_int8_rvi(int a) #define av_clip_int16 av_clip_int16_rvi static av_always_inline av_const int16_t av_clip_int16_rvi(int a) { - union { uint8_t u; int8_t s; } u = { .u = a }; + union { uint16_t u; int16_t s; } u = { .u = a }; if (a != u.s) - a = ((a >> 31) ^ 0x7F); + a = ((a >> 31) ^ 0x7FFF); return a; } From 8fc2dedfe6e8fcc58dd052bf3b85cd4754133b17 Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Thu, 8 Sep 2022 14:36:32 +0300 Subject: [PATCH 268/590] avcodec/vorbisdec: don't use a flag to determine if frames have been output If a developer using FFmpeg libraries seeks into an earlier position and calls avcodec_flush_buffers() afterwards as recommended, the Vorbis decoder will drop the next frame, since buffer flushing clears the first_frame flag. As a result, the audio samples the calling code receives may be ahead of the requested seek position, which is unacceptable in some use cases such as playing a looping sound effect. This commit records the presentation timestamp of the first frame and determines after that if the new frame is the first frame (possible after seeking to the start) by comparing its pts to the stored pts. --- libavcodec/vorbisdec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 4d03947c49..38a5367be3 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -131,6 +131,7 @@ typedef struct vorbis_context_s { FFTContext mdct[2]; uint8_t first_frame; + int64_t initial_pts; uint32_t version; uint8_t audio_channels; uint32_t audio_samplerate; @@ -1847,6 +1848,10 @@ static int vorbis_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (!vc->first_frame) { vc->first_frame = 1; + vc->initial_pts = frame->pts; + } + + if (frame->pts == vc->initial_pts) { *got_frame_ptr = 0; av_frame_unref(frame); return buf_size; @@ -1881,7 +1886,6 @@ static av_cold void vorbis_decode_flush(AVCodecContext *avctx) sizeof(*vc->saved)); } vc->previous_window = -1; - vc->first_frame = 0; } const FFCodec ff_vorbis_decoder = { From 8357d4790fd0f11d7b76e20d321ec8241d80bd05 Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Wed, 14 Sep 2022 18:05:50 +0200 Subject: [PATCH 269/590] avfilter/vf_libvmaf: copy all values also for 10 bit input --- libavfilter/vf_libvmaf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index eee1c280ef..8d5ba4e2d5 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -108,6 +108,7 @@ static enum VmafPixelFormat pix_fmt_map(enum AVPixelFormat av_pix_fmt) static int copy_picture_data(AVFrame *src, VmafPicture *dst, unsigned bpc) { + const int bytes_per_value = bpc > 8 ? 2 : 1; int err = vmaf_picture_alloc(dst, pix_fmt_map(src->format), bpc, src->width, src->height); if (err) @@ -117,7 +118,7 @@ static int copy_picture_data(AVFrame *src, VmafPicture *dst, unsigned bpc) uint8_t *src_data = src->data[i]; uint8_t *dst_data = dst->data[i]; for (unsigned j = 0; j < dst->h[i]; j++) { - memcpy(dst_data, src_data, sizeof(*dst_data) * dst->w[i]); + memcpy(dst_data, src_data, bytes_per_value * dst->w[i]); src_data += src->linesize[i]; dst_data += dst->stride[i]; } From f4af504a1ff2561c9980a61ec2394841f35911df Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 2 Sep 2022 16:06:08 +0200 Subject: [PATCH 270/590] avfilter/avfilter: Don't use AVFrame.channel_layout Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 965f5d0f63..bde41637dd 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -21,6 +21,7 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/bprint.h" #include "libavutil/buffer.h" #include "libavutil/channel_layout.h" #include "libavutil/common.h" @@ -45,6 +46,7 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end) { +#ifdef TRACE ff_tlog(ctx, "ref[%p buf:%p data:%p linesize[%d, %d, %d, %d] pts:%"PRId64" pos:%"PRId64, ref, ref->buf, ref->data[0], @@ -61,13 +63,19 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end) av_get_picture_type_char(ref->pict_type)); } if (ref->nb_samples) { - ff_tlog(ctx, " cl:%"PRId64"d n:%d r:%d", - ref->channel_layout, + AVBPrint bprint; + + av_bprint_init(&bprint, 1, AV_BPRINT_SIZE_UNLIMITED); + av_channel_layout_describe_bprint(&ref->ch_layout, &bprint); + ff_tlog(ctx, " cl:%s n:%d r:%d", + bprint.str, ref->nb_samples, ref->sample_rate); + av_bprint_finalize(&bprint, NULL); } ff_tlog(ctx, "]%s", end ? "\n" : ""); +#endif } void ff_command_queue_pop(AVFilterContext *filter) From e10774a8cc539e166d4e5849fef4d9f86efbfa8d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 12 Sep 2022 17:52:18 +0200 Subject: [PATCH 271/590] avfilter/avfilter: #if ff_tlog_link() away when empty It is currently calling av_channel_layout_describe() unnecessarily. Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 2 ++ libavfilter/internal.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index bde41637dd..f34204e650 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -381,6 +381,7 @@ int avfilter_config_links(AVFilterContext *filter) return 0; } +#ifdef TRACE void ff_tlog_link(void *ctx, AVFilterLink *link, int end) { if (link->type == AVMEDIA_TYPE_VIDEO) { @@ -404,6 +405,7 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end) end ? "\n" : ""); } } +#endif int ff_request_frame(AVFilterLink *link) { diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 0f8da367d0..0128820be0 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -268,7 +268,11 @@ void ff_command_queue_pop(AVFilterContext *filter); char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms); +#ifdef TRACE void ff_tlog_link(void *ctx, AVFilterLink *link, int end); +#else +#define ff_tlog_link(ctx, link, end) do { } while(0) +#endif /** * Append a new input/output pad to the filter's list of such pads. From 859b31de5064535128f2ecd510c8e2d8b3be0214 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 12 Sep 2022 17:58:04 +0200 Subject: [PATCH 272/590] avfilter/video: Fix newline in trace output Forgotten in 7e350379f87e7f74420b4813170fe808e2313911. Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt --- libavfilter/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/video.c b/libavfilter/video.c index e9eb110ff4..7683ef6fd4 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -102,7 +102,7 @@ AVFrame *ff_get_video_buffer(AVFilterLink *link, int w, int h) { AVFrame *ret = NULL; - FF_TPRINTF_START(NULL, get_video_buffer); ff_tlog_link(NULL, link, 0); + FF_TPRINTF_START(NULL, get_video_buffer); ff_tlog_link(NULL, link, 1); if (link->dstpad->get_buffer.video) ret = link->dstpad->get_buffer.video(link, w, h); From 3f0fac9303b430c5114da62f9a63ed0b945b435f Mon Sep 17 00:00:00 2001 From: Wang Yaqiang Date: Mon, 5 Sep 2022 18:40:36 +0800 Subject: [PATCH 273/590] fftools/ffplay: fix rotation incorrect when frame contains the displaymatrix For example, if the jpeg contains exif information and the rotation direction is included in the exif, the displaymatrix will be set on the side_data of the frame when decoding. However, when ffplay is used to play the image, only the side data in the stream will be determined. It does not check whether the frame also contains rotation information, causing it to play in the wrong direction Reviewed-by: Zhao Zhili Signed-off-by: Wang Yaqiang --- fftools/ffplay.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 9242047f5c..bcc00afe31 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1915,8 +1915,14 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c } while (0) if (autorotate) { - int32_t *displaymatrix = (int32_t *)av_stream_get_side_data(is->video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL); - double theta = get_rotation(displaymatrix); + double theta = 0.0; + int32_t *displaymatrix = NULL; + AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX); + if (sd) + displaymatrix = (int32_t *)sd->data; + if (!displaymatrix) + displaymatrix = (int32_t *)av_stream_get_side_data(is->video_st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { INSERT_FILT("transpose", "clock"); From 0e0f74b6328498d1a7bcf6af7146774e1a22c628 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 15 Sep 2022 00:08:24 -0300 Subject: [PATCH 274/590] avfilter/vf_drawbox: use the correct macro to fill rgb plane pointers Fixes ticket #9924 Reviewed-by: Paul B Mahol Signed-off-by: James Almer --- libavfilter/vf_drawbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c index 65bd039d65..64eeeece12 100644 --- a/libavfilter/vf_drawbox.c +++ b/libavfilter/vf_drawbox.c @@ -162,7 +162,7 @@ static void draw_region(AVFrame *frame, DrawBoxContext *ctx, int left, int top, row[2] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[2]; #define ASSIGN_FOUR_CHANNELS_PACKED \ - ASSIGN_THREE_CHANNELS \ + ASSIGN_THREE_CHANNELS_PACKED \ row[3] = frame->data[0] + y * frame->linesize[0] + ctx->rgba_map[3]; static void draw_region_rgb_packed(AVFrame *frame, DrawBoxContext *ctx, int left, int top, int right, int down, From a90e5335b3bf1f21b738b5bdf33de1b4fedf202d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 15 Sep 2022 18:05:33 +0300 Subject: [PATCH 275/590] avutil/lfg: fix comment typo --- libavutil/lfg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/lfg.h b/libavutil/lfg.h index 2b669205d1..9a1e277acd 100644 --- a/libavutil/lfg.h +++ b/libavutil/lfg.h @@ -27,7 +27,7 @@ /** * Context structure for the Lagged Fibonacci PRNG. * The exact layout, types and content of this struct may change and should - * not be accessed directly. Only its sizeof() is guranteed to stay the same + * not be accessed directly. Only its sizeof() is guaranteed to stay the same * to allow easy instanciation. */ typedef struct AVLFG { From c9bd6ee5cb33c6462d6e74b9e39c159e1143ff65 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Thu, 15 Sep 2022 19:35:30 +0200 Subject: [PATCH 276/590] avfilter/vf_colorspace_cuda: mark fall-through --- libavfilter/vf_colorspace_cuda.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vf_colorspace_cuda.c b/libavfilter/vf_colorspace_cuda.c index 131c4ad72b..07d4edd0d8 100644 --- a/libavfilter/vf_colorspace_cuda.c +++ b/libavfilter/vf_colorspace_cuda.c @@ -281,6 +281,7 @@ static int conv_cuda_convert(AVFilterContext* ctx, AVFrame* out, AVFrame* in) break; case AV_PIX_FMT_YUV420P: width = comp_id ? in->width / 2 : in->width; + /* fall-through */ case AV_PIX_FMT_NV12: height = comp_id ? in->height / 2 : in->height; break; From bffc8f9af1f8e760a63cbc3680ad814b3c1b99ec Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 15 Sep 2022 17:42:25 +0200 Subject: [PATCH 277/590] avcodec/adpcmenc: Round up required buffer size Otherwise the buffer might be too small. Fixes assert violations when encoding mono audio with exactly one sample. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/adpcmenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 1ffc5b410f..57709b19a1 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -614,7 +614,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_ALP || avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_APM || avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_WS) - pkt_size = (frame->nb_samples * channels) / 2; + pkt_size = (frame->nb_samples * channels + 1) / 2; else pkt_size = avctx->block_align; if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0) From f0be9129ad14ae3c94849648d3fdfccbbc3d7fc3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 19:03:12 +0200 Subject: [PATCH 278/590] avcodec/iff: Split extract_header into extradata and packet part 183132872a1d8bc8a32e7fd8f994fa2f1b2d6bfc made the iff demuxer output extradata and made the decoder parse said extradata. To make this extradata extensible, it came with its own internal length field (containing the offset of the palette at the end of the extradata). Furthermore, in order to support mid-stream extradata changes, the packets returned by the demuxer also have such a length field (containing the offset of the actual packet data). Therefore the packet parsing the extradata accepted its input from both AVPackets as well as from ordinary extradata. Yet the demuxer never made use of this "feature": The packet's length field always indicated that the packet data starts immediately after the length field. Later, commit cb928fc448f9566e6f6c28d53fa4c2388e732a2b stopped appending the length field to the packets' data; of course, it also stopped searching for extradata in this data. Instead it added code to parse the packet's header to the function that parses extradata. This made this function consist of two disjoint parts, one of which is only reachable if this function is called from init (when parsing extradata) and one of which is reachable when parsing packet headers. Therefore this commit splits this function into two. Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 116 +++++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 6c0f031238..d7eca289ee 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -198,11 +198,9 @@ static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) * decoder structures. * * @param avctx the AVCodecContext where to extract extra context to - * @param avpkt the AVPacket to extract extra context from or NULL to use avctx * @return >= 0 in case of success, a negative error code otherwise */ -static int extract_header(AVCodecContext *const avctx, - const AVPacket *const avpkt) +static int extract_header(AVCodecContext *const avctx) { IffContext *s = avctx->priv_data; const uint8_t *buf; @@ -215,55 +213,6 @@ static int extract_header(AVCodecContext *const avctx, } palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); - if (avpkt && avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) { - uint32_t chunk_id; - uint64_t data_size; - GetByteContext *gb = &s->gb; - - bytestream2_skip(gb, 4); - while (bytestream2_get_bytes_left(gb) >= 1) { - chunk_id = bytestream2_get_le32(gb); - data_size = bytestream2_get_be32(gb); - - if (chunk_id == MKTAG('B', 'M', 'H', 'D')) { - bytestream2_skip(gb, data_size + (data_size & 1)); - } else if (chunk_id == MKTAG('A', 'N', 'H', 'D')) { - unsigned extra; - if (data_size < 40) - return AVERROR_INVALIDDATA; - - s->compression = (bytestream2_get_byte(gb) << 8) | (s->compression & 0xFF); - bytestream2_skip(gb, 19); - extra = bytestream2_get_be32(gb); - s->is_short = !(extra & 1); - s->is_brush = extra == 2; - s->is_interlaced = !!(extra & 0x40); - data_size -= 24; - bytestream2_skip(gb, data_size + (data_size & 1)); - } else if (chunk_id == MKTAG('D', 'L', 'T', 'A') || - chunk_id == MKTAG('B', 'O', 'D', 'Y')) { - if (chunk_id == MKTAG('B','O','D','Y')) - s->compression &= 0xFF; - break; - } else if (chunk_id == MKTAG('C', 'M', 'A', 'P')) { - int count = data_size / 3; - uint32_t *pal = s->pal; - - if (count > 256) - return AVERROR_INVALIDDATA; - if (s->ham) { - for (i = 0; i < count; i++) - pal[i] = 0xFF000000 | bytestream2_get_le24(gb); - } else { - for (i = 0; i < count; i++) - pal[i] = 0xFF000000 | bytestream2_get_be24(gb); - } - bytestream2_skip(gb, data_size & 1); - } else { - bytestream2_skip(gb, data_size + (data_size&1)); - } - } - } else if (!avpkt) { buf = avctx->extradata; buf_size = bytestream_get_be16(&buf); if (buf_size <= 1 || palette_size < 0) { @@ -272,7 +221,6 @@ static int extract_header(AVCodecContext *const avctx, buf_size, palette_size); return AVERROR_INVALIDDATA; } - } if (buf_size >= 41) { s->compression = bytestream_get_byte(&buf); @@ -448,7 +396,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } - if ((err = extract_header(avctx, NULL)) < 0) + if ((err = extract_header(avctx)) < 0) return err; return 0; @@ -1524,6 +1472,64 @@ static int unsupported(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } +static int parse_packet_header(AVCodecContext *const avctx, + GetByteContext *gb) +{ + IffContext *s = avctx->priv_data; + int i; + + if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) { + uint32_t chunk_id; + uint64_t data_size; + + bytestream2_skip(gb, 4); + while (bytestream2_get_bytes_left(gb) >= 1) { + chunk_id = bytestream2_get_le32(gb); + data_size = bytestream2_get_be32(gb); + + if (chunk_id == MKTAG('B', 'M', 'H', 'D')) { + bytestream2_skip(gb, data_size + (data_size & 1)); + } else if (chunk_id == MKTAG('A', 'N', 'H', 'D')) { + unsigned extra; + if (data_size < 40) + return AVERROR_INVALIDDATA; + + s->compression = (bytestream2_get_byte(gb) << 8) | (s->compression & 0xFF); + bytestream2_skip(gb, 19); + extra = bytestream2_get_be32(gb); + s->is_short = !(extra & 1); + s->is_brush = extra == 2; + s->is_interlaced = !!(extra & 0x40); + data_size -= 24; + bytestream2_skip(gb, data_size + (data_size & 1)); + } else if (chunk_id == MKTAG('D', 'L', 'T', 'A') || + chunk_id == MKTAG('B', 'O', 'D', 'Y')) { + if (chunk_id == MKTAG('B','O','D','Y')) + s->compression &= 0xFF; + break; + } else if (chunk_id == MKTAG('C', 'M', 'A', 'P')) { + int count = data_size / 3; + uint32_t *pal = s->pal; + + if (count > 256) + return AVERROR_INVALIDDATA; + if (s->ham) { + for (i = 0; i < count; i++) + pal[i] = 0xFF000000 | bytestream2_get_le24(gb); + } else { + for (i = 0; i < count; i++) + pal[i] = 0xFF000000 | bytestream2_get_be24(gb); + } + bytestream2_skip(gb, data_size & 1); + } else { + bytestream2_skip(gb, data_size + (data_size&1)); + } + } + } + + return 0; +} + static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt) { @@ -1537,7 +1543,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, bytestream2_init(gb, avpkt->data, avpkt->size); - if ((res = extract_header(avctx, avpkt)) < 0) + if ((res = parse_packet_header(avctx, gb)) < 0) return res; if ((res = ff_get_buffer(avctx, frame, 0)) < 0) From 46b586e5b262052f09dfd22d06356c875203c245 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 19:57:07 +0200 Subject: [PATCH 279/590] avcodec/iff: Avoid redundant frees This code is only called once during init, so none of the buffers here have been allocated already. Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index d7eca289ee..d596ad4ba4 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -245,8 +245,6 @@ static int extract_header(AVCodecContext *const avctx) if (s->masking == MASK_HAS_MASK) { if (s->bpp >= 8 && !s->ham) { avctx->pix_fmt = AV_PIX_FMT_RGB32; - av_freep(&s->mask_buf); - av_freep(&s->mask_palbuf); if (s->bpp > 16) { av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", s->bpp); return AVERROR(ENOMEM); @@ -255,10 +253,8 @@ static int extract_header(AVCodecContext *const avctx) if (!s->mask_buf) return AVERROR(ENOMEM); s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->mask_palbuf) { - av_freep(&s->mask_buf); + if (!s->mask_palbuf) return AVERROR(ENOMEM); - } } s->bpp++; } else if (s->masking != MASK_NONE && s->masking != MASK_HAS_TRANSPARENT_COLOR) { @@ -272,9 +268,6 @@ static int extract_header(AVCodecContext *const avctx) if (s->video_size && s->planesize * s->bpp * avctx->height > s->video_size) return AVERROR_INVALIDDATA; - av_freep(&s->ham_buf); - av_freep(&s->ham_palbuf); - if (s->ham) { int i, count = FFMIN(palette_size / 3, 1 << s->ham); int ham_count; @@ -290,10 +283,8 @@ static int extract_header(AVCodecContext *const avctx) ham_count = 8 * (1 << s->ham); s->ham_palbuf = av_malloc(extra_space * (ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->ham_palbuf) { - av_freep(&s->ham_buf); + if (!s->ham_palbuf) return AVERROR(ENOMEM); - } if (count) { // HAM with color palette attached // prefill with black and palette and set HAM take direct value mask to zero From d0df74553bebdc33e960ea9bce9bfb323c0a1bd7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 20:01:56 +0200 Subject: [PATCH 280/590] avcodec/iff: Return early when possible It allows to save one level of indentation. Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index d596ad4ba4..d64cb4ae62 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -222,7 +222,9 @@ static int extract_header(AVCodecContext *const avctx) return AVERROR_INVALIDDATA; } - if (buf_size >= 41) { + if (buf_size < 41) + return 0; + s->compression = bytestream_get_byte(&buf); s->bpp = bytestream_get_byte(&buf); s->ham = bytestream_get_byte(&buf); @@ -315,7 +317,6 @@ static int extract_header(AVCodecContext *const avctx) s->ham_palbuf[(1 << s->bpp) + i] = s->ham_palbuf[i] | 0xFF000000; } } - } return 0; } @@ -1469,10 +1470,12 @@ static int parse_packet_header(AVCodecContext *const avctx, IffContext *s = avctx->priv_data; int i; - if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) { uint32_t chunk_id; uint64_t data_size; + if (avctx->codec_tag != MKTAG('A', 'N', 'I', 'M')) + return 0; + bytestream2_skip(gb, 4); while (bytestream2_get_bytes_left(gb) >= 1) { chunk_id = bytestream2_get_le32(gb); @@ -1516,7 +1519,6 @@ static int parse_packet_header(AVCodecContext *const avctx, bytestream2_skip(gb, data_size + (data_size&1)); } } - } return 0; } From 8612b26202caddf47c9c277b75e88ac27b2fbda8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 20:07:11 +0200 Subject: [PATCH 281/590] avcodec/iff: Pass extradata and extradata_size explicitly This might be useful in case this decoder were changed to support new extradata passed via side-data. Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index d64cb4ae62..9371763fba 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -200,20 +200,20 @@ static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) * @param avctx the AVCodecContext where to extract extra context to * @return >= 0 in case of success, a negative error code otherwise */ -static int extract_header(AVCodecContext *const avctx) +static int extract_header(AVCodecContext *const avctx, + const uint8_t *const extradata, int extradata_size) { IffContext *s = avctx->priv_data; - const uint8_t *buf; + const uint8_t *buf = extradata; unsigned buf_size = 0; int i, palette_size; - if (avctx->extradata_size < 2) { + if (extradata_size < 2) { av_log(avctx, AV_LOG_ERROR, "not enough extradata\n"); return AVERROR_INVALIDDATA; } - palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + palette_size = extradata_size - AV_RB16(extradata); - buf = avctx->extradata; buf_size = bytestream_get_be16(&buf); if (buf_size <= 1 || palette_size < 0) { av_log(avctx, AV_LOG_ERROR, @@ -273,7 +273,7 @@ static int extract_header(AVCodecContext *const avctx) if (s->ham) { int i, count = FFMIN(palette_size / 3, 1 << s->ham); int ham_count; - const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata); + const uint8_t *const palette = extradata + AV_RB16(extradata); int extra_space = 1; if (avctx->codec_tag == MKTAG('P', 'B', 'M', ' ') && s->ham == 4) @@ -388,7 +388,8 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } - if ((err = extract_header(avctx)) < 0) + err = extract_header(avctx, avctx->extradata, avctx->extradata_size); + if (err < 0) return err; return 0; From 828a0c4254c89699e0ececde3f35a0e262d4fd6e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 20:24:00 +0200 Subject: [PATCH 282/590] avcodec/iff: Reindent after the previous commits Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 260 +++++++++++++++++++++++------------------------ 1 file changed, 128 insertions(+), 132 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 9371763fba..33e02b543d 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -206,7 +206,7 @@ static int extract_header(AVCodecContext *const avctx, IffContext *s = avctx->priv_data; const uint8_t *buf = extradata; unsigned buf_size = 0; - int i, palette_size; + int palette_size; if (extradata_size < 2) { av_log(avctx, AV_LOG_ERROR, "not enough extradata\n"); @@ -214,109 +214,109 @@ static int extract_header(AVCodecContext *const avctx, } palette_size = extradata_size - AV_RB16(extradata); - buf_size = bytestream_get_be16(&buf); - if (buf_size <= 1 || palette_size < 0) { - av_log(avctx, AV_LOG_ERROR, - "Invalid palette size received: %u -> palette data offset: %d\n", - buf_size, palette_size); - return AVERROR_INVALIDDATA; - } + buf_size = bytestream_get_be16(&buf); + if (buf_size <= 1 || palette_size < 0) { + av_log(avctx, AV_LOG_ERROR, + "Invalid palette size received: %u -> palette data offset: %d\n", + buf_size, palette_size); + return AVERROR_INVALIDDATA; + } if (buf_size < 41) return 0; - s->compression = bytestream_get_byte(&buf); - s->bpp = bytestream_get_byte(&buf); - s->ham = bytestream_get_byte(&buf); - s->flags = bytestream_get_byte(&buf); - s->transparency = bytestream_get_be16(&buf); - s->masking = bytestream_get_byte(&buf); - for (i = 0; i < 16; i++) - s->tvdc[i] = bytestream_get_be16(&buf); - - if (s->ham) { - if (s->bpp > 8) { - av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u\n", s->ham); - return AVERROR_INVALIDDATA; - } else if (s->ham != (s->bpp > 6 ? 6 : 4)) { - av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u, BPP: %u\n", s->ham, s->bpp); - return AVERROR_INVALIDDATA; - } + s->compression = bytestream_get_byte(&buf); + s->bpp = bytestream_get_byte(&buf); + s->ham = bytestream_get_byte(&buf); + s->flags = bytestream_get_byte(&buf); + s->transparency = bytestream_get_be16(&buf); + s->masking = bytestream_get_byte(&buf); + for (int i = 0; i < 16; i++) + s->tvdc[i] = bytestream_get_be16(&buf); + + if (s->ham) { + if (s->bpp > 8) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u\n", s->ham); + return AVERROR_INVALIDDATA; + } else if (s->ham != (s->bpp > 6 ? 6 : 4)) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: %u, BPP: %u\n", s->ham, s->bpp); + return AVERROR_INVALIDDATA; } + } - if (s->masking == MASK_HAS_MASK) { - if (s->bpp >= 8 && !s->ham) { - avctx->pix_fmt = AV_PIX_FMT_RGB32; - if (s->bpp > 16) { - av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", s->bpp); - return AVERROR(ENOMEM); - } - s->mask_buf = av_malloc((s->planesize * 32) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->mask_buf) - return AVERROR(ENOMEM); - s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->mask_palbuf) - return AVERROR(ENOMEM); + if (s->masking == MASK_HAS_MASK) { + if (s->bpp >= 8 && !s->ham) { + avctx->pix_fmt = AV_PIX_FMT_RGB32; + if (s->bpp > 16) { + av_log(avctx, AV_LOG_ERROR, "bpp %d too large for palette\n", s->bpp); + return AVERROR(ENOMEM); } - s->bpp++; - } else if (s->masking != MASK_NONE && s->masking != MASK_HAS_TRANSPARENT_COLOR) { - av_log(avctx, AV_LOG_ERROR, "Masking not supported\n"); - return AVERROR_PATCHWELCOME; - } - if (!s->bpp || s->bpp > 32) { - av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", s->bpp); - return AVERROR_INVALIDDATA; + s->mask_buf = av_malloc((s->planesize * 32) + AV_INPUT_BUFFER_PADDING_SIZE); + if (!s->mask_buf) + return AVERROR(ENOMEM); + s->mask_palbuf = av_malloc((2 << s->bpp) * sizeof(uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); + if (!s->mask_palbuf) + return AVERROR(ENOMEM); } - if (s->video_size && s->planesize * s->bpp * avctx->height > s->video_size) - return AVERROR_INVALIDDATA; + s->bpp++; + } else if (s->masking != MASK_NONE && s->masking != MASK_HAS_TRANSPARENT_COLOR) { + av_log(avctx, AV_LOG_ERROR, "Masking not supported\n"); + return AVERROR_PATCHWELCOME; + } + if (!s->bpp || s->bpp > 32) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", s->bpp); + return AVERROR_INVALIDDATA; + } + if (s->video_size && s->planesize * s->bpp * avctx->height > s->video_size) + return AVERROR_INVALIDDATA; - if (s->ham) { - int i, count = FFMIN(palette_size / 3, 1 << s->ham); - int ham_count; - const uint8_t *const palette = extradata + AV_RB16(extradata); - int extra_space = 1; + if (s->ham) { + int count = FFMIN(palette_size / 3, 1 << s->ham); + int ham_count; + const uint8_t *const palette = extradata + AV_RB16(extradata); + int extra_space = 1; - if (avctx->codec_tag == MKTAG('P', 'B', 'M', ' ') && s->ham == 4) - extra_space = 4; + if (avctx->codec_tag == MKTAG('P', 'B', 'M', ' ') && s->ham == 4) + extra_space = 4; - s->ham_buf = av_malloc((s->planesize * 8) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->ham_buf) - return AVERROR(ENOMEM); + s->ham_buf = av_malloc((s->planesize * 8) + AV_INPUT_BUFFER_PADDING_SIZE); + if (!s->ham_buf) + return AVERROR(ENOMEM); - ham_count = 8 * (1 << s->ham); - s->ham_palbuf = av_malloc(extra_space * (ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!s->ham_palbuf) - return AVERROR(ENOMEM); + ham_count = 8 * (1 << s->ham); + s->ham_palbuf = av_malloc(extra_space * (ham_count << !!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE); + if (!s->ham_palbuf) + return AVERROR(ENOMEM); - if (count) { // HAM with color palette attached - // prefill with black and palette and set HAM take direct value mask to zero - memset(s->ham_palbuf, 0, (1 << s->ham) * 2 * sizeof (uint32_t)); - for (i=0; i < count; i++) { - s->ham_palbuf[i*2+1] = 0xFF000000 | AV_RL24(palette + i*3); - } - count = 1 << s->ham; - } else { // HAM with grayscale color palette - count = 1 << s->ham; - for (i=0; i < count; i++) { - s->ham_palbuf[i*2] = 0xFF000000; // take direct color value from palette - s->ham_palbuf[i*2+1] = 0xFF000000 | av_le2ne32(gray2rgb((i * 255) >> s->ham)); - } - } - for (i=0; i < count; i++) { - uint32_t tmp = i << (8 - s->ham); - tmp |= tmp >> s->ham; - s->ham_palbuf[(i+count)*2] = 0xFF00FFFF; // just modify blue color component - s->ham_palbuf[(i+count*2)*2] = 0xFFFFFF00; // just modify red color component - s->ham_palbuf[(i+count*3)*2] = 0xFFFF00FF; // just modify green color component - s->ham_palbuf[(i+count)*2+1] = 0xFF000000 | tmp << 16; - s->ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp; - s->ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8; + if (count) { // HAM with color palette attached + // prefill with black and palette and set HAM take direct value mask to zero + memset(s->ham_palbuf, 0, (1 << s->ham) * 2 * sizeof (uint32_t)); + for (int i = 0; i < count; i++) { + s->ham_palbuf[i*2+1] = 0xFF000000 | AV_RL24(palette + i*3); } - if (s->masking == MASK_HAS_MASK) { - for (i = 0; i < ham_count; i++) - s->ham_palbuf[(1 << s->bpp) + i] = s->ham_palbuf[i] | 0xFF000000; + count = 1 << s->ham; + } else { // HAM with grayscale color palette + count = 1 << s->ham; + for (int i = 0; i < count; i++) { + s->ham_palbuf[i*2] = 0xFF000000; // take direct color value from palette + s->ham_palbuf[i*2+1] = 0xFF000000 | av_le2ne32(gray2rgb((i * 255) >> s->ham)); } } + for (int i = 0; i < count; i++) { + uint32_t tmp = i << (8 - s->ham); + tmp |= tmp >> s->ham; + s->ham_palbuf[(i+count)*2] = 0xFF00FFFF; // just modify blue color component + s->ham_palbuf[(i+count*2)*2] = 0xFFFFFF00; // just modify red color component + s->ham_palbuf[(i+count*3)*2] = 0xFFFF00FF; // just modify green color component + s->ham_palbuf[(i+count)*2+1] = 0xFF000000 | tmp << 16; + s->ham_palbuf[(i+count*2)*2+1] = 0xFF000000 | tmp; + s->ham_palbuf[(i+count*3)*2+1] = 0xFF000000 | tmp << 8; + } + if (s->masking == MASK_HAS_MASK) { + for (int i = 0; i < ham_count; i++) + s->ham_palbuf[(1 << s->bpp) + i] = s->ham_palbuf[i] | 0xFF000000; + } + } return 0; } @@ -1469,57 +1469,53 @@ static int parse_packet_header(AVCodecContext *const avctx, GetByteContext *gb) { IffContext *s = avctx->priv_data; - int i; - - uint32_t chunk_id; - uint64_t data_size; if (avctx->codec_tag != MKTAG('A', 'N', 'I', 'M')) return 0; - bytestream2_skip(gb, 4); - while (bytestream2_get_bytes_left(gb) >= 1) { - chunk_id = bytestream2_get_le32(gb); - data_size = bytestream2_get_be32(gb); - - if (chunk_id == MKTAG('B', 'M', 'H', 'D')) { - bytestream2_skip(gb, data_size + (data_size & 1)); - } else if (chunk_id == MKTAG('A', 'N', 'H', 'D')) { - unsigned extra; - if (data_size < 40) - return AVERROR_INVALIDDATA; - - s->compression = (bytestream2_get_byte(gb) << 8) | (s->compression & 0xFF); - bytestream2_skip(gb, 19); - extra = bytestream2_get_be32(gb); - s->is_short = !(extra & 1); - s->is_brush = extra == 2; - s->is_interlaced = !!(extra & 0x40); - data_size -= 24; - bytestream2_skip(gb, data_size + (data_size & 1)); - } else if (chunk_id == MKTAG('D', 'L', 'T', 'A') || - chunk_id == MKTAG('B', 'O', 'D', 'Y')) { - if (chunk_id == MKTAG('B','O','D','Y')) - s->compression &= 0xFF; - break; - } else if (chunk_id == MKTAG('C', 'M', 'A', 'P')) { - int count = data_size / 3; - uint32_t *pal = s->pal; - - if (count > 256) - return AVERROR_INVALIDDATA; - if (s->ham) { - for (i = 0; i < count; i++) - pal[i] = 0xFF000000 | bytestream2_get_le24(gb); - } else { - for (i = 0; i < count; i++) - pal[i] = 0xFF000000 | bytestream2_get_be24(gb); - } - bytestream2_skip(gb, data_size & 1); + bytestream2_skip(gb, 4); + while (bytestream2_get_bytes_left(gb) >= 1) { + uint32_t chunk_id = bytestream2_get_le32(gb); + uint64_t data_size = bytestream2_get_be32(gb); + + if (chunk_id == MKTAG('B', 'M', 'H', 'D')) { + bytestream2_skip(gb, data_size + (data_size & 1)); + } else if (chunk_id == MKTAG('A', 'N', 'H', 'D')) { + unsigned extra; + if (data_size < 40) + return AVERROR_INVALIDDATA; + + s->compression = (bytestream2_get_byte(gb) << 8) | (s->compression & 0xFF); + bytestream2_skip(gb, 19); + extra = bytestream2_get_be32(gb); + s->is_short = !(extra & 1); + s->is_brush = extra == 2; + s->is_interlaced = !!(extra & 0x40); + data_size -= 24; + bytestream2_skip(gb, data_size + (data_size & 1)); + } else if (chunk_id == MKTAG('D', 'L', 'T', 'A') || + chunk_id == MKTAG('B', 'O', 'D', 'Y')) { + if (chunk_id == MKTAG('B','O','D','Y')) + s->compression &= 0xFF; + break; + } else if (chunk_id == MKTAG('C', 'M', 'A', 'P')) { + int count = data_size / 3; + uint32_t *pal = s->pal; + + if (count > 256) + return AVERROR_INVALIDDATA; + if (s->ham) { + for (int i = 0; i < count; i++) + pal[i] = 0xFF000000 | bytestream2_get_le24(gb); } else { - bytestream2_skip(gb, data_size + (data_size&1)); + for (int i = 0; i < count; i++) + pal[i] = 0xFF000000 | bytestream2_get_be24(gb); } + bytestream2_skip(gb, data_size & 1); + } else { + bytestream2_skip(gb, data_size + (data_size&1)); } + } return 0; } From 487fc61cb22f7ed07626577044eda7bd2deb2366 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 20:29:03 +0200 Subject: [PATCH 283/590] avcodec/iff: Remove transient objects from the context This avoids keeping invalid pointers in the context. Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 33e02b543d..4910d2f859 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -44,7 +44,6 @@ typedef enum { } mask_type; typedef struct IffContext { - AVFrame *frame; int planesize; uint8_t * planebuf; uint8_t * ham_buf; ///< temporary buffer for planar to chunky conversation @@ -62,7 +61,6 @@ typedef struct IffContext { unsigned masking; ///< TODO: masking method used int init; // 1 if buffer and palette data already initialized, 0 otherwise int16_t tvdc[16]; ///< TVDC lookup table - GetByteContext gb; uint8_t *video[2]; unsigned video_size; uint32_t *pal; @@ -1528,7 +1526,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int buf_size = avpkt->size; const uint8_t *buf_end = buf + buf_size; int y, plane, res; - GetByteContext *gb = &s->gb; + GetByteContext gb0, *const gb = &gb0; const AVPixFmtDescriptor *desc; bytestream2_init(gb, avpkt->data, avpkt->size); @@ -1538,7 +1536,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, if ((res = ff_get_buffer(avctx, frame, 0)) < 0) return res; - s->frame = frame; buf += bytestream2_tell(gb); buf_size -= bytestream2_tell(gb); @@ -1557,7 +1554,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, if (s->compression <= 0xff && (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M'))) { if (avctx->pix_fmt == AV_PIX_FMT_PAL8) - memcpy(s->pal, s->frame->data[1], 256 * 4); + memcpy(s->pal, frame->data[1], 256 * 4); } switch (s->compression) { From 4cd1d3e3b7e7412818553ae84e04ae3e077b680f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 11 Jul 2022 20:52:48 +0200 Subject: [PATCH 284/590] avcodec/iff: Use unsigned to avoid compiler warning GCC 12 apparently believes that negative palette sizes are possible (they are not, as this has already been checked during init) and therefore emits a -Wstringop-overflow= for the memcpy. Using unsigned avoids this. (To be honest, there might be a compiler bug involved.) Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 4910d2f859..e02d2e77e5 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -151,9 +151,10 @@ static av_always_inline uint32_t gray2rgb(const uint32_t x) { static int cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) { IffContext *s = avctx->priv_data; - int count, i; + unsigned count, i; const uint8_t *const palette = avctx->extradata + AV_RB16(avctx->extradata); - int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + /* extract_header() already checked that the RHS is >= 0. */ + unsigned palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); if (avctx->bits_per_coded_sample > 8) { av_log(avctx, AV_LOG_ERROR, "bits_per_coded_sample > 8 not supported\n"); From a2c6bf2314472dde268d641b19f08487af356517 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 15 Sep 2022 11:57:24 +0200 Subject: [PATCH 285/590] avcodec/intrax8: Remove reference to inexistent parameter Forgotten in eb5c5ae658aaf8cd7c03e1d0a6c84274d3a39a66. Signed-off-by: Andreas Rheinhardt --- libavcodec/intrax8.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h index 966f1b18a0..9ef2fc3dd3 100644 --- a/libavcodec/intrax8.h +++ b/libavcodec/intrax8.h @@ -77,7 +77,6 @@ typedef struct IntraX8Context { * Initialize IntraX8 frame decoder. * @param avctx pointer to AVCodecContext * @param w pointer to IntraX8Context - * @param idsp pointer to IDCTDSPContext * @param block pointer to block array * @param block_last_index pointer to index array * @param mb_width macroblock width From 6df3ad9687c41d17094ae5d16b4904f50338e0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 15 Sep 2022 21:26:48 +0300 Subject: [PATCH 286/590] lavu/riscv: fix off-by-one in bit-magnitude clip --- libavutil/riscv/intmath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h index 3263a79dc4..45bce9a0e7 100644 --- a/libavutil/riscv/intmath.h +++ b/libavutil/riscv/intmath.h @@ -61,8 +61,8 @@ static av_always_inline av_const int32_t av_clipl_int32_rvi(int64_t a) #define av_clip_intp2 av_clip_intp2_rvi static av_always_inline av_const int av_clip_intp2_rvi(int a, int p) { - const int shift = 32 - p; - int b = (a << shift) >> shift; + const int shift = 31 - p; + int b = ((int)(((unsigned)a) << shift)) >> shift; if (a != b) b = (a >> 31) ^ ((1 << p) - 1); From ea93943bee2efbfc44417eccdac712c5d9d677ec Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 8 Sep 2022 20:44:49 +0200 Subject: [PATCH 287/590] avcodec: add MI-SC4 audio decoder --- Changelog | 1 + doc/general_contents.texi | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/misc4.c | 186 ++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 2 +- libavformat/riff.c | 1 + 9 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 libavcodec/misc4.c diff --git a/Changelog b/Changelog index f76fce36b8..9e1f705539 100644 --- a/Changelog +++ b/Changelog @@ -12,6 +12,7 @@ version : - WBMP (Wireless Application Protocol Bitmap) image format - a3dscope filter - bonk decoder and demuxer +- Micronas SC-4 audio decoder version 5.1: diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 86ec6d606b..150b7944a8 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -1256,6 +1256,7 @@ following image formats are supported: @item Interplay ACM @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X +@item MI-SC4 (Micronas SC-4 Audio) @tab @tab X @item MLP (Meridian Lossless Packing) @tab X @tab X @tab Used in DVD-Audio discs. @item Monkey's Audio @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0b46bc0173..4112a0fb2e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -471,6 +471,7 @@ OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o OBJS-$(CONFIG_MICRODVD_DECODER) += microdvddec.o ass.o OBJS-$(CONFIG_MIMIC_DECODER) += mimic.o +OBJS-$(CONFIG_MISC4_DECODER) += misc4.o OBJS-$(CONFIG_MJPEG_DECODER) += mjpegdec.o mjpegdec_common.o OBJS-$(CONFIG_MJPEG_QSV_DECODER) += qsvdec.o OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 5d58a5d9f0..447225e26b 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -483,6 +483,7 @@ extern const FFCodec ff_interplay_acm_decoder; extern const FFCodec ff_mace3_decoder; extern const FFCodec ff_mace6_decoder; extern const FFCodec ff_metasound_decoder; +extern const FFCodec ff_misc4_decoder; extern const FFCodec ff_mlp_encoder; extern const FFCodec ff_mlp_decoder; extern const FFCodec ff_mp1_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index c002480d39..648c518b3c 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3297,6 +3297,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Bonk audio"), .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, + { + .id = AV_CODEC_ID_MISC4, + .type = AVMEDIA_TYPE_AUDIO, + .name = "misc4", + .long_name = NULL_IF_CONFIG_SMALL("Micronas SC-4 Audio"), + .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_INTRA_ONLY, + }, /* subtitle codecs */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 858b5c3a75..bc8226ff07 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -528,6 +528,7 @@ enum AVCodecID { AV_CODEC_ID_MSNSIREN, AV_CODEC_ID_DFPWM, AV_CODEC_ID_BONK, + AV_CODEC_ID_MISC4, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/misc4.c b/libavcodec/misc4.c new file mode 100644 index 0000000000..1bf162e120 --- /dev/null +++ b/libavcodec/misc4.c @@ -0,0 +1,186 @@ +/* + * Micronas SC-4 audio decoder + * Copyright (c) 2022 Paul B Mahol + * + * 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 "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "avcodec.h" +#include "codec_internal.h" +#include "decode.h" +#include "bytestream.h" +#include "mathops.h" + +static const int16_t steps[16] = { + 4084, 18, 41, 64, 112, 198, 355, 1122, + 1122, 355, 198, 112, 64, 41, 18, 4084, +}; + +static const int16_t diffs[16] = { + 2048, 4, 135, 213, 273, 323, 373, 425, + 425, 373, 323, 273, 213, 135, 4, 2048, +}; + +typedef struct ChannelContext { + unsigned last_step; + int64_t new_pred; + int64_t pred; + int64_t weights_tab[6]; + int32_t diffs_tab[6]; +} ChannelContext; + +typedef struct MISC4Context { + GetByteContext gb; + + uint32_t marker; + + ChannelContext ch[2]; +} MISC4Context; + +static av_cold int misc4_init(AVCodecContext *avctx) +{ + MISC4Context *s = avctx->priv_data; + + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + switch (avctx->sample_rate) { + case 8000: + case 11025: + s->marker = 0x11b; + break; + case 16000: + case 32000: + s->marker = 0x2b2; + break; + } + + return 0; +} + +#define FRACBITS 12 +#define WEIGHTSBITS 26 + +static int64_t prediction(int delta, ChannelContext *c) +{ + const int isign = FFDIFFSIGN(delta, 0); + int64_t dotpr = 0; + + c->new_pred = delta * (1LL << FRACBITS) + c->pred; + + for (int i = 0; i < 6; i++) { + const int sign = FFSIGN(c->diffs_tab[i]); + c->weights_tab[i] = (c->weights_tab[i] * 255LL) / 256; + c->weights_tab[i] += (1LL << (WEIGHTSBITS + 1)) * sign * isign; + } + + memmove(&c->diffs_tab[1], &c->diffs_tab[0], 5 * sizeof(int32_t)); + + c->diffs_tab[0] = -delta * (1 << (FRACBITS-8)); + c->pred = c->new_pred; + + dotpr = 0; + for (int i = 0; i < 6; i++) + dotpr += ((int64_t)c->diffs_tab[i] * c->weights_tab[i]) >> WEIGHTSBITS; + + c->pred += dotpr; + c->pred = av_clip64(c->pred, -16383 * (1 << FRACBITS), 16383 * (1 << FRACBITS)); + c->pred = c->pred * 9 / 10; + + return c->new_pred; +} + +static int16_t decode(ChannelContext *c, unsigned nibble) +{ + int diff, diff_sign, adiff = 0, delta; + uint32_t step, newstep; + int64_t pred; + + diff_sign = nibble >> 3; + diff = diffs[nibble]; + step = diff + (c->last_step >> 2); + newstep = step & 0xfff; + if (newstep >> 11 == 0) + adiff = (((step & 0x7f) + 0x80) * 128) >> + (14 - (newstep >> 7)); + delta = diff_sign ? -adiff : adiff; + delta = av_clip_intp2(delta, 15); + pred = prediction(delta, c); + nibble = steps[nibble]; + newstep = nibble * 32 - c->last_step & 0x1ffff; + newstep = ((newstep >> 5) + (newstep & 0x10000 ? 0x1000 : 0) + c->last_step) & 0x1fff; + c->last_step = av_clip(newstep, 544, 5120); + + return av_clip_int16(pred >> (FRACBITS - 3)); +} + +static int misc4_decode(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *pkt) +{ + MISC4Context *s = avctx->priv_data; + GetByteContext *gb = &s->gb; + uint32_t hdr; + int ret; + + bytestream2_init(gb, pkt->data, pkt->size); + + frame->nb_samples = 29 * (1 + (avctx->ch_layout.nb_channels == 1)); + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + hdr = bytestream2_peek_be32(gb); + if (hdr == s->marker) { + bytestream2_skip(gb, 5); + } else if ((hdr >> 16) == s->marker) { + bytestream2_skip(gb, 3); + } + + { + int16_t *samples = (int16_t *)frame->data[0]; + const int st = avctx->ch_layout.nb_channels == 2; + int n; + + for (n = 0; n < 29; n++) { + int nibble = bytestream2_get_byte(gb); + samples[2*n+0] = decode(&s->ch[0 ], nibble >> 4); + samples[2*n+1] = decode(&s->ch[st], nibble & 15); + if (bytestream2_get_bytes_left(gb) <= 0) + break; + } + + if (n == 29 && bytestream2_get_byte(gb) != 0x55) + return AVERROR_INVALIDDATA; + } + + *got_frame_ptr = 1; + + return bytestream2_tell(gb); +} + +const FFCodec ff_misc4_decoder = { + .p.name = "misc4", + CODEC_LONG_NAME("Micronas SC-4 Audio"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MISC4, + .priv_data_size = sizeof(MISC4Context), + .init = misc4_init, + FF_CODEC_DECODE_CB(misc4_decode), + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SUBFRAMES | + AV_CODEC_CAP_CHANNEL_CONF, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, + AV_SAMPLE_FMT_NONE }, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 2328be4b26..2cad78e640 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 43 +#define LIBAVCODEC_VERSION_MINOR 44 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/riff.c b/libavformat/riff.c index 6c06ad2d60..5114114364 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -564,6 +564,7 @@ const AVCodecTag ff_codec_wav_tags[] = { { AV_CODEC_ID_ATRAC3, 0x0270 }, { AV_CODEC_ID_MSNSIREN, 0x028E }, { AV_CODEC_ID_ADPCM_G722, 0x028F }, + { AV_CODEC_ID_MISC4, 0x0350 }, { AV_CODEC_ID_IMC, 0x0401 }, { AV_CODEC_ID_IAC, 0x0402 }, { AV_CODEC_ID_ON2AVC, 0x0500 }, From e91bc521afff17a73012af153f219c3e5f3f2ce5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 9 Sep 2022 09:57:12 +0200 Subject: [PATCH 288/590] avcodec: add Micronas SC-4 parser --- libavcodec/Makefile | 1 + libavcodec/misc4_parser.c | 81 +++++++++++++++++++++++++++++++++++++++ libavcodec/parsers.c | 1 + 3 files changed, 83 insertions(+) create mode 100644 libavcodec/misc4_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4112a0fb2e..e938564a1f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1143,6 +1143,7 @@ OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o OBJS-$(CONFIG_HDR_PARSER) += hdr_parser.o OBJS-$(CONFIG_IPU_PARSER) += ipu_parser.o OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o +OBJS-$(CONFIG_MISC4_PARSER) += misc4_parser.o OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o OBJS-$(CONFIG_MLP_PARSER) += mlp_parse.o mlp_parser.o mlp.o OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ diff --git a/libavcodec/misc4_parser.c b/libavcodec/misc4_parser.c new file mode 100644 index 0000000000..d234dbb629 --- /dev/null +++ b/libavcodec/misc4_parser.c @@ -0,0 +1,81 @@ +/* + * Micronas SC-4 parser + * + * 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 "parser.h" + +typedef struct MISC4Context { + ParseContext pc; +} MISC4Context; + +static int misc4_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + MISC4Context *ctx = s->priv_data; + uint32_t state = ctx->pc.state; + int next = END_NOT_FOUND, i = 0; + + *poutbuf_size = 0; + *poutbuf = NULL; + + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { + uint32_t marker = 0; + + switch (avctx->sample_rate) { + case 8000: + case 11025: + marker = 0x11b; + break; + case 16000: + case 32000: + marker = 0x2b2; + break; + } + + for (; i < buf_size; i++) { + state = (state << 8) | buf[i]; + if (state == marker && i > 3) { + next = i - 3; + break; + } + } + + ctx->pc.state = state; + if (ff_combine_frame(&ctx->pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } + } + + *poutbuf = buf; + *poutbuf_size = buf_size; + + return next; +} + +const AVCodecParser ff_misc4_parser = { + .codec_ids = { AV_CODEC_ID_MISC4 }, + .priv_data_size = sizeof(MISC4Context), + .parser_parse = misc4_parse, + .parser_close = ff_parse_close, +}; diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index a8d52af6cb..362f6f8bc6 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -53,6 +53,7 @@ extern const AVCodecParser ff_hevc_parser; extern const AVCodecParser ff_hdr_parser; extern const AVCodecParser ff_ipu_parser; extern const AVCodecParser ff_jpeg2000_parser; +extern const AVCodecParser ff_misc4_parser; extern const AVCodecParser ff_mjpeg_parser; extern const AVCodecParser ff_mlp_parser; extern const AVCodecParser ff_mpeg4video_parser; From dd2a01ef5cad08347ecbbcba7afd5e5a0810f504 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 11 Sep 2022 20:10:27 +0200 Subject: [PATCH 289/590] avformat: add LAF demuxer --- Changelog | 1 + doc/general_contents.texi | 2 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/lafdec.c | 271 ++++++++++++++++++++++++++++++++++++++ libavformat/version.h | 2 +- 6 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 libavformat/lafdec.c diff --git a/Changelog b/Changelog index 9e1f705539..720a092659 100644 --- a/Changelog +++ b/Changelog @@ -13,6 +13,7 @@ version : - a3dscope filter - bonk decoder and demuxer - Micronas SC-4 audio decoder +- LAF demuxer version 5.1: diff --git a/doc/general_contents.texi b/doc/general_contents.texi index 150b7944a8..a632b23f6f 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -510,6 +510,8 @@ library: @tab A format used by libvpx @item Internet Video Recording @tab @tab X @item IRCAM @tab X @tab X +@item LAF @tab @tab X + @tab Limitless Audio Format @item LATM @tab X @tab X @item LMLM4 @tab @tab X @tab Used by Linux Media Labs MPEG-4 PCI boards diff --git a/libavformat/Makefile b/libavformat/Makefile index 5cdcda3239..19a4ba2a8f 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -319,6 +319,7 @@ OBJS-$(CONFIG_JV_DEMUXER) += jvdec.o OBJS-$(CONFIG_KUX_DEMUXER) += flvdec.o OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o OBJS-$(CONFIG_KVAG_MUXER) += kvag.o rawenc.o +OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o OBJS-$(CONFIG_LATM_MUXER) += latmenc.o rawenc.o OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index cebd5e0c67..a545b5ff45 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -236,6 +236,7 @@ extern const AVInputFormat ff_jv_demuxer; extern const AVInputFormat ff_kux_demuxer; extern const AVInputFormat ff_kvag_demuxer; extern const AVOutputFormat ff_kvag_muxer; +extern const AVInputFormat ff_laf_demuxer; extern const AVOutputFormat ff_latm_muxer; extern const AVInputFormat ff_lmlm4_demuxer; extern const AVInputFormat ff_loas_demuxer; diff --git a/libavformat/lafdec.c b/libavformat/lafdec.c new file mode 100644 index 0000000000..12b0d8540b --- /dev/null +++ b/libavformat/lafdec.c @@ -0,0 +1,271 @@ +/* + * Limitless Audio Format demuxer + * Copyright (c) 2022 Paul B Mahol + * + * 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 "libavutil/intreadwrite.h" +#include "avformat.h" +#include "internal.h" + +#define MAX_STREAMS 4096 + +typedef struct StreamParams { + AVChannelLayout layout; + float horizontal; + float vertical; + int lfe; + int stored; +} StreamParams; + +typedef struct LAFContext { + uint8_t *data; + unsigned nb_stored; + unsigned stored_index; + unsigned index; + unsigned bpp; + + StreamParams p[MAX_STREAMS]; + + int header_len; + uint8_t header[(MAX_STREAMS + 7) / 8]; +} LAFContext; + +static int laf_probe(const AVProbeData *p) +{ + if (memcmp(p->buf, "LIMITLESS", 9)) + return 0; + if (memcmp(p->buf + 9, "HEAD", 4)) + return 0; + return AVPROBE_SCORE_MAX; +} + +static int laf_read_header(AVFormatContext *ctx) +{ + LAFContext *s = ctx->priv_data; + AVIOContext *pb = ctx->pb; + unsigned st_count, mode; + unsigned sample_rate; + int64_t duration; + int codec_id; + int quality; + int bpp; + + avio_skip(pb, 9); + if (avio_rb32(pb) != MKBETAG('H','E','A','D')) + return AVERROR_INVALIDDATA; + + quality = avio_r8(pb); + if (quality > 3) + return AVERROR_INVALIDDATA; + mode = avio_r8(pb); + if (mode > 1) + return AVERROR_INVALIDDATA; + st_count = avio_rl32(pb); + if (st_count == 0 || st_count > MAX_STREAMS) + return AVERROR_INVALIDDATA; + + for (int i = 0; i < st_count; i++) { + StreamParams *stp = &s->p[i]; + + stp->vertical = av_int2float(avio_rl32(pb)); + stp->horizontal = av_int2float(avio_rl32(pb)); + stp->lfe = avio_r8(pb); + if (stp->lfe) { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MASK(1, (AV_CH_LOW_FREQUENCY)); + } else if (stp->vertical == 0.f && + stp->horizontal == 0.f) { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MASK(1, (AV_CH_FRONT_CENTER)); + } else if (stp->vertical == 0.f && + stp->horizontal == -30.f) { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MASK(1, (AV_CH_FRONT_LEFT)); + } else if (stp->vertical == 0.f && + stp->horizontal == 30.f) { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MASK(1, (AV_CH_FRONT_RIGHT)); + } else if (stp->vertical == 0.f && + stp->horizontal == -110.f) { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MASK(1, (AV_CH_SIDE_LEFT)); + } else if (stp->vertical == 0.f && + stp->horizontal == 110.f) { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MASK(1, (AV_CH_SIDE_RIGHT)); + } else { + stp->layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; + } + } + + sample_rate = avio_rl32(pb); + duration = avio_rl64(pb) / st_count; + + switch (quality) { + case 0: + codec_id = AV_CODEC_ID_PCM_U8; + bpp = 1; + break; + case 1: + codec_id = AV_CODEC_ID_PCM_S16LE; + bpp = 2; + break; + case 2: + codec_id = AV_CODEC_ID_PCM_F32LE; + bpp = 4; + break; + case 3: + codec_id = AV_CODEC_ID_PCM_S24LE; + bpp = 3; + break; + } + + s->index = 0; + s->stored_index = 0; + s->bpp = bpp; + if ((int64_t)bpp * st_count * (int64_t)sample_rate >= INT32_MAX) + return AVERROR_INVALIDDATA; + s->data = av_calloc(st_count * sample_rate, bpp); + if (!s->data) + return AVERROR(ENOMEM); + + for (int st = 0; st < st_count; st++) { + StreamParams *stp = &s->p[st]; + AVCodecParameters *par; + AVStream *st = avformat_new_stream(ctx, NULL); + if (!st) + return AVERROR(ENOMEM); + + par = st->codecpar; + par->codec_id = codec_id; + par->codec_type = AVMEDIA_TYPE_AUDIO; + par->ch_layout.nb_channels = 1; + par->ch_layout = stp->layout; + par->sample_rate = sample_rate; + st->duration = duration; + + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + } + + s->header_len = (ctx->nb_streams + 7) / 8; + + return 0; +} + +static int laf_read_packet(AVFormatContext *ctx, AVPacket *pkt) +{ + AVIOContext *pb = ctx->pb; + LAFContext *s = ctx->priv_data; + AVStream *st = ctx->streams[0]; + const int bpp = s->bpp; + StreamParams *stp; + int64_t pos; + int ret; + + pos = avio_tell(pb); + +again: + if (avio_feof(pb)) + return AVERROR_EOF; + + if (s->index >= ctx->nb_streams) { + int cur_st = 0, st_count = 0, st_index = 0; + + avio_read(pb, s->header, s->header_len); + for (int i = 0; i < s->header_len; i++) { + uint8_t val = s->header[i]; + + for (int j = 0; j < 8 && cur_st < ctx->nb_streams; j++, cur_st++) { + StreamParams *stp = &s->p[st_index]; + + stp->stored = 0; + if (val & 1) { + stp->stored = 1; + st_count++; + } + val >>= 1; + st_index++; + } + } + + s->index = s->stored_index = 0; + s->nb_stored = st_count; + if (!st_count) + return AVERROR_INVALIDDATA; + ret = avio_read(pb, s->data, st_count * st->codecpar->sample_rate * bpp); + if (ret < 0) + return ret; + } + + st = ctx->streams[s->index]; + stp = &s->p[s->index]; + while (!stp->stored) { + s->index++; + if (s->index >= ctx->nb_streams) + goto again; + stp = &s->p[s->index]; + } + st = ctx->streams[s->index]; + + ret = av_new_packet(pkt, st->codecpar->sample_rate * bpp); + if (ret < 0) + return ret; + + switch (bpp) { + case 1: + for (int n = 0; n < st->codecpar->sample_rate; n++) + pkt->data[n] = s->data[n * s->nb_stored + s->stored_index]; + break; + case 2: + for (int n = 0; n < st->codecpar->sample_rate; n++) + AV_WN16(pkt->data + n * 2, AV_RN16(s->data + n * s->nb_stored * 2 + s->stored_index * 2)); + break; + case 3: + for (int n = 0; n < st->codecpar->sample_rate; n++) + AV_WL24(pkt->data + n * 3, AV_RL24(s->data + n * s->nb_stored * 3 + s->stored_index * 3)); + break; + case 4: + for (int n = 0; n < st->codecpar->sample_rate; n++) + AV_WN32(pkt->data + n * 4, AV_RN32(s->data + n * s->nb_stored * 4 + s->stored_index * 4)); + break; + } + + pkt->stream_index = s->index; + pkt->pos = pos; + s->index++; + s->stored_index++; + + return 0; +} + +static int laf_read_seek(AVFormatContext *ctx, int stream_index, + int64_t timestamp, int flags) +{ + LAFContext *s = ctx->priv_data; + + s->stored_index = s->index = s->nb_stored = 0; + + return -1; +} + +const AVInputFormat ff_laf_demuxer = { + .name = "laf", + .long_name = NULL_IF_CONFIG_SMALL("LAF (Limitless Audio Format)"), + .priv_data_size = sizeof(LAFContext), + .read_probe = laf_probe, + .read_header = laf_read_header, + .read_packet = laf_read_packet, + .read_seek = laf_read_seek, + .extensions = "laf", + .flags = AVFMT_GENERIC_INDEX, +}; diff --git a/libavformat/version.h b/libavformat/version.h index 36f22982d8..ede3f46428 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 31 +#define LIBAVFORMAT_VERSION_MINOR 32 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ From 53523ed530d0aceb0581c2e4f120ae3915e9bc05 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 13 Sep 2022 14:38:18 +0200 Subject: [PATCH 290/590] avcodec/tak*: use cached bitstream reader on !x86_32 Increases single thread decoding speed in one example from 85x to 90x --- libavcodec/tak.c | 1 + libavcodec/tak_parser.c | 1 + libavcodec/takdec.c | 1 + 3 files changed, 3 insertions(+) diff --git a/libavcodec/tak.c b/libavcodec/tak.c index 7221a80094..f26574c968 100644 --- a/libavcodec/tak.c +++ b/libavcodec/tak.c @@ -23,6 +23,7 @@ #include "libavutil/crc.h" #include "libavutil/intreadwrite.h" +#define CACHED_BITSTREAM_READER !ARCH_X86_32 #define BITSTREAM_READER_LE #include "tak.h" diff --git a/libavcodec/tak_parser.c b/libavcodec/tak_parser.c index b9f47db8ac..7f5f5314af 100644 --- a/libavcodec/tak_parser.c +++ b/libavcodec/tak_parser.c @@ -24,6 +24,7 @@ * TAK parser **/ +#define CACHED_BITSTREAM_READER !ARCH_X86_32 #define BITSTREAM_READER_LE #include "parser.h" #include "tak.h" diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 68ad1e9ed7..5cbc2de6bd 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -29,6 +29,7 @@ #include "libavutil/mem_internal.h" #include "libavutil/samplefmt.h" +#define CACHED_BITSTREAM_READER !ARCH_X86_32 #define BITSTREAM_READER_LE #include "audiodsp.h" #include "thread.h" From b15a2f25044583909aaedc3995d4aaad30df2619 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 16 Sep 2022 09:05:20 +0200 Subject: [PATCH 291/590] avcodec/adx: Move ff_adx_decode_header() to adxdec.c Possible since 9325d88eba8038b3e2a4485e473a018410379e2d. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/adx.c | 53 ------------------------------ libavcodec/adx.h | 18 ----------- libavcodec/adxdec.c | 79 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 71 insertions(+), 79 deletions(-) diff --git a/libavcodec/adx.c b/libavcodec/adx.c index c60fabb40b..6323e5c856 100644 --- a/libavcodec/adx.c +++ b/libavcodec/adx.c @@ -19,7 +19,6 @@ */ #include "libavutil/common.h" -#include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "adx.h" @@ -34,55 +33,3 @@ void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff) coeff[0] = lrintf(c * 2.0 * (1 << bits)); coeff[1] = lrintf(-(c * c) * (1 << bits)); } - -int ff_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, - int bufsize, int *header_size, int *coeff) -{ - int offset, cutoff, channels; - - if (bufsize < 24) - return AVERROR_INVALIDDATA; - - if (AV_RB16(buf) != 0x8000) - return AVERROR_INVALIDDATA; - offset = AV_RB16(buf + 2) + 4; - - /* if copyright string is within the provided data, validate it */ - if (bufsize >= offset && offset >= 6 && memcmp(buf + offset - 6, "(c)CRI", 6)) - return AVERROR_INVALIDDATA; - - /* check for encoding=3 block_size=18, sample_size=4 */ - if (buf[4] != 3 || buf[5] != 18 || buf[6] != 4) { - avpriv_request_sample(avctx, "Support for this ADX format"); - return AVERROR_PATCHWELCOME; - } - - /* channels */ - channels = buf[7]; - if (channels <= 0 || channels > 2) - return AVERROR_INVALIDDATA; - - if (avctx->ch_layout.nb_channels != channels) { - av_channel_layout_uninit(&avctx->ch_layout); - avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; - avctx->ch_layout.nb_channels = channels; - } - - /* sample rate */ - avctx->sample_rate = AV_RB32(buf + 8); - if (avctx->sample_rate < 1 || - avctx->sample_rate > INT_MAX / (channels * BLOCK_SIZE * 8)) - return AVERROR_INVALIDDATA; - - /* bit rate */ - avctx->bit_rate = avctx->sample_rate * channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES; - - /* LPC coefficients */ - if (coeff) { - cutoff = AV_RB16(buf + 16); - ff_adx_calculate_coeffs(cutoff, avctx->sample_rate, COEFF_BITS, coeff); - } - - *header_size = offset; - return 0; -} diff --git a/libavcodec/adx.h b/libavcodec/adx.h index 08f749a046..8d5e0869ae 100644 --- a/libavcodec/adx.h +++ b/libavcodec/adx.h @@ -31,10 +31,6 @@ #ifndef AVCODEC_ADX_H #define AVCODEC_ADX_H -#include - -#include "avcodec.h" - typedef struct ADXChannelState { int s1,s2; } ADXChannelState; @@ -63,18 +59,4 @@ typedef struct ADXContext { */ void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff); -/** - * Decode ADX stream header. - * Sets avctx->channels and avctx->sample_rate. - * - * @param avctx codec context - * @param buf header data - * @param bufsize data size, should be at least 24 bytes - * @param[out] header_size size of ADX header - * @param[out] coeff 2 LPC coefficients, can be NULL - * @return data offset or negative error code if header is invalid - */ -int ff_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, - int bufsize, int *header_size, int *coeff); - #endif /* AVCODEC_ADX_H */ diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index a2701608ff..97a7e59686 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -35,15 +35,78 @@ * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/ */ +/** + * Decode ADX stream header. + * Sets avctx->channels and avctx->sample_rate. + * + * @param avctx codec context + * @param buf header data + * @param bufsize data size, should be at least 24 bytes + * @param[out] header_size size of ADX header + * @param[out] coeff 2 LPC coefficients, can be NULL + * @return data offset or negative error code if header is invalid + */ +static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, + int bufsize, int *header_size, int *coeff) +{ + int offset, cutoff, channels; + + if (bufsize < 24) + return AVERROR_INVALIDDATA; + + if (AV_RB16(buf) != 0x8000) + return AVERROR_INVALIDDATA; + offset = AV_RB16(buf + 2) + 4; + + /* if copyright string is within the provided data, validate it */ + if (bufsize >= offset && offset >= 6 && memcmp(buf + offset - 6, "(c)CRI", 6)) + return AVERROR_INVALIDDATA; + + /* check for encoding=3 block_size=18, sample_size=4 */ + if (buf[4] != 3 || buf[5] != 18 || buf[6] != 4) { + avpriv_request_sample(avctx, "Support for this ADX format"); + return AVERROR_PATCHWELCOME; + } + + /* channels */ + channels = buf[7]; + if (channels <= 0 || channels > 2) + return AVERROR_INVALIDDATA; + + if (avctx->ch_layout.nb_channels != channels) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avctx->ch_layout.nb_channels = channels; + } + + /* sample rate */ + avctx->sample_rate = AV_RB32(buf + 8); + if (avctx->sample_rate < 1 || + avctx->sample_rate > INT_MAX / (channels * BLOCK_SIZE * 8)) + return AVERROR_INVALIDDATA; + + /* bit rate */ + avctx->bit_rate = avctx->sample_rate * channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES; + + /* LPC coefficients */ + if (coeff) { + cutoff = AV_RB16(buf + 16); + ff_adx_calculate_coeffs(cutoff, avctx->sample_rate, COEFF_BITS, coeff); + } + + *header_size = offset; + return 0; +} + static av_cold int adx_decode_init(AVCodecContext *avctx) { ADXContext *c = avctx->priv_data; int ret, header_size; if (avctx->extradata_size >= 24) { - if ((ret = ff_adx_decode_header(avctx, avctx->extradata, - avctx->extradata_size, &header_size, - c->coeff)) < 0) { + if ((ret = adx_decode_header(avctx, avctx->extradata, + avctx->extradata_size, &header_size, + c->coeff)) < 0) { av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); return AVERROR_INVALIDDATA; } @@ -110,9 +173,9 @@ static int adx_decode_frame(AVCodecContext *avctx, AVFrame *frame, &new_extradata_size); if (new_extradata && new_extradata_size > 0) { int header_size; - if ((ret = ff_adx_decode_header(avctx, new_extradata, - new_extradata_size, &header_size, - c->coeff)) < 0) { + if ((ret = adx_decode_header(avctx, new_extradata, + new_extradata_size, &header_size, + c->coeff)) < 0) { av_log(avctx, AV_LOG_ERROR, "error parsing new ADX extradata\n"); return AVERROR_INVALIDDATA; } @@ -127,8 +190,8 @@ static int adx_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) { int header_size; - if ((ret = ff_adx_decode_header(avctx, buf, buf_size, &header_size, - c->coeff)) < 0) { + if ((ret = adx_decode_header(avctx, buf, buf_size, &header_size, + c->coeff)) < 0) { av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); return AVERROR_INVALIDDATA; } From aaf6d85283f2d7fbcec7af3f8b4d4723113fc6d8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 16 Sep 2022 09:10:49 +0200 Subject: [PATCH 292/590] avcodec/Makefile: Remove obsolete adx_parser->adx.c dependency Obsolete since b024209b1fe57b7902d30a8e0d38f5ecb628e6f3. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index e938564a1f..e23b03e5dd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1112,7 +1112,7 @@ OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o OBJS-$(CONFIG_AC3_PARSER) += aac_ac3_parser.o ac3tab.o \ ac3_channel_layout_tab.o -OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o +OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o OBJS-$(CONFIG_AMR_PARSER) += amr_parser.o OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o OBJS-$(CONFIG_AVS2_PARSER) += avs2.o avs2_parser.o From 2c23cd0181ef18c8dd968218d45c15c1b035ba65 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 12 Sep 2022 15:51:11 +0200 Subject: [PATCH 293/590] avformat/bonk: Don't set data_offset to what it would be set to anyway Signed-off-by: Andreas Rheinhardt --- libavformat/bonk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/bonk.c b/libavformat/bonk.c index fc400979b3..0fff0b5bda 100644 --- a/libavformat/bonk.c +++ b/libavformat/bonk.c @@ -79,7 +79,6 @@ static int bonk_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; st->duration = AV_RL32(st->codecpar->extradata + 1) / st->codecpar->ch_layout.nb_channels; avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); - ffformatcontext(s)->data_offset = avio_tell(s->pb); return 0; } From 8f115122733fd640b6f12290f2108939fda4c9cf Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 16 Sep 2022 17:54:54 +0200 Subject: [PATCH 294/590] avformat/ape: set packet duration --- libavformat/ape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/ape.c b/libavformat/ape.c index bf1254e7bd..e694df7302 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -411,6 +411,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt) /* note: we need to modify the packet size here to handle the last packet */ pkt->size = ret + extra_size; + pkt->duration = nblocks; ape->currentframe++; From 9c05f178a6a9672411e5f5149c1b04adb4e77b51 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 16 Sep 2022 17:58:36 +0200 Subject: [PATCH 295/590] avformat/ape: fix overflow in total_blocks --- libavformat/ape.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/ape.c b/libavformat/ape.c index e694df7302..f904fde178 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -146,7 +146,7 @@ static int ape_read_header(AVFormatContext * s) AVStream *st; uint32_t tag; int i, ret; - int total_blocks; + int64_t total_blocks; int64_t final_size = 0; int64_t pts, file_size; @@ -327,7 +327,7 @@ static int ape_read_header(AVFormatContext * s) if (!st) return AVERROR(ENOMEM); - total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks; + total_blocks = (ape->totalframes == 0) ? 0 : ((int64_t)(ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks; st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = AV_CODEC_ID_APE; From 0b1b93823f1ad0fb711075872fdf873f5a0dc0bf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 21:35:29 +0200 Subject: [PATCH 296/590] avcodec/dolby_e_parser: Remove unnecessary headers Possible since 81d070dd09ce154d635414fd07d80a591266b421. Signed-off-by: Andreas Rheinhardt --- libavcodec/dolby_e_parser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/dolby_e_parser.c b/libavcodec/dolby_e_parser.c index 9f54627356..d2566e5446 100644 --- a/libavcodec/dolby_e_parser.c +++ b/libavcodec/dolby_e_parser.c @@ -21,8 +21,6 @@ #include "libavutil/channel_layout.h" #include "avcodec.h" #include "dolby_e.h" -#include "get_bits.h" -#include "put_bits.h" typedef struct DBEParseContext { DBEContext dectx; From 13cddfc4533a6b36bec7416a8be46f9f6fbc01db Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 15:38:49 +0200 Subject: [PATCH 297/590] avcodec/dcahuff: Remove unused define In reality, the bit allocation VLCs do not use the same number of bits at all. Signed-off-by: Andreas Rheinhardt --- libavcodec/dcahuff.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index 8d5541f9d0..d1b64798ab 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -44,7 +44,6 @@ static const uint8_t tmode_bits[TMODE_COUNT][4] = { { 2, 2, 2, 2 } }; -#define BITALLOC_12_VLC_BITS 9 static const uint8_t bitalloc_12_vlc_bits[DCA_BITALLOC_12_COUNT] = { 9, 7, 7, 9, 9 }; From 649a2d8d526795adf57bc87481668ca6615ee0c4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 21:49:23 +0200 Subject: [PATCH 298/590] avcodec/dcahuff: Avoid redundant offset table Signed-off-by: Andreas Rheinhardt --- libavcodec/dcahuff.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index d1b64798ab..9b809cc415 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -1232,17 +1232,6 @@ static const uint8_t rsd_bitvals[18] = { 6, 4, }; -static const uint16_t vlc_offs[80] = { - 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364, - 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508, - 5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564, - 7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240, - 12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264, - 18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622, 24200, 24748, 25276, - 25792, 26306, 26826, 26890, 26954, 27468, 27500, 28038, 28554, 29086, 29630, - 30150, 30214 -}; - DCAVLC ff_dca_vlc_bit_allocation; DCAVLC ff_dca_vlc_transition_mode; DCAVLC ff_dca_vlc_scale_factor; @@ -1264,14 +1253,15 @@ VLC ff_dca_vlc_rsd; av_cold void ff_dca_init_vlcs(void) { static VLCElem dca_table[30214]; - int i, j, k = 0; + unsigned offset = 0; + int i, j; #define DCA_INIT_VLC(vlc, a, b, c, d) \ do { \ - vlc.table = &dca_table[vlc_offs[k]]; \ - vlc.table_allocated = vlc_offs[k + 1] - vlc_offs[k]; \ - init_vlc(&vlc, a, b, c, 1, 1, d, 2, 2, INIT_VLC_USE_NEW_STATIC); \ - k++; \ + vlc.table = &dca_table[offset]; \ + vlc.table_allocated = FF_ARRAY_ELEMS(dca_table) - offset; \ + init_vlc(&vlc, a, b, c, 1, 1, d, 2, 2, INIT_VLC_STATIC_OVERLONG); \ + offset += vlc.table_size; \ } while (0) ff_dca_vlc_bit_allocation.offset = 1; @@ -1302,14 +1292,14 @@ av_cold void ff_dca_init_vlcs(void) #define LBR_INIT_VLC(vlc, tab, nb_bits) \ do { \ - vlc.table = &dca_table[vlc_offs[k]]; \ - vlc.table_allocated = vlc_offs[k + 1] - vlc_offs[k]; \ + vlc.table = &dca_table[offset]; \ + vlc.table_allocated = FF_ARRAY_ELEMS(dca_table) - offset; \ ff_init_vlc_sparse(&vlc, nb_bits, FF_ARRAY_ELEMS(tab##_codes), \ &tab##_bitvals[0], 2, 1, \ tab##_codes, 2, 2, \ &tab##_bitvals[1], 2, 1, \ - INIT_VLC_LE | INIT_VLC_USE_NEW_STATIC); \ - k++; \ + INIT_VLC_LE | INIT_VLC_STATIC_OVERLONG); \ + offset += vlc.table_size; \ } while (0) LBR_INIT_VLC(ff_dca_vlc_tnl_grp[0], tnl_grp_0, 9); From 8819860f34bb2065ec82d3b39d5053c13fb9ab31 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 03:53:46 +0200 Subject: [PATCH 299/590] avcodec/dca_core, dcahuff: Don't use DCAVLC unnecessarily The ff_dca_vlc_transition_mode VLCs don't use an offset at all, so just use ordinary VLCs for them. Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 3 ++- libavcodec/dcahuff.c | 8 +++----- libavcodec/dcahuff.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index bbf36ea678..499afc8204 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -456,7 +456,8 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf, int sel = s->transition_mode_sel[ch]; for (band = 0; band < s->subband_vq_start[ch]; band++) if (s->bit_allocation[ch][band]) - s->transition_mode[sf][ch][band] = dca_get_vlc(&s->gb, &ff_dca_vlc_transition_mode, sel); + s->transition_mode[sf][ch][band] = get_vlc2(&s->gb, ff_dca_vlc_transition_mode[sel].table, + ff_dca_vlc_transition_mode[sel].bits,1); } } diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index 9b809cc415..49fb06eeb4 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -1233,7 +1233,7 @@ static const uint8_t rsd_bitvals[18] = { }; DCAVLC ff_dca_vlc_bit_allocation; -DCAVLC ff_dca_vlc_transition_mode; +VLC ff_dca_vlc_transition_mode[4]; DCAVLC ff_dca_vlc_scale_factor; DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; @@ -1276,10 +1276,8 @@ av_cold void ff_dca_init_vlcs(void) DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129, scales_bits[i], scales_codes[i]); - ff_dca_vlc_transition_mode.offset = 0; - ff_dca_vlc_transition_mode.max_depth = 1; - for (i = 0; i < 4; i++) - DCA_INIT_VLC(ff_dca_vlc_transition_mode.vlc[i], tmode_vlc_bits[i], 4, + for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++) + DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], tmode_vlc_bits[i], 4, tmode_bits[i], tmode_codes[i]); for (i = 0; i < DCA_CODE_BOOKS; i++) { diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index c0e04b725a..87e1fd1cea 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -40,7 +40,7 @@ typedef struct DCAVLC { } DCAVLC; extern DCAVLC ff_dca_vlc_bit_allocation; -extern DCAVLC ff_dca_vlc_transition_mode; +extern VLC ff_dca_vlc_transition_mode[4]; extern DCAVLC ff_dca_vlc_scale_factor; extern DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; From 077880ad88eb1218c5c6b3b134e75317701dbe81 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 12:21:28 +0200 Subject: [PATCH 300/590] avcodec/dcahuff: Always use three bits for transition mode VLCs It increases the size of one VLC from two to three bits, thereby requiring four more VLCEntries (16 bytes .bss), but it allows to inline the number of bits used when reading them. Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 2 +- libavcodec/dcahuff.c | 5 ++--- libavcodec/dcahuff.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 499afc8204..069d428fff 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -457,7 +457,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf, for (band = 0; band < s->subband_vq_start[ch]; band++) if (s->bit_allocation[ch][band]) s->transition_mode[sf][ch][band] = get_vlc2(&s->gb, ff_dca_vlc_transition_mode[sel].table, - ff_dca_vlc_transition_mode[sel].bits,1); + DCA_TMODE_VLC_BITS, 1); } } diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index 49fb06eeb4..842b1401dd 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -29,7 +29,6 @@ #include "put_bits.h" #define TMODE_COUNT 4 -static const uint8_t tmode_vlc_bits[TMODE_COUNT] = { 3, 3, 3, 2 }; static const uint16_t tmode_codes[TMODE_COUNT][4] = { { 0x0000, 0x0002, 0x0006, 0x0007 }, { 0x0002, 0x0006, 0x0007, 0x0000 }, @@ -1252,7 +1251,7 @@ VLC ff_dca_vlc_rsd; av_cold void ff_dca_init_vlcs(void) { - static VLCElem dca_table[30214]; + static VLCElem dca_table[30218]; unsigned offset = 0; int i, j; @@ -1277,7 +1276,7 @@ av_cold void ff_dca_init_vlcs(void) scales_bits[i], scales_codes[i]); for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++) - DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], tmode_vlc_bits[i], 4, + DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4, tmode_bits[i], tmode_codes[i]); for (i = 0; i < DCA_CODE_BOOKS; i++) { diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index 87e1fd1cea..1f13b6f443 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -40,6 +40,7 @@ typedef struct DCAVLC { } DCAVLC; extern DCAVLC ff_dca_vlc_bit_allocation; +#define DCA_TMODE_VLC_BITS 3 extern VLC ff_dca_vlc_transition_mode[4]; extern DCAVLC ff_dca_vlc_scale_factor; extern DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; From 2339f63eac90a7a3b25f2d5ee5749dbc46563684 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 Sep 2022 23:28:01 +0200 Subject: [PATCH 301/590] avcodec/dcaenc: Create encoder-adapted tables Up until now, the encoder used the same tables that the decoder uses to create its VLCs. These have the downside of requiring the encoder to offset the tables at runtime as well as having to read from separate tables for the length as well as the code of the symbol to encode. The former are uint8_t, the latter uint16_t, so using a joint table would require padding, but this doesn't matter when these tables are generated at runtime, because they live in the .bss segment. Also move these init functions as well as the functions that actually use them to dcaenc.c, because they are encoder-specific. This also allows to remove an inclusion of PutBitContext from dcahuff.h (and indirectly from all dca-decoder files). Signed-off-by: Andreas Rheinhardt --- libavcodec/dcaenc.c | 82 ++++++++++++++++++++++++++++++++++++++++---- libavcodec/dcahuff.c | 64 ++++++---------------------------- libavcodec/dcahuff.h | 16 ++++++--- 3 files changed, 96 insertions(+), 66 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index d02602761b..4a02aa9d46 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -29,6 +29,7 @@ #include "libavutil/ffmath.h" #include "libavutil/mem_internal.h" #include "libavutil/opt.h" +#include "libavutil/thread.h" #include "avcodec.h" #include "codec_internal.h" #include "dca.h" @@ -159,8 +160,41 @@ static void subband_bufer_free(DCAEncContext *c) } } +static uint16_t bitalloc_12_table[DCA_BITALLOC_12_COUNT][12 + 1][2]; + +static uint16_t bitalloc_table[DCA_NUM_BITALLOC_CODES][2]; +static const uint16_t (*bitalloc_tables[DCA_CODE_BOOKS][8])[2]; + +static av_cold void create_enc_table(uint16_t dst[][2], unsigned count, + const uint8_t len[], const uint16_t codes[]) +{ + for (unsigned i = 0; i < count; i++) { + dst[i][0] = codes[i]; + dst[i][1] = len[i]; + } +} + +static av_cold void dcaenc_init_static_tables(void) +{ + uint16_t (*bitalloc_dst)[2] = bitalloc_table; + + for (unsigned i = 0; i < DCA_CODE_BOOKS; i++) { + for (unsigned j = 0; ff_dca_bitalloc_codes[i][j]; j++) { + create_enc_table(bitalloc_dst, ff_dca_bitalloc_sizes[i], + ff_dca_bitalloc_bits[i][j], ff_dca_bitalloc_codes[i][j]); + bitalloc_tables[i][j] = bitalloc_dst - ff_dca_bitalloc_offsets[i]; + bitalloc_dst += ff_dca_bitalloc_sizes[i]; + } + } + + for (unsigned i = 0; i < DCA_BITALLOC_12_COUNT; i++) + create_enc_table(&bitalloc_12_table[i][1], 12, + ff_dca_bitalloc_12_bits[i], ff_dca_bitalloc_12_codes[i]); +} + static int encode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; DCAEncContext *c = avctx->priv_data; AVChannelLayout layout = avctx->ch_layout; int i, j, k, min_frame_bits; @@ -307,6 +341,7 @@ static int encode_init(AVCodecContext *avctx) c->band_spectrum_tab[1][j] = (int32_t)(200 * log10(accum)); } + ff_thread_once(&init_static_once, dcaenc_init_static_tables); return 0; } @@ -400,6 +435,39 @@ static void lfe_downsample(DCAEncContext *c, const int32_t *input) } } +static uint32_t dca_vlc_calc_alloc_bits(const int values[], uint8_t n, uint8_t sel) +{ + uint32_t sum = 0; + for (unsigned i = 0; i < n; i++) + sum += bitalloc_12_table[sel][values[i]][1]; + return sum; +} + +static void dca_vlc_enc_alloc(PutBitContext *pb, const int values[], + uint8_t n, uint8_t sel) +{ + for (unsigned i = 0; i < n; i++) + put_bits(pb, bitalloc_12_table[sel][values[i]][1], + bitalloc_12_table[sel][values[i]][0]); +} + +static uint32_t dca_vlc_calc_quant_bits(const int values[], uint8_t n, + uint8_t sel, uint8_t table) +{ + uint32_t sum = 0; + for (unsigned i = 0; i < n; i++) + sum += bitalloc_tables[table][sel][values[i]][1]; + return sum; +} + +static void dca_vlc_enc_quant(PutBitContext *pb, const int values[], + uint8_t n, uint8_t sel, uint8_t table) +{ + for (unsigned i = 0; i < n; i++) + put_bits(pb, bitalloc_tables[table][sel][values[i]][1], + bitalloc_tables[table][sel][values[i]][0]); +} + static int32_t get_cb(DCAEncContext *c, int32_t in) { int i, res = 0; @@ -695,8 +763,8 @@ static void accumulate_huff_bit_consumption(int abits, int32_t *quantized, { uint8_t sel, id = abits - 1; for (sel = 0; sel < ff_dca_quant_index_group_size[id]; sel++) - result[sel] += ff_dca_vlc_calc_quant_bits(quantized, SUBBAND_SAMPLES, - sel, id); + result[sel] += dca_vlc_calc_quant_bits(quantized, SUBBAND_SAMPLES, + sel, id); } static uint32_t set_best_code(uint32_t vlc_bits[DCA_CODE_BOOKS][7], @@ -757,7 +825,7 @@ static uint32_t set_best_abits_code(int abits[DCAENC_SUBBANDS], int bands, } for (i = 0; i < DCA_BITALLOC_12_COUNT; i++) { - t = ff_dca_vlc_calc_alloc_bits(abits, bands, i); + t = dca_vlc_calc_alloc_bits(abits, bands, i); if (t < best_bits) { best_bits = t; best_sel = i; @@ -1081,8 +1149,8 @@ static void put_subframe_samples(DCAEncContext *c, int ss, int band, int ch) sel = c->quant_index_sel[ch][c->abits[ch][band] - 1]; // Huffman codes if (sel < ff_dca_quant_index_group_size[c->abits[ch][band] - 1]) { - ff_dca_vlc_enc_quant(&c->pb, &c->quantized[ch][band][ss * 8], 8, - sel, c->abits[ch][band] - 1); + dca_vlc_enc_quant(&c->pb, &c->quantized[ch][band][ss * 8], 8, + sel, c->abits[ch][band] - 1); return; } @@ -1135,8 +1203,8 @@ static void put_subframe(DCAEncContext *c, int subframe) put_bits(&c->pb, 5, c->abits[ch][band]); } } else { - ff_dca_vlc_enc_alloc(&c->pb, c->abits[ch], DCAENC_SUBBANDS, - c->bit_allocation_sel[ch]); + dca_vlc_enc_alloc(&c->pb, c->abits[ch], DCAENC_SUBBANDS, + c->bit_allocation_sel[ch]); } } diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index 842b1401dd..d17b49a089 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -22,11 +22,9 @@ #include -#include "libavutil/avassert.h" #include "libavutil/macros.h" #include "dcahuff.h" -#include "put_bits.h" #define TMODE_COUNT 4 static const uint16_t tmode_codes[TMODE_COUNT][4] = { @@ -47,7 +45,7 @@ static const uint8_t bitalloc_12_vlc_bits[DCA_BITALLOC_12_COUNT] = { 9, 7, 7, 9, 9 }; -static const uint16_t bitalloc_12_codes[DCA_BITALLOC_12_COUNT][12] = { +const uint16_t ff_dca_bitalloc_12_codes[DCA_BITALLOC_12_COUNT][12] = { { 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, 0x00FF, 0x00FE, 0x01FB, 0x01FA, 0x01F9, 0x01F8, }, { 0x0001, 0x0000, 0x0002, 0x000F, 0x000C, 0x001D, 0x0039, 0x0038, @@ -60,7 +58,7 @@ static const uint16_t bitalloc_12_codes[DCA_BITALLOC_12_COUNT][12] = { 0x0079, 0x0078, 0x00FB, 0x00FA, } }; -static const uint8_t bitalloc_12_bits[DCA_BITALLOC_12_COUNT][12] = { +const uint8_t ff_dca_bitalloc_12_bits[DCA_BITALLOC_12_COUNT][12] = { { 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 9, 9 }, { 1, 2, 3, 5, 5, 6, 7, 7, 7, 7, 7, 7 }, { 2, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 7 }, @@ -980,11 +978,11 @@ static const uint8_t bitalloc_129_bits_g[129] = { 13, }; -static const uint8_t bitalloc_sizes[DCA_CODE_BOOKS] = { +const uint8_t ff_dca_bitalloc_sizes[DCA_CODE_BOOKS] = { 3, 5, 7, 9, 13, 17, 25, 33, 65, 129 }; -static const int8_t bitalloc_offsets[DCA_CODE_BOOKS] = { +const int8_t ff_dca_bitalloc_offsets[DCA_CODE_BOOKS] = { -1, -2, -3, -4, -6, -8, -12, -16, -32, -64 }; @@ -1001,7 +999,7 @@ static const uint8_t bitalloc_maxbits[DCA_CODE_BOOKS][7] = { { 9, 9, 9, 9, 9, 9, 9 } }; -static const uint16_t *const bitalloc_codes[DCA_CODE_BOOKS][8] = { +const uint16_t *const ff_dca_bitalloc_codes[DCA_CODE_BOOKS][8] = { { bitalloc_3_codes, NULL }, { bitalloc_5_codes_a, bitalloc_5_codes_b, bitalloc_5_codes_c, NULL }, { bitalloc_7_codes_a, bitalloc_7_codes_b, bitalloc_7_codes_c, NULL }, @@ -1019,7 +1017,7 @@ static const uint16_t *const bitalloc_codes[DCA_CODE_BOOKS][8] = { bitalloc_129_codes_e, bitalloc_129_codes_f, bitalloc_129_codes_g, NULL } }; -static const uint8_t *const bitalloc_bits[DCA_CODE_BOOKS][8] = { +const uint8_t *const ff_dca_bitalloc_bits[DCA_CODE_BOOKS][8] = { { bitalloc_3_bits, NULL }, { bitalloc_5_bits_a, bitalloc_5_bits_b, bitalloc_5_bits_c, NULL }, { bitalloc_7_bits_a, bitalloc_7_bits_b, bitalloc_7_bits_c, NULL }, @@ -1267,7 +1265,7 @@ av_cold void ff_dca_init_vlcs(void) ff_dca_vlc_bit_allocation.max_depth = 2; for (i = 0; i < 5; i++) DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, - bitalloc_12_bits[i], bitalloc_12_codes[i]); + ff_dca_bitalloc_12_bits[i], ff_dca_bitalloc_12_codes[i]); ff_dca_vlc_scale_factor.offset = -64; ff_dca_vlc_scale_factor.max_depth = 2; @@ -1280,11 +1278,11 @@ av_cold void ff_dca_init_vlcs(void) tmode_bits[i], tmode_codes[i]); for (i = 0; i < DCA_CODE_BOOKS; i++) { - ff_dca_vlc_quant_index[i].offset = bitalloc_offsets[i]; + ff_dca_vlc_quant_index[i].offset = ff_dca_bitalloc_offsets[i]; ff_dca_vlc_quant_index[i].max_depth = 1 + (i > 4); - for (j = 0; bitalloc_codes[i][j]; j++) + for (j = 0; ff_dca_bitalloc_codes[i][j]; j++) DCA_INIT_VLC(ff_dca_vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j], - bitalloc_sizes[i], bitalloc_bits[i][j], bitalloc_codes[i][j]); + ff_dca_bitalloc_sizes[i], ff_dca_bitalloc_bits[i][j], ff_dca_bitalloc_codes[i][j]); } #define LBR_INIT_VLC(vlc, tab, nb_bits) \ @@ -1316,45 +1314,3 @@ av_cold void ff_dca_init_vlcs(void) LBR_INIT_VLC(ff_dca_vlc_grid_3, grid_3, 9); LBR_INIT_VLC(ff_dca_vlc_rsd, rsd, 6); } - -uint32_t ff_dca_vlc_calc_quant_bits(int *values, uint8_t n, uint8_t sel, uint8_t table) -{ - uint8_t i, id; - uint32_t sum = 0; - for (i = 0; i < n; i++) { - id = values[i] - bitalloc_offsets[table]; - av_assert0(id < bitalloc_sizes[table]); - sum += bitalloc_bits[table][sel][id]; - } - return sum; -} - -void ff_dca_vlc_enc_quant(PutBitContext *pb, int *values, uint8_t n, uint8_t sel, uint8_t table) -{ - uint8_t i, id; - for (i = 0; i < n; i++) { - id = values[i] - bitalloc_offsets[table]; - av_assert0(id < bitalloc_sizes[table]); - put_bits(pb, bitalloc_bits[table][sel][id], bitalloc_codes[table][sel][id]); - } -} - -uint32_t ff_dca_vlc_calc_alloc_bits(int *values, uint8_t n, uint8_t sel) -{ - uint8_t i, id; - uint32_t sum = 0; - for (i = 0; i < n; i++) { - id = values[i] - 1; - sum += bitalloc_12_bits[sel][id]; - } - return sum; -} - -void ff_dca_vlc_enc_alloc(PutBitContext *pb, int *values, uint8_t n, uint8_t sel) -{ - uint8_t i, id; - for (i = 0; i < n; i++) { - id = values[i] - 1; - put_bits(pb, bitalloc_12_bits[sel][id], bitalloc_12_codes[sel][id]); - } -} diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index 1f13b6f443..68974d9965 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -27,11 +27,13 @@ #include "libavutil/attributes.h" -#include "put_bits.h" #include "vlc.h" #define DCA_CODE_BOOKS 10 #define DCA_BITALLOC_12_COUNT 5 +#define DCA_NUM_BITALLOC_CODES (1 * 3 + \ + 3 * (5 + 7 + 9 + 13) \ + + 7 * (17 + 25 + 33 + 65 + 129)) typedef struct DCAVLC { int offset; ///< Code values offset @@ -58,10 +60,14 @@ extern VLC ff_dca_vlc_grid_2; extern VLC ff_dca_vlc_grid_3; extern VLC ff_dca_vlc_rsd; +extern const int8_t ff_dca_bitalloc_offsets[DCA_CODE_BOOKS]; +extern const uint8_t ff_dca_bitalloc_sizes[DCA_CODE_BOOKS]; +extern const uint16_t *const ff_dca_bitalloc_codes[DCA_CODE_BOOKS][8]; +extern const uint8_t *const ff_dca_bitalloc_bits[DCA_CODE_BOOKS][8]; + +extern const uint8_t ff_dca_bitalloc_12_bits[DCA_BITALLOC_12_COUNT][12]; +extern const uint16_t ff_dca_bitalloc_12_codes[DCA_BITALLOC_12_COUNT][12]; + av_cold void ff_dca_init_vlcs(void); -uint32_t ff_dca_vlc_calc_quant_bits(int *values, uint8_t n, uint8_t sel, uint8_t abits); -void ff_dca_vlc_enc_quant(PutBitContext *pb, int *values, uint8_t n, uint8_t sel, uint8_t abits); -uint32_t ff_dca_vlc_calc_alloc_bits(int *values, uint8_t n, uint8_t sel); -void ff_dca_vlc_enc_alloc(PutBitContext *pb, int *values, uint8_t n, uint8_t sel); #endif /* AVCODEC_DCAHUFF_H */ From 97610e856a4498c725e51497e287f31b367e5dd7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 02:12:14 +0200 Subject: [PATCH 302/590] avcodec/dcahuff: Combine tables, use ff_init_vlc_from_lengths() Up until now, initializing the dca VLC tables uses ff_init_vlc_sparse() with length tables of type uint8_t and code tables of type uint16_t (except for the LBR tables, which uses length and symbols of type uint8_t; these tables are interleaved). In case of the quant index codebooks these arrays were accessed via tables of pointers to the individual tables. This commit changes this: First, we switch to ff_init_vlc_from_lengths() to replace the uint16_t code tables by uint8_t symbol tables (this necessitates ordering the tables from left-to-right in the tree first). These symbol tables are interleaved with the length tables. Furthermore, these tables are combined in order to remove the table of pointers to individual tables, thereby avoiding relocations (for x64 elf systems this amounts to 96*24B = 2304B saved in .rela.dyn) and saving 1280B from .data.rel.ro (for 64bit systems). Meanwhile the savings in .rodata amount to 2709 + 2 * 334 = 3377B. Due to padding the actual savings are higher: The ELF x64 ABI requires objects >= 16B to be padded to 16B and lots of the tables have 2^n + 1 elements of these were from replacing uint16_t codes with uint8_t symbols; the rest was due to the fact that combining the tables eliminated padding (the ELF x64 ABI requires objects >= 16B to be padded to 16B and lots of the tables have 2^n + 1 elements)). Taking this into account gives savings of 4548B. (GCC by default uses an even higher alignment (controlled by -malign-data); for it the savings are 5748B.) These changes also necessitated to modify the init code for the encoder tables. Signed-off-by: Andreas Rheinhardt --- libavcodec/dcaenc.c | 22 +- libavcodec/dcahuff.c | 1963 ++++++++++++++++-------------------------- libavcodec/dcahuff.h | 6 +- 3 files changed, 766 insertions(+), 1225 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 4a02aa9d46..d0de6d3eee 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -166,30 +166,38 @@ static uint16_t bitalloc_table[DCA_NUM_BITALLOC_CODES][2]; static const uint16_t (*bitalloc_tables[DCA_CODE_BOOKS][8])[2]; static av_cold void create_enc_table(uint16_t dst[][2], unsigned count, - const uint8_t len[], const uint16_t codes[]) + const uint8_t (**src_tablep)[2]) { + const uint8_t (*src_table)[2] = *src_tablep; + uint16_t code = 0; + for (unsigned i = 0; i < count; i++) { - dst[i][0] = codes[i]; - dst[i][1] = len[i]; + unsigned dst_idx = src_table[i][0]; + + dst[dst_idx][0] = code >> (16 - src_table[i][1]); + dst[dst_idx][1] = src_table[i][1]; + + code += 1 << (16 - src_table[i][1]); } + *src_tablep += count; } static av_cold void dcaenc_init_static_tables(void) { uint16_t (*bitalloc_dst)[2] = bitalloc_table; + const uint8_t (*src_table)[2] = ff_dca_vlc_src_tables; for (unsigned i = 0; i < DCA_CODE_BOOKS; i++) { - for (unsigned j = 0; ff_dca_bitalloc_codes[i][j]; j++) { + for (unsigned j = 0; j < ff_dca_quant_index_group_size[i]; j++) { create_enc_table(bitalloc_dst, ff_dca_bitalloc_sizes[i], - ff_dca_bitalloc_bits[i][j], ff_dca_bitalloc_codes[i][j]); + &src_table); bitalloc_tables[i][j] = bitalloc_dst - ff_dca_bitalloc_offsets[i]; bitalloc_dst += ff_dca_bitalloc_sizes[i]; } } for (unsigned i = 0; i < DCA_BITALLOC_12_COUNT; i++) - create_enc_table(&bitalloc_12_table[i][1], 12, - ff_dca_bitalloc_12_bits[i], ff_dca_bitalloc_12_codes[i]); + create_enc_table(&bitalloc_12_table[i][1], 12, &src_table); } static int encode_init(AVCodecContext *avctx) diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index d17b49a089..ee4d4bcd6d 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -24,959 +24,15 @@ #include "libavutil/macros.h" +#include "dcadata.h" #include "dcahuff.h" -#define TMODE_COUNT 4 -static const uint16_t tmode_codes[TMODE_COUNT][4] = { - { 0x0000, 0x0002, 0x0006, 0x0007 }, - { 0x0002, 0x0006, 0x0007, 0x0000 }, - { 0x0006, 0x0007, 0x0000, 0x0002 }, - { 0x0000, 0x0001, 0x0002, 0x0003 } -}; - -static const uint8_t tmode_bits[TMODE_COUNT][4] = { - { 1, 2, 3, 3 }, - { 2, 3, 3, 1 }, - { 3, 3, 1, 2 }, - { 2, 2, 2, 2 } -}; - static const uint8_t bitalloc_12_vlc_bits[DCA_BITALLOC_12_COUNT] = { 9, 7, 7, 9, 9 }; -const uint16_t ff_dca_bitalloc_12_codes[DCA_BITALLOC_12_COUNT][12] = { - { 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, 0x00FF, 0x00FE, - 0x01FB, 0x01FA, 0x01F9, 0x01F8, }, - { 0x0001, 0x0000, 0x0002, 0x000F, 0x000C, 0x001D, 0x0039, 0x0038, - 0x0037, 0x0036, 0x0035, 0x0034, }, - { 0x0000, 0x0007, 0x0005, 0x0004, 0x0002, 0x000D, 0x000C, 0x0006, - 0x000F, 0x001D, 0x0039, 0x0038, }, - { 0x0003, 0x0002, 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, - 0x007E, 0x00FE, 0x01FF, 0x01FE, }, - { 0x0001, 0x0000, 0x0002, 0x0006, 0x000E, 0x003F, 0x003D, 0x007C, - 0x0079, 0x0078, 0x00FB, 0x00FA, } -}; - -const uint8_t ff_dca_bitalloc_12_bits[DCA_BITALLOC_12_COUNT][12] = { - { 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 9, 9 }, - { 1, 2, 3, 5, 5, 6, 7, 7, 7, 7, 7, 7 }, - { 2, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 7 }, - { 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10 }, - { 1, 2, 3, 4, 5, 7, 7, 8, 8, 8, 9, 9 } -}; - -#define SCALES_COUNT 5 #define SCALES_VLC_BITS 9 -static const uint16_t scales_codes[SCALES_COUNT][129] = { - { 0x3AB0, 0x3AB2, 0x3AB4, 0x3AB6, 0x3AB8, 0x3ABA, 0x3ABC, 0x3ABE, - 0x3AC0, 0x3AC2, 0x3AC4, 0x3AC6, 0x3AC8, 0x3ACA, 0x3ACC, 0x3ACE, - 0x3AD0, 0x3AD2, 0x3AD4, 0x3AD6, 0x3AD8, 0x3ADA, 0x3ADC, 0x3ADE, - 0x3AE0, 0x3AE2, 0x3AE4, 0x3AE6, 0x3AE8, 0x3AEA, 0x3AEC, 0x3AEE, - 0x3AF0, 0x3AF2, 0x3AF4, 0x3AF6, 0x3AF8, 0x3AFA, 0x3AFC, 0x3AFE, - 0x0540, 0x0542, 0x0544, 0x0546, 0x0548, 0x054A, 0x054C, 0x054E, - 0x0558, 0x055E, 0x02AD, 0x0154, 0x0754, 0x03A8, 0x0056, 0x0028, - 0x00E8, 0x004A, 0x000B, 0x003B, 0x0013, 0x0003, 0x000F, 0x0005, - 0x0001, 0x0006, 0x0000, 0x0008, 0x001C, 0x0004, 0x0024, 0x004B, - 0x00E9, 0x0029, 0x0057, 0x03A9, 0x0755, 0x0155, 0x02AE, 0x055F, - 0x0559, 0x054F, 0x054D, 0x054B, 0x0549, 0x0547, 0x0545, 0x0543, - 0x0541, 0x3AFF, 0x3AFD, 0x3AFB, 0x3AF9, 0x3AF7, 0x3AF5, 0x3AF3, - 0x3AF1, 0x3AEF, 0x3AED, 0x3AEB, 0x3AE9, 0x3AE7, 0x3AE5, 0x3AE3, - 0x3AE1, 0x3ADF, 0x3ADD, 0x3ADB, 0x3AD9, 0x3AD7, 0x3AD5, 0x3AD3, - 0x3AD1, 0x3ACF, 0x3ACD, 0x3ACB, 0x3AC9, 0x3AC7, 0x3AC5, 0x3AC3, - 0x3AC1, 0x3ABF, 0x3ABD, 0x3ABB, 0x3AB9, 0x3AB7, 0x3AB5, 0x3AB3, - 0x3AB1, }, - { 0x0F60, 0x0F62, 0x0F64, 0x0F66, 0x0F68, 0x0F6A, 0x0F6C, 0x0F6E, - 0x0F70, 0x0F72, 0x0F74, 0x0F76, 0x0F78, 0x0F7A, 0x0F7C, 0x0F7E, - 0x0F80, 0x0F82, 0x0F84, 0x0F86, 0x0F88, 0x0F8A, 0x0F8C, 0x0F8E, - 0x0F90, 0x0F92, 0x0F94, 0x0F96, 0x0F98, 0x0F9A, 0x0F9C, 0x0F9E, - 0x0FA0, 0x0FA2, 0x0FA4, 0x0FA6, 0x0FA8, 0x0FAA, 0x0FAC, 0x0FAE, - 0x0FB0, 0x0FB2, 0x0FB4, 0x0FB6, 0x0FB8, 0x0FBA, 0x0FBC, 0x0FBE, - 0x07A0, 0x07A2, 0x03D2, 0x01EA, 0x00FC, 0x007F, 0x001C, 0x000C, - 0x0004, 0x0034, 0x0010, 0x001B, 0x0009, 0x000B, 0x000E, 0x0001, - 0x0003, 0x0002, 0x000F, 0x000C, 0x000A, 0x0000, 0x0011, 0x0035, - 0x0005, 0x000D, 0x001D, 0x003C, 0x00FD, 0x01EB, 0x03D3, 0x07A3, - 0x07A1, 0x0FBF, 0x0FBD, 0x0FBB, 0x0FB9, 0x0FB7, 0x0FB5, 0x0FB3, - 0x0FB1, 0x0FAF, 0x0FAD, 0x0FAB, 0x0FA9, 0x0FA7, 0x0FA5, 0x0FA3, - 0x0FA1, 0x0F9F, 0x0F9D, 0x0F9B, 0x0F99, 0x0F97, 0x0F95, 0x0F93, - 0x0F91, 0x0F8F, 0x0F8D, 0x0F8B, 0x0F89, 0x0F87, 0x0F85, 0x0F83, - 0x0F81, 0x0F7F, 0x0F7D, 0x0F7B, 0x0F79, 0x0F77, 0x0F75, 0x0F73, - 0x0F71, 0x0F6F, 0x0F6D, 0x0F6B, 0x0F69, 0x0F67, 0x0F65, 0x0F63, - 0x0F61, }, - { 0x51D0, 0x51D2, 0x51D4, 0x51D6, 0x51D8, 0x51DA, 0x51DC, 0x51DE, - 0x51E0, 0x51E2, 0x51E4, 0x51E6, 0x51E8, 0x51EA, 0x51EC, 0x51EE, - 0x51F0, 0x51F2, 0x51F4, 0x51F6, 0x51F8, 0x51FA, 0x51FC, 0x51FE, - 0x70C0, 0x70C2, 0x70C4, 0x70C6, 0x70C8, 0x70CA, 0x70CC, 0x70CE, - 0x70EC, 0x10EA, 0x3868, 0x3877, 0x0876, 0x1C35, 0x0434, 0x0A34, - 0x0E1B, 0x021B, 0x051B, 0x070F, 0x010F, 0x0380, 0x0080, 0x0140, - 0x01C1, 0x0041, 0x00A1, 0x00E2, 0x0022, 0x0052, 0x0072, 0x0012, - 0x002A, 0x003A, 0x000A, 0x0016, 0x001E, 0x0006, 0x000C, 0x0000, - 0x0004, 0x0001, 0x000D, 0x0007, 0x001F, 0x0017, 0x000B, 0x003B, - 0x002B, 0x0013, 0x0073, 0x0053, 0x0023, 0x00E3, 0x00A2, 0x0042, - 0x01C2, 0x0141, 0x0081, 0x0381, 0x028C, 0x010C, 0x051C, 0x021C, - 0x0E1C, 0x0A35, 0x0435, 0x1C3A, 0x0877, 0x0874, 0x3869, 0x10EB, - 0x70ED, 0x70CF, 0x70CD, 0x70CB, 0x70C9, 0x70C7, 0x70C5, 0x70C3, - 0x70C1, 0x51FF, 0x51FD, 0x51FB, 0x51F9, 0x51F7, 0x51F5, 0x51F3, - 0x51F1, 0x51EF, 0x51ED, 0x51EB, 0x51E9, 0x51E7, 0x51E5, 0x51E3, - 0x51E1, 0x51DF, 0x51DD, 0x51DB, 0x51D9, 0x51D7, 0x51D5, 0x51D3, - 0x51D1, }, - { 0x6F64, 0x6F66, 0x6F68, 0x6F6A, 0x6F6C, 0x6F6E, 0x6F70, 0x6F72, - 0x6F74, 0x6F76, 0x6F78, 0x6F7A, 0x6F7C, 0x6F7E, 0x6F80, 0x6F82, - 0x6F84, 0x6F86, 0x6F88, 0x6F8A, 0x6F8C, 0x6F8E, 0x6F90, 0x6F92, - 0x6F94, 0x6F96, 0x6F98, 0x6F9A, 0x6F9C, 0x6F9E, 0x6FA0, 0x6FA2, - 0x6FA4, 0x6FA6, 0x6FA8, 0x6FAA, 0x6FAC, 0x6FAE, 0x6FB0, 0x6FB2, - 0x6FB4, 0x6FB6, 0x17B4, 0x37DC, 0x0BDB, 0x1BEF, 0x05EE, 0x0DF8, - 0x02F8, 0x06FD, 0x017D, 0x037F, 0x00BF, 0x0040, 0x00C0, 0x0021, - 0x0061, 0x0011, 0x0031, 0x0009, 0x0019, 0x0006, 0x000E, 0x0004, - 0x0000, 0x0005, 0x000F, 0x0007, 0x001A, 0x000A, 0x0036, 0x0016, - 0x006E, 0x002E, 0x00C1, 0x0041, 0x01BC, 0x00BC, 0x037A, 0x017A, - 0x02F9, 0x0DF9, 0x05EF, 0x05EC, 0x1BD8, 0x37DD, 0x17B5, 0x6FB7, - 0x6FB5, 0x6FB3, 0x6FB1, 0x6FAF, 0x6FAD, 0x6FAB, 0x6FA9, 0x6FA7, - 0x6FA5, 0x6FA3, 0x6FA1, 0x6F9F, 0x6F9D, 0x6F9B, 0x6F99, 0x6F97, - 0x6F95, 0x6F93, 0x6F91, 0x6F8F, 0x6F8D, 0x6F8B, 0x6F89, 0x6F87, - 0x6F85, 0x6F83, 0x6F81, 0x6F7F, 0x6F7D, 0x6F7B, 0x6F79, 0x6F77, - 0x6F75, 0x6F73, 0x6F71, 0x6F6F, 0x6F6D, 0x6F6B, 0x6F69, 0x6F67, - 0x6F65, }, - { 0xDF54, 0xDF56, 0xDFC8, 0xDFCA, 0xDFCC, 0xDFCE, 0xDFD0, 0xDFD2, - 0xDFD4, 0xDFD6, 0xDFD8, 0xDFDA, 0xDFDC, 0xDFDE, 0xDFE0, 0xDFE2, - 0x0FE8, 0x2FEA, 0x6FA8, 0x6FF6, 0x07F5, 0x07F7, 0x37D2, 0x37F9, - 0x03F8, 0x0BF8, 0x0BFB, 0x1BEB, 0x01FA, 0x05FA, 0x09FA, 0x0DFA, - 0x0DFF, 0x00FF, 0x02FF, 0x06FB, 0x007C, 0x017C, 0x027C, 0x027F, - 0x003C, 0x00BC, 0x013C, 0x01BC, 0x001C, 0x005C, 0x009C, 0x00DC, - 0x000C, 0x002C, 0x004C, 0x006C, 0x0004, 0x0014, 0x0024, 0x0034, - 0x0000, 0x0008, 0x0010, 0x0018, 0x001E, 0x0002, 0x0006, 0x000A, - 0x000E, 0x000B, 0x0007, 0x0003, 0x001F, 0x0019, 0x0011, 0x0009, - 0x0001, 0x0035, 0x0025, 0x0015, 0x0005, 0x006D, 0x004D, 0x002D, - 0x000D, 0x00DD, 0x009D, 0x005D, 0x001D, 0x01BD, 0x013D, 0x00BD, - 0x003D, 0x037C, 0x027D, 0x017D, 0x007D, 0x06FC, 0x04FC, 0x02FC, - 0x00FC, 0x0DFB, 0x09FB, 0x05FB, 0x01FB, 0x1BF8, 0x1BE8, 0x0BF9, - 0x03F9, 0x37FA, 0x37D3, 0x17F4, 0x07F6, 0x6FF7, 0x6FA9, 0x2FEB, - 0x0FE9, 0xDFE3, 0xDFE1, 0xDFDF, 0xDFDD, 0xDFDB, 0xDFD9, 0xDFD7, - 0xDFD5, 0xDFD3, 0xDFD1, 0xDFCF, 0xDFCD, 0xDFCB, 0xDFC9, 0xDF57, - 0xDF55, } -}; - -static const uint8_t scales_bits[SCALES_COUNT][129] = { - { 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 12, 11, 11, 10, 9, 8, - 8, 7, 6, 6, 5, 4, 4, 3, - 2, 3, 3, 4, 5, 5, 6, 7, - 8, 8, 9, 10, 11, 11, 12, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, }, - { 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 14, 14, 13, 12, 11, 10, 8, 7, - 6, 6, 5, 5, 4, 4, 4, 3, - 3, 3, 4, 4, 4, 4, 5, 6, - 6, 7, 8, 9, 11, 12, 13, 14, - 14, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, }, - { 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 14, 14, 14, 13, 13, 12, 12, - 12, 11, 11, 11, 10, 10, 9, 9, - 9, 8, 8, 8, 7, 7, 7, 6, - 6, 6, 5, 5, 5, 4, 4, 3, - 3, 3, 4, 4, 5, 5, 5, 6, - 6, 6, 7, 7, 7, 8, 8, 8, - 9, 9, 9, 10, 10, 10, 11, 11, - 12, 12, 12, 13, 13, 13, 14, 14, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, }, - { 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 14, 14, 13, 13, 12, 12, - 11, 11, 10, 10, 9, 8, 8, 7, - 7, 6, 6, 5, 5, 4, 4, 3, - 2, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, - 11, 12, 12, 12, 13, 14, 14, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, }, - { 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 15, 15, 15, 15, 14, 14, 14, 14, - 13, 13, 13, 13, 12, 12, 12, 12, - 12, 11, 11, 11, 10, 10, 10, 10, - 9, 9, 9, 9, 8, 8, 8, 8, - 7, 7, 7, 7, 6, 6, 6, 6, - 5, 5, 5, 5, 5, 4, 4, 4, - 4, 4, 4, 4, 5, 5, 5, 5, - 5, 6, 6, 6, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 10, 11, 11, 11, - 11, 12, 12, 12, 12, 13, 13, 13, - 13, 14, 14, 14, 14, 15, 15, 15, - 15, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, - } -}; - -static const uint16_t bitalloc_3_codes[3] = { - 0x0003, 0x0000, 0x0002, -}; - -static const uint8_t bitalloc_3_bits[3] = { - 2, 1, 2, -}; - -static const uint16_t bitalloc_5_codes_a[5] = { - 0x000F, 0x0006, 0x0000, 0x0002, 0x000E, -}; - -static const uint16_t bitalloc_5_codes_b[5] = { - 0x0007, 0x0001, 0x0002, 0x0000, 0x0006, -}; - -static const uint16_t bitalloc_5_codes_c[5] = { - 0x0007, 0x0005, 0x0000, 0x0004, 0x0006, -}; - -static const uint8_t bitalloc_5_bits_a[5] = { - 4, 3, 1, 2, 4, -}; - -static const uint8_t bitalloc_5_bits_b[5] = { - 3, 2, 2, 2, 3, -}; - -static const uint8_t bitalloc_5_bits_c[5] = { - 3, 3, 1, 3, 3, -}; - -static const uint16_t bitalloc_7_codes_a[7] = { - 0x001E, 0x000E, 0x0005, 0x0000, 0x0006, 0x0004, 0x001F, -}; - -static const uint16_t bitalloc_7_codes_b[7] = { - 0x0014, 0x000B, 0x0000, 0x0003, 0x0001, 0x0004, 0x0015, -}; - -static const uint16_t bitalloc_7_codes_c[7] = { - 0x0000, 0x0002, 0x0001, 0x0003, 0x0002, 0x0003, 0x0001, -}; - -static const uint8_t bitalloc_7_bits_a[7] = { - 5, 4, 3, 1, 3, 3, 5, -}; - -static const uint8_t bitalloc_7_bits_b[7] = { - 5, 4, 2, 2, 2, 3, 5, -}; - -static const uint8_t bitalloc_7_bits_c[7] = { - 4, 4, 2, 2, 2, 4, 4, -}; - -static const uint16_t bitalloc_9_codes_a[9] = { - 0x0030, 0x0019, 0x0009, 0x0005, 0x0000, 0x0007, 0x000D, 0x0008, - 0x0031, -}; - -static const uint16_t bitalloc_9_codes_b[9] = { - 0x0018, 0x001A, 0x0002, 0x0007, 0x0002, 0x0000, 0x0003, 0x001B, - 0x0019, -}; - -static const uint16_t bitalloc_9_codes_c[9] = { - 0x001C, 0x000F, 0x0002, 0x0007, 0x0002, 0x0000, 0x0006, 0x0006, - 0x001D, -}; - -static const uint8_t bitalloc_9_bits_a[9] = { - 6, 5, 4, 3, 1, 3, 4, 4, 6, -}; - -static const uint8_t bitalloc_9_bits_b[9] = { - 5, 5, 3, 3, 2, 2, 3, 5, 5, -}; - -static const uint8_t bitalloc_9_bits_c[9] = { - 6, 5, 3, 3, 2, 2, 3, 4, 6, -}; - -static const uint16_t bitalloc_13_codes_a[13] = { - 0x0070, 0x002E, 0x0039, 0x001D, 0x000C, 0x000F, 0x0000, 0x0004, - 0x000D, 0x000A, 0x0016, 0x002F, 0x0071, -}; - -static const uint16_t bitalloc_13_codes_b[13] = { - 0x0038, 0x0010, 0x001D, 0x0007, 0x000F, 0x0005, 0x0000, 0x0006, - 0x0002, 0x0009, 0x0006, 0x0011, 0x0039, -}; - -static const uint16_t bitalloc_13_codes_c[13] = { - 0x0004, 0x001A, 0x0003, 0x000E, 0x0000, 0x0003, 0x0005, 0x0004, - 0x0002, 0x000F, 0x000C, 0x001B, 0x0005, -}; - -static const uint8_t bitalloc_13_bits_a[13] = { - 7, 6, 6, 5, 4, 4, 1, 3, 4, 4, 5, 6, 7, -}; - -static const uint8_t bitalloc_13_bits_b[13] = { - 6, 5, 5, 4, 4, 3, 2, 3, 3, 4, 4, 5, 6, -}; - -static const uint8_t bitalloc_13_bits_c[13] = { - 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, -}; - -static const uint16_t bitalloc_17_codes_a[17] = { - 0x0154, 0x00AB, 0x002B, 0x000B, 0x0003, 0x000A, 0x0001, 0x0006, - 0x0001, 0x0007, 0x0004, 0x000B, 0x0000, 0x0004, 0x0014, 0x0054, - 0x0155, -}; - -static const uint16_t bitalloc_17_codes_b[17] = { - 0x007C, 0x003F, 0x0019, 0x000D, 0x001C, 0x0008, 0x000F, 0x0005, - 0x0000, 0x0006, 0x0002, 0x0009, 0x001D, 0x000E, 0x001E, 0x0018, - 0x007D, -}; - -static const uint16_t bitalloc_17_codes_c[17] = { - 0x002C, 0x0017, 0x0005, 0x001C, 0x0003, 0x000A, 0x000F, 0x0003, - 0x0006, 0x0004, 0x0000, 0x000B, 0x0004, 0x001D, 0x000A, 0x0004, - 0x002D, -}; - -static const uint16_t bitalloc_17_codes_d[17] = { - 0x0100, 0x0102, 0x0082, 0x0042, 0x0022, 0x0012, 0x000A, 0x0006, - 0x0000, 0x0007, 0x000B, 0x0013, 0x0023, 0x0043, 0x0083, 0x0103, - 0x0101, -}; - -static const uint16_t bitalloc_17_codes_e[17] = { - 0x00E8, 0x00F6, 0x0075, 0x0034, 0x003B, 0x001B, 0x001F, 0x0004, - 0x0000, 0x0005, 0x000C, 0x001C, 0x003C, 0x0035, 0x007A, 0x00F7, - 0x00E9, -}; - -static const uint16_t bitalloc_17_codes_f[17] = { - 0x0004, 0x0003, 0x001E, 0x0001, 0x0001, 0x000E, 0x0001, 0x0004, - 0x0006, 0x0005, 0x0002, 0x000F, 0x0006, 0x000E, 0x001F, 0x0000, - 0x0005, -}; - -static const uint16_t bitalloc_17_codes_g[17] = { - 0x0060, 0x007E, 0x0031, 0x0019, 0x000D, 0x0004, 0x0000, 0x0006, - 0x0002, 0x0007, 0x0001, 0x0005, 0x000E, 0x001E, 0x003E, 0x007F, - 0x0061, -}; - -static const uint8_t bitalloc_17_bits_a[17] = { - 12, 11, 9, 7, 5, 4, 3, 3, 2, 3, 3, 4, 4, 6, 8, 10, - 12, -}; - -static const uint8_t bitalloc_17_bits_b[17] = { - 8, 7, 6, 5, 5, 4, 4, 3, 2, 3, 3, 4, 5, 5, 6, 6, - 8, -}; - -static const uint8_t bitalloc_17_bits_c[17] = { - 7, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 5, 5, 5, - 7, -}; - -static const uint8_t bitalloc_17_bits_d[17] = { - 9, 9, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, 8, 9, - 9, -}; - -static const uint8_t bitalloc_17_bits_e[17] = { - 8, 8, 7, 6, 6, 5, 5, 3, 1, 3, 4, 5, 6, 6, 7, 8, - 8, -}; - -static const uint8_t bitalloc_17_bits_f[17] = { - 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, - 8, -}; - -static const uint8_t bitalloc_17_bits_g[17] = { - 8, 8, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4, 5, 6, 7, 8, - 8, -}; - -static const uint16_t bitalloc_25_codes_a[25] = { - 0x2854, 0x142B, 0x050B, 0x0143, 0x00A2, 0x0052, 0x002E, 0x0015, - 0x0004, 0x000E, 0x0000, 0x0003, 0x0006, 0x0004, 0x0001, 0x000F, - 0x0005, 0x0016, 0x002F, 0x0053, 0x00A3, 0x00A0, 0x0284, 0x0A14, - 0x2855, -}; - -static const uint16_t bitalloc_25_codes_b[25] = { - 0x001C, 0x000F, 0x0005, 0x0000, 0x0030, 0x0036, 0x000E, 0x0019, - 0x0001, 0x0008, 0x000E, 0x0001, 0x0005, 0x0002, 0x000F, 0x0009, - 0x0006, 0x001A, 0x000F, 0x0037, 0x0031, 0x0001, 0x0006, 0x0004, - 0x001D, -}; - -static const uint16_t bitalloc_25_codes_c[25] = { - 0x004C, 0x0027, 0x006D, 0x0028, 0x0037, 0x000E, 0x0015, 0x0000, - 0x0005, 0x0008, 0x000B, 0x000E, 0x0001, 0x000F, 0x000C, 0x0009, - 0x0006, 0x0001, 0x001A, 0x000F, 0x0008, 0x0029, 0x0012, 0x006C, - 0x004D, -}; - -static const uint16_t bitalloc_25_codes_d[25] = { - 0x0780, 0x0782, 0x03C2, 0x01E2, 0x00FE, 0x0079, 0x003D, 0x001C, - 0x000C, 0x0004, 0x0000, 0x0006, 0x0002, 0x0007, 0x0001, 0x0005, - 0x000D, 0x001D, 0x003E, 0x007E, 0x00FF, 0x01E3, 0x03C3, 0x0783, - 0x0781, -}; - -static const uint16_t bitalloc_25_codes_e[25] = { - 0x003C, 0x0092, 0x0018, 0x001F, 0x004E, 0x000D, 0x0025, 0x0004, - 0x0010, 0x0000, 0x000A, 0x0002, 0x0003, 0x0003, 0x000B, 0x0001, - 0x0011, 0x0005, 0x0026, 0x000E, 0x004F, 0x0048, 0x0019, 0x0093, - 0x003D, -}; - -static const uint16_t bitalloc_25_codes_f[25] = { - 0x0324, 0x0193, 0x00CE, 0x0065, 0x0024, 0x000C, 0x0013, 0x0004, - 0x0007, 0x000A, 0x000D, 0x000F, 0x0001, 0x0000, 0x000E, 0x000B, - 0x0008, 0x0005, 0x0018, 0x000D, 0x0025, 0x0066, 0x00CF, 0x00C8, - 0x0325, -}; - -static const uint16_t bitalloc_25_codes_g[25] = { - 0x03A8, 0x03AE, 0x01D5, 0x0094, 0x0014, 0x004B, 0x000B, 0x003B, - 0x0013, 0x0003, 0x000F, 0x0005, 0x0001, 0x0006, 0x0000, 0x0008, - 0x001C, 0x0004, 0x0024, 0x0074, 0x0015, 0x0095, 0x01D6, 0x03AF, - 0x03A9, -}; - -static const uint8_t bitalloc_25_bits_a[25] = { - 14, 13, 11, 9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 4, - 4, 5, 6, 7, 8, 8, 10, 12, 14, -}; - -static const uint8_t bitalloc_25_bits_b[25] = { - 9, 8, 7, 6, 6, 6, 5, 5, 4, 4, 4, 3, 3, 3, 4, 4, - 4, 5, 5, 6, 6, 6, 7, 7, 9, -}; - -static const uint8_t bitalloc_25_bits_c[25] = { - 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 4, 4, 3, 4, 4, 4, - 4, 4, 5, 5, 5, 6, 6, 7, 8, -}; - -static const uint8_t bitalloc_25_bits_d[25] = { - 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 12, -}; - -static const uint8_t bitalloc_25_bits_e[25] = { - 8, 8, 7, 7, 7, 6, 6, 5, 5, 4, 4, 3, 2, 3, 4, 4, - 5, 5, 6, 6, 7, 7, 7, 8, 8, -}; - -static const uint8_t bitalloc_25_bits_f[25] = { - 10, 9, 8, 7, 6, 5, 5, 4, 4, 4, 4, 4, 3, 3, 4, 4, - 4, 4, 5, 5, 6, 7, 8, 8, 10, -}; - -static const uint8_t bitalloc_25_bits_g[25] = { - 10, 10, 9, 8, 7, 7, 6, 6, 5, 4, 4, 3, 2, 3, 3, 4, - 5, 5, 6, 7, 7, 8, 9, 10, 10, -}; - -static const uint16_t bitalloc_33_codes_a[33] = { - 0x1580, 0x1582, 0x0AC2, 0x0562, 0x02B2, 0x015E, 0x00AD, 0x0054, - 0x001C, 0x003C, 0x000F, 0x001F, 0x0008, 0x000B, 0x000D, 0x0000, - 0x0002, 0x0001, 0x000E, 0x000C, 0x0009, 0x0006, 0x0014, 0x003D, - 0x001D, 0x0055, 0x00AE, 0x015F, 0x02B3, 0x0563, 0x0AC3, 0x1583, - 0x1581, -}; - -static const uint16_t bitalloc_33_codes_b[33] = { - 0x030C, 0x0187, 0x006D, 0x0028, 0x0037, 0x0066, 0x0015, 0x0031, - 0x0000, 0x000B, 0x0012, 0x001A, 0x0001, 0x0007, 0x000A, 0x000E, - 0x0001, 0x000F, 0x000B, 0x0008, 0x0004, 0x001B, 0x0013, 0x000C, - 0x0001, 0x0032, 0x001A, 0x0067, 0x0060, 0x0029, 0x00C2, 0x006C, - 0x030D, -}; - -static const uint16_t bitalloc_33_codes_c[33] = { - 0x00CC, 0x0067, 0x0005, 0x0070, 0x0003, 0x001A, 0x0039, 0x003F, - 0x000A, 0x0012, 0x0018, 0x001D, 0x0001, 0x0003, 0x0007, 0x000A, - 0x000D, 0x000B, 0x0008, 0x0004, 0x0002, 0x001E, 0x0019, 0x0013, - 0x000B, 0x0000, 0x003E, 0x001B, 0x0018, 0x0071, 0x0032, 0x0004, - 0x00CD, -}; - -static const uint16_t bitalloc_33_codes_d[33] = { - 0x3AF8, 0x3AFA, 0x1D7E, 0x0EBC, 0x075C, 0x03AC, 0x01D4, 0x0094, - 0x0014, 0x004B, 0x000B, 0x003B, 0x0013, 0x0003, 0x000F, 0x0005, - 0x0001, 0x0006, 0x0000, 0x0008, 0x001C, 0x0004, 0x0024, 0x0074, - 0x0015, 0x0095, 0x01D5, 0x03AD, 0x075D, 0x0EBD, 0x1D7F, 0x3AFB, - 0x3AF9, -}; - -static const uint16_t bitalloc_33_codes_e[33] = { - 0x01C8, 0x01E6, 0x0064, 0x00E2, 0x00E5, 0x0030, 0x0033, 0x0073, - 0x007A, 0x001A, 0x003A, 0x0002, 0x001A, 0x001F, 0x0007, 0x0001, - 0x0002, 0x0002, 0x000C, 0x0000, 0x001B, 0x0003, 0x003B, 0x001B, - 0x007B, 0x0078, 0x0070, 0x0031, 0x00F2, 0x00E3, 0x0065, 0x01E7, - 0x01C9, -}; - -static const uint16_t bitalloc_33_codes_f[33] = { - 0x0724, 0x0393, 0x01CE, 0x00E5, 0x002C, 0x0008, 0x0017, 0x003E, - 0x0005, 0x0014, 0x001D, 0x0000, 0x0003, 0x0006, 0x0008, 0x000B, - 0x000D, 0x000C, 0x0009, 0x0007, 0x0004, 0x0001, 0x001E, 0x0015, - 0x000A, 0x003F, 0x0038, 0x0009, 0x002D, 0x00E6, 0x01CF, 0x01C8, - 0x0725, -}; - -static const uint16_t bitalloc_33_codes_g[33] = { - 0x0284, 0x0042, 0x0140, 0x0143, 0x003E, 0x00BE, 0x0011, 0x0051, - 0x0009, 0x0029, 0x0005, 0x0015, 0x0000, 0x0008, 0x000E, 0x0002, - 0x0006, 0x0003, 0x000F, 0x0009, 0x0001, 0x0016, 0x0006, 0x002E, - 0x000E, 0x005E, 0x001E, 0x00BF, 0x003F, 0x0020, 0x0141, 0x0043, - 0x0285, -}; - -static const uint8_t bitalloc_33_bits_a[33] = { - 13, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4, 3, - 3, 3, 4, 4, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, - 13, -}; - -static const uint8_t bitalloc_33_bits_b[33] = { - 10, 9, 8, 7, 7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, - 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, - 10, -}; - -static const uint8_t bitalloc_33_bits_c[33] = { - 9, 8, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, - 9, -}; - -static const uint8_t bitalloc_33_bits_d[33] = { - 14, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 5, 4, 4, 3, - 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, - 14, -}; - -static const uint8_t bitalloc_33_bits_e[33] = { - 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 5, 5, 5, 4, 3, - 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, - 9, -}; - -static const uint8_t bitalloc_33_bits_f[33] = { - 11, 10, 9, 8, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9, - 11, -}; - -static const uint8_t bitalloc_33_bits_g[33] = { - 10, 9, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3, - 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9, - 10, -}; - -static const uint16_t bitalloc_65_codes_a[65] = { - 0x9E5C, 0x9E5E, 0x4F2C, 0x2794, 0x13C4, 0x1E44, 0x09E3, 0x0F23, - 0x04F3, 0x0792, 0x027E, 0x03CE, 0x013D, 0x01E5, 0x009C, 0x00CC, - 0x0040, 0x0058, 0x0067, 0x001E, 0x0021, 0x002D, 0x003D, 0x0007, - 0x0011, 0x0014, 0x0017, 0x001A, 0x001C, 0x001F, 0x0001, 0x0004, - 0x0006, 0x0005, 0x0002, 0x0000, 0x001D, 0x001B, 0x0018, 0x0015, - 0x0012, 0x000E, 0x0006, 0x0032, 0x0026, 0x001F, 0x0078, 0x0059, - 0x0041, 0x00CD, 0x009D, 0x01E6, 0x013E, 0x03CF, 0x027F, 0x0793, - 0x0790, 0x04F0, 0x09E4, 0x1E45, 0x13C5, 0x2795, 0x4F2D, 0x9E5F, - 0x9E5D, -}; - -static const uint16_t bitalloc_65_codes_b[65] = { - 0x0A8C, 0x0547, 0x01B5, 0x0008, 0x00DB, 0x0152, 0x0005, 0x000B, - 0x008E, 0x00AE, 0x00E4, 0x0003, 0x0037, 0x0039, 0x0055, 0x006C, - 0x0073, 0x0003, 0x0015, 0x001D, 0x0028, 0x0030, 0x0037, 0x003E, - 0x0006, 0x000B, 0x000F, 0x0012, 0x0016, 0x0019, 0x001D, 0x0001, - 0x0004, 0x0002, 0x001E, 0x001A, 0x0017, 0x0013, 0x0010, 0x000C, - 0x0007, 0x003F, 0x0038, 0x0031, 0x0029, 0x0022, 0x001A, 0x0014, - 0x0000, 0x006D, 0x0056, 0x0046, 0x0038, 0x0004, 0x00E5, 0x00AF, - 0x008F, 0x006C, 0x000A, 0x0153, 0x0150, 0x0009, 0x02A2, 0x01B4, - 0x0A8D, -}; - -static const uint16_t bitalloc_65_codes_c[65] = { - 0x045C, 0x022F, 0x03F5, 0x01BC, 0x01FB, 0x0059, 0x00D0, 0x00DF, - 0x000A, 0x002D, 0x002F, 0x0052, 0x0069, 0x0078, 0x007F, 0x000A, - 0x0010, 0x001C, 0x0023, 0x002A, 0x0035, 0x003A, 0x003D, 0x0000, - 0x0003, 0x0006, 0x0009, 0x000C, 0x000F, 0x0012, 0x0016, 0x0018, - 0x001C, 0x0019, 0x0017, 0x0013, 0x0010, 0x000D, 0x000A, 0x0007, - 0x0004, 0x0001, 0x003E, 0x003B, 0x0036, 0x002B, 0x0028, 0x001D, - 0x0011, 0x000B, 0x0004, 0x0079, 0x006E, 0x0053, 0x0044, 0x002E, - 0x000B, 0x00FC, 0x00D1, 0x008A, 0x0058, 0x01BD, 0x0116, 0x03F4, - 0x045D, -}; - -static const uint16_t bitalloc_65_codes_d[65] = { - 0x70B0, 0x70B2, 0x70B4, 0x2852, 0x385B, 0x142E, 0x1C2E, 0x0A15, - 0x0E14, 0x0214, 0x0704, 0x0104, 0x010B, 0x0383, 0x0083, 0x0143, - 0x01C3, 0x0043, 0x00A2, 0x00E2, 0x0022, 0x0052, 0x0072, 0x0012, - 0x002A, 0x003A, 0x000A, 0x0016, 0x001E, 0x0006, 0x000C, 0x0000, - 0x0004, 0x0001, 0x000D, 0x0007, 0x001F, 0x0017, 0x000B, 0x003B, - 0x002B, 0x0013, 0x0073, 0x0053, 0x0023, 0x00E3, 0x00A3, 0x00A0, - 0x0040, 0x01C0, 0x0084, 0x0384, 0x0284, 0x0105, 0x0705, 0x0215, - 0x0E15, 0x0A16, 0x1C2F, 0x142F, 0x1428, 0x2853, 0x70B5, 0x70B3, - 0x70B1, -}; - -static const uint16_t bitalloc_65_codes_e[65] = { - 0x032C, 0x0332, 0x0378, 0x037E, 0x008C, 0x014A, 0x0188, 0x0197, - 0x019E, 0x01BD, 0x0044, 0x0047, 0x00AA, 0x00C5, 0x00CD, 0x00DC, - 0x001C, 0x002C, 0x0053, 0x0063, 0x0068, 0x0008, 0x000F, 0x0017, - 0x002B, 0x0035, 0x0005, 0x0009, 0x0016, 0x001C, 0x0006, 0x000F, - 0x0004, 0x0000, 0x0007, 0x001D, 0x0017, 0x000A, 0x0006, 0x0036, - 0x0030, 0x0028, 0x0010, 0x0009, 0x0069, 0x0064, 0x0054, 0x002D, - 0x001D, 0x00DD, 0x00CE, 0x00CA, 0x00AB, 0x00A4, 0x0045, 0x01BE, - 0x019F, 0x0198, 0x0189, 0x014B, 0x008D, 0x037F, 0x0379, 0x0333, - 0x032D, -}; - -static const uint16_t bitalloc_65_codes_f[65] = { - 0x0FE0, 0x0FE2, 0x0FE8, 0x0FEA, 0x0FEC, 0x0FEE, 0x0FF0, 0x0FF2, - 0x0FF4, 0x2FF2, 0x07F2, 0x07FB, 0x03F6, 0x0BFA, 0x0BFD, 0x01FF, - 0x05FF, 0x02FC, 0x007C, 0x017C, 0x003C, 0x00BC, 0x001C, 0x005C, - 0x000C, 0x002C, 0x0004, 0x0014, 0x0000, 0x0008, 0x000E, 0x0002, - 0x0006, 0x0003, 0x000F, 0x0009, 0x0001, 0x0015, 0x0005, 0x002D, - 0x000D, 0x005D, 0x001D, 0x00BD, 0x003D, 0x017D, 0x007D, 0x02FD, - 0x00FC, 0x05FC, 0x01FA, 0x0BFB, 0x03F7, 0x17F8, 0x07F3, 0x2FF3, - 0x0FF5, 0x0FF3, 0x0FF1, 0x0FEF, 0x0FED, 0x0FEB, 0x0FE9, 0x0FE3, - 0x0FE1, -}; - -static const uint16_t bitalloc_65_codes_g[65] = { - 0x010C, 0x038A, 0x0608, 0x0786, 0x0084, 0x0087, 0x0302, 0x0305, - 0x0040, 0x00E0, 0x00E3, 0x0183, 0x001E, 0x005E, 0x009E, 0x00DE, - 0x00F1, 0x0011, 0x0039, 0x0061, 0x0079, 0x0009, 0x001D, 0x0031, - 0x003D, 0x0005, 0x000F, 0x0019, 0x001F, 0x0003, 0x0006, 0x000A, - 0x000E, 0x000B, 0x0008, 0x0004, 0x0000, 0x001A, 0x0012, 0x000A, - 0x0002, 0x0036, 0x0026, 0x0016, 0x0006, 0x006E, 0x004E, 0x002E, - 0x000E, 0x00DF, 0x009F, 0x005F, 0x001F, 0x01E0, 0x0180, 0x00E1, - 0x0041, 0x03C2, 0x0303, 0x01C4, 0x0085, 0x0787, 0x0609, 0x038B, - 0x010D, -}; - -static const uint8_t bitalloc_65_bits_a[65] = { - 16, 16, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, - 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4, - 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, - 7, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 13, 13, 14, 15, 16, - 16, -}; - -static const uint8_t bitalloc_65_bits_b[65] = { - 12, 11, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, - 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, - 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, - 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 10, 10, - 12, -}; - -static const uint8_t bitalloc_65_bits_c[65] = { - 11, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, - 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 10, - 11, -}; - -static const uint8_t bitalloc_65_bits_d[65] = { - 15, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9, - 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 3, - 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, - 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 15, 15, - 15, -}; - -static const uint8_t bitalloc_65_bits_e[65] = { - 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, - 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, - 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, - 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, - 10, -}; - -static const uint8_t bitalloc_65_bits_f[65] = { - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 12, 12, 12, 11, - 11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3, - 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, - 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, -}; - -static const uint8_t bitalloc_65_bits_g[65] = { - 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, - 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, - 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, - 11, -}; - -static const uint16_t bitalloc_129_codes_a[129] = { - 0x0660, 0x0666, 0x06EC, 0x0722, 0x0760, 0x076E, 0x004C, 0x004E, - 0x00F4, 0x010A, 0x0148, 0x0156, 0x01D4, 0x01F2, 0x0331, 0x0370, - 0x0377, 0x0396, 0x03B1, 0x0024, 0x0064, 0x007B, 0x008A, 0x00A5, - 0x00D4, 0x00EB, 0x00FA, 0x019A, 0x01B9, 0x01C9, 0x01D9, 0x0010, - 0x0030, 0x0033, 0x0043, 0x0053, 0x006B, 0x007A, 0x00CA, 0x00D2, - 0x00DE, 0x00E6, 0x00F6, 0x000E, 0x001F, 0x0023, 0x002B, 0x003B, - 0x003F, 0x0067, 0x0070, 0x0077, 0x0005, 0x000D, 0x0012, 0x001B, - 0x002C, 0x0035, 0x003A, 0x0004, 0x000B, 0x0017, 0x001F, 0x0009, - 0x0008, 0x000A, 0x0000, 0x0018, 0x000C, 0x0005, 0x003C, 0x0036, - 0x002D, 0x001C, 0x0013, 0x000E, 0x0006, 0x007A, 0x0071, 0x0068, - 0x0064, 0x003C, 0x0034, 0x0028, 0x0020, 0x000F, 0x00F7, 0x00E7, - 0x00DF, 0x00D3, 0x00CB, 0x007B, 0x0074, 0x0054, 0x0044, 0x003C, - 0x0031, 0x0011, 0x01DA, 0x01CA, 0x01BA, 0x019B, 0x00FB, 0x00F8, - 0x00D5, 0x00AA, 0x008B, 0x0084, 0x0065, 0x0025, 0x03B6, 0x0397, - 0x0390, 0x0371, 0x0332, 0x01F3, 0x01D5, 0x0157, 0x0149, 0x010B, - 0x00F5, 0x004F, 0x004D, 0x076F, 0x0761, 0x0723, 0x06ED, 0x0667, - 0x0661, -}; - -static const uint16_t bitalloc_129_codes_b[129] = { - 0x29DC, 0x14EF, 0x0455, 0x0E9C, 0x022B, 0x0489, 0x0740, 0x074F, - 0x0172, 0x0245, 0x0247, 0x030A, 0x03A1, 0x001C, 0x008B, 0x00D6, - 0x010C, 0x0148, 0x014F, 0x0186, 0x01D1, 0x0008, 0x000F, 0x0046, - 0x005D, 0x0078, 0x0087, 0x0096, 0x00A5, 0x00BC, 0x00D8, 0x00DE, - 0x00F6, 0x0005, 0x0014, 0x0024, 0x002F, 0x003A, 0x003D, 0x0049, - 0x0050, 0x0058, 0x005F, 0x0066, 0x006D, 0x0075, 0x007C, 0x0004, - 0x000B, 0x0013, 0x0018, 0x001B, 0x001F, 0x0022, 0x0026, 0x002A, - 0x002D, 0x0031, 0x0034, 0x0038, 0x003B, 0x003F, 0x0003, 0x0006, - 0x000A, 0x0007, 0x0004, 0x0000, 0x003C, 0x0039, 0x0035, 0x0032, - 0x002E, 0x002B, 0x0027, 0x0023, 0x0020, 0x001C, 0x0019, 0x0016, - 0x0010, 0x0005, 0x007D, 0x007A, 0x006E, 0x0067, 0x0060, 0x0059, - 0x0051, 0x004A, 0x0042, 0x003B, 0x0034, 0x0025, 0x0015, 0x0006, - 0x00F7, 0x00DF, 0x00D9, 0x00BD, 0x00A6, 0x0097, 0x0090, 0x0079, - 0x006A, 0x0047, 0x0044, 0x0009, 0x01D2, 0x0187, 0x0184, 0x0149, - 0x010D, 0x00D7, 0x00B8, 0x001D, 0x03A6, 0x030B, 0x029C, 0x0246, - 0x0173, 0x0114, 0x0741, 0x053A, 0x0488, 0x0E9D, 0x0A76, 0x0454, - 0x29DD, -}; - -static const uint16_t bitalloc_129_codes_c[129] = { - 0x0E5C, 0x072F, 0x001D, 0x0724, 0x000F, 0x010D, 0x0324, 0x0393, - 0x03E9, 0x0080, 0x0087, 0x00FA, 0x0164, 0x0193, 0x01DE, 0x01F5, - 0x0010, 0x002A, 0x0041, 0x0064, 0x0073, 0x008E, 0x00A4, 0x00B3, - 0x00D6, 0x00E5, 0x00F4, 0x00FB, 0x0002, 0x0009, 0x0013, 0x001E, - 0x0026, 0x002C, 0x0033, 0x003F, 0x0041, 0x004C, 0x0053, 0x005E, - 0x0065, 0x0070, 0x0073, 0x0078, 0x007B, 0x007E, 0x0002, 0x0005, - 0x0007, 0x000B, 0x000D, 0x0011, 0x0014, 0x0017, 0x001A, 0x001D, - 0x0021, 0x0024, 0x0027, 0x002A, 0x002D, 0x0030, 0x0033, 0x0036, - 0x003A, 0x0037, 0x0034, 0x0031, 0x002E, 0x002B, 0x0028, 0x0025, - 0x0022, 0x001E, 0x001B, 0x0018, 0x0015, 0x0012, 0x000E, 0x000C, - 0x0008, 0x0006, 0x0003, 0x007F, 0x007C, 0x0079, 0x0076, 0x0071, - 0x006A, 0x005F, 0x0058, 0x004D, 0x0046, 0x0040, 0x0038, 0x002D, - 0x0027, 0x001F, 0x0014, 0x0012, 0x0003, 0x0000, 0x00F5, 0x00EE, - 0x00D7, 0x00C8, 0x00A5, 0x008F, 0x007C, 0x0065, 0x0042, 0x002B, - 0x0011, 0x0002, 0x01DF, 0x01C8, 0x0165, 0x00FB, 0x00E4, 0x0081, - 0x0006, 0x03E8, 0x0325, 0x01CA, 0x010C, 0x0725, 0x0396, 0x001C, - 0x0E5D, -}; - -static const uint16_t bitalloc_129_codes_d[129] = { - 0xA598, 0xA59A, 0xA59C, 0xA59E, 0xC598, 0xE586, 0x3ACC, 0x52CA, - 0x62CD, 0x0D48, 0x1D67, 0x2978, 0x3167, 0x3966, 0x06A5, 0x0EBC, - 0x14BD, 0x1CB1, 0x0350, 0x0353, 0x075F, 0x0A5F, 0x0C5E, 0x0E5E, - 0x01AE, 0x03AD, 0x052D, 0x062D, 0x072D, 0x00D5, 0x01D4, 0x0294, - 0x0314, 0x0394, 0x0014, 0x0094, 0x0114, 0x0174, 0x01B4, 0x01F4, - 0x000B, 0x004B, 0x008B, 0x00BB, 0x00DB, 0x00FB, 0x001B, 0x003B, - 0x0053, 0x0063, 0x0073, 0x0003, 0x0013, 0x0023, 0x002F, 0x0037, - 0x003F, 0x0007, 0x000F, 0x0015, 0x0019, 0x001D, 0x0001, 0x0005, - 0x0009, 0x0006, 0x0002, 0x001E, 0x001A, 0x0016, 0x0010, 0x0008, - 0x0000, 0x0038, 0x0030, 0x0028, 0x001C, 0x000C, 0x007C, 0x006C, - 0x005C, 0x0044, 0x0024, 0x0004, 0x00E4, 0x00C4, 0x00A4, 0x0074, - 0x0034, 0x01F5, 0x01B5, 0x0175, 0x0115, 0x0095, 0x0015, 0x0395, - 0x0315, 0x0295, 0x01D5, 0x00D6, 0x072E, 0x062E, 0x052E, 0x03AE, - 0x01AF, 0x0E5F, 0x0C5F, 0x0C58, 0x0A58, 0x0758, 0x0351, 0x1CB2, - 0x18B2, 0x0EBD, 0x0EB2, 0x3967, 0x3960, 0x2979, 0x2964, 0x0D49, - 0x72C2, 0x52CB, 0x3ACD, 0xE587, 0xC599, 0xA59F, 0xA59D, 0xA59B, - 0xA599, -}; - -static const uint16_t bitalloc_129_codes_e[129] = { - 0xA13C, 0xC720, 0xA13F, 0xA13E, 0xA13D, 0xE722, 0x5090, 0x6393, - 0x7392, 0x2849, 0x31CE, 0x39CE, 0x1425, 0x18E5, 0x1CE5, 0x0844, - 0x0A1C, 0x0C7C, 0x036C, 0x0423, 0x050F, 0x063F, 0x01B7, 0x0216, - 0x0285, 0x031D, 0x039D, 0x0109, 0x0140, 0x0180, 0x01C8, 0x01CF, - 0x007A, 0x008A, 0x00A2, 0x00C1, 0x00E5, 0x0014, 0x0037, 0x0043, - 0x004E, 0x0056, 0x0061, 0x006C, 0x007C, 0x000B, 0x001C, 0x001F, - 0x0023, 0x0025, 0x0029, 0x002C, 0x002E, 0x0032, 0x0034, 0x0037, - 0x003A, 0x003C, 0x003F, 0x0001, 0x0003, 0x0006, 0x0008, 0x000A, - 0x000C, 0x000B, 0x0009, 0x0007, 0x0004, 0x0002, 0x0000, 0x003D, - 0x003B, 0x0038, 0x0035, 0x0033, 0x002F, 0x002D, 0x002A, 0x0026, - 0x0024, 0x0020, 0x001D, 0x001A, 0x007D, 0x006D, 0x0062, 0x0057, - 0x004F, 0x0044, 0x003C, 0x0015, 0x00E6, 0x00C6, 0x00A3, 0x008B, - 0x007B, 0x006C, 0x01C9, 0x0181, 0x0141, 0x010A, 0x00DA, 0x031E, - 0x0286, 0x0217, 0x0210, 0x0738, 0x0638, 0x0508, 0x036D, 0x0C7D, - 0x0A1D, 0x0845, 0x1CE6, 0x18E6, 0x1426, 0x39CF, 0x31CF, 0x284E, - 0x7393, 0x7390, 0x5091, 0xE723, 0xC724, 0xC725, 0xC722, 0xC723, - 0xC721, -}; - -static const uint16_t bitalloc_129_codes_f[129] = { - 0x762C, 0x3B17, 0x1555, 0x0608, 0x0AAB, 0x0FF2, 0x0305, 0x0307, - 0x0763, 0x0046, 0x010C, 0x01BC, 0x02AB, 0x03B6, 0x03FD, 0x0080, - 0x0087, 0x00DF, 0x0156, 0x01D9, 0x01F8, 0x01FF, 0x002A, 0x0041, - 0x0061, 0x0094, 0x00D4, 0x00EA, 0x00F2, 0x00FD, 0x0009, 0x000B, - 0x001A, 0x0026, 0x0031, 0x0040, 0x004B, 0x006B, 0x0073, 0x0077, - 0x007A, 0x007C, 0x0000, 0x0002, 0x0006, 0x0008, 0x000B, 0x000E, - 0x0011, 0x0014, 0x0016, 0x0019, 0x001C, 0x001E, 0x0021, 0x0023, - 0x0026, 0x0028, 0x002B, 0x002D, 0x002F, 0x0031, 0x0033, 0x0036, - 0x0038, 0x0037, 0x0034, 0x0032, 0x0030, 0x002E, 0x002C, 0x0029, - 0x0027, 0x0024, 0x0022, 0x001F, 0x001D, 0x001A, 0x0017, 0x0015, - 0x0012, 0x000F, 0x000C, 0x0009, 0x0007, 0x0003, 0x0001, 0x007D, - 0x007B, 0x0078, 0x0074, 0x0072, 0x0054, 0x0041, 0x0036, 0x0027, - 0x001B, 0x0014, 0x000A, 0x00FE, 0x00F3, 0x00EB, 0x00D5, 0x0095, - 0x006E, 0x0042, 0x002B, 0x0010, 0x01F9, 0x01DA, 0x0157, 0x0154, - 0x00C0, 0x0081, 0x0022, 0x03B7, 0x03B0, 0x01BD, 0x010D, 0x0047, - 0x07F8, 0x0554, 0x0306, 0x0FF3, 0x0EC4, 0x0609, 0x1D8A, 0x1554, - 0x762D, -}; - -static const uint16_t bitalloc_129_codes_g[129] = { - 0x1E20, 0x1E5E, 0x031C, 0x051A, 0x0718, 0x0916, 0x0B14, 0x0D12, - 0x0F11, 0x0090, 0x018F, 0x028E, 0x038D, 0x048C, 0x058B, 0x068A, - 0x0789, 0x0049, 0x00C8, 0x0148, 0x01C7, 0x0247, 0x02C6, 0x0346, - 0x03C5, 0x0025, 0x0065, 0x00A5, 0x00E4, 0x0124, 0x0164, 0x01A4, - 0x01E3, 0x0013, 0x0033, 0x0053, 0x0073, 0x0093, 0x00B3, 0x00D3, - 0x00F3, 0x000A, 0x001A, 0x002A, 0x003A, 0x004A, 0x005A, 0x006A, - 0x007A, 0x0006, 0x000E, 0x0016, 0x001E, 0x0026, 0x002E, 0x0036, - 0x003E, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, - 0x0000, 0x001D, 0x0019, 0x0015, 0x0011, 0x000D, 0x0009, 0x0005, - 0x003F, 0x0037, 0x002F, 0x0027, 0x001F, 0x0017, 0x000F, 0x0007, - 0x007B, 0x006B, 0x005B, 0x004B, 0x003B, 0x002B, 0x001B, 0x000B, - 0x0008, 0x00F0, 0x00D0, 0x00B0, 0x0090, 0x0070, 0x0050, 0x0030, - 0x01E4, 0x01A5, 0x0165, 0x0125, 0x00E5, 0x00E2, 0x00A2, 0x0062, - 0x03CA, 0x0347, 0x02C7, 0x02C4, 0x0244, 0x0149, 0x00C9, 0x00C6, - 0x0796, 0x068B, 0x0688, 0x048D, 0x048A, 0x028F, 0x028C, 0x0091, - 0x0F2E, 0x0D13, 0x0B15, 0x0917, 0x0719, 0x051B, 0x031D, 0x1E5F, - 0x1E21, -}; - -static const uint8_t bitalloc_129_bits_a[129] = { - 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4, - 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, - 11, -}; - -static const uint8_t bitalloc_129_bits_b[129] = { - 14, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, - 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, - 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, - 14, -}; - -static const uint8_t bitalloc_129_bits_c[129] = { - 13, 12, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, - 13, -}; - -static const uint8_t bitalloc_129_bits_d[129] = { - 16, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, - 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10, - 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, - 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, - 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, - 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, - 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16, - 16, -}; - -static const uint8_t bitalloc_129_bits_e[129] = { - 16, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, - 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, - 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, - 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16, - 16, -}; - -static const uint8_t bitalloc_129_bits_f[129] = { - 15, 14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9, - 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, - 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, - 15, -}; - -static const uint8_t bitalloc_129_bits_g[129] = { - 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, - 11, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, - 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, - 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, - 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13, - 13, -}; +static const uint8_t tnl_grp_sizes[] = { 37, 34, 31, 28, 23 }; const uint8_t ff_dca_bitalloc_sizes[DCA_CODE_BOOKS] = { 3, 5, 7, 9, 13, 17, 25, 33, 65, 129 @@ -999,234 +55,717 @@ static const uint8_t bitalloc_maxbits[DCA_CODE_BOOKS][7] = { { 9, 9, 9, 9, 9, 9, 9 } }; -const uint16_t *const ff_dca_bitalloc_codes[DCA_CODE_BOOKS][8] = { - { bitalloc_3_codes, NULL }, - { bitalloc_5_codes_a, bitalloc_5_codes_b, bitalloc_5_codes_c, NULL }, - { bitalloc_7_codes_a, bitalloc_7_codes_b, bitalloc_7_codes_c, NULL }, - { bitalloc_9_codes_a, bitalloc_9_codes_b, bitalloc_9_codes_c, NULL }, - { bitalloc_13_codes_a, bitalloc_13_codes_b, bitalloc_13_codes_c, NULL }, - { bitalloc_17_codes_a, bitalloc_17_codes_b, bitalloc_17_codes_c, bitalloc_17_codes_d, - bitalloc_17_codes_e, bitalloc_17_codes_f, bitalloc_17_codes_g, NULL }, - { bitalloc_25_codes_a, bitalloc_25_codes_b, bitalloc_25_codes_c, bitalloc_25_codes_d, - bitalloc_25_codes_e, bitalloc_25_codes_f, bitalloc_25_codes_g, NULL }, - { bitalloc_33_codes_a, bitalloc_33_codes_b, bitalloc_33_codes_c, bitalloc_33_codes_d, - bitalloc_33_codes_e, bitalloc_33_codes_f, bitalloc_33_codes_g, NULL }, - { bitalloc_65_codes_a, bitalloc_65_codes_b, bitalloc_65_codes_c, bitalloc_65_codes_d, - bitalloc_65_codes_e, bitalloc_65_codes_f, bitalloc_65_codes_g, NULL }, - { bitalloc_129_codes_a, bitalloc_129_codes_b, bitalloc_129_codes_c, bitalloc_129_codes_d, - bitalloc_129_codes_e, bitalloc_129_codes_f, bitalloc_129_codes_g, NULL } -}; - -const uint8_t *const ff_dca_bitalloc_bits[DCA_CODE_BOOKS][8] = { - { bitalloc_3_bits, NULL }, - { bitalloc_5_bits_a, bitalloc_5_bits_b, bitalloc_5_bits_c, NULL }, - { bitalloc_7_bits_a, bitalloc_7_bits_b, bitalloc_7_bits_c, NULL }, - { bitalloc_9_bits_a, bitalloc_9_bits_b, bitalloc_9_bits_c, NULL }, - { bitalloc_13_bits_a, bitalloc_13_bits_b, bitalloc_13_bits_c, NULL }, - { bitalloc_17_bits_a, bitalloc_17_bits_b, bitalloc_17_bits_c, bitalloc_17_bits_d, - bitalloc_17_bits_e, bitalloc_17_bits_f, bitalloc_17_bits_g, NULL }, - { bitalloc_25_bits_a, bitalloc_25_bits_b, bitalloc_25_bits_c, bitalloc_25_bits_d, - bitalloc_25_bits_e, bitalloc_25_bits_f, bitalloc_25_bits_g, NULL }, - { bitalloc_33_bits_a, bitalloc_33_bits_b, bitalloc_33_bits_c, bitalloc_33_bits_d, - bitalloc_33_bits_e, bitalloc_33_bits_f, bitalloc_33_bits_g, NULL }, - { bitalloc_65_bits_a, bitalloc_65_bits_b, bitalloc_65_bits_c, bitalloc_65_bits_d, - bitalloc_65_bits_e, bitalloc_65_bits_f, bitalloc_65_bits_g, NULL }, - { bitalloc_129_bits_a, bitalloc_129_bits_b, bitalloc_129_bits_c, bitalloc_129_bits_d, - bitalloc_129_bits_e, bitalloc_129_bits_f, bitalloc_129_bits_g, NULL } -}; - -static const uint16_t tnl_grp_0_codes[37] = { - 0x0000, 0x0003, 0x0004, 0x0007, 0x0001, 0x0009, 0x000a, 0x000d, - 0x000e, 0x0006, 0x0012, 0x0005, 0x0015, 0x0016, 0x0022, 0x0025, - 0x0035, 0x0076, 0x0002, 0x0042, 0x00b6, 0x0036, 0x00c2, 0x0136, - 0x0182, 0x01c2, 0x03c2, 0x0482, 0x0682, 0x0082, 0x0882, 0x0a82, - 0x0282, 0x2282, 0x3282, 0x1282, 0x5282, -}; - -static const uint16_t tnl_grp_1_codes[34] = { - 0x0001, 0x0003, 0x0006, 0x0000, 0x0002, 0x0004, 0x0005, 0x0007, - 0x0008, 0x000f, 0x001a, 0x001c, 0x001d, 0x000a, 0x002c, 0x002d, - 0x000d, 0x002a, 0x004c, 0x004d, 0x006a, 0x008c, 0x00cd, 0x00ea, - 0x000c, 0x010c, 0x01ea, 0x020c, 0x030c, 0x07ea, 0x0bea, 0x03ea, - 0x13ea, 0x33ea, -}; - -static const uint16_t tnl_grp_2_codes[31] = { - 0x0001, 0x0003, 0x0006, 0x0007, 0x0004, 0x0008, 0x000c, 0x0010, - 0x0012, 0x001a, 0x0022, 0x0000, 0x000a, 0x0020, 0x0040, 0x004a, - 0x006a, 0x0002, 0x002a, 0x0042, 0x0082, 0x00aa, 0x00e0, 0x0060, - 0x00c2, 0x01c2, 0x0160, 0x0360, 0x0f60, 0x0760, 0x1760, -}; - -static const uint16_t tnl_grp_3_codes[28] = { - 0x0001, 0x0006, 0x0008, 0x0014, 0x001c, 0x0000, 0x0002, 0x0004, - 0x000a, 0x000c, 0x0010, 0x0012, 0x001a, 0x0020, 0x002a, 0x002c, - 0x0032, 0x003a, 0x0022, 0x0030, 0x0062, 0x0064, 0x0070, 0x0024, - 0x00a4, 0x01a4, 0x03a4, 0x07a4, -}; - -static const uint16_t tnl_grp_4_codes[23] = { - 0x0001, 0x0000, 0x000a, 0x0006, 0x0012, 0x001e, 0x0022, 0x002e, - 0x0036, 0x003e, 0x0002, 0x0016, 0x0032, 0x004e, 0x0056, 0x000e, - 0x0042, 0x0072, 0x00c2, 0x00f2, 0x008e, 0x018e, 0x038e, -}; - -static const uint16_t tnl_scf_codes[20] = { - 0x0000, 0x0001, 0x0002, 0x0005, 0x0006, 0x0007, 0x000b, 0x000c, - 0x0013, 0x0014, 0x0003, 0x0004, 0x0023, 0x0064, 0x00a4, 0x0024, - 0x0124, 0x0324, 0x0724, 0x0f24, -}; - -static const uint16_t damp_codes[7] = { - 0x0001, 0x0000, 0x0002, 0x0006, 0x000e, 0x001e, 0x003e, -}; - -static const uint16_t dph_codes[9] = { - 0x0000, 0x0002, 0x0003, 0x0001, 0x0009, 0x000d, 0x0005, 0x0015, - 0x0035, -}; - -static const uint16_t fst_rsd_amp_codes[24] = { - 0x0003, 0x0005, 0x0006, 0x0007, 0x0000, 0x0001, 0x0002, 0x0008, - 0x0009, 0x000a, 0x0014, 0x0004, 0x001a, 0x001c, 0x0024, 0x002c, - 0x003a, 0x000c, 0x003c, 0x004c, 0x00fc, 0x007c, 0x017c, 0x037c, -}; - -static const uint16_t rsd_apprx_codes[6] = { - 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, -}; - -static const uint16_t rsd_amp_codes[33] = { - 0x0001, 0x0000, 0x0002, 0x0003, 0x0004, 0x000e, 0x000f, 0x0016, - 0x0007, 0x0027, 0x0037, 0x0026, 0x0066, 0x0006, 0x0017, 0x0046, - 0x0097, 0x00d7, 0x0086, 0x00c6, 0x01c6, 0x0157, 0x0186, 0x0257, - 0x0357, 0x0057, 0x0786, 0x0386, 0x0b86, 0x0457, 0x0c57, 0x1457, - 0x1c57, -}; - -static const uint16_t avg_g3_codes[18] = { - 0x0001, 0x0002, 0x0003, 0x0000, 0x000c, 0x0014, 0x0018, 0x0004, - 0x0008, 0x0028, 0x0068, 0x0024, 0x00a4, 0x00e4, 0x0164, 0x0064, - 0x0264, 0x0664, -}; - -static const uint16_t st_grid_codes[22] = { - 0x0001, 0x0002, 0x0000, 0x0004, 0x0008, 0x001c, 0x004c, 0x006c, - 0x000c, 0x002c, 0x008c, 0x00ac, 0x012c, 0x018c, 0x01ac, 0x038c, - 0x03ac, 0x032c, 0x072c, 0x0f2c, 0x172c, 0x1f2c, -}; - -static const uint16_t grid_2_codes[20] = { - 0x0000, 0x0002, 0x0003, 0x0001, 0x0005, 0x000d, 0x003d, 0x005d, - 0x009d, 0x011d, 0x001d, 0x061d, 0x041d, 0x0c1d, 0x0a1d, 0x121d, - 0x021d, 0x1a1d, 0x221d, 0x3a1d, -}; - -static const uint16_t grid_3_codes[13] = { - 0x0001, 0x0002, 0x0000, 0x0004, 0x000c, 0x001c, 0x007c, 0x003c, - 0x01bc, 0x00bc, 0x06bc, 0x02bc, 0x0abc, -}; - -static const uint16_t rsd_codes[9] = { - 0x0001, 0x0003, 0x0000, 0x0002, 0x0006, 0x0004, 0x000c, 0x001c, - 0x003c, -}; - -static const uint8_t tnl_grp_0_bitvals[74] = { - 3, 5, 3, 9, 3, 4, 3, 6, 4, 10, 4, 13, 4, 7, 4, 11, - 4, 8, 5, 12, 5, 14, 6, 15, 6, 18, 6, 1, 6, 17, 6, 16, - 6, 21, 7, 20, 8, 19, 8, 22, 8, 25, 9, 26, 9, 23, 9, 3, - 9, 24, 10, 29, 10, 27, 11, 28, 11, 30, 12, 33, 12, 31, 12, 32, - 14, 34, 14, 37, 14, 36, 15, 35, 15, 0, -}; - -static const uint8_t tnl_grp_1_bitvals[68] = { - 3, 9, 3, 6, 3, 5, 4, 4, 4, 8, 4, 10, 4, 1, 4, 11, - 4, 7, 4, 13, 5, 12, 5, 14, 5, 17, 6, 16, 6, 15, 6, 18, - 7, 20, 7, 19, 7, 21, 8, 25, 8, 23, 8, 22, 8, 24, 9, 26, - 10, 3, 10, 29, 10, 30, 10, 27, 10, 28, 11, 31, 12, 32, 13, 33, - 14, 34, 14, 0, -}; - -static const uint8_t tnl_grp_2_bitvals[62] = { - 2, 1, 3, 6, 3, 5, 3, 7, 4, 9, 4, 8, 4, 4, 5, 10, - 5, 11, 5, 13, 6, 12, 7, 14, 7, 16, 7, 15, 7, 17, 7, 18, - 7, 19, 8, 22, 8, 20, 8, 21, 8, 3, 8, 24, 8, 25, 9, 23, - 9, 26, 9, 27, 10, 28, 11, 29, 12, 31, 13, 30, 13, 0, -}; - -static const uint8_t tnl_grp_3_bitvals[56] = { - 1, 1, 3, 6, 4, 5, 5, 9, 5, 4, 6, 8, 6, 14, 6, 10, - 6, 21, 6, 13, 6, 7, 6, 3, 6, 16, 6, 2, 6, 18, 6, 17, - 6, 11, 6, 15, 7, 19, 7, 23, 7, 24, 7, 22, 7, 12, 8, 20, - 9, 25, 10, 26, 11, 27, 11, 0, -}; - -static const uint8_t tnl_grp_4_bitvals[46] = { - 1, 1, 2, 2, 4, 4, 5, 5, 6, 6, 6, 8, 6, 3, 6, 19, - 6, 20, 6, 9, 7, 7, 7, 11, 7, 13, 7, 17, 7, 10, 8, 12, - 8, 15, 8, 14, 8, 21, 8, 18, 9, 16, 10, 22, 10, 0, -}; - -static const uint8_t tnl_scf_bitvals[40] = { - 3, 3, 3, 1, 3, 2, 3, 5, 3, 4, 3, 6, 4, 8, 4, 7, - 5, 10, 5, 9, 6, 12, 6, 11, 6, 13, 7, 14, 8, 15, 9, 16, - 10, 17, 11, 18, 12, 19, 12, 0, -}; - -static const uint8_t damp_bitvals[14] = { - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 0, -}; - -static const uint8_t dph_bitvals[18] = { - 2, 2, 2, 1, 2, 8, 4, 3, 4, 7, 4, 4, 5, 6, 6, 5, - 6, 0, -}; - -static const uint8_t fst_rsd_amp_bitvals[48] = { - 3, 13, 3, 15, 3, 16, 3, 14, 4, 12, 4, 10, 4, 11, 4, 17, - 4, 18, 5, 19, 5, 9, 6, 1, 6, 7, 6, 6, 6, 8, 6, 5, - 6, 4, 7, 20, 7, 2, 7, 3, 8, 21, 9, 22, 10, 23, 10, 0, -}; - -static const uint8_t rsd_apprx_bitvals[12] = { - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 0, -}; - -static const uint8_t rsd_amp_bitvals[66] = { - 2, 3, 3, 2, 3, 5, 3, 4, 3, 1, 4, 7, 4, 6, 5, 9, - 6, 8, 6, 11, 6, 10, 7, 12, 7, 13, 8, 14, 8, 18, 8, 16, - 8, 15, 8, 22, 9, 20, 9, 24, 9, 17, 10, 28, 10, 26, 10, 21, - 10, 23, 11, 30, 11, 19, 12, 25, 12, 32, 13, 36, 13, 29, 13, 34, - 13, 0, -}; - -static const uint8_t avg_g3_bitvals[36] = { - 2, 15, 2, 16, 2, 17, 4, 14, 4, 18, 5, 12, 5, 13, 6, 10, - 6, 11, 7, 19, 7, 9, 8, 20, 8, 8, 8, 7, 9, 21, 10, 6, - 11, 23, 11, 0, -}; - -static const uint8_t st_grid_bitvals[44] = { - 1, 6, 2, 1, 4, 4, 4, 8, 4, 3, 5, 10, 7, 12, 7, 5, - 8, 14, 9, 16, 9, 7, 9, 18, 10, 11, 10, 9, 10, 20, 10, 22, - 10, 2, 11, 13, 13, 17, 13, 24, 13, 15, 13, 0, -}; - -static const uint8_t grid_2_bitvals[40] = { - 2, 3, 2, 2, 2, 1, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, - 8, 9, 9, 10, 11, 11, 11, 12, 12, 13, 12, 17, 13, 15, 13, 18, - 14, 19, 14, 16, 14, 14, 14, 0, -}; - -static const uint8_t grid_3_bitvals[26] = { - 1, 17, 2, 16, 3, 18, 4, 15, 5, 19, 6, 14, 7, 20, 8, 13, - 9, 21, 10, 12, 11, 22, 12, 11, 12, 0, -}; - -static const uint8_t rsd_bitvals[18] = { - 2, 2, 2, 3, 3, 1, 3, 4, 3, 0, 4, 5, 5, 6, 6, 7, - 6, 4, +const uint8_t ff_dca_vlc_src_tables[][2] = { + /* bitalloc_3 - 3 entries */ + { 1, 1 }, { 2, 2 }, { 0, 2 }, + /* bitalloc_5_a - 5 entries */ + { 2, 1 }, { 3, 2 }, { 1, 3 }, { 4, 4 }, { 0, 4 }, + /* bitalloc_5_b - 5 entries */ + { 3, 2 }, { 1, 2 }, { 2, 2 }, { 4, 3 }, { 0, 3 }, + /* bitalloc_5_c - 5 entries */ + { 2, 1 }, { 3, 3 }, { 1, 3 }, { 4, 3 }, { 0, 3 }, + /* bitalloc_7_a - 7 entries */ + { 3, 1 }, { 5, 3 }, { 2, 3 }, { 4, 3 }, { 1, 4 }, + { 0, 5 }, { 6, 5 }, + /* bitalloc_7_b - 7 entries */ + { 2, 2 }, { 4, 2 }, { 5, 3 }, { 0, 5 }, { 6, 5 }, + { 1, 4 }, { 3, 2 }, + /* bitalloc_7_c - 7 entries */ + { 0, 4 }, { 6, 4 }, { 1, 4 }, { 5, 4 }, { 2, 2 }, + { 4, 2 }, { 3, 2 }, + /* bitalloc_9_a - 9 entries */ + { 4, 1 }, { 7, 4 }, { 2, 4 }, { 3, 3 }, { 0, 6 }, + { 8, 6 }, { 1, 5 }, { 6, 4 }, { 5, 3 }, + /* bitalloc_9_b - 9 entries */ + { 5, 2 }, { 2, 3 }, { 6, 3 }, { 4, 2 }, { 0, 5 }, + { 8, 5 }, { 1, 5 }, { 7, 5 }, { 3, 3 }, + /* bitalloc_9_c - 9 entries */ + { 5, 2 }, { 2, 3 }, { 7, 4 }, { 0, 6 }, { 8, 6 }, + { 1, 5 }, { 4, 2 }, { 6, 3 }, { 3, 3 }, + /* bitalloc_13_a - 13 entries */ + { 6, 1 }, { 7, 3 }, { 9, 4 }, { 10, 5 }, { 1, 6 }, + { 11, 6 }, { 4, 4 }, { 8, 4 }, { 0, 7 }, { 12, 7 }, + { 2, 6 }, { 3, 5 }, { 5, 4 }, + /* bitalloc_13_b - 13 entries */ + { 6, 2 }, { 8, 3 }, { 10, 4 }, { 3, 4 }, { 1, 5 }, + { 11, 5 }, { 9, 4 }, { 5, 3 }, { 7, 3 }, { 0, 6 }, + { 12, 6 }, { 2, 5 }, { 4, 4 }, + /* bitalloc_13_c - 13 entries */ + { 4, 3 }, { 0, 5 }, { 12, 5 }, { 2, 4 }, { 8, 3 }, + { 5, 3 }, { 7, 3 }, { 6, 3 }, { 10, 4 }, { 1, 5 }, + { 11, 5 }, { 3, 4 }, { 9, 4 }, + /* bitalloc_17_a - 17 entries */ + { 12, 4 }, { 13, 6 }, { 14, 8 }, { 15, 10 }, { 0, 12 }, + { 16, 12 }, { 1, 11 }, { 2, 9 }, { 3, 7 }, { 4, 5 }, + { 6, 3 }, { 8, 2 }, { 10, 3 }, { 5, 4 }, { 11, 4 }, + { 7, 3 }, { 9, 3 }, + /* bitalloc_17_b - 17 entries */ + { 8, 2 }, { 10, 3 }, { 15, 6 }, { 2, 6 }, { 3, 5 }, + { 13, 5 }, { 14, 6 }, { 0, 8 }, { 16, 8 }, { 1, 7 }, + { 5, 4 }, { 11, 4 }, { 7, 3 }, { 9, 3 }, { 4, 5 }, + { 12, 5 }, { 6, 4 }, + /* bitalloc_17_c - 17 entries */ + { 10, 3 }, { 15, 5 }, { 2, 5 }, { 4, 4 }, { 12, 4 }, + { 14, 5 }, { 0, 7 }, { 16, 7 }, { 1, 6 }, { 7, 3 }, + { 9, 3 }, { 5, 4 }, { 11, 4 }, { 8, 3 }, { 3, 5 }, + { 13, 5 }, { 6, 4 }, + /* bitalloc_17_d - 17 entries */ + { 8, 1 }, { 0, 9 }, { 16, 9 }, { 1, 9 }, { 15, 9 }, + { 2, 8 }, { 14, 8 }, { 3, 7 }, { 13, 7 }, { 4, 6 }, + { 12, 6 }, { 5, 5 }, { 11, 5 }, { 6, 4 }, { 10, 4 }, + { 7, 3 }, { 9, 3 }, + /* bitalloc_17_e - 17 entries */ + { 8, 1 }, { 7, 3 }, { 9, 3 }, { 10, 4 }, { 3, 6 }, + { 13, 6 }, { 5, 5 }, { 11, 5 }, { 0, 8 }, { 16, 8 }, + { 2, 7 }, { 4, 6 }, { 12, 6 }, { 14, 7 }, { 1, 8 }, + { 15, 8 }, { 6, 5 }, + /* bitalloc_17_f - 17 entries */ + { 15, 6 }, { 0, 8 }, { 16, 8 }, { 1, 7 }, { 3, 5 }, + { 4, 4 }, { 6, 3 }, { 10, 3 }, { 12, 4 }, { 13, 5 }, + { 2, 6 }, { 14, 6 }, { 7, 3 }, { 9, 3 }, { 8, 3 }, + { 5, 4 }, { 11, 4 }, + /* bitalloc_17_g - 17 entries */ + { 6, 3 }, { 10, 3 }, { 5, 4 }, { 11, 4 }, { 0, 8 }, + { 16, 8 }, { 2, 7 }, { 3, 6 }, { 4, 5 }, { 12, 5 }, + { 13, 6 }, { 14, 7 }, { 1, 8 }, { 15, 8 }, { 8, 2 }, + { 7, 3 }, { 9, 3 }, + /* bitalloc_25_a - 25 entries */ + { 10, 3 }, { 14, 3 }, { 8, 4 }, { 16, 4 }, { 11, 3 }, + { 13, 3 }, { 21, 8 }, { 22, 10 }, { 23, 12 }, { 0, 14 }, + { 24, 14 }, { 1, 13 }, { 2, 11 }, { 3, 9 }, { 4, 8 }, + { 20, 8 }, { 5, 7 }, { 19, 7 }, { 7, 5 }, { 17, 5 }, + { 6, 6 }, { 18, 6 }, { 12, 3 }, { 9, 4 }, { 15, 4 }, + /* bitalloc_25_b - 25 entries */ + { 3, 6 }, { 21, 6 }, { 23, 7 }, { 2, 7 }, { 22, 7 }, + { 0, 9 }, { 24, 9 }, { 1, 8 }, { 8, 4 }, { 11, 3 }, + { 13, 3 }, { 16, 4 }, { 6, 5 }, { 18, 5 }, { 9, 4 }, + { 15, 4 }, { 12, 3 }, { 4, 6 }, { 20, 6 }, { 7, 5 }, + { 17, 5 }, { 5, 6 }, { 19, 6 }, { 10, 4 }, { 14, 4 }, + /* bitalloc_25_c - 25 entries */ + { 7, 4 }, { 17, 4 }, { 12, 3 }, { 20, 5 }, { 22, 6 }, + { 0, 8 }, { 24, 8 }, { 1, 7 }, { 8, 4 }, { 16, 4 }, + { 5, 5 }, { 19, 5 }, { 9, 4 }, { 15, 4 }, { 3, 6 }, + { 21, 6 }, { 6, 5 }, { 10, 4 }, { 14, 4 }, { 18, 5 }, + { 23, 7 }, { 2, 7 }, { 4, 6 }, { 11, 4 }, { 13, 4 }, + /* bitalloc_25_d - 25 entries */ + { 10, 3 }, { 14, 3 }, { 9, 4 }, { 15, 4 }, { 8, 5 }, + { 16, 5 }, { 7, 6 }, { 17, 6 }, { 0, 12 }, { 24, 12 }, + { 1, 12 }, { 23, 12 }, { 2, 11 }, { 22, 11 }, { 3, 10 }, + { 21, 10 }, { 5, 8 }, { 6, 7 }, { 18, 7 }, { 19, 8 }, + { 4, 9 }, { 20, 9 }, { 12, 2 }, { 11, 3 }, { 13, 3 }, + /* bitalloc_25_e - 25 entries */ + { 9, 4 }, { 15, 4 }, { 7, 5 }, { 17, 5 }, { 2, 7 }, + { 22, 7 }, { 5, 6 }, { 19, 6 }, { 0, 8 }, { 24, 8 }, + { 3, 7 }, { 11, 3 }, { 13, 3 }, { 8, 5 }, { 16, 5 }, + { 21, 7 }, { 1, 8 }, { 23, 8 }, { 6, 6 }, { 18, 6 }, + { 4, 7 }, { 20, 7 }, { 10, 4 }, { 14, 4 }, { 12, 2 }, + /* bitalloc_25_f - 25 entries */ + { 13, 3 }, { 12, 3 }, { 7, 4 }, { 17, 4 }, { 5, 5 }, + { 19, 5 }, { 8, 4 }, { 16, 4 }, { 4, 6 }, { 20, 6 }, + { 6, 5 }, { 9, 4 }, { 15, 4 }, { 18, 5 }, { 23, 8 }, + { 0, 10 }, { 24, 10 }, { 1, 9 }, { 3, 7 }, { 21, 7 }, + { 2, 8 }, { 22, 8 }, { 10, 4 }, { 14, 4 }, { 11, 4 }, + /* bitalloc_25_g - 25 entries */ + { 14, 3 }, { 17, 5 }, { 4, 7 }, { 20, 7 }, { 6, 6 }, + { 9, 4 }, { 12, 2 }, { 15, 4 }, { 18, 6 }, { 3, 8 }, + { 21, 8 }, { 5, 7 }, { 8, 5 }, { 11, 3 }, { 13, 3 }, + { 16, 5 }, { 19, 7 }, { 0, 10 }, { 24, 10 }, { 2, 9 }, + { 22, 9 }, { 1, 10 }, { 23, 10 }, { 7, 6 }, { 10, 4 }, + /* bitalloc_33_a - 33 entries */ + { 15, 3 }, { 17, 3 }, { 16, 3 }, { 21, 4 }, { 8, 6 }, + { 24, 6 }, { 10, 5 }, { 12, 4 }, { 20, 4 }, { 22, 5 }, + { 7, 7 }, { 25, 7 }, { 0, 13 }, { 32, 13 }, { 1, 13 }, + { 31, 13 }, { 2, 12 }, { 30, 12 }, { 3, 11 }, { 29, 11 }, + { 4, 10 }, { 28, 10 }, { 6, 8 }, { 26, 8 }, { 5, 9 }, + { 27, 9 }, { 13, 4 }, { 19, 4 }, { 14, 4 }, { 18, 4 }, + { 9, 6 }, { 23, 6 }, { 11, 5 }, + /* bitalloc_33_b - 33 entries */ + { 8, 5 }, { 24, 5 }, { 12, 4 }, { 16, 3 }, { 20, 4 }, + { 3, 7 }, { 29, 7 }, { 6, 6 }, { 9, 5 }, { 23, 5 }, + { 26, 6 }, { 31, 8 }, { 2, 8 }, { 4, 7 }, { 13, 4 }, + { 19, 4 }, { 10, 5 }, { 22, 5 }, { 14, 4 }, { 18, 4 }, + { 28, 7 }, { 30, 8 }, { 0, 10 }, { 32, 10 }, { 1, 9 }, + { 7, 6 }, { 25, 6 }, { 5, 7 }, { 27, 7 }, { 11, 5 }, + { 21, 5 }, { 15, 4 }, { 17, 4 }, + /* bitalloc_33_c - 33 entries */ + { 25, 5 }, { 31, 7 }, { 2, 7 }, { 4, 6 }, { 12, 4 }, + { 20, 4 }, { 13, 4 }, { 19, 4 }, { 8, 5 }, { 24, 5 }, + { 28, 6 }, { 30, 7 }, { 0, 9 }, { 32, 9 }, { 1, 8 }, + { 5, 6 }, { 27, 6 }, { 14, 4 }, { 18, 4 }, { 9, 5 }, + { 23, 5 }, { 15, 4 }, { 17, 4 }, { 10, 5 }, { 22, 5 }, + { 16, 4 }, { 3, 7 }, { 29, 7 }, { 6, 6 }, { 11, 5 }, + { 21, 5 }, { 26, 6 }, { 7, 6 }, + /* bitalloc_33_d - 33 entries */ + { 18, 3 }, { 21, 5 }, { 8, 7 }, { 24, 7 }, { 10, 6 }, + { 13, 4 }, { 16, 2 }, { 19, 4 }, { 22, 6 }, { 7, 8 }, + { 25, 8 }, { 9, 7 }, { 12, 5 }, { 15, 3 }, { 17, 3 }, + { 20, 5 }, { 23, 7 }, { 6, 9 }, { 26, 9 }, { 5, 10 }, + { 27, 10 }, { 4, 11 }, { 28, 11 }, { 3, 12 }, { 29, 12 }, + { 0, 14 }, { 32, 14 }, { 1, 14 }, { 31, 14 }, { 2, 13 }, + { 30, 13 }, { 11, 6 }, { 14, 4 }, + /* bitalloc_33_e - 33 entries */ + { 19, 4 }, { 11, 5 }, { 21, 5 }, { 15, 3 }, { 17, 3 }, + { 5, 7 }, { 27, 7 }, { 2, 8 }, { 30, 8 }, { 6, 7 }, + { 9, 6 }, { 23, 6 }, { 14, 4 }, { 16, 2 }, { 18, 4 }, + { 12, 5 }, { 20, 5 }, { 26, 7 }, { 3, 8 }, { 29, 8 }, + { 0, 9 }, { 32, 9 }, { 4, 8 }, { 7, 7 }, { 10, 6 }, + { 22, 6 }, { 25, 7 }, { 28, 8 }, { 1, 9 }, { 31, 9 }, + { 8, 7 }, { 24, 7 }, { 13, 5 }, + /* bitalloc_33_f - 33 entries */ + { 11, 4 }, { 21, 4 }, { 5, 6 }, { 27, 6 }, { 8, 5 }, + { 12, 4 }, { 20, 4 }, { 24, 5 }, { 4, 7 }, { 28, 7 }, + { 6, 6 }, { 13, 4 }, { 19, 4 }, { 14, 4 }, { 18, 4 }, + { 9, 5 }, { 23, 5 }, { 15, 4 }, { 17, 4 }, { 16, 4 }, + { 26, 6 }, { 31, 9 }, { 0, 11 }, { 32, 11 }, { 1, 10 }, + { 3, 8 }, { 29, 8 }, { 2, 9 }, { 30, 9 }, { 10, 5 }, + { 22, 5 }, { 7, 6 }, { 25, 6 }, + /* bitalloc_33_g - 33 entries */ + { 12, 4 }, { 20, 4 }, { 29, 8 }, { 1, 9 }, { 31, 9 }, + { 6, 7 }, { 8, 6 }, { 10, 5 }, { 22, 5 }, { 24, 6 }, + { 26, 7 }, { 4, 8 }, { 28, 8 }, { 15, 3 }, { 17, 3 }, + { 13, 4 }, { 19, 4 }, { 2, 9 }, { 30, 9 }, { 0, 10 }, + { 32, 10 }, { 3, 9 }, { 7, 7 }, { 9, 6 }, { 11, 5 }, + { 21, 5 }, { 23, 6 }, { 25, 7 }, { 5, 8 }, { 27, 8 }, + { 16, 3 }, { 14, 4 }, { 18, 4 }, + /* bitalloc_65_a - 65 entries */ + { 35, 4 }, { 30, 4 }, { 34, 4 }, { 42, 5 }, { 23, 5 }, + { 31, 4 }, { 33, 4 }, { 32, 4 }, { 41, 5 }, { 19, 6 }, + { 45, 6 }, { 16, 7 }, { 48, 7 }, { 20, 6 }, { 24, 5 }, + { 40, 5 }, { 44, 6 }, { 14, 8 }, { 50, 8 }, { 57, 11 }, + { 4, 13 }, { 60, 13 }, { 6, 12 }, { 58, 12 }, { 3, 14 }, + { 61, 14 }, { 2, 15 }, { 62, 15 }, { 0, 16 }, { 64, 16 }, + { 1, 16 }, { 63, 16 }, { 8, 11 }, { 12, 9 }, { 52, 9 }, + { 10, 10 }, { 54, 10 }, { 25, 5 }, { 39, 5 }, { 17, 7 }, + { 47, 7 }, { 21, 6 }, { 26, 5 }, { 38, 5 }, { 43, 6 }, + { 15, 8 }, { 49, 8 }, { 18, 7 }, { 27, 5 }, { 37, 5 }, + { 28, 5 }, { 36, 5 }, { 46, 7 }, { 56, 11 }, { 5, 13 }, + { 59, 13 }, { 7, 12 }, { 9, 11 }, { 55, 11 }, { 13, 9 }, + { 51, 9 }, { 11, 10 }, { 53, 10 }, { 22, 6 }, { 29, 5 }, + /* bitalloc_65_b - 65 entries */ + { 48, 6 }, { 3, 9 }, { 61, 9 }, { 6, 8 }, { 11, 7 }, + { 53, 7 }, { 58, 8 }, { 7, 8 }, { 17, 6 }, { 31, 4 }, + { 33, 4 }, { 24, 5 }, { 40, 5 }, { 32, 4 }, { 47, 6 }, + { 18, 6 }, { 25, 5 }, { 39, 5 }, { 46, 6 }, { 57, 8 }, + { 63, 10 }, { 2, 10 }, { 4, 9 }, { 12, 7 }, { 52, 7 }, + { 13, 7 }, { 19, 6 }, { 26, 5 }, { 38, 5 }, { 45, 6 }, + { 51, 7 }, { 8, 8 }, { 56, 8 }, { 27, 5 }, { 37, 5 }, + { 20, 6 }, { 44, 6 }, { 60, 9 }, { 62, 10 }, { 0, 12 }, + { 64, 12 }, { 1, 11 }, { 5, 9 }, { 59, 9 }, { 14, 7 }, + { 50, 7 }, { 9, 8 }, { 55, 8 }, { 28, 5 }, { 36, 5 }, + { 21, 6 }, { 43, 6 }, { 29, 5 }, { 35, 5 }, { 15, 7 }, + { 49, 7 }, { 22, 6 }, { 42, 6 }, { 10, 8 }, { 54, 8 }, + { 16, 7 }, { 30, 5 }, { 34, 5 }, { 23, 6 }, { 41, 6 }, + /* bitalloc_65_c - 65 entries */ + { 23, 5 }, { 41, 5 }, { 50, 6 }, { 8, 7 }, { 56, 7 }, + { 24, 5 }, { 40, 5 }, { 15, 6 }, { 49, 6 }, { 25, 5 }, + { 39, 5 }, { 16, 6 }, { 48, 6 }, { 26, 5 }, { 38, 5 }, + { 60, 8 }, { 5, 8 }, { 9, 7 }, { 55, 7 }, { 10, 7 }, + { 27, 5 }, { 37, 5 }, { 17, 6 }, { 47, 6 }, { 28, 5 }, + { 36, 5 }, { 54, 7 }, { 59, 8 }, { 62, 9 }, { 0, 11 }, + { 64, 11 }, { 1, 10 }, { 18, 6 }, { 29, 5 }, { 35, 5 }, + { 46, 6 }, { 11, 7 }, { 53, 7 }, { 19, 6 }, { 45, 6 }, + { 30, 5 }, { 34, 5 }, { 31, 5 }, { 33, 5 }, { 6, 8 }, + { 58, 8 }, { 12, 7 }, { 20, 6 }, { 44, 6 }, { 52, 7 }, + { 3, 9 }, { 61, 9 }, { 7, 8 }, { 32, 5 }, { 21, 6 }, + { 43, 6 }, { 13, 7 }, { 51, 7 }, { 22, 6 }, { 42, 6 }, + { 57, 8 }, { 63, 10 }, { 2, 10 }, { 4, 9 }, { 14, 7 }, + /* bitalloc_65_d - 65 entries */ + { 31, 3 }, { 33, 3 }, { 48, 8 }, { 11, 10 }, { 53, 10 }, + { 14, 9 }, { 50, 9 }, { 9, 11 }, { 55, 11 }, { 12, 10 }, + { 17, 8 }, { 20, 7 }, { 44, 7 }, { 23, 6 }, { 41, 6 }, + { 26, 5 }, { 38, 5 }, { 29, 4 }, { 35, 4 }, { 32, 3 }, + { 47, 8 }, { 52, 10 }, { 60, 13 }, { 3, 14 }, { 61, 14 }, + { 7, 12 }, { 57, 12 }, { 5, 13 }, { 59, 13 }, { 15, 9 }, + { 18, 8 }, { 46, 8 }, { 21, 7 }, { 43, 7 }, { 24, 6 }, + { 40, 6 }, { 27, 5 }, { 37, 5 }, { 30, 4 }, { 34, 4 }, + { 49, 9 }, { 10, 11 }, { 54, 11 }, { 13, 10 }, { 51, 10 }, + { 8, 12 }, { 56, 12 }, { 0, 15 }, { 64, 15 }, { 1, 15 }, + { 63, 15 }, { 2, 15 }, { 62, 15 }, { 4, 14 }, { 6, 13 }, + { 58, 13 }, { 16, 9 }, { 19, 8 }, { 45, 8 }, { 22, 7 }, + { 42, 7 }, { 25, 6 }, { 39, 6 }, { 28, 5 }, { 36, 5 }, + /* bitalloc_65_e - 65 entries */ + { 33, 3 }, { 21, 6 }, { 43, 6 }, { 26, 5 }, { 38, 5 }, + { 16, 7 }, { 48, 7 }, { 22, 6 }, { 42, 6 }, { 10, 8 }, + { 54, 8 }, { 4, 9 }, { 60, 9 }, { 11, 8 }, { 27, 5 }, + { 37, 5 }, { 17, 7 }, { 47, 7 }, { 23, 6 }, { 30, 4 }, + { 34, 4 }, { 32, 3 }, { 41, 6 }, { 53, 8 }, { 5, 9 }, + { 59, 9 }, { 18, 7 }, { 46, 7 }, { 12, 8 }, { 52, 8 }, + { 24, 6 }, { 28, 5 }, { 36, 5 }, { 40, 6 }, { 6, 9 }, + { 58, 9 }, { 13, 8 }, { 19, 7 }, { 45, 7 }, { 51, 8 }, + { 0, 10 }, { 64, 10 }, { 7, 9 }, { 57, 9 }, { 1, 10 }, + { 63, 10 }, { 14, 8 }, { 50, 8 }, { 8, 9 }, { 56, 9 }, + { 20, 7 }, { 44, 7 }, { 25, 6 }, { 39, 6 }, { 15, 8 }, + { 49, 8 }, { 2, 10 }, { 62, 10 }, { 9, 9 }, { 55, 9 }, + { 3, 10 }, { 61, 10 }, { 29, 5 }, { 35, 5 }, { 31, 4 }, + /* bitalloc_65_f - 65 entries */ + { 28, 4 }, { 36, 4 }, { 26, 5 }, { 38, 5 }, { 24, 6 }, + { 40, 6 }, { 22, 7 }, { 42, 7 }, { 20, 8 }, { 44, 8 }, + { 18, 9 }, { 46, 9 }, { 48, 10 }, { 50, 11 }, { 12, 12 }, + { 52, 12 }, { 0, 14 }, { 64, 14 }, { 1, 14 }, { 63, 14 }, + { 10, 13 }, { 54, 13 }, { 2, 14 }, { 62, 14 }, { 3, 14 }, + { 61, 14 }, { 4, 14 }, { 60, 14 }, { 5, 14 }, { 59, 14 }, + { 6, 14 }, { 58, 14 }, { 7, 14 }, { 57, 14 }, { 8, 14 }, + { 56, 14 }, { 11, 13 }, { 15, 11 }, { 31, 3 }, { 33, 3 }, + { 29, 4 }, { 35, 4 }, { 27, 5 }, { 37, 5 }, { 25, 6 }, + { 39, 6 }, { 23, 7 }, { 41, 7 }, { 21, 8 }, { 43, 8 }, + { 19, 9 }, { 45, 9 }, { 17, 10 }, { 47, 10 }, { 49, 11 }, + { 13, 12 }, { 51, 12 }, { 53, 13 }, { 9, 14 }, { 55, 14 }, + { 14, 12 }, { 16, 11 }, { 32, 3 }, { 30, 4 }, { 34, 4 }, + /* bitalloc_65_g - 65 entries */ + { 36, 4 }, { 40, 5 }, { 44, 6 }, { 48, 7 }, { 12, 8 }, + { 52, 8 }, { 8, 9 }, { 56, 9 }, { 4, 10 }, { 60, 10 }, + { 0, 11 }, { 64, 11 }, { 5, 10 }, { 17, 7 }, { 21, 6 }, + { 25, 5 }, { 29, 4 }, { 35, 4 }, { 39, 5 }, { 43, 6 }, + { 47, 7 }, { 13, 8 }, { 51, 8 }, { 30, 4 }, { 9, 9 }, + { 55, 9 }, { 59, 10 }, { 1, 11 }, { 63, 11 }, { 10, 9 }, + { 18, 7 }, { 22, 6 }, { 26, 5 }, { 34, 4 }, { 38, 5 }, + { 42, 6 }, { 46, 7 }, { 14, 8 }, { 50, 8 }, { 31, 4 }, + { 33, 4 }, { 54, 9 }, { 6, 10 }, { 58, 10 }, { 2, 11 }, + { 62, 11 }, { 7, 10 }, { 11, 9 }, { 19, 7 }, { 23, 6 }, + { 27, 5 }, { 37, 5 }, { 41, 6 }, { 45, 7 }, { 15, 8 }, + { 49, 8 }, { 32, 4 }, { 53, 9 }, { 57, 10 }, { 3, 11 }, + { 61, 11 }, { 16, 8 }, { 20, 7 }, { 24, 6 }, { 28, 5 }, + /* bitalloc_129_a - 129 entries */ + { 66, 4 }, { 31, 8 }, { 97, 8 }, { 19, 9 }, { 109, 9 }, + { 6, 10 }, { 122, 10 }, { 7, 10 }, { 121, 10 }, { 52, 6 }, + { 76, 6 }, { 43, 7 }, { 85, 7 }, { 59, 5 }, { 69, 5 }, + { 32, 8 }, { 96, 8 }, { 20, 9 }, { 108, 9 }, { 33, 8 }, + { 53, 6 }, { 75, 6 }, { 95, 8 }, { 8, 10 }, { 120, 10 }, + { 21, 9 }, { 44, 7 }, { 84, 7 }, { 107, 9 }, { 9, 10 }, + { 119, 10 }, { 34, 8 }, { 94, 8 }, { 22, 9 }, { 106, 9 }, + { 45, 7 }, { 54, 6 }, { 74, 6 }, { 83, 7 }, { 10, 10 }, + { 118, 10 }, { 23, 9 }, { 35, 8 }, { 93, 8 }, { 105, 9 }, + { 11, 10 }, { 117, 10 }, { 46, 7 }, { 60, 5 }, { 68, 5 }, + { 82, 7 }, { 24, 9 }, { 104, 9 }, { 36, 8 }, { 55, 6 }, + { 73, 6 }, { 92, 8 }, { 12, 10 }, { 116, 10 }, { 25, 9 }, + { 47, 7 }, { 81, 7 }, { 37, 8 }, { 91, 8 }, { 103, 9 }, + { 13, 10 }, { 115, 10 }, { 26, 9 }, { 102, 9 }, { 48, 7 }, + { 64, 4 }, { 63, 4 }, { 65, 4 }, { 56, 6 }, { 72, 6 }, + { 61, 5 }, { 67, 5 }, { 80, 7 }, { 38, 8 }, { 90, 8 }, + { 0, 11 }, { 128, 11 }, { 14, 10 }, { 114, 10 }, { 1, 11 }, + { 127, 11 }, { 27, 9 }, { 101, 9 }, { 49, 7 }, { 79, 7 }, + { 39, 8 }, { 89, 8 }, { 57, 6 }, { 71, 6 }, { 15, 10 }, + { 113, 10 }, { 28, 9 }, { 100, 9 }, { 2, 11 }, { 126, 11 }, + { 16, 10 }, { 40, 8 }, { 88, 8 }, { 50, 7 }, { 78, 7 }, + { 112, 10 }, { 3, 11 }, { 125, 11 }, { 29, 9 }, { 99, 9 }, + { 17, 10 }, { 111, 10 }, { 41, 8 }, { 87, 8 }, { 58, 6 }, + { 4, 11 }, { 124, 11 }, { 18, 10 }, { 30, 9 }, { 98, 9 }, + { 110, 10 }, { 5, 11 }, { 123, 11 }, { 51, 7 }, { 70, 6 }, + { 77, 7 }, { 42, 8 }, { 86, 8 }, { 62, 5 }, + /* bitalloc_129_b - 129 entries */ + { 67, 5 }, { 21, 8 }, { 107, 8 }, { 33, 7 }, { 95, 7 }, + { 13, 9 }, { 115, 9 }, { 22, 8 }, { 47, 6 }, { 81, 6 }, + { 62, 5 }, { 66, 5 }, { 34, 7 }, { 94, 7 }, { 48, 6 }, + { 63, 5 }, { 65, 5 }, { 80, 6 }, { 106, 8 }, { 121, 10 }, + { 127, 12 }, { 2, 12 }, { 4, 11 }, { 14, 9 }, { 23, 8 }, + { 105, 8 }, { 35, 7 }, { 93, 7 }, { 49, 6 }, { 64, 5 }, + { 79, 6 }, { 114, 9 }, { 8, 10 }, { 120, 10 }, { 24, 8 }, + { 36, 7 }, { 50, 6 }, { 78, 6 }, { 92, 7 }, { 104, 8 }, + { 15, 9 }, { 113, 9 }, { 51, 6 }, { 77, 6 }, { 37, 7 }, + { 91, 7 }, { 25, 8 }, { 103, 8 }, { 38, 7 }, { 52, 6 }, + { 76, 6 }, { 90, 7 }, { 16, 9 }, { 112, 9 }, { 26, 8 }, + { 53, 6 }, { 75, 6 }, { 102, 8 }, { 124, 11 }, { 5, 11 }, + { 9, 10 }, { 119, 10 }, { 10, 10 }, { 39, 7 }, { 89, 7 }, + { 27, 8 }, { 101, 8 }, { 54, 6 }, { 74, 6 }, { 40, 7 }, + { 88, 7 }, { 17, 9 }, { 111, 9 }, { 28, 8 }, { 100, 8 }, + { 118, 10 }, { 123, 11 }, { 126, 12 }, { 0, 14 }, { 128, 14 }, + { 1, 13 }, { 18, 9 }, { 55, 6 }, { 73, 6 }, { 41, 7 }, + { 87, 7 }, { 56, 6 }, { 72, 6 }, { 29, 8 }, { 99, 8 }, + { 42, 7 }, { 86, 7 }, { 110, 9 }, { 11, 10 }, { 117, 10 }, + { 19, 9 }, { 109, 9 }, { 57, 6 }, { 71, 6 }, { 43, 7 }, + { 85, 7 }, { 58, 6 }, { 70, 6 }, { 30, 8 }, { 98, 8 }, + { 44, 7 }, { 84, 7 }, { 31, 8 }, { 97, 8 }, { 59, 6 }, + { 69, 6 }, { 6, 11 }, { 122, 11 }, { 12, 10 }, { 20, 9 }, + { 108, 9 }, { 116, 10 }, { 3, 12 }, { 125, 12 }, { 7, 11 }, + { 45, 7 }, { 60, 6 }, { 68, 6 }, { 83, 7 }, { 32, 8 }, + { 96, 8 }, { 46, 7 }, { 82, 7 }, { 61, 6 }, + /* bitalloc_129_c - 129 entries */ + { 101, 7 }, { 113, 8 }, { 120, 9 }, { 127, 11 }, { 2, 11 }, + { 4, 10 }, { 28, 7 }, { 100, 7 }, { 46, 6 }, { 82, 6 }, + { 16, 8 }, { 112, 8 }, { 29, 7 }, { 47, 6 }, { 81, 6 }, + { 48, 6 }, { 80, 6 }, { 99, 7 }, { 30, 7 }, { 98, 7 }, + { 17, 8 }, { 111, 8 }, { 49, 6 }, { 79, 6 }, { 50, 6 }, + { 78, 6 }, { 31, 7 }, { 97, 7 }, { 9, 9 }, { 119, 9 }, + { 18, 8 }, { 110, 8 }, { 124, 10 }, { 5, 10 }, { 10, 9 }, + { 51, 6 }, { 77, 6 }, { 32, 7 }, { 96, 7 }, { 52, 6 }, + { 76, 6 }, { 33, 7 }, { 95, 7 }, { 53, 6 }, { 75, 6 }, + { 19, 8 }, { 109, 8 }, { 34, 7 }, { 54, 6 }, { 74, 6 }, + { 94, 7 }, { 118, 9 }, { 123, 10 }, { 126, 11 }, { 0, 13 }, + { 128, 13 }, { 1, 12 }, { 20, 8 }, { 55, 6 }, { 73, 6 }, + { 108, 8 }, { 11, 9 }, { 117, 9 }, { 35, 7 }, { 93, 7 }, + { 36, 7 }, { 56, 6 }, { 72, 6 }, { 92, 7 }, { 21, 8 }, + { 107, 8 }, { 57, 6 }, { 71, 6 }, { 37, 7 }, { 91, 7 }, + { 58, 6 }, { 70, 6 }, { 22, 8 }, { 106, 8 }, { 38, 7 }, + { 59, 6 }, { 69, 6 }, { 90, 7 }, { 12, 9 }, { 116, 9 }, + { 23, 8 }, { 60, 6 }, { 68, 6 }, { 39, 7 }, { 89, 7 }, + { 61, 6 }, { 67, 6 }, { 105, 8 }, { 6, 10 }, { 122, 10 }, + { 13, 9 }, { 40, 7 }, { 62, 6 }, { 66, 6 }, { 88, 7 }, + { 24, 8 }, { 104, 8 }, { 63, 6 }, { 65, 6 }, { 41, 7 }, + { 87, 7 }, { 115, 9 }, { 3, 11 }, { 125, 11 }, { 7, 10 }, + { 25, 8 }, { 42, 7 }, { 64, 6 }, { 86, 7 }, { 103, 8 }, + { 14, 9 }, { 114, 9 }, { 43, 7 }, { 85, 7 }, { 26, 8 }, + { 102, 8 }, { 44, 7 }, { 84, 7 }, { 121, 10 }, { 8, 10 }, + { 15, 9 }, { 27, 8 }, { 45, 7 }, { 83, 7 }, + /* bitalloc_129_d - 129 entries */ + { 72, 5 }, { 83, 7 }, { 34, 9 }, { 94, 9 }, { 40, 8 }, + { 51, 6 }, { 62, 4 }, { 66, 4 }, { 77, 6 }, { 88, 8 }, + { 18, 12 }, { 110, 12 }, { 9, 14 }, { 119, 14 }, { 14, 13 }, + { 19, 12 }, { 29, 10 }, { 99, 10 }, { 24, 11 }, { 104, 11 }, + { 46, 7 }, { 57, 5 }, { 71, 5 }, { 82, 7 }, { 35, 9 }, + { 93, 9 }, { 41, 8 }, { 52, 6 }, { 63, 4 }, { 65, 4 }, + { 76, 6 }, { 87, 8 }, { 30, 10 }, { 98, 10 }, { 109, 12 }, + { 114, 13 }, { 6, 15 }, { 122, 15 }, { 10, 14 }, { 25, 11 }, + { 103, 11 }, { 15, 13 }, { 113, 13 }, { 20, 12 }, { 47, 7 }, + { 58, 5 }, { 70, 5 }, { 81, 7 }, { 36, 9 }, { 92, 9 }, + { 42, 8 }, { 53, 6 }, { 64, 4 }, { 75, 6 }, { 86, 8 }, + { 31, 10 }, { 97, 10 }, { 108, 12 }, { 118, 14 }, { 7, 15 }, + { 121, 15 }, { 0, 16 }, { 128, 16 }, { 1, 16 }, { 127, 16 }, + { 2, 16 }, { 126, 16 }, { 3, 16 }, { 125, 16 }, { 26, 11 }, + { 102, 11 }, { 11, 14 }, { 117, 14 }, { 16, 13 }, { 21, 12 }, + { 48, 7 }, { 59, 5 }, { 69, 5 }, { 80, 7 }, { 37, 9 }, + { 91, 9 }, { 43, 8 }, { 54, 6 }, { 74, 6 }, { 85, 8 }, + { 32, 10 }, { 96, 10 }, { 107, 12 }, { 112, 13 }, { 4, 16 }, + { 124, 16 }, { 8, 15 }, { 12, 14 }, { 27, 11 }, { 101, 11 }, + { 22, 12 }, { 106, 12 }, { 49, 7 }, { 60, 5 }, { 68, 5 }, + { 79, 7 }, { 38, 9 }, { 90, 9 }, { 44, 8 }, { 55, 6 }, + { 73, 6 }, { 84, 8 }, { 33, 10 }, { 95, 10 }, { 116, 14 }, + { 120, 15 }, { 5, 16 }, { 123, 16 }, { 17, 13 }, { 111, 13 }, + { 13, 14 }, { 115, 14 }, { 28, 11 }, { 100, 11 }, { 23, 12 }, + { 105, 12 }, { 50, 7 }, { 61, 5 }, { 67, 5 }, { 78, 7 }, + { 39, 9 }, { 89, 9 }, { 45, 8 }, { 56, 6 }, + /* bitalloc_129_e - 129 entries */ + { 70, 5 }, { 59, 5 }, { 69, 5 }, { 60, 5 }, { 68, 5 }, + { 37, 7 }, { 91, 7 }, { 45, 6 }, { 61, 5 }, { 67, 5 }, + { 62, 5 }, { 66, 5 }, { 63, 5 }, { 65, 5 }, { 64, 5 }, + { 83, 6 }, { 97, 8 }, { 102, 9 }, { 18, 11 }, { 110, 11 }, + { 22, 10 }, { 38, 7 }, { 46, 6 }, { 82, 6 }, { 90, 7 }, + { 32, 8 }, { 96, 8 }, { 47, 6 }, { 81, 6 }, { 106, 10 }, + { 15, 12 }, { 113, 12 }, { 19, 11 }, { 27, 9 }, { 101, 9 }, + { 23, 10 }, { 105, 10 }, { 39, 7 }, { 89, 7 }, { 33, 8 }, + { 95, 8 }, { 48, 6 }, { 80, 6 }, { 49, 6 }, { 79, 6 }, + { 40, 7 }, { 88, 7 }, { 28, 9 }, { 100, 9 }, { 109, 11 }, + { 6, 15 }, { 122, 15 }, { 9, 14 }, { 12, 13 }, { 116, 13 }, + { 119, 14 }, { 0, 16 }, { 4, 16 }, { 3, 16 }, { 2, 16 }, + { 24, 10 }, { 104, 10 }, { 16, 12 }, { 112, 12 }, { 20, 11 }, + { 34, 8 }, { 94, 8 }, { 50, 6 }, { 78, 6 }, { 41, 7 }, + { 87, 7 }, { 51, 6 }, { 77, 6 }, { 52, 6 }, { 76, 6 }, + { 29, 9 }, { 99, 9 }, { 35, 8 }, { 42, 7 }, { 86, 7 }, + { 93, 8 }, { 108, 11 }, { 1, 16 }, { 128, 16 }, { 126, 16 }, + { 127, 16 }, { 124, 16 }, { 125, 16 }, { 7, 15 }, { 13, 13 }, + { 115, 13 }, { 10, 14 }, { 118, 14 }, { 25, 10 }, { 103, 10 }, + { 17, 12 }, { 111, 12 }, { 21, 11 }, { 53, 6 }, { 75, 6 }, + { 54, 6 }, { 74, 6 }, { 43, 7 }, { 85, 7 }, { 55, 6 }, + { 73, 6 }, { 30, 9 }, { 98, 9 }, { 36, 8 }, { 92, 8 }, + { 107, 11 }, { 121, 15 }, { 5, 16 }, { 123, 16 }, { 8, 15 }, + { 120, 15 }, { 14, 13 }, { 114, 13 }, { 11, 14 }, { 117, 14 }, + { 26, 10 }, { 31, 9 }, { 56, 6 }, { 72, 6 }, { 57, 6 }, + { 71, 6 }, { 44, 7 }, { 84, 7 }, { 58, 6 }, + /* bitalloc_129_f - 129 entries */ + { 42, 6 }, { 86, 6 }, { 43, 6 }, { 85, 6 }, { 107, 8 }, + { 114, 9 }, { 9, 10 }, { 119, 10 }, { 30, 7 }, { 98, 7 }, + { 31, 7 }, { 44, 6 }, { 84, 6 }, { 45, 6 }, { 83, 6 }, + { 97, 7 }, { 22, 8 }, { 106, 8 }, { 46, 6 }, { 82, 6 }, + { 32, 7 }, { 96, 7 }, { 47, 6 }, { 81, 6 }, { 15, 9 }, + { 113, 9 }, { 23, 8 }, { 105, 8 }, { 10, 10 }, { 118, 10 }, + { 16, 9 }, { 48, 6 }, { 80, 6 }, { 33, 7 }, { 95, 7 }, + { 49, 6 }, { 79, 6 }, { 50, 6 }, { 78, 6 }, { 112, 9 }, + { 3, 12 }, { 125, 12 }, { 6, 11 }, { 122, 11 }, { 7, 11 }, + { 24, 8 }, { 34, 7 }, { 51, 6 }, { 77, 6 }, { 94, 7 }, + { 104, 8 }, { 11, 10 }, { 117, 10 }, { 17, 9 }, { 52, 6 }, + { 76, 6 }, { 53, 6 }, { 75, 6 }, { 35, 7 }, { 93, 7 }, + { 54, 6 }, { 74, 6 }, { 55, 6 }, { 73, 6 }, { 25, 8 }, + { 103, 8 }, { 36, 7 }, { 56, 6 }, { 72, 6 }, { 57, 6 }, + { 71, 6 }, { 92, 7 }, { 111, 9 }, { 121, 11 }, { 127, 13 }, + { 2, 13 }, { 4, 12 }, { 12, 10 }, { 18, 9 }, { 110, 9 }, + { 58, 6 }, { 70, 6 }, { 59, 6 }, { 69, 6 }, { 60, 6 }, + { 68, 6 }, { 61, 6 }, { 67, 6 }, { 62, 6 }, { 66, 6 }, + { 26, 8 }, { 102, 8 }, { 37, 7 }, { 63, 6 }, { 65, 6 }, + { 64, 6 }, { 91, 7 }, { 38, 7 }, { 90, 7 }, { 27, 8 }, + { 101, 8 }, { 116, 10 }, { 124, 12 }, { 126, 13 }, { 0, 15 }, + { 128, 15 }, { 1, 14 }, { 8, 11 }, { 19, 9 }, { 109, 9 }, + { 13, 10 }, { 115, 10 }, { 39, 7 }, { 89, 7 }, { 28, 8 }, + { 100, 8 }, { 40, 7 }, { 88, 7 }, { 41, 7 }, { 87, 7 }, + { 20, 9 }, { 108, 9 }, { 29, 8 }, { 99, 8 }, { 120, 11 }, + { 5, 12 }, { 123, 12 }, { 14, 10 }, { 21, 9 }, + /* bitalloc_129_g - 129 entries */ + { 64, 4 }, { 88, 7 }, { 9, 11 }, { 119, 11 }, { 17, 10 }, + { 25, 9 }, { 33, 8 }, { 41, 7 }, { 87, 7 }, { 49, 6 }, + { 79, 6 }, { 57, 5 }, { 71, 5 }, { 95, 8 }, { 103, 9 }, + { 111, 10 }, { 2, 12 }, { 126, 12 }, { 10, 11 }, { 18, 10 }, + { 110, 10 }, { 26, 9 }, { 34, 8 }, { 42, 7 }, { 86, 7 }, + { 50, 6 }, { 78, 6 }, { 58, 5 }, { 70, 5 }, { 94, 8 }, + { 102, 9 }, { 118, 11 }, { 3, 12 }, { 125, 12 }, { 11, 11 }, + { 117, 11 }, { 19, 10 }, { 109, 10 }, { 27, 9 }, { 35, 8 }, + { 43, 7 }, { 85, 7 }, { 51, 6 }, { 77, 6 }, { 59, 5 }, + { 69, 5 }, { 93, 8 }, { 101, 9 }, { 4, 12 }, { 124, 12 }, + { 12, 11 }, { 20, 10 }, { 28, 9 }, { 100, 9 }, { 36, 8 }, + { 44, 7 }, { 84, 7 }, { 52, 6 }, { 76, 6 }, { 60, 5 }, + { 68, 5 }, { 92, 8 }, { 108, 10 }, { 116, 11 }, { 5, 12 }, + { 123, 12 }, { 13, 11 }, { 115, 11 }, { 21, 10 }, { 29, 9 }, + { 99, 9 }, { 37, 8 }, { 45, 7 }, { 83, 7 }, { 53, 6 }, + { 75, 6 }, { 61, 5 }, { 67, 5 }, { 91, 8 }, { 107, 10 }, + { 6, 12 }, { 122, 12 }, { 14, 11 }, { 22, 10 }, { 106, 10 }, + { 30, 9 }, { 98, 9 }, { 38, 8 }, { 46, 7 }, { 82, 7 }, + { 54, 6 }, { 74, 6 }, { 62, 5 }, { 66, 5 }, { 90, 8 }, + { 114, 11 }, { 7, 12 }, { 121, 12 }, { 15, 11 }, { 113, 11 }, + { 23, 10 }, { 105, 10 }, { 31, 9 }, { 97, 9 }, { 39, 8 }, + { 47, 7 }, { 81, 7 }, { 55, 6 }, { 73, 6 }, { 63, 5 }, + { 65, 5 }, { 89, 8 }, { 0, 13 }, { 128, 13 }, { 8, 12 }, + { 16, 11 }, { 24, 10 }, { 32, 9 }, { 96, 9 }, { 104, 10 }, + { 112, 11 }, { 120, 12 }, { 1, 13 }, { 127, 13 }, { 40, 8 }, + { 48, 7 }, { 80, 7 }, { 56, 6 }, { 72, 6 }, + /* bit_alloc_12[0] - 12 entries */ + { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 4 }, { 4, 5 }, + { 5, 6 }, { 11, 9 }, { 10, 9 }, { 9, 9 }, { 8, 9 }, + { 7, 8 }, { 6, 8 }, + /* bit_alloc_12[1] - 12 entries */ + { 1, 2 }, { 2, 3 }, { 4, 5 }, { 11, 7 }, { 10, 7 }, + { 9, 7 }, { 8, 7 }, { 7, 7 }, { 6, 7 }, { 5, 6 }, + { 3, 5 }, { 0, 1 }, + /* bit_alloc_12[2] - 12 entries */ + { 0, 2 }, { 4, 3 }, { 7, 4 }, { 11, 7 }, { 10, 7 }, + { 9, 6 }, { 8, 5 }, { 3, 3 }, { 2, 3 }, { 6, 4 }, + { 5, 4 }, { 1, 3 }, + /* bit_alloc_12[3] - 12 entries */ + { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, + { 7, 7 }, { 8, 8 }, { 9, 9 }, { 11, 10 }, { 10, 10 }, + { 1, 2 }, { 0, 2 }, + /* bit_alloc_12[4] - 12 entries */ + { 1, 2 }, { 2, 3 }, { 3, 4 }, { 4, 5 }, { 9, 8 }, + { 8, 8 }, { 6, 7 }, { 7, 8 }, { 11, 9 }, { 10, 9 }, + { 5, 7 }, { 0, 1 }, + /* scale_factor[0] - 129 entries */ + { 66, 3 }, { 69, 5 }, { 55, 8 }, { 73, 8 }, { 40, 13 }, + { 88, 13 }, { 41, 13 }, { 87, 13 }, { 42, 13 }, { 86, 13 }, + { 43, 13 }, { 85, 13 }, { 44, 13 }, { 84, 13 }, { 45, 13 }, + { 83, 13 }, { 46, 13 }, { 82, 13 }, { 47, 13 }, { 81, 13 }, + { 51, 11 }, { 77, 11 }, { 48, 13 }, { 80, 13 }, { 50, 12 }, + { 78, 12 }, { 49, 13 }, { 79, 13 }, { 54, 9 }, { 74, 9 }, + { 58, 6 }, { 61, 4 }, { 64, 2 }, { 67, 4 }, { 70, 6 }, + { 57, 7 }, { 71, 7 }, { 60, 5 }, { 63, 3 }, { 65, 3 }, + { 68, 5 }, { 56, 8 }, { 72, 8 }, { 53, 10 }, { 75, 10 }, + { 52, 11 }, { 76, 11 }, { 0, 14 }, { 128, 14 }, { 1, 14 }, + { 127, 14 }, { 2, 14 }, { 126, 14 }, { 3, 14 }, { 125, 14 }, + { 4, 14 }, { 124, 14 }, { 5, 14 }, { 123, 14 }, { 6, 14 }, + { 122, 14 }, { 7, 14 }, { 121, 14 }, { 8, 14 }, { 120, 14 }, + { 9, 14 }, { 119, 14 }, { 10, 14 }, { 118, 14 }, { 11, 14 }, + { 117, 14 }, { 12, 14 }, { 116, 14 }, { 13, 14 }, { 115, 14 }, + { 14, 14 }, { 114, 14 }, { 15, 14 }, { 113, 14 }, { 16, 14 }, + { 112, 14 }, { 17, 14 }, { 111, 14 }, { 18, 14 }, { 110, 14 }, + { 19, 14 }, { 109, 14 }, { 20, 14 }, { 108, 14 }, { 21, 14 }, + { 107, 14 }, { 22, 14 }, { 106, 14 }, { 23, 14 }, { 105, 14 }, + { 24, 14 }, { 104, 14 }, { 25, 14 }, { 103, 14 }, { 26, 14 }, + { 102, 14 }, { 27, 14 }, { 101, 14 }, { 28, 14 }, { 100, 14 }, + { 29, 14 }, { 99, 14 }, { 30, 14 }, { 98, 14 }, { 31, 14 }, + { 97, 14 }, { 32, 14 }, { 96, 14 }, { 33, 14 }, { 95, 14 }, + { 34, 14 }, { 94, 14 }, { 35, 14 }, { 93, 14 }, { 36, 14 }, + { 92, 14 }, { 37, 14 }, { 91, 14 }, { 38, 14 }, { 90, 14 }, + { 39, 14 }, { 89, 14 }, { 59, 6 }, { 62, 4 }, + /* scale_factor[1] - 129 entries */ + { 69, 4 }, { 56, 6 }, { 72, 6 }, { 55, 7 }, { 73, 7 }, + { 54, 8 }, { 74, 8 }, { 75, 9 }, { 48, 14 }, { 80, 14 }, + { 49, 14 }, { 79, 14 }, { 50, 13 }, { 78, 13 }, { 51, 12 }, + { 77, 12 }, { 0, 15 }, { 128, 15 }, { 1, 15 }, { 127, 15 }, + { 2, 15 }, { 126, 15 }, { 3, 15 }, { 125, 15 }, { 4, 15 }, + { 124, 15 }, { 5, 15 }, { 123, 15 }, { 6, 15 }, { 122, 15 }, + { 7, 15 }, { 121, 15 }, { 8, 15 }, { 120, 15 }, { 9, 15 }, + { 119, 15 }, { 10, 15 }, { 118, 15 }, { 11, 15 }, { 117, 15 }, + { 12, 15 }, { 116, 15 }, { 13, 15 }, { 115, 15 }, { 14, 15 }, + { 114, 15 }, { 15, 15 }, { 113, 15 }, { 16, 15 }, { 112, 15 }, + { 17, 15 }, { 111, 15 }, { 18, 15 }, { 110, 15 }, { 19, 15 }, + { 109, 15 }, { 20, 15 }, { 108, 15 }, { 21, 15 }, { 107, 15 }, + { 22, 15 }, { 106, 15 }, { 23, 15 }, { 105, 15 }, { 24, 15 }, + { 104, 15 }, { 25, 15 }, { 103, 15 }, { 26, 15 }, { 102, 15 }, + { 27, 15 }, { 101, 15 }, { 28, 15 }, { 100, 15 }, { 29, 15 }, + { 99, 15 }, { 30, 15 }, { 98, 15 }, { 31, 15 }, { 97, 15 }, + { 32, 15 }, { 96, 15 }, { 33, 15 }, { 95, 15 }, { 34, 15 }, + { 94, 15 }, { 35, 15 }, { 93, 15 }, { 36, 15 }, { 92, 15 }, + { 37, 15 }, { 91, 15 }, { 38, 15 }, { 90, 15 }, { 39, 15 }, + { 89, 15 }, { 40, 15 }, { 88, 15 }, { 41, 15 }, { 87, 15 }, + { 42, 15 }, { 86, 15 }, { 43, 15 }, { 85, 15 }, { 44, 15 }, + { 84, 15 }, { 45, 15 }, { 83, 15 }, { 46, 15 }, { 82, 15 }, + { 47, 15 }, { 81, 15 }, { 52, 11 }, { 76, 11 }, { 53, 10 }, + { 63, 3 }, { 65, 3 }, { 64, 3 }, { 58, 5 }, { 70, 5 }, + { 60, 4 }, { 68, 4 }, { 61, 4 }, { 67, 4 }, { 57, 6 }, + { 71, 6 }, { 59, 5 }, { 62, 4 }, { 66, 4 }, + /* scale_factor[2] - 129 entries */ + { 63, 3 }, { 65, 3 }, { 46, 9 }, { 82, 9 }, { 49, 8 }, + { 79, 8 }, { 85, 10 }, { 38, 12 }, { 90, 12 }, { 41, 11 }, + { 87, 11 }, { 93, 13 }, { 33, 14 }, { 95, 14 }, { 36, 13 }, + { 92, 13 }, { 44, 10 }, { 52, 7 }, { 76, 7 }, { 55, 6 }, + { 73, 6 }, { 58, 5 }, { 70, 5 }, { 61, 4 }, { 67, 4 }, + { 64, 3 }, { 47, 9 }, { 81, 9 }, { 50, 8 }, { 78, 8 }, + { 84, 10 }, { 39, 12 }, { 89, 12 }, { 42, 11 }, { 86, 11 }, + { 0, 15 }, { 128, 15 }, { 1, 15 }, { 127, 15 }, { 2, 15 }, + { 126, 15 }, { 3, 15 }, { 125, 15 }, { 4, 15 }, { 124, 15 }, + { 5, 15 }, { 123, 15 }, { 6, 15 }, { 122, 15 }, { 7, 15 }, + { 121, 15 }, { 8, 15 }, { 120, 15 }, { 9, 15 }, { 119, 15 }, + { 10, 15 }, { 118, 15 }, { 11, 15 }, { 117, 15 }, { 12, 15 }, + { 116, 15 }, { 13, 15 }, { 115, 15 }, { 14, 15 }, { 114, 15 }, + { 15, 15 }, { 113, 15 }, { 16, 15 }, { 112, 15 }, { 17, 15 }, + { 111, 15 }, { 18, 15 }, { 110, 15 }, { 19, 15 }, { 109, 15 }, + { 20, 15 }, { 108, 15 }, { 21, 15 }, { 107, 15 }, { 22, 15 }, + { 106, 15 }, { 23, 15 }, { 105, 15 }, { 53, 7 }, { 75, 7 }, + { 56, 6 }, { 72, 6 }, { 59, 5 }, { 69, 5 }, { 62, 4 }, + { 66, 4 }, { 45, 10 }, { 83, 10 }, { 48, 9 }, { 80, 9 }, + { 24, 15 }, { 104, 15 }, { 25, 15 }, { 103, 15 }, { 26, 15 }, + { 102, 15 }, { 27, 15 }, { 101, 15 }, { 28, 15 }, { 100, 15 }, + { 29, 15 }, { 99, 15 }, { 30, 15 }, { 98, 15 }, { 31, 15 }, + { 97, 15 }, { 34, 14 }, { 94, 14 }, { 37, 13 }, { 40, 12 }, + { 88, 12 }, { 91, 13 }, { 32, 15 }, { 96, 15 }, { 35, 14 }, + { 43, 11 }, { 51, 8 }, { 77, 8 }, { 54, 7 }, { 74, 7 }, + { 57, 6 }, { 71, 6 }, { 60, 5 }, { 68, 5 }, + /* scale_factor[3] - 129 entries */ + { 64, 2 }, { 53, 8 }, { 75, 8 }, { 55, 7 }, { 57, 6 }, + { 59, 5 }, { 69, 5 }, { 71, 6 }, { 73, 7 }, { 77, 9 }, + { 79, 10 }, { 83, 12 }, { 42, 14 }, { 86, 14 }, { 44, 13 }, + { 46, 12 }, { 82, 12 }, { 48, 11 }, { 80, 11 }, { 50, 10 }, + { 52, 9 }, { 61, 4 }, { 67, 4 }, { 63, 3 }, { 65, 3 }, + { 54, 8 }, { 74, 8 }, { 56, 7 }, { 58, 6 }, { 60, 5 }, + { 68, 5 }, { 70, 6 }, { 72, 7 }, { 76, 9 }, { 78, 10 }, + { 84, 13 }, { 0, 15 }, { 128, 15 }, { 1, 15 }, { 127, 15 }, + { 2, 15 }, { 126, 15 }, { 3, 15 }, { 125, 15 }, { 4, 15 }, + { 124, 15 }, { 5, 15 }, { 123, 15 }, { 6, 15 }, { 122, 15 }, + { 7, 15 }, { 121, 15 }, { 8, 15 }, { 120, 15 }, { 9, 15 }, + { 119, 15 }, { 10, 15 }, { 118, 15 }, { 11, 15 }, { 117, 15 }, + { 12, 15 }, { 116, 15 }, { 13, 15 }, { 115, 15 }, { 14, 15 }, + { 114, 15 }, { 15, 15 }, { 113, 15 }, { 16, 15 }, { 112, 15 }, + { 17, 15 }, { 111, 15 }, { 18, 15 }, { 110, 15 }, { 19, 15 }, + { 109, 15 }, { 20, 15 }, { 108, 15 }, { 21, 15 }, { 107, 15 }, + { 22, 15 }, { 106, 15 }, { 23, 15 }, { 105, 15 }, { 24, 15 }, + { 104, 15 }, { 25, 15 }, { 103, 15 }, { 26, 15 }, { 102, 15 }, + { 27, 15 }, { 101, 15 }, { 28, 15 }, { 100, 15 }, { 29, 15 }, + { 99, 15 }, { 30, 15 }, { 98, 15 }, { 31, 15 }, { 97, 15 }, + { 32, 15 }, { 96, 15 }, { 33, 15 }, { 95, 15 }, { 34, 15 }, + { 94, 15 }, { 35, 15 }, { 93, 15 }, { 36, 15 }, { 92, 15 }, + { 37, 15 }, { 91, 15 }, { 38, 15 }, { 90, 15 }, { 39, 15 }, + { 89, 15 }, { 40, 15 }, { 88, 15 }, { 41, 15 }, { 87, 15 }, + { 43, 14 }, { 85, 14 }, { 45, 13 }, { 47, 12 }, { 81, 12 }, + { 49, 11 }, { 51, 10 }, { 62, 4 }, { 66, 4 }, + /* scale_factor[4] - 129 entries */ + { 56, 5 }, { 72, 5 }, { 52, 6 }, { 76, 6 }, { 48, 7 }, + { 80, 7 }, { 44, 8 }, { 84, 8 }, { 40, 9 }, { 88, 9 }, + { 36, 10 }, { 92, 10 }, { 96, 11 }, { 28, 12 }, { 100, 12 }, + { 24, 13 }, { 104, 13 }, { 16, 15 }, { 112, 15 }, { 20, 14 }, + { 108, 14 }, { 21, 14 }, { 33, 11 }, { 61, 4 }, { 67, 4 }, + { 57, 5 }, { 71, 5 }, { 53, 6 }, { 75, 6 }, { 49, 7 }, + { 79, 7 }, { 45, 8 }, { 83, 8 }, { 41, 9 }, { 87, 9 }, + { 37, 10 }, { 91, 10 }, { 95, 11 }, { 29, 12 }, { 99, 12 }, + { 25, 13 }, { 103, 13 }, { 107, 14 }, { 17, 15 }, { 111, 15 }, + { 26, 13 }, { 34, 11 }, { 62, 4 }, { 66, 4 }, { 58, 5 }, + { 70, 5 }, { 54, 6 }, { 74, 6 }, { 50, 7 }, { 78, 7 }, + { 46, 8 }, { 82, 8 }, { 42, 9 }, { 86, 9 }, { 38, 10 }, + { 90, 10 }, { 94, 11 }, { 30, 12 }, { 98, 12 }, { 39, 10 }, + { 63, 4 }, { 65, 4 }, { 59, 5 }, { 69, 5 }, { 55, 6 }, + { 73, 6 }, { 51, 7 }, { 77, 7 }, { 47, 8 }, { 81, 8 }, + { 43, 9 }, { 85, 9 }, { 89, 10 }, { 102, 13 }, { 22, 14 }, + { 106, 14 }, { 18, 15 }, { 110, 15 }, { 0, 16 }, { 128, 16 }, + { 1, 16 }, { 127, 16 }, { 27, 13 }, { 35, 11 }, { 93, 11 }, + { 31, 12 }, { 97, 12 }, { 101, 13 }, { 2, 16 }, { 126, 16 }, + { 3, 16 }, { 125, 16 }, { 4, 16 }, { 124, 16 }, { 5, 16 }, + { 123, 16 }, { 6, 16 }, { 122, 16 }, { 7, 16 }, { 121, 16 }, + { 8, 16 }, { 120, 16 }, { 9, 16 }, { 119, 16 }, { 10, 16 }, + { 118, 16 }, { 11, 16 }, { 117, 16 }, { 12, 16 }, { 116, 16 }, + { 13, 16 }, { 115, 16 }, { 14, 16 }, { 114, 16 }, { 15, 16 }, + { 113, 16 }, { 23, 14 }, { 105, 14 }, { 19, 15 }, { 109, 15 }, + { 32, 12 }, { 64, 4 }, { 60, 5 }, { 68, 5 }, + /* transition_mode[0] - 4 entries */ + { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 3 }, + /* transition_mode[1] - 4 entries */ + { 3, 1 }, { 0, 2 }, { 1, 3 }, { 2, 3 }, + /* transition_mode[2] - 4 entries */ + { 2, 1 }, { 3, 2 }, { 0, 3 }, { 1, 3 }, + /* transition_mode[3] - 4 entries */ + { 0, 2 }, { 1, 2 }, { 2, 2 }, { 3, 2 }, + /* tnl_group[0] - 37 entries */ + { 5, 3 }, { 4, 3 }, { 19, 8 }, { 33, 12 }, { 31, 12 }, + { 28, 11 }, { 34, 14 }, { 37, 14 }, { 35, 15 }, { 0, 15 }, + { 36, 14 }, { 32, 12 }, { 30, 11 }, { 24, 9 }, { 22, 8 }, + { 23, 9 }, { 29, 10 }, { 27, 10 }, { 17, 6 }, { 14, 5 }, + { 7, 4 }, { 12, 5 }, { 1, 6 }, { 26, 9 }, { 3, 9 }, + { 25, 8 }, { 20, 7 }, { 8, 4 }, { 10, 4 }, { 13, 4 }, + { 15, 6 }, { 16, 6 }, { 18, 6 }, { 21, 6 }, { 11, 4 }, + { 9, 3 }, { 6, 3 }, + /* tnl_group[1] - 34 entries */ + { 4, 4 }, { 7, 4 }, { 10, 4 }, { 3, 10 }, { 27, 10 }, + { 29, 10 }, { 28, 10 }, { 22, 8 }, { 21, 7 }, { 15, 6 }, + { 14, 5 }, { 8, 4 }, { 16, 6 }, { 19, 7 }, { 23, 8 }, + { 26, 9 }, { 30, 10 }, { 33, 13 }, { 34, 14 }, { 0, 14 }, + { 32, 12 }, { 31, 11 }, { 12, 5 }, { 5, 3 }, { 9, 3 }, + { 1, 4 }, { 20, 7 }, { 25, 8 }, { 24, 8 }, { 18, 6 }, + { 17, 5 }, { 6, 3 }, { 11, 4 }, { 13, 4 }, + /* tnl_group[2] - 31 entries */ + { 14, 7 }, { 17, 7 }, { 15, 7 }, { 23, 9 }, { 28, 10 }, + { 29, 11 }, { 30, 13 }, { 0, 13 }, { 31, 12 }, { 25, 8 }, + { 10, 5 }, { 8, 4 }, { 9, 4 }, { 4, 4 }, { 22, 8 }, + { 3, 8 }, { 21, 8 }, { 26, 9 }, { 27, 9 }, { 12, 6 }, + { 11, 5 }, { 16, 7 }, { 18, 7 }, { 20, 8 }, { 24, 8 }, + { 19, 7 }, { 13, 5 }, { 5, 3 }, { 1, 2 }, { 6, 3 }, + { 7, 3 }, + /* tnl_group[3] - 28 entries */ + { 8, 6 }, { 2, 6 }, { 7, 6 }, { 23, 7 }, { 12, 7 }, + { 5, 4 }, { 10, 6 }, { 20, 8 }, { 25, 9 }, { 26, 10 }, + { 27, 11 }, { 0, 11 }, { 22, 7 }, { 9, 5 }, { 13, 6 }, + { 17, 6 }, { 4, 5 }, { 14, 6 }, { 19, 7 }, { 24, 7 }, + { 3, 6 }, { 11, 6 }, { 21, 6 }, { 18, 6 }, { 16, 6 }, + { 15, 6 }, { 6, 3 }, { 1, 1 }, + /* tnl_group[4] - 23 entries */ + { 2, 2 }, { 7, 7 }, { 15, 8 }, { 21, 8 }, { 3, 6 }, + { 6, 6 }, { 13, 7 }, { 14, 8 }, { 18, 8 }, { 4, 4 }, + { 5, 5 }, { 11, 7 }, { 10, 7 }, { 20, 6 }, { 12, 8 }, + { 16, 9 }, { 22, 10 }, { 0, 10 }, { 17, 7 }, { 19, 6 }, + { 8, 6 }, { 9, 6 }, { 1, 1 }, + /* tnl_scf - 20 entries */ + { 3, 3 }, { 11, 6 }, { 16, 9 }, { 17, 10 }, { 18, 11 }, + { 19, 12 }, { 0, 12 }, { 15, 8 }, { 14, 7 }, { 9, 5 }, + { 7, 4 }, { 2, 3 }, { 4, 3 }, { 1, 3 }, { 5, 3 }, + { 12, 6 }, { 13, 6 }, { 10, 5 }, { 8, 4 }, { 6, 3 }, + /* damp - 7 entries */ + { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, + { 0, 6 }, { 1, 1 }, + /* dph - 9 entries */ + { 2, 2 }, { 1, 2 }, { 3, 4 }, { 7, 4 }, { 6, 5 }, + { 5, 6 }, { 0, 6 }, { 4, 4 }, { 8, 2 }, + /* fst_rsd_amp - 24 entries */ + { 12, 4 }, { 17, 4 }, { 1, 6 }, { 8, 6 }, { 9, 5 }, + { 20, 7 }, { 3, 7 }, { 5, 6 }, { 6, 6 }, { 2, 7 }, + { 22, 9 }, { 23, 10 }, { 0, 10 }, { 21, 8 }, { 11, 4 }, + { 19, 5 }, { 7, 6 }, { 4, 6 }, { 16, 3 }, { 10, 4 }, + { 18, 4 }, { 15, 3 }, { 13, 3 }, { 14, 3 }, + /* rsd_apprx - 6 entries */ + { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, + { 0, 5 }, + /* rsd_amp - 33 entries */ + { 2, 3 }, { 1, 3 }, { 5, 3 }, { 14, 8 }, { 20, 9 }, + { 26, 10 }, { 25, 12 }, { 32, 12 }, { 19, 11 }, { 16, 8 }, + { 24, 9 }, { 17, 9 }, { 12, 7 }, { 13, 7 }, { 9, 5 }, + { 7, 4 }, { 3, 2 }, { 4, 3 }, { 8, 6 }, { 11, 6 }, + { 18, 8 }, { 15, 8 }, { 30, 11 }, { 36, 13 }, { 34, 13 }, + { 29, 13 }, { 0, 13 }, { 21, 10 }, { 28, 10 }, { 23, 10 }, + { 22, 8 }, { 10, 6 }, { 6, 4 }, + /* avg_g3 - 18 entries */ + { 14, 4 }, { 11, 6 }, { 19, 7 }, { 9, 7 }, { 13, 5 }, + { 10, 6 }, { 20, 8 }, { 8, 8 }, { 6, 10 }, { 23, 11 }, + { 0, 11 }, { 21, 9 }, { 7, 8 }, { 12, 5 }, { 18, 4 }, + { 16, 2 }, { 15, 2 }, { 17, 2 }, + /* st_grid - 22 entries */ + { 4, 4 }, { 3, 4 }, { 8, 4 }, { 14, 8 }, { 7, 9 }, + { 9, 10 }, { 22, 10 }, { 12, 7 }, { 16, 9 }, { 11, 10 }, + { 13, 11 }, { 17, 13 }, { 15, 13 }, { 24, 13 }, { 0, 13 }, + { 18, 9 }, { 20, 10 }, { 2, 10 }, { 5, 7 }, { 10, 5 }, + { 1, 2 }, { 6, 1 }, + /* grid_2 - 20 entries */ + { 3, 2 }, { 2, 2 }, { 4, 3 }, { 5, 4 }, { 6, 5 }, + { 11, 11 }, { 13, 12 }, { 17, 12 }, { 19, 14 }, { 14, 14 }, + { 18, 13 }, { 15, 13 }, { 16, 14 }, { 0, 14 }, { 12, 11 }, + { 10, 9 }, { 9, 8 }, { 8, 7 }, { 7, 6 }, { 1, 2 }, + /* grid_3 - 13 entries */ + { 18, 3 }, { 15, 4 }, { 19, 5 }, { 14, 6 }, { 13, 8 }, + { 12, 10 }, { 11, 12 }, { 0, 12 }, { 22, 11 }, { 21, 9 }, + { 20, 7 }, { 16, 2 }, { 17, 1 }, + /* rsd - 9 entries */ + { 1, 3 }, { 5, 4 }, { 6, 5 }, { 7, 6 }, { 4, 6 }, + { 4, 3 }, { 0, 3 }, { 2, 2 }, { 3, 2 }, }; DCAVLC ff_dca_vlc_bit_allocation; @@ -1250,67 +789,65 @@ VLC ff_dca_vlc_rsd; av_cold void ff_dca_init_vlcs(void) { static VLCElem dca_table[30218]; + const uint8_t (*src_table)[2] = ff_dca_vlc_src_tables; unsigned offset = 0; - int i, j; + int i; -#define DCA_INIT_VLC(vlc, a, b, c, d) \ +#define DCA_INIT_VLC(vlc, nb_bits, nb_codes) \ do { \ vlc.table = &dca_table[offset]; \ vlc.table_allocated = FF_ARRAY_ELEMS(dca_table) - offset; \ - init_vlc(&vlc, a, b, c, 1, 1, d, 2, 2, INIT_VLC_STATIC_OVERLONG); \ + ff_init_vlc_from_lengths(&vlc, nb_bits, nb_codes, &src_table[0][1], 2, \ + &src_table[0][0], 2, 1, \ + 0, INIT_VLC_STATIC_OVERLONG, NULL); \ offset += vlc.table_size; \ + src_table += nb_codes; \ } while (0) + for (unsigned i = 0; i < DCA_CODE_BOOKS; i++) { + ff_dca_vlc_quant_index[i].offset = ff_dca_bitalloc_offsets[i]; + ff_dca_vlc_quant_index[i].max_depth = 1 + (i > 4); + for (unsigned j = 0; j < ff_dca_quant_index_group_size[i]; j++) + DCA_INIT_VLC(ff_dca_vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j], + ff_dca_bitalloc_sizes[i]); + } + ff_dca_vlc_bit_allocation.offset = 1; ff_dca_vlc_bit_allocation.max_depth = 2; for (i = 0; i < 5; i++) - DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, - ff_dca_bitalloc_12_bits[i], ff_dca_bitalloc_12_codes[i]); + DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12); ff_dca_vlc_scale_factor.offset = -64; ff_dca_vlc_scale_factor.max_depth = 2; for (i = 0; i < 5; i++) - DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129, - scales_bits[i], scales_codes[i]); + DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129); for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++) - DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4, - tmode_bits[i], tmode_codes[i]); - - for (i = 0; i < DCA_CODE_BOOKS; i++) { - ff_dca_vlc_quant_index[i].offset = ff_dca_bitalloc_offsets[i]; - ff_dca_vlc_quant_index[i].max_depth = 1 + (i > 4); - for (j = 0; ff_dca_bitalloc_codes[i][j]; j++) - DCA_INIT_VLC(ff_dca_vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j], - ff_dca_bitalloc_sizes[i], ff_dca_bitalloc_bits[i][j], ff_dca_bitalloc_codes[i][j]); - } + DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4); -#define LBR_INIT_VLC(vlc, tab, nb_bits) \ +#define LBR_INIT_VLC(vlc, nb_bits, nb_codes) \ do { \ vlc.table = &dca_table[offset]; \ vlc.table_allocated = FF_ARRAY_ELEMS(dca_table) - offset; \ - ff_init_vlc_sparse(&vlc, nb_bits, FF_ARRAY_ELEMS(tab##_codes), \ - &tab##_bitvals[0], 2, 1, \ - tab##_codes, 2, 2, \ - &tab##_bitvals[1], 2, 1, \ - INIT_VLC_LE | INIT_VLC_STATIC_OVERLONG); \ + ff_init_vlc_from_lengths(&vlc, nb_bits, nb_codes, &src_table[0][1], 2, \ + &src_table[0][0], 2, 1, 0, \ + INIT_VLC_STATIC_OVERLONG | INIT_VLC_LE,\ + NULL); \ offset += vlc.table_size; \ + src_table += nb_codes; \ } while (0) - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[0], tnl_grp_0, 9); - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[1], tnl_grp_1, 9); - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[2], tnl_grp_2, 9); - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[3], tnl_grp_3, 9); - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[4], tnl_grp_4, 9); - LBR_INIT_VLC(ff_dca_vlc_tnl_scf, tnl_scf, 9); - LBR_INIT_VLC(ff_dca_vlc_damp, damp, 6); - LBR_INIT_VLC(ff_dca_vlc_dph, dph, 6); - LBR_INIT_VLC(ff_dca_vlc_fst_rsd_amp, fst_rsd_amp, 9); - LBR_INIT_VLC(ff_dca_vlc_rsd_apprx, rsd_apprx, 5); - LBR_INIT_VLC(ff_dca_vlc_rsd_amp, rsd_amp, 9); - LBR_INIT_VLC(ff_dca_vlc_avg_g3, avg_g3, 9); - LBR_INIT_VLC(ff_dca_vlc_st_grid, st_grid, 9); - LBR_INIT_VLC(ff_dca_vlc_grid_2, grid_2, 9); - LBR_INIT_VLC(ff_dca_vlc_grid_3, grid_3, 9); - LBR_INIT_VLC(ff_dca_vlc_rsd, rsd, 6); + for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_tnl_grp); i++) + LBR_INIT_VLC(ff_dca_vlc_tnl_grp[i], 9, tnl_grp_sizes[i]); + LBR_INIT_VLC(ff_dca_vlc_tnl_scf, 9, 20); + LBR_INIT_VLC(ff_dca_vlc_damp, 6, 7); + LBR_INIT_VLC(ff_dca_vlc_dph, 6, 9); + LBR_INIT_VLC(ff_dca_vlc_fst_rsd_amp, 9, 24); + LBR_INIT_VLC(ff_dca_vlc_rsd_apprx, 5, 6); + LBR_INIT_VLC(ff_dca_vlc_rsd_amp, 9, 33); + LBR_INIT_VLC(ff_dca_vlc_avg_g3, 9, 18); + LBR_INIT_VLC(ff_dca_vlc_st_grid, 9, 22); + LBR_INIT_VLC(ff_dca_vlc_grid_2, 9, 20); + LBR_INIT_VLC(ff_dca_vlc_grid_3, 9, 13); + LBR_INIT_VLC(ff_dca_vlc_rsd, 6, 9); } diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index 68974d9965..c0bdce5998 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -62,11 +62,7 @@ extern VLC ff_dca_vlc_rsd; extern const int8_t ff_dca_bitalloc_offsets[DCA_CODE_BOOKS]; extern const uint8_t ff_dca_bitalloc_sizes[DCA_CODE_BOOKS]; -extern const uint16_t *const ff_dca_bitalloc_codes[DCA_CODE_BOOKS][8]; -extern const uint8_t *const ff_dca_bitalloc_bits[DCA_CODE_BOOKS][8]; - -extern const uint8_t ff_dca_bitalloc_12_bits[DCA_BITALLOC_12_COUNT][12]; -extern const uint16_t ff_dca_bitalloc_12_codes[DCA_BITALLOC_12_COUNT][12]; +extern const uint8_t ff_dca_vlc_src_tables[][2]; av_cold void ff_dca_init_vlcs(void); From 597bfff342666288a6a7b335eae859e2f8230659 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 04:04:59 +0200 Subject: [PATCH 303/590] avcodec/dcahuff, dca_core, dca_lbr: Apply offset during VLC creation Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 2 +- libavcodec/dca_lbr.c | 4 ++-- libavcodec/dcahuff.c | 45 ++++++++++++++++++++----------------------- libavcodec/dcahuff.h | 1 - 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 069d428fff..96787fe95d 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -69,7 +69,7 @@ static const uint8_t block_code_nbits[7] = { static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i) { - return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, v->max_depth) + v->offset; + return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, v->max_depth); } static void get_array(GetBitContext *s, int32_t *array, int size, int n) diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index 5343bcde8a..579bd9c469 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -263,8 +263,8 @@ static int parse_lfe_chunk(DCALbrDecoder *s, LBRChunk *chunk) static inline int parse_vlc(GetBitContext *s, VLC *vlc, int max_depth) { int v = get_vlc2(s, vlc->table, vlc->bits, max_depth); - if (v > 0) - return v - 1; + if (v >= 0) + return v; // Rare value return get_bits(s, get_bits(s, 3) + 1); } diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index ee4d4bcd6d..7a5b054dd5 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -793,44 +793,41 @@ av_cold void ff_dca_init_vlcs(void) unsigned offset = 0; int i; -#define DCA_INIT_VLC(vlc, nb_bits, nb_codes) \ +#define DCA_INIT_VLC(vlc, nb_bits, nb_codes, entry_offset) \ do { \ vlc.table = &dca_table[offset]; \ vlc.table_allocated = FF_ARRAY_ELEMS(dca_table) - offset; \ ff_init_vlc_from_lengths(&vlc, nb_bits, nb_codes, &src_table[0][1], 2, \ - &src_table[0][0], 2, 1, \ - 0, INIT_VLC_STATIC_OVERLONG, NULL); \ + &src_table[0][0], 2, 1, entry_offset, \ + INIT_VLC_STATIC_OVERLONG, NULL); \ offset += vlc.table_size; \ src_table += nb_codes; \ } while (0) for (unsigned i = 0; i < DCA_CODE_BOOKS; i++) { - ff_dca_vlc_quant_index[i].offset = ff_dca_bitalloc_offsets[i]; ff_dca_vlc_quant_index[i].max_depth = 1 + (i > 4); for (unsigned j = 0; j < ff_dca_quant_index_group_size[i]; j++) DCA_INIT_VLC(ff_dca_vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j], - ff_dca_bitalloc_sizes[i]); + ff_dca_bitalloc_sizes[i], ff_dca_bitalloc_offsets[i]); } - ff_dca_vlc_bit_allocation.offset = 1; ff_dca_vlc_bit_allocation.max_depth = 2; for (i = 0; i < 5; i++) - DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12); + DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, 1); - ff_dca_vlc_scale_factor.offset = -64; ff_dca_vlc_scale_factor.max_depth = 2; for (i = 0; i < 5; i++) - DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129); + DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129, -64); for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++) - DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4); + DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4, 0); -#define LBR_INIT_VLC(vlc, nb_bits, nb_codes) \ +#define LBR_INIT_VLC(vlc, nb_bits, nb_codes, entry_offset) \ do { \ vlc.table = &dca_table[offset]; \ vlc.table_allocated = FF_ARRAY_ELEMS(dca_table) - offset; \ ff_init_vlc_from_lengths(&vlc, nb_bits, nb_codes, &src_table[0][1], 2, \ - &src_table[0][0], 2, 1, 0, \ + &src_table[0][0], 2, 1, entry_offset, \ INIT_VLC_STATIC_OVERLONG | INIT_VLC_LE,\ NULL); \ offset += vlc.table_size; \ @@ -838,16 +835,16 @@ av_cold void ff_dca_init_vlcs(void) } while (0) for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_tnl_grp); i++) - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[i], 9, tnl_grp_sizes[i]); - LBR_INIT_VLC(ff_dca_vlc_tnl_scf, 9, 20); - LBR_INIT_VLC(ff_dca_vlc_damp, 6, 7); - LBR_INIT_VLC(ff_dca_vlc_dph, 6, 9); - LBR_INIT_VLC(ff_dca_vlc_fst_rsd_amp, 9, 24); - LBR_INIT_VLC(ff_dca_vlc_rsd_apprx, 5, 6); - LBR_INIT_VLC(ff_dca_vlc_rsd_amp, 9, 33); - LBR_INIT_VLC(ff_dca_vlc_avg_g3, 9, 18); - LBR_INIT_VLC(ff_dca_vlc_st_grid, 9, 22); - LBR_INIT_VLC(ff_dca_vlc_grid_2, 9, 20); - LBR_INIT_VLC(ff_dca_vlc_grid_3, 9, 13); - LBR_INIT_VLC(ff_dca_vlc_rsd, 6, 9); + LBR_INIT_VLC(ff_dca_vlc_tnl_grp[i], 9, tnl_grp_sizes[i], -1); + LBR_INIT_VLC(ff_dca_vlc_tnl_scf, 9, 20, -1); + LBR_INIT_VLC(ff_dca_vlc_damp, 6, 7, -1); + LBR_INIT_VLC(ff_dca_vlc_dph, 6, 9, -1); + LBR_INIT_VLC(ff_dca_vlc_fst_rsd_amp, 9, 24, -1); + LBR_INIT_VLC(ff_dca_vlc_rsd_apprx, 5, 6, -1); + LBR_INIT_VLC(ff_dca_vlc_rsd_amp, 9, 33, -1); + LBR_INIT_VLC(ff_dca_vlc_avg_g3, 9, 18, -1); + LBR_INIT_VLC(ff_dca_vlc_st_grid, 9, 22, -1); + LBR_INIT_VLC(ff_dca_vlc_grid_2, 9, 20, -1); + LBR_INIT_VLC(ff_dca_vlc_grid_3, 9, 13, -1); + LBR_INIT_VLC(ff_dca_vlc_rsd, 6, 9, 0); } diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index c0bdce5998..a50d49d6dd 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -36,7 +36,6 @@ + 7 * (17 + 25 + 33 + 65 + 129)) typedef struct DCAVLC { - int offset; ///< Code values offset int max_depth; ///< Parameter for get_vlc2() VLC vlc[7]; ///< Actual codes } DCAVLC; From 9dbc37076978c2127606c70e0d6b6004a3224426 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 14:53:48 +0200 Subject: [PATCH 304/590] avcodec/dca_core: Inline number of bits of scale factor VLCs Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 6 ++++-- libavcodec/dcahuff.c | 7 +++---- libavcodec/dcahuff.h | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 96787fe95d..7dff6633df 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -362,7 +362,8 @@ static inline int parse_scale(DCACoreDecoder *s, int *scale_index, int sel) // If Huffman code was used, the difference of scales was encoded if (sel < 5) - *scale_index += dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel); + *scale_index += get_vlc2(&s->gb, ff_dca_vlc_scale_factor[sel].table, + DCA_SCALES_VLC_BITS, 2); else *scale_index = get_bits(&s->gb, sel + 1); @@ -381,7 +382,8 @@ static inline int parse_joint_scale(DCACoreDecoder *s, int sel) // Absolute value was encoded even when Huffman code was used if (sel < 5) - scale_index = dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel); + scale_index = get_vlc2(&s->gb, ff_dca_vlc_scale_factor[sel].table, + DCA_SCALES_VLC_BITS, 2); else scale_index = get_bits(&s->gb, sel + 1); diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index 7a5b054dd5..a7518aded8 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -770,7 +770,7 @@ const uint8_t ff_dca_vlc_src_tables[][2] = { DCAVLC ff_dca_vlc_bit_allocation; VLC ff_dca_vlc_transition_mode[4]; -DCAVLC ff_dca_vlc_scale_factor; +VLC ff_dca_vlc_scale_factor[5]; DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; VLC ff_dca_vlc_tnl_grp[5]; @@ -815,9 +815,8 @@ av_cold void ff_dca_init_vlcs(void) for (i = 0; i < 5; i++) DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, 1); - ff_dca_vlc_scale_factor.max_depth = 2; - for (i = 0; i < 5; i++) - DCA_INIT_VLC(ff_dca_vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129, -64); + for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_scale_factor); i++) + DCA_INIT_VLC(ff_dca_vlc_scale_factor[i], DCA_SCALES_VLC_BITS, 129, -64); for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_transition_mode); i++) DCA_INIT_VLC(ff_dca_vlc_transition_mode[i], DCA_TMODE_VLC_BITS, 4, 0); diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index a50d49d6dd..8663f8ba12 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -43,7 +43,8 @@ typedef struct DCAVLC { extern DCAVLC ff_dca_vlc_bit_allocation; #define DCA_TMODE_VLC_BITS 3 extern VLC ff_dca_vlc_transition_mode[4]; -extern DCAVLC ff_dca_vlc_scale_factor; +#define DCA_SCALES_VLC_BITS 9 +extern VLC ff_dca_vlc_scale_factor[5]; extern DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; extern VLC ff_dca_vlc_tnl_grp[5]; From 3652114596096a2b015972e9db063323c408c91e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 04:06:48 +0200 Subject: [PATCH 305/590] avcodec/dca_core: Don't use too big max_depth in get_vlc2() Most of the VLCs used here have a max_depth of two; some have a max_depth of one. Therefore one can just use two and avoid the runtime check for whether one should perform another round of LUT lookup in case the first read did not read a complete codeword. Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 7dff6633df..7b23a40df4 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -69,7 +69,7 @@ static const uint8_t block_code_nbits[7] = { static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i) { - return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, v->max_depth); + return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, 2); } static void get_array(GetBitContext *s, int32_t *array, int size, int n) From 465e27e0f2b35b13d348c882c723158a36a802ef Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 6 Sep 2022 16:53:48 +0200 Subject: [PATCH 306/590] avcodec/dcahuff: Replace DCAVLC by ordinary VLCs This is possible now that the offsets are already applied when creating the VLC. Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_core.c | 10 +++++----- libavcodec/dcahuff.c | 13 +++++-------- libavcodec/dcahuff.h | 9 ++------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c index 7b23a40df4..c204e41cb7 100644 --- a/libavcodec/dca_core.c +++ b/libavcodec/dca_core.c @@ -67,9 +67,9 @@ static const uint8_t block_code_nbits[7] = { 7, 10, 12, 13, 15, 17, 19 }; -static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i) +static int dca_get_vlc(GetBitContext *s, const VLC *vlc) { - return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, 2); + return get_vlc2(s, vlc->table, vlc->bits, 2); } static void get_array(GetBitContext *s, int32_t *array, int size, int n) @@ -435,7 +435,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf, int abits; if (sel < 5) - abits = dca_get_vlc(&s->gb, &ff_dca_vlc_bit_allocation, sel); + abits = dca_get_vlc(&s->gb, &ff_dca_vlc_bit_allocation[sel]); else abits = get_bits(&s->gb, sel - 1); @@ -570,7 +570,7 @@ static inline int parse_huffman_codes(DCACoreDecoder *s, int32_t *audio, int abi // Extract Huffman codes from the bit stream for (i = 0; i < DCA_SUBBAND_SAMPLES; i++) - audio[i] = dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[abits - 1], sel); + audio[i] = dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[abits - 1][sel]); return 1; } @@ -1340,7 +1340,7 @@ static int parse_x96_subframe_header(DCACoreDecoder *s, int xch_base) for (band = s->x96_subband_start; band < s->nsubbands[ch]; band++) { // If Huffman code was used, the difference of abits was encoded if (sel < 7) - abits += dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[5 + 2 * s->x96_high_res], sel); + abits += dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[5 + 2 * s->x96_high_res][sel]); else abits = get_bits(&s->gb, 3 + s->x96_high_res); diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index a7518aded8..937a87ee05 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -768,10 +768,10 @@ const uint8_t ff_dca_vlc_src_tables[][2] = { { 4, 3 }, { 0, 3 }, { 2, 2 }, { 3, 2 }, }; -DCAVLC ff_dca_vlc_bit_allocation; +VLC ff_dca_vlc_bit_allocation[5]; VLC ff_dca_vlc_transition_mode[4]; VLC ff_dca_vlc_scale_factor[5]; -DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; +VLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS][7]; VLC ff_dca_vlc_tnl_grp[5]; VLC ff_dca_vlc_tnl_scf; @@ -791,7 +791,6 @@ av_cold void ff_dca_init_vlcs(void) static VLCElem dca_table[30218]; const uint8_t (*src_table)[2] = ff_dca_vlc_src_tables; unsigned offset = 0; - int i; #define DCA_INIT_VLC(vlc, nb_bits, nb_codes, entry_offset) \ do { \ @@ -805,15 +804,13 @@ av_cold void ff_dca_init_vlcs(void) } while (0) for (unsigned i = 0; i < DCA_CODE_BOOKS; i++) { - ff_dca_vlc_quant_index[i].max_depth = 1 + (i > 4); for (unsigned j = 0; j < ff_dca_quant_index_group_size[i]; j++) - DCA_INIT_VLC(ff_dca_vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j], + DCA_INIT_VLC(ff_dca_vlc_quant_index[i][j], bitalloc_maxbits[i][j], ff_dca_bitalloc_sizes[i], ff_dca_bitalloc_offsets[i]); } - ff_dca_vlc_bit_allocation.max_depth = 2; - for (i = 0; i < 5; i++) - DCA_INIT_VLC(ff_dca_vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12, 1); + for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_bit_allocation); i++) + DCA_INIT_VLC(ff_dca_vlc_bit_allocation[i], bitalloc_12_vlc_bits[i], 12, 1); for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_scale_factor); i++) DCA_INIT_VLC(ff_dca_vlc_scale_factor[i], DCA_SCALES_VLC_BITS, 129, -64); diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index 8663f8ba12..eaae234479 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -35,17 +35,12 @@ 3 * (5 + 7 + 9 + 13) \ + 7 * (17 + 25 + 33 + 65 + 129)) -typedef struct DCAVLC { - int max_depth; ///< Parameter for get_vlc2() - VLC vlc[7]; ///< Actual codes -} DCAVLC; - -extern DCAVLC ff_dca_vlc_bit_allocation; +extern VLC ff_dca_vlc_bit_allocation[5]; #define DCA_TMODE_VLC_BITS 3 extern VLC ff_dca_vlc_transition_mode[4]; #define DCA_SCALES_VLC_BITS 9 extern VLC ff_dca_vlc_scale_factor[5]; -extern DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]; +extern VLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS][7]; extern VLC ff_dca_vlc_tnl_grp[5]; extern VLC ff_dca_vlc_tnl_scf; From 62d9b1195a039f88f8f82d2a519bf88c75f3cdbd Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 12 Sep 2022 22:24:04 +0200 Subject: [PATCH 307/590] avcodec/dca_lbr: Hardcode lpc table to save space The code to initialize it takes more space (in .text) than the table to be initialized (namely 86B vs 64B for GCC 11.2 with -O3 in an av_cold function), so hardcode the table. Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_lbr.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index 579bd9c469..9a0eb62f06 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -119,7 +119,17 @@ static const uint16_t channel_layouts[7] = { }; static float cos_tab[256]; -static float lpc_tab[16]; +static const float lpc_tab[16] = { + /* lpc_tab[i] = sin((i - 8) * (M_PI / ((i < 8) ? 17 : 15))) */ + -0.995734176295034521871191178905, -0.961825643172819070408796290732, + -0.895163291355062322067016499754, -0.798017227280239503332805112796, + -0.673695643646557211712691912426, -0.526432162877355800244607799141, + -0.361241666187152948744714596184, -0.183749517816570331574408839621, + 0.0, 0.207911690817759337101742284405, + 0.406736643075800207753985990341, 0.587785252292473129168705954639, + 0.743144825477394235014697048974, 0.866025403784438646763723170753, + 0.951056516295153572116439333379, 0.994521895368273336922691944981 +}; av_cold void ff_dca_lbr_init_tables(void) { @@ -127,9 +137,6 @@ av_cold void ff_dca_lbr_init_tables(void) for (i = 0; i < 256; i++) cos_tab[i] = cos(M_PI * i / 128); - - for (i = 0; i < 16; i++) - lpc_tab[i] = sin((i - 8) * (M_PI / ((i < 8) ? 17 : 15))); } static int parse_lfe_24(DCALbrDecoder *s) From 629aa5fbc06d57871868f99142243d9377a33563 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 13 Sep 2022 09:56:40 +0200 Subject: [PATCH 308/590] avcodec/dca_lbr: Inline nb_bits for VLCs Signed-off-by: Andreas Rheinhardt --- libavcodec/dca_lbr.c | 31 ++++++++++++++++--------------- libavcodec/dcahuff.c | 24 ++++++++++++------------ libavcodec/dcahuff.h | 11 +++++++++++ 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c index 9a0eb62f06..73bc16d275 100644 --- a/libavcodec/dca_lbr.c +++ b/libavcodec/dca_lbr.c @@ -267,9 +267,10 @@ static int parse_lfe_chunk(DCALbrDecoder *s, LBRChunk *chunk) return AVERROR_INVALIDDATA; } -static inline int parse_vlc(GetBitContext *s, VLC *vlc, int max_depth) +static inline int parse_vlc(GetBitContext *s, const VLC *vlc, + int nb_bits, int max_depth) { - int v = get_vlc2(s, vlc->table, vlc->bits, max_depth); + int v = get_vlc2(s, vlc->table, nb_bits, max_depth); if (v >= 0) return v; // Rare value @@ -296,7 +297,7 @@ static int parse_tonal(DCALbrDecoder *s, int group) return AVERROR_INVALIDDATA; } - diff = parse_vlc(&s->gb, &ff_dca_vlc_tnl_grp[group], 2); + diff = parse_vlc(&s->gb, &ff_dca_vlc_tnl_grp[group], DCA_TNL_GRP_VLC_BITS, 2); if (diff >= FF_ARRAY_ELEMS(ff_dca_fst_amp)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid tonal frequency diff\n"); return AVERROR_INVALIDDATA; @@ -314,7 +315,7 @@ static int parse_tonal(DCALbrDecoder *s, int group) // Main channel main_ch = get_bitsz(&s->gb, ch_nbits); - main_amp = parse_vlc(&s->gb, &ff_dca_vlc_tnl_scf, 2) + main_amp = parse_vlc(&s->gb, &ff_dca_vlc_tnl_scf, DCA_TNL_SCF_VLC_BITS, 2) + s->tonal_scf[ff_dca_freq_to_sb[freq >> (7 - group)]] + s->limited_range - 2; amp[main_ch] = main_amp < AMP_MAX ? main_amp : 0; @@ -325,8 +326,8 @@ static int parse_tonal(DCALbrDecoder *s, int group) if (ch == main_ch) continue; if (get_bits1(&s->gb)) { - amp[ch] = amp[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_damp, 1); - phs[ch] = phs[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_dph, 1); + amp[ch] = amp[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_damp, DCA_DAMP_VLC_BITS, 1); + phs[ch] = phs[main_ch] - parse_vlc(&s->gb, &ff_dca_vlc_dph, DCA_DPH_VLC_BITS, 1); } else { amp[ch] = 0; phs[ch] = 0; @@ -430,7 +431,7 @@ static int parse_scale_factors(DCALbrDecoder *s, uint8_t *scf) return 0; // Initial scale factor - prev = parse_vlc(&s->gb, &ff_dca_vlc_fst_rsd_amp, 2); + prev = parse_vlc(&s->gb, &ff_dca_vlc_fst_rsd_amp, DCA_FST_RSD_VLC_BITS, 2); for (sf = 0; sf < 7; sf += dist) { scf[sf] = prev; // Store previous value @@ -439,7 +440,7 @@ static int parse_scale_factors(DCALbrDecoder *s, uint8_t *scf) return 0; // Interpolation distance - dist = parse_vlc(&s->gb, &ff_dca_vlc_rsd_apprx, 1) + 1; + dist = parse_vlc(&s->gb, &ff_dca_vlc_rsd_apprx, DCA_RSD_APPRX_VLC_BITS, 1) + 1; if (dist > 7 - sf) { av_log(s->avctx, AV_LOG_ERROR, "Invalid scale factor distance\n"); return AVERROR_INVALIDDATA; @@ -449,7 +450,7 @@ static int parse_scale_factors(DCALbrDecoder *s, uint8_t *scf) return 0; // Final interpolation point - next = parse_vlc(&s->gb, &ff_dca_vlc_rsd_amp, 2); + next = parse_vlc(&s->gb, &ff_dca_vlc_rsd_amp, DCA_RSD_AMP_VLC_BITS, 2); if (next & 1) next = prev + ((next + 1) >> 1); @@ -493,7 +494,7 @@ static int parse_scale_factors(DCALbrDecoder *s, uint8_t *scf) static int parse_st_code(GetBitContext *s, int min_v) { - unsigned int v = parse_vlc(s, &ff_dca_vlc_st_grid, 2) + min_v; + unsigned int v = parse_vlc(s, &ff_dca_vlc_st_grid, DCA_ST_GRID_VLC_BITS, 2) + min_v; if (v & 1) v = 16 + (v >> 1); @@ -534,10 +535,10 @@ static int parse_grid_1_chunk(DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch // Average values for third grid for (sb = 0; sb < s->nsubbands - 4; sb++) { - s->grid_3_avg[ch1][sb] = parse_vlc(&s->gb, &ff_dca_vlc_avg_g3, 2) - 16; + s->grid_3_avg[ch1][sb] = parse_vlc(&s->gb, &ff_dca_vlc_avg_g3, DCA_AVG_G3_VLC_BITS, 2) - 16; if (ch1 != ch2) { if (sb + 4 < s->min_mono_subband) - s->grid_3_avg[ch2][sb] = parse_vlc(&s->gb, &ff_dca_vlc_avg_g3, 2) - 16; + s->grid_3_avg[ch2][sb] = parse_vlc(&s->gb, &ff_dca_vlc_avg_g3, DCA_AVG_G3_VLC_BITS, 2) - 16; else s->grid_3_avg[ch2][sb] = s->grid_3_avg[ch1][sb]; } @@ -592,7 +593,7 @@ static int parse_grid_1_sec_ch(DCALbrDecoder *s, int ch2) if (sb + 4 >= s->min_mono_subband) { if (ensure_bits(&s->gb, 20)) return 0; - s->grid_3_avg[ch2][sb] = parse_vlc(&s->gb, &ff_dca_vlc_avg_g3, 2) - 16; + s->grid_3_avg[ch2][sb] = parse_vlc(&s->gb, &ff_dca_vlc_avg_g3, DCA_AVG_G3_VLC_BITS, 2) - 16; } } @@ -613,7 +614,7 @@ static void parse_grid_3(DCALbrDecoder *s, int ch1, int ch2, int sb, int flag) for (i = 0; i < 8; i++) { if (ensure_bits(&s->gb, 20)) return; - s->grid_3_scf[ch][sb][i] = parse_vlc(&s->gb, &ff_dca_vlc_grid_3, 2) - 16; + s->grid_3_scf[ch][sb][i] = parse_vlc(&s->gb, &ff_dca_vlc_grid_3, DCA_GRID_VLC_BITS, 2) - 16; } // Flag scale factors for this subband parsed @@ -896,7 +897,7 @@ static int parse_grid_2(DCALbrDecoder *s, int ch1, int ch2, for (j = 0; j < 8; j++) { if (ensure_bits(&s->gb, 20)) break; - g2_scf[j] = parse_vlc(&s->gb, &ff_dca_vlc_grid_2, 2); + g2_scf[j] = parse_vlc(&s->gb, &ff_dca_vlc_grid_2, DCA_GRID_VLC_BITS, 2); } } else { memset(g2_scf, 0, 8); diff --git a/libavcodec/dcahuff.c b/libavcodec/dcahuff.c index 937a87ee05..af3a6e5326 100644 --- a/libavcodec/dcahuff.c +++ b/libavcodec/dcahuff.c @@ -831,16 +831,16 @@ av_cold void ff_dca_init_vlcs(void) } while (0) for (unsigned i = 0; i < FF_ARRAY_ELEMS(ff_dca_vlc_tnl_grp); i++) - LBR_INIT_VLC(ff_dca_vlc_tnl_grp[i], 9, tnl_grp_sizes[i], -1); - LBR_INIT_VLC(ff_dca_vlc_tnl_scf, 9, 20, -1); - LBR_INIT_VLC(ff_dca_vlc_damp, 6, 7, -1); - LBR_INIT_VLC(ff_dca_vlc_dph, 6, 9, -1); - LBR_INIT_VLC(ff_dca_vlc_fst_rsd_amp, 9, 24, -1); - LBR_INIT_VLC(ff_dca_vlc_rsd_apprx, 5, 6, -1); - LBR_INIT_VLC(ff_dca_vlc_rsd_amp, 9, 33, -1); - LBR_INIT_VLC(ff_dca_vlc_avg_g3, 9, 18, -1); - LBR_INIT_VLC(ff_dca_vlc_st_grid, 9, 22, -1); - LBR_INIT_VLC(ff_dca_vlc_grid_2, 9, 20, -1); - LBR_INIT_VLC(ff_dca_vlc_grid_3, 9, 13, -1); - LBR_INIT_VLC(ff_dca_vlc_rsd, 6, 9, 0); + LBR_INIT_VLC(ff_dca_vlc_tnl_grp[i], DCA_TNL_GRP_VLC_BITS, tnl_grp_sizes[i], -1); + LBR_INIT_VLC(ff_dca_vlc_tnl_scf, DCA_TNL_SCF_VLC_BITS, 20, -1); + LBR_INIT_VLC(ff_dca_vlc_damp, DCA_DAMP_VLC_BITS, 7, -1); + LBR_INIT_VLC(ff_dca_vlc_dph, DCA_DPH_VLC_BITS, 9, -1); + LBR_INIT_VLC(ff_dca_vlc_fst_rsd_amp, DCA_FST_RSD_VLC_BITS, 24, -1); + LBR_INIT_VLC(ff_dca_vlc_rsd_apprx, DCA_RSD_APPRX_VLC_BITS, 6, -1); + LBR_INIT_VLC(ff_dca_vlc_rsd_amp, DCA_RSD_AMP_VLC_BITS, 33, -1); + LBR_INIT_VLC(ff_dca_vlc_avg_g3, DCA_AVG_G3_VLC_BITS, 18, -1); + LBR_INIT_VLC(ff_dca_vlc_st_grid, DCA_ST_GRID_VLC_BITS, 22, -1); + LBR_INIT_VLC(ff_dca_vlc_grid_2, DCA_GRID_VLC_BITS, 20, -1); + LBR_INIT_VLC(ff_dca_vlc_grid_3, DCA_GRID_VLC_BITS, 13, -1); + LBR_INIT_VLC(ff_dca_vlc_rsd, DCA_RSD_VLC_BITS, 9, 0); } diff --git a/libavcodec/dcahuff.h b/libavcodec/dcahuff.h index eaae234479..fdfe7e922a 100644 --- a/libavcodec/dcahuff.h +++ b/libavcodec/dcahuff.h @@ -42,17 +42,28 @@ extern VLC ff_dca_vlc_transition_mode[4]; extern VLC ff_dca_vlc_scale_factor[5]; extern VLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS][7]; +#define DCA_TNL_GRP_VLC_BITS 9 extern VLC ff_dca_vlc_tnl_grp[5]; +#define DCA_TNL_SCF_VLC_BITS 9 extern VLC ff_dca_vlc_tnl_scf; +#define DCA_DAMP_VLC_BITS 6 extern VLC ff_dca_vlc_damp; +#define DCA_DPH_VLC_BITS 6 extern VLC ff_dca_vlc_dph; +#define DCA_FST_RSD_VLC_BITS 9 extern VLC ff_dca_vlc_fst_rsd_amp; +#define DCA_RSD_APPRX_VLC_BITS 5 extern VLC ff_dca_vlc_rsd_apprx; +#define DCA_RSD_AMP_VLC_BITS 9 extern VLC ff_dca_vlc_rsd_amp; +#define DCA_AVG_G3_VLC_BITS 9 extern VLC ff_dca_vlc_avg_g3; +#define DCA_ST_GRID_VLC_BITS 9 extern VLC ff_dca_vlc_st_grid; +#define DCA_GRID_VLC_BITS 9 extern VLC ff_dca_vlc_grid_2; extern VLC ff_dca_vlc_grid_3; +#define DCA_RSD_VLC_BITS 6 extern VLC ff_dca_vlc_rsd; extern const int8_t ff_dca_bitalloc_offsets[DCA_CODE_BOOKS]; From d5679d6899465450be9f0b3ebd725006e7da4e2b Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 9 Sep 2022 17:41:46 +0800 Subject: [PATCH 309/590] lavc/mips: Fix bugs in me_cmp_msa.c file. This patch fixes a bug where the fate-checkasm-motion fails when h is not a multiple of 8. Reviewed-by: Shiyou Yin Signed-off-by: Michael Niedermayer --- libavcodec/mips/me_cmp_msa.c | 201 ++++++++++++++++++++++++++++++----- 1 file changed, 173 insertions(+), 28 deletions(-) diff --git a/libavcodec/mips/me_cmp_msa.c b/libavcodec/mips/me_cmp_msa.c index 00a3cfd53f..351494161f 100644 --- a/libavcodec/mips/me_cmp_msa.c +++ b/libavcodec/mips/me_cmp_msa.c @@ -25,11 +25,13 @@ static uint32_t sad_8width_msa(const uint8_t *src, int32_t src_stride, const uint8_t *ref, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 2; + int res = (height & 0x03); v16u8 src0, src1, src2, src3, ref0, ref1, ref2, ref3; + v8u16 zero = { 0 }; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 2); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); LD_UB4(ref, ref_stride, ref0, ref1, ref2, ref3); @@ -39,6 +41,16 @@ static uint32_t sad_8width_msa(const uint8_t *src, int32_t src_stride, src0, src1, ref0, ref1); sad += SAD_UB2_UH(src0, src1, ref0, ref1); } + for (; res--; ) { + v16u8 diff; + src0 = LD_UB(src); + ref0 = LD_UB(ref); + src += src_stride; + ref += ref_stride; + diff = __msa_asub_u_b((v16u8) src0, (v16u8) ref0); + diff = (v16u8)__msa_ilvr_d((v2i64)zero, (v2i64)diff); + sad += __msa_hadd_u_h((v16u8) diff, (v16u8) diff); + } return (HADD_UH_U32(sad)); } @@ -47,11 +59,12 @@ static uint32_t sad_16width_msa(const uint8_t *src, int32_t src_stride, const uint8_t *ref, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 2; + int res = (height & 0x03); v16u8 src0, src1, ref0, ref1; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 2); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB2(src, src_stride, src0, src1); src += (2 * src_stride); LD_UB2(ref, ref_stride, ref0, ref1); @@ -64,7 +77,15 @@ static uint32_t sad_16width_msa(const uint8_t *src, int32_t src_stride, ref += (2 * ref_stride); sad += SAD_UB2_UH(src0, src1, ref0, ref1); } - + for (; res > 0; res--) { + v16u8 diff; + src0 = LD_UB(src); + ref0 = LD_UB(ref); + src += src_stride; + ref += ref_stride; + diff = __msa_asub_u_b((v16u8) src0, (v16u8) ref0); + sad += __msa_hadd_u_h((v16u8) diff, (v16u8) diff); + } return (HADD_UH_U32(sad)); } @@ -74,12 +95,14 @@ static uint32_t sad_horiz_bilinear_filter_8width_msa(const uint8_t *src, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 3; + int32_t res = height & 0x07; v16u8 src0, src1, src2, src3, comp0, comp1; v16u8 ref0, ref1, ref2, ref3, ref4, ref5; + v8u16 zero = { 0 }; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 3); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); LD_UB4(ref, ref_stride, ref0, ref1, ref2, ref3); @@ -107,6 +130,18 @@ static uint32_t sad_horiz_bilinear_filter_8width_msa(const uint8_t *src, sad += SAD_UB2_UH(src0, src1, comp0, comp1); } + for (; res--; ) { + v16u8 diff; + src0 = LD_UB(src); + ref0 = LD_UB(ref); + ref1 = LD_UB(ref + 1); + src += src_stride; + ref += ref_stride; + comp0 = (v16u8)__msa_aver_u_b((v16u8) ref0, (v16u8) ref1); + diff = __msa_asub_u_b((v16u8) src0, (v16u8) comp0); + diff = (v16u8)__msa_ilvr_d((v2i64) zero, (v2i64) diff); + sad += __msa_hadd_u_h((v16u8) diff, (v16u8) diff); + } return (HADD_UH_U32(sad)); } @@ -116,12 +151,13 @@ static uint32_t sad_horiz_bilinear_filter_16width_msa(const uint8_t *src, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 3; + int32_t res = height & 0x07; v16u8 src0, src1, src2, src3, comp0, comp1; v16u8 ref00, ref10, ref20, ref30, ref01, ref11, ref21, ref31; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 3); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); LD_UB4(ref, ref_stride, ref00, ref10, ref20, ref30); @@ -145,6 +181,17 @@ static uint32_t sad_horiz_bilinear_filter_16width_msa(const uint8_t *src, sad += SAD_UB2_UH(src2, src3, comp0, comp1); } + for (; res--; ) { + v16u8 diff; + src0 = LD_UB(src); + ref00 = LD_UB(ref); + ref01 = LD_UB(ref + 1); + src += src_stride; + ref += ref_stride; + comp0 = (v16u8)__msa_aver_u_b((v16u8) ref00, (v16u8) ref01); + diff = __msa_asub_u_b((v16u8) src0, (v16u8) comp0); + sad += __msa_hadd_u_h((v16u8) diff, (v16u8) diff); + } return (HADD_UH_U32(sad)); } @@ -154,12 +201,14 @@ static uint32_t sad_vert_bilinear_filter_8width_msa(const uint8_t *src, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 3; + int32_t res = height & 0x07; v16u8 src0, src1, src2, src3, comp0, comp1; v16u8 ref0, ref1, ref2, ref3, ref4; + v8u16 zero = { 0 }; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 3); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); LD_UB5(ref, ref_stride, ref0, ref1, ref2, ref3, ref4); @@ -183,6 +232,17 @@ static uint32_t sad_vert_bilinear_filter_8width_msa(const uint8_t *src, sad += SAD_UB2_UH(src0, src1, comp0, comp1); } + for (; res--; ) { + v16u8 diff; + src0 = LD_UB(src); + LD_UB2(ref, ref_stride, ref0, ref1); + src += src_stride; + ref += ref_stride; + comp0 = (v16u8)__msa_aver_u_b((v16u8) ref0, (v16u8) ref1); + diff = __msa_asub_u_b((v16u8) src0, (v16u8) comp0); + diff = (v16u8)__msa_ilvr_d((v2i64) zero, (v2i64) diff); + sad += __msa_hadd_u_h((v16u8) diff, (v16u8) diff); + } return (HADD_UH_U32(sad)); } @@ -192,12 +252,13 @@ static uint32_t sad_vert_bilinear_filter_16width_msa(const uint8_t *src, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 3; + int32_t res = height & 0x07; v16u8 src0, src1, src2, src3, comp0, comp1; v16u8 ref0, ref1, ref2, ref3, ref4; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 3); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB5(ref, ref_stride, ref4, ref0, ref1, ref2, ref3); ref += (5 * ref_stride); LD_UB4(src, src_stride, src0, src1, src2, src3); @@ -221,6 +282,16 @@ static uint32_t sad_vert_bilinear_filter_16width_msa(const uint8_t *src, sad += SAD_UB2_UH(src2, src3, comp0, comp1); } + for (; res--; ) { + v16u8 diff; + src0 = LD_UB(src); + LD_UB2(ref, ref_stride, ref0, ref1); + src += src_stride; + ref += ref_stride; + comp0 = (v16u8)__msa_aver_u_b((v16u8) ref0, (v16u8) ref1); + diff = __msa_asub_u_b((v16u8) src0, (v16u8) comp0); + sad += __msa_hadd_u_h((v16u8) diff, (v16u8) diff); + } return (HADD_UH_U32(sad)); } @@ -230,11 +301,13 @@ static uint32_t sad_hv_bilinear_filter_8width_msa(const uint8_t *src, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 2; + int32_t res = height & 0x03; v16u8 src0, src1, src2, src3, temp0, temp1, diff; v16u8 ref0, ref1, ref2, ref3, ref4; v16i8 mask = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8 }; v8u16 comp0, comp1, comp2, comp3; + v8u16 zero = { 0 }; v8u16 sad = { 0 }; for (ht_cnt = (height >> 2); ht_cnt--;) { @@ -277,6 +350,22 @@ static uint32_t sad_hv_bilinear_filter_8width_msa(const uint8_t *src, sad += __msa_hadd_u_h(diff, diff); } + for (; res--; ) { + src0 = LD_UB(src); + LD_UB2(ref, ref_stride, ref0, ref1); + temp0 = (v16u8) __msa_vshf_b(mask, (v16i8) ref0, (v16i8) ref0); + temp1 = (v16u8) __msa_vshf_b(mask, (v16i8) ref1, (v16i8) ref1); + src += src_stride; + ref += ref_stride; + comp0 = __msa_hadd_u_h(temp0, temp0); + comp2 = __msa_hadd_u_h(temp1, temp1); + comp2 += comp0; + comp2 = (v8u16)__msa_srari_h((v8i16) comp2, 2); + comp0 = (v16u8) __msa_pckev_b((v16i8) zero, (v16i8) comp2); + diff = __msa_asub_u_b(src0, comp0); + diff = (v16u8)__msa_ilvr_d((v2i64) zero, (v2i64) diff); + sad += __msa_hadd_u_h(diff, diff); + } return (HADD_UH_U32(sad)); } @@ -286,14 +375,15 @@ static uint32_t sad_hv_bilinear_filter_16width_msa(const uint8_t *src, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 3; + int32_t res = height & 0x07; v16u8 src0, src1, src2, src3, comp, diff; v16u8 temp0, temp1, temp2, temp3; v16u8 ref00, ref01, ref02, ref03, ref04, ref10, ref11, ref12, ref13, ref14; v8u16 comp0, comp1, comp2, comp3; v8u16 sad = { 0 }; - for (ht_cnt = (height >> 3); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); LD_UB5(ref, ref_stride, ref04, ref00, ref01, ref02, ref03); @@ -389,6 +479,25 @@ static uint32_t sad_hv_bilinear_filter_16width_msa(const uint8_t *src, diff = __msa_asub_u_b(src3, comp); sad += __msa_hadd_u_h(diff, diff); } + for (; res--; ) { + src0 = LD_UB(src); + LD_UB2(ref, ref_stride, ref00, ref10); + LD_UB2(ref + 1, ref_stride, ref01, ref11); + src += src_stride; + ref += ref_stride; + ILVRL_B2_UB(ref10, ref00, temp0, temp1); + ILVRL_B2_UB(ref11, ref01, temp2, temp3); + comp0 = __msa_hadd_u_h(temp0, temp0); + comp1 = __msa_hadd_u_h(temp1, temp1); + comp2 = __msa_hadd_u_h(temp2, temp2); + comp3 = __msa_hadd_u_h(temp3, temp3); + comp2 += comp0; + comp3 += comp1; + SRARI_H2_UH(comp2, comp3, 2); + comp = (v16u8) __msa_pckev_b((v16i8) comp3, (v16i8) comp2); + diff = __msa_asub_u_b(src0, comp); + sad += __msa_hadd_u_h(diff, diff); + } return (HADD_UH_U32(sad)); } @@ -407,15 +516,17 @@ static uint32_t sse_4width_msa(const uint8_t *src_ptr, int32_t src_stride, const uint8_t *ref_ptr, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 2; + int32_t res = height & 0x03; uint32_t sse; uint32_t src0, src1, src2, src3; uint32_t ref0, ref1, ref2, ref3; - v16u8 src = { 0 }; - v16u8 ref = { 0 }; - v4i32 var = { 0 }; + v16u8 src = { 0 }; + v16u8 ref = { 0 }; + v16u8 zero = { 0 }; + v4i32 var = { 0 }; - for (ht_cnt = (height >> 2); ht_cnt--;) { + for (; ht_cnt--; ) { LW4(src_ptr, src_stride, src0, src1, src2, src3); src_ptr += (4 * src_stride); LW4(ref_ptr, ref_stride, ref0, ref1, ref2, ref3); @@ -426,6 +537,20 @@ static uint32_t sse_4width_msa(const uint8_t *src_ptr, int32_t src_stride, CALC_MSE_B(src, ref, var); } + for (; res--; ) { + v16u8 reg0; + v8i16 tmp0; + src0 = LW(src_ptr); + ref0 = LW(ref_ptr); + src_ptr += src_stride; + ref_ptr += ref_stride; + src = (v16u8)__msa_insert_w((v4i32) src, 0, src0); + ref = (v16u8)__msa_insert_w((v4i32) ref, 0, ref0); + reg0 = (v16u8)__msa_ilvr_b(src, ref); + reg0 = (v16u8)__msa_ilvr_d((v2i64) zero, (v2i64) reg0); + tmp0 = (v8i16)__msa_hsub_u_h((v16u8) reg0, (v16u8) reg0); + var = (v4i32)__msa_dpadd_s_w((v4i32) var, (v8i16) tmp0, (v8i16) tmp0); + } sse = HADD_SW_S32(var); return sse; @@ -435,13 +560,14 @@ static uint32_t sse_8width_msa(const uint8_t *src_ptr, int32_t src_stride, const uint8_t *ref_ptr, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 2; + int32_t res = height & 0x03; uint32_t sse; v16u8 src0, src1, src2, src3; v16u8 ref0, ref1, ref2, ref3; v4i32 var = { 0 }; - for (ht_cnt = (height >> 2); ht_cnt--;) { + for (; ht_cnt--; ) { LD_UB4(src_ptr, src_stride, src0, src1, src2, src3); src_ptr += (4 * src_stride); LD_UB4(ref_ptr, ref_stride, ref0, ref1, ref2, ref3); @@ -453,6 +579,16 @@ static uint32_t sse_8width_msa(const uint8_t *src_ptr, int32_t src_stride, CALC_MSE_B(src1, ref1, var); } + for (; res--; ) { + v8i16 tmp0; + src0 = LD_UB(src_ptr); + ref0 = LD_UB(ref_ptr); + src_ptr += src_stride; + ref_ptr += ref_stride; + ref1 = (v16u8)__msa_ilvr_b(src0, ref0); + tmp0 = (v8i16)__msa_hsub_u_h((v16u8) ref1, (v16u8) ref1); + var = (v4i32)__msa_dpadd_s_w((v4i32) var, (v8i16) tmp0, (v8i16) tmp0); + } sse = HADD_SW_S32(var); return sse; @@ -462,12 +598,13 @@ static uint32_t sse_16width_msa(const uint8_t *src_ptr, int32_t src_stride, const uint8_t *ref_ptr, int32_t ref_stride, int32_t height) { - int32_t ht_cnt; + int32_t ht_cnt = height >> 2; + int32_t res = height & 0x03; uint32_t sse; v16u8 src, ref; v4i32 var = { 0 }; - for (ht_cnt = (height >> 2); ht_cnt--;) { + for (; ht_cnt--; ) { src = LD_UB(src_ptr); src_ptr += src_stride; ref = LD_UB(ref_ptr); @@ -493,6 +630,14 @@ static uint32_t sse_16width_msa(const uint8_t *src_ptr, int32_t src_stride, CALC_MSE_B(src, ref, var); } + for (; res--; ) { + src = LD_UB(src_ptr); + src_ptr += src_stride; + ref = LD_UB(ref_ptr); + ref_ptr += ref_stride; + CALC_MSE_B(src, ref, var); + } + sse = HADD_SW_S32(var); return sse; @@ -544,7 +689,7 @@ static int32_t hadamard_diff_8x8_msa(const uint8_t *src, int32_t src_stride, } static int32_t hadamard_intra_8x8_msa(const uint8_t *src, int32_t src_stride, - const uint8_t *ref, int32_t ref_stride) + const uint8_t *dumy, int32_t ref_stride) { int32_t sum_res = 0; v16u8 src0, src1, src2, src3, src4, src5, src6, src7; @@ -659,10 +804,10 @@ int ff_hadamard8_diff8x8_msa(MpegEncContext *s, const uint8_t *dst, const uint8_ return hadamard_diff_8x8_msa(src, stride, dst, stride); } -int ff_hadamard8_intra8x8_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src, +int ff_hadamard8_intra8x8_msa(MpegEncContext *s, const uint8_t *src, const uint8_t *dummy, ptrdiff_t stride, int h) { - return hadamard_intra_8x8_msa(src, stride, dst, stride); + return hadamard_intra_8x8_msa(src, stride, dummy, stride); } /* Hadamard Transform functions */ From fb233771ce3205d25551df1c031eb520ca9d7a99 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Fri, 9 Sep 2022 17:41:47 +0800 Subject: [PATCH 310/590] lavc/mips: Fix hevc decoding bugs on MIPS paltform. The patch fixes the bugs that occurred when running fate-checkasm-hevc_pel on MIPS paltform. Reviewed-by: Shiyou Yin Signed-off-by: Michael Niedermayer --- libavcodec/mips/hevc_macros_msa.h | 9 + libavcodec/mips/hevc_mc_bi_msa.c | 149 + libavcodec/mips/hevc_mc_biw_msa.c | 140 +- libavcodec/mips/hevc_mc_uni_msa.c | 89 + libavcodec/mips/hevc_mc_uniw_msa.c | 4176 +++++++++++++++++----------- libavcodec/mips/hevcdsp_msa.c | 86 +- 6 files changed, 3021 insertions(+), 1628 deletions(-) diff --git a/libavcodec/mips/hevc_macros_msa.h b/libavcodec/mips/hevc_macros_msa.h index ea53812b64..02c96b752b 100644 --- a/libavcodec/mips/hevc_macros_msa.h +++ b/libavcodec/mips/hevc_macros_msa.h @@ -52,6 +52,15 @@ out_m; \ } ) +#define HEVC_FILT_4TAP_SW(in0, in1, filt0, filt1) \ +( { \ + v4i32 out_m; \ + \ + out_m = __msa_dotp_s_w((v8i16) in0, (v8i16) filt0); \ + out_m = __msa_dpadd_s_w(out_m, (v8i16) in1, (v8i16) filt1); \ + out_m; \ +} ) + #define HEVC_FILT_4TAP(in0, in1, filt0, filt1) \ ( { \ v4i32 out_m; \ diff --git a/libavcodec/mips/hevc_mc_bi_msa.c b/libavcodec/mips/hevc_mc_bi_msa.c index 701e12ab86..dac6a32ab4 100644 --- a/libavcodec/mips/hevc_mc_bi_msa.c +++ b/libavcodec/mips/hevc_mc_bi_msa.c @@ -136,6 +136,7 @@ static void hevc_bi_copy_6w_msa(const uint8_t *src0_ptr, { uint32_t loop_cnt; uint64_t tp0, tp1, tp2, tp3; + int32_t res = height & 0x07; v16u8 out0, out1, out2, out3; v16i8 zero = { 0 }; v16i8 src0 = { 0 }, src1 = { 0 }, src2 = { 0 }, src3 = { 0 }; @@ -176,6 +177,45 @@ static void hevc_bi_copy_6w_msa(const uint8_t *src0_ptr, ST_H2(out3, 2, 6, dst + 2 * dst_stride + 4, dst_stride); dst += (4 * dst_stride); } + if (res) { + LD4(src0_ptr, src_stride, tp0, tp1, tp2, tp3); + src0_ptr += (4 * src_stride); + INSERT_D2_SB(tp0, tp1, src0); + INSERT_D2_SB(tp2, tp3, src1); + LD4(src0_ptr, src_stride, tp0, tp1, tp2, tp3); + INSERT_D2_SB(tp0, tp1, src2); + INSERT_D2_SB(tp2, tp3, src3); + LD_SH8(src1_ptr, src2_stride, in0, in1, in2, in3, in4, in5, in6, in7); + ILVRL_B2_SH(zero, src0, dst0, dst1); + ILVRL_B2_SH(zero, src1, dst2, dst3); + ILVRL_B2_SH(zero, src2, dst4, dst5); + ILVRL_B2_SH(zero, src3, dst6, dst7); + SLLI_4V(dst0, dst1, dst2, dst3, 6); + SLLI_4V(dst4, dst5, dst6, dst7, 6); + HEVC_BI_RND_CLIP4_MAX_SATU(in0, in1, in2, in3, dst0, dst1, dst2, dst3, + 7, dst0, dst1, dst2, dst3); + HEVC_BI_RND_CLIP4_MAX_SATU(in4, in5, in6, in7, dst4, dst5, dst6, dst7, + 7, dst4, dst5, dst6, dst7); + PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + if (res == 2) { + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + } else if (res == 4) { + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); + ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); + } else { + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); + ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); + dst += (4 * dst_stride); + ST_W2(out2, 0, 2, dst, dst_stride); + ST_H2(out2, 2, 6, dst + 4, dst_stride); + } + } } static void hevc_bi_copy_8w_msa(const uint8_t *src0_ptr, @@ -536,6 +576,7 @@ static void hevc_hz_bi_8t_4w_msa(const uint8_t *src0_ptr, int32_t height) { uint32_t loop_cnt; + int32_t res = height & 0x07; v8i16 filt0, filt1, filt2, filt3; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v16i8 mask1, mask2, mask3; @@ -597,6 +638,50 @@ static void hevc_hz_bi_8t_4w_msa(const uint8_t *src0_ptr, ST_W8(dst0, dst1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); } + if (res) { + LD_SB8(src0_ptr, src_stride, src0, src1, src2, src3, + src4, src5, src6, src7); + LD_SH8(src1_ptr, src2_stride, in0, in1, in2, in3, in4, in5, in6, in7); + + ILVR_D2_SH(in1, in0, in3, in2, in0, in1); + ILVR_D2_SH(in5, in4, in7, in6, in2, in3); + XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + + dst0 = const_vec; + dst1 = const_vec; + dst2 = const_vec; + dst3 = const_vec; + VSHF_B2_SB(src0, src1, src2, src3, mask0, mask0, vec0, vec1); + VSHF_B2_SB(src4, src5, src6, src7, mask0, mask0, vec2, vec3); + DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt0, filt0, filt0, dst0, + dst1, dst2, dst3); + VSHF_B2_SB(src0, src1, src2, src3, mask1, mask1, vec0, vec1); + VSHF_B2_SB(src4, src5, src6, src7, mask1, mask1, vec2, vec3); + DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt1, filt1, filt1, filt1, dst0, + dst1, dst2, dst3); + VSHF_B2_SB(src0, src1, src2, src3, mask2, mask2, vec0, vec1); + VSHF_B2_SB(src4, src5, src6, src7, mask2, mask2, vec2, vec3); + DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt2, filt2, filt2, filt2, dst0, + dst1, dst2, dst3); + VSHF_B2_SB(src0, src1, src2, src3, mask3, mask3, vec0, vec1); + VSHF_B2_SB(src4, src5, src6, src7, mask3, mask3, vec2, vec3); + DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt3, filt3, filt3, filt3, dst0, + dst1, dst2, dst3); + + HEVC_BI_RND_CLIP4(in0, in1, in2, in3, + dst0, dst1, dst2, dst3, 7, dst0, dst1, dst2, dst3); + + PCKEV_B2_SH(dst1, dst0, dst3, dst2, dst0, dst1); + if (res == 2) { + ST_W2(dst0, 0, 1, dst, dst_stride); + } else if (res == 4) { + ST_W4(dst0, 0, 1, 2, 3, dst, dst_stride); + } else { + ST_W4(dst0, 0, 1, 2, 3, dst, dst_stride); + dst += (4 * dst_stride); + ST_W2(dst1, 0, 1, dst, dst_stride); + } + } } static void hevc_hz_bi_8t_8w_msa(const uint8_t *src0_ptr, @@ -1182,6 +1267,7 @@ static void hevc_vt_bi_8t_4w_msa(const uint8_t *src0_ptr, int32_t height) { int32_t loop_cnt; + int32_t res = height & 0x07; v16i8 src0, src1, src2, src3, src4, src5; v16i8 src6, src7, src8, src9, src10; v8i16 in0, in1, in2, in3, in4, in5, in6, in7; @@ -1256,6 +1342,50 @@ static void hevc_vt_bi_8t_4w_msa(const uint8_t *src0_ptr, src6554 = src14131312; src6 = src14; } + if (res) { + LD_SB8(src0_ptr, src_stride, + src7, src8, src9, src10, src11, src12, src13, src14); + LD_SH8(src1_ptr, src2_stride, in0, in1, in2, in3, in4, in5, in6, in7); + + ILVR_D2_SH(in1, in0, in3, in2, in0, in1); + ILVR_D2_SH(in5, in4, in7, in6, in2, in3); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + ILVR_B4_SB(src11, src10, src12, src11, src13, src12, src14, src13, + src1110_r, src1211_r, src1312_r, src1413_r); + ILVR_D4_SB(src87_r, src76_r, src109_r, src98_r, src1211_r, src1110_r, + src1413_r, src1312_r, + src8776, src10998, src12111110, src14131312); + XORI_B4_128_SB(src8776, src10998, src12111110, src14131312); + + dst10 = const_vec; + DPADD_SB4_SH(src2110, src4332, src6554, src8776, + filt0, filt1, filt2, filt3, dst10, dst10, dst10, dst10); + dst32 = const_vec; + DPADD_SB4_SH(src4332, src6554, src8776, src10998, + filt0, filt1, filt2, filt3, dst32, dst32, dst32, dst32); + dst54 = const_vec; + DPADD_SB4_SH(src6554, src8776, src10998, src12111110, + filt0, filt1, filt2, filt3, dst54, dst54, dst54, dst54); + dst76 = const_vec; + DPADD_SB4_SH(src8776, src10998, src12111110, src14131312, + filt0, filt1, filt2, filt3, dst76, dst76, dst76, dst76); + + HEVC_BI_RND_CLIP4(in0, in1, in2, in3, + dst10, dst32, dst54, dst76, 7, + dst10, dst32, dst54, dst76); + + PCKEV_B2_SH(dst32, dst10, dst76, dst54, dst10, dst54); + if (res == 2) { + ST_W2(dst10, 0, 1, dst, dst_stride); + } else if (res == 4) { + ST_W4(dst10, 0, 1, 2, 3, dst, dst_stride); + } else { + ST_W4(dst10, 0, 1, 2, 3, dst, dst_stride); + dst += 4 * dst_stride; + ST_W2(dst54, 0, 1, dst, dst_stride); + } + } } static void hevc_vt_bi_8t_8w_msa(const uint8_t *src0_ptr, @@ -2363,6 +2493,7 @@ static void hevc_hz_bi_4t_6w_msa(const uint8_t *src0_ptr, int32_t height) { uint32_t loop_cnt; + int32_t res = height & 0x03; v8i16 filt0, filt1; v16i8 src0, src1, src2, src3; v8i16 in0, in1, in2, in3; @@ -2412,6 +2543,24 @@ static void hevc_hz_bi_4t_6w_msa(const uint8_t *src0_ptr, ST_H2(dst1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); dst += (4 * dst_stride); } + if (res) { + LD_SB2(src0_ptr, src_stride, src0, src1); + LD_SH2(src1_ptr, src2_stride, in0, in1); + XORI_B2_128_SB(src0, src1); + + dst0 = const_vec; + dst1 = const_vec; + VSHF_B2_SB(src0, src0, src1, src1, mask0, mask0, vec0, vec1); + DPADD_SB2_SH(vec0, vec1, filt0, filt0, dst0, dst1); + VSHF_B2_SB(src0, src0, src1, src1, mask1, mask1, vec0, vec1); + DPADD_SB2_SH(vec0, vec1, filt1, filt1, dst0, dst1); + + HEVC_BI_RND_CLIP2(in0, in1, dst0, dst1, 7, dst0, dst1); + + dst0 = (v8i16) __msa_pckev_b((v16i8) dst1, (v16i8) dst0); + ST_W2(dst0, 0, 2, dst, dst_stride); + ST_H2(dst0, 2, 6, dst + 4, dst_stride); + } } static void hevc_hz_bi_4t_8x2_msa(const uint8_t *src0_ptr, diff --git a/libavcodec/mips/hevc_mc_biw_msa.c b/libavcodec/mips/hevc_mc_biw_msa.c index 981c37d7e8..260ec84496 100644 --- a/libavcodec/mips/hevc_mc_biw_msa.c +++ b/libavcodec/mips/hevc_mc_biw_msa.c @@ -42,8 +42,8 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = { out1_l = __msa_dpadd_s_w(offset, (v8i16) out1_l, (v8i16) wgt); \ \ SRAR_W4_SW(out0_r, out1_r, out0_l, out1_l, rnd); \ + CLIP_SW4_0_255(out0_l, out0_r, out1_l, out1_r); \ PCKEV_H2_SH(out0_l, out0_r, out1_l, out1_r, out0, out1); \ - CLIP_SH2_0_255(out0, out1); \ } #define HEVC_BIW_RND_CLIP4(in0, in1, in2, in3, vec0, vec1, vec2, vec3, \ @@ -65,8 +65,8 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = { out0_l = __msa_dpadd_s_w(offset, (v8i16) out0_l, (v8i16) wgt); \ out1_l = __msa_dpadd_s_w(offset, (v8i16) out1_l, (v8i16) wgt); \ SRAR_W4_SW(out0_r, out1_r, out0_l, out1_l, rnd); \ + CLIP_SW4_0_255(out0_r, out1_r, out0_l, out1_l); \ PCKEV_H2_SH(out0_l, out0_r, out1_l, out1_r, out0, out1); \ - CLIP_SH2_0_255(out0, out1); \ } #define HEVC_BIW_RND_CLIP4_MAX_SATU(in0, in1, in2, in3, vec0, vec1, vec2, \ @@ -123,8 +123,8 @@ static void hevc_biwgt_copy_4w_msa(const uint8_t *src0_ptr, dst0_r = __msa_dpadd_s_w(offset_vec, (v8i16) dst0_r, weight_vec); dst0_l = __msa_dpadd_s_w(offset_vec, (v8i16) dst0_l, weight_vec); SRAR_W2_SW(dst0_r, dst0_l, rnd_vec); + CLIP_SW2_0_255(dst0_r, dst0_l); dst0 = (v8i16) __msa_pckev_h((v8i16) dst0_l, (v8i16) dst0_r); - CLIP_SH_0_255(dst0); out0 = (v16u8) __msa_pckev_b((v16i8) dst0, (v16i8) dst0); ST_W2(out0, 0, 1, dst, dst_stride); } else if (4 == height) { @@ -182,6 +182,7 @@ static void hevc_biwgt_copy_6w_msa(const uint8_t *src0_ptr, int32_t rnd_val) { uint32_t loop_cnt; + int32_t res = height & 0x03; int32_t offset, weight; uint64_t tp0, tp1, tp2, tp3; v16u8 out0, out1; @@ -220,6 +221,27 @@ static void hevc_biwgt_copy_6w_msa(const uint8_t *src0_ptr, ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); dst += (4 * dst_stride); } + if (res) { + LD4(src0_ptr, src_stride, tp0, tp1, tp2, tp3); + src0_ptr += (4 * src_stride); + INSERT_D2_SB(tp0, tp1, src0); + INSERT_D2_SB(tp2, tp3, src1); + LD_SH4(src1_ptr, src2_stride, in0, in1, in2, in3); + src1_ptr += (4 * src2_stride); + ILVRL_B2_SH(zero, src0, dst0, dst1); + ILVRL_B2_SH(zero, src1, dst2, dst3); + SLLI_4V(dst0, dst1, dst2, dst3, 6); + HEVC_BIW_RND_CLIP4_MAX_SATU(dst0, dst1, dst2, dst3, + in0, in1, in2, in3, + weight_vec, rnd_vec, offset_vec, + dst0, dst1, dst2, dst3); + + PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); + ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); + } } static void hevc_biwgt_copy_8w_msa(const uint8_t *src0_ptr, @@ -340,7 +362,7 @@ static void hevc_biwgt_copy_12w_msa(const uint8_t *src0_ptr, weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val + 1); - for (loop_cnt = (16 >> 2); loop_cnt--;) { + for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src0_ptr, src_stride, src0, src1, src2, src3); src0_ptr += (4 * src_stride); LD_SH4(src1_ptr, src2_stride, in0, in1, in2, in3); @@ -1069,8 +1091,8 @@ static void hevc_hz_biwgt_8t_24w_msa(const uint8_t *src0_ptr, dst2_l = __msa_dpadd_s_w(offset_vec, (v8i16) dst2_l, (v8i16) weight_vec); SRAR_W2_SW(dst2_r, dst2_l, rnd_vec); + CLIP_SW2_0_255(dst2_r, dst2_l); out2 = __msa_pckev_h((v8i16) dst2_l, (v8i16) dst2_r); - CLIP_SH_0_255(out2); LD_SB2(src0_ptr, 16, src0, src1); src0_ptr += src_stride; @@ -1100,8 +1122,8 @@ static void hevc_hz_biwgt_8t_24w_msa(const uint8_t *src0_ptr, dst2_r = __msa_dpadd_s_w(offset_vec, (v8i16) dst2_r, (v8i16) weight_vec); dst2_l = __msa_dpadd_s_w(offset_vec, (v8i16) dst2_l, (v8i16) weight_vec); SRAR_W2_SW(dst2_r, dst2_l, rnd_vec); + CLIP_SW2_0_255(dst2_r, dst2_l); out2 = __msa_pckev_h((v8i16) dst2_l, (v8i16) dst2_r); - CLIP_SH_0_255(out2); PCKEV_B2_SH(out1, out0, out2, out2, out0, out2); dst_val0 = __msa_copy_u_d((v2i64) out2, 0); ST_SH(out0, dst); @@ -1413,6 +1435,7 @@ static void hevc_vt_biwgt_8t_4w_msa(const uint8_t *src0_ptr, int32_t rnd_val) { uint32_t loop_cnt; + int32_t res = height & 0x07; int32_t offset, weight; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 src11, src12, src13, src14; @@ -1489,6 +1512,46 @@ static void hevc_vt_biwgt_8t_4w_msa(const uint8_t *src0_ptr, ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); + src2110 = src10998; + src4332 = src12111110; + src6554 = src14131312; + src6 = src14; + } + if (res) { + LD_SB8(src0_ptr, src_stride, + src7, src8, src9, src10, src11, src12, src13, src14); + src0_ptr += (8 * src_stride); + LD_SH8(src1_ptr, src2_stride, in0, in1, in2, in3, in4, in5, in6, in7); + src1_ptr += (8 * src2_stride); + + ILVR_D2_SH(in1, in0, in3, in2, in0, in1); + ILVR_D2_SH(in5, in4, in7, in6, in2, in3); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + ILVR_B4_SB(src11, src10, src12, src11, src13, src12, src14, src13, + src1110_r, src1211_r, src1312_r, src1413_r); + ILVR_D4_SB(src87_r, src76_r, src109_r, src98_r, src1211_r, src1110_r, + src1413_r, src1312_r, + src8776, src10998, src12111110, src14131312); + XORI_B4_128_SB(src8776, src10998, src12111110, src14131312); + + DOTP_SB4_SH(src2110, src4332, src6554, src8776, filt0, filt0, filt0, + filt0, dst10, dst32, dst54, dst76); + DPADD_SB4_SH(src4332, src6554, src8776, src10998, filt1, filt1, filt1, + filt1, dst10, dst32, dst54, dst76); + DPADD_SB4_SH(src6554, src8776, src10998, src12111110, filt2, filt2, + filt2, filt2, dst10, dst32, dst54, dst76); + DPADD_SB4_SH(src8776, src10998, src12111110, src14131312, filt3, filt3, + filt3, filt3, dst10, dst32, dst54, dst76); + + HEVC_BIW_RND_CLIP4(dst10, dst32, dst54, dst76, + in0, in1, in2, in3, + weight_vec, rnd_vec, offset_vec, + out0, out1, out2, out3); + + PCKEV_B2_SH(out1, out0, out3, out2, out0, out1); + ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); + src2110 = src10998; src4332 = src12111110; src6554 = src14131312; @@ -1674,8 +1737,8 @@ static void hevc_vt_biwgt_8t_12w_msa(const uint8_t *src0_ptr, dst2_l = __msa_dpadd_s_w(offset_vec, (v8i16) dst2_l, (v8i16) weight_vec); SRAR_W2_SW(dst2_r, dst2_l, rnd_vec); + CLIP_SW2_0_255(dst2_r, dst2_l); out2 = __msa_pckev_h((v8i16) dst2_l, (v8i16) dst2_r); - CLIP_SH_0_255(out2); PCKEV_B2_SH(out1, out0, out2, out2, out0, out2); ST_D2(out0, 0, 1, dst, dst_stride); ST_W2(out2, 0, 1, dst + 8, dst_stride); @@ -3555,8 +3618,8 @@ static void hevc_vt_biwgt_4t_4x2_msa(const uint8_t *src0_ptr, dst10_r = __msa_dpadd_s_w(offset_vec, (v8i16) dst10_r, (v8i16) weight_vec); dst10_l = __msa_dpadd_s_w(offset_vec, (v8i16) dst10_l, (v8i16) weight_vec); SRAR_W2_SW(dst10_r, dst10_l, rnd_vec); + CLIP_SW2_0_255(dst10_r, dst10_l); out = __msa_pckev_h((v8i16) dst10_l, (v8i16) dst10_r); - CLIP_SH_0_255(out); out = (v8i16) __msa_pckev_b((v16i8) out, (v16i8) out); ST_W2(out, 0, 1, dst, dst_stride); } @@ -3760,6 +3823,7 @@ static void hevc_vt_biwgt_4t_6w_msa(const uint8_t *src0_ptr, int32_t rnd_val) { uint32_t loop_cnt; + int32_t res = height & 0x03; int32_t offset, weight, constant; v16i8 src0, src1, src2, src3, src4; v8i16 in0, in1, in2, in3; @@ -3820,6 +3884,35 @@ static void hevc_vt_biwgt_4t_6w_msa(const uint8_t *src0_ptr, ST_H2(tmp1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); dst += (4 * dst_stride); } + if (res) { + LD_SB2(src0_ptr, src_stride, src3, src4); + src0_ptr += (2 * src_stride); + LD_SH4(src1_ptr, src2_stride, in0, in1, in2, in3); + src1_ptr += (4 * src2_stride); + XORI_B2_128_SB(src3, src4); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + + tmp0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); + tmp1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); + + LD_SB2(src0_ptr, src_stride, src1, src2); + src0_ptr += (2 * src_stride); + XORI_B2_128_SB(src1, src2); + ILVR_B2_SB(src1, src4, src2, src1, src10_r, src21_r); + + tmp2 = HEVC_FILT_4TAP_SH(src32_r, src10_r, filt0, filt1); + tmp3 = HEVC_FILT_4TAP_SH(src43_r, src21_r, filt0, filt1); + HEVC_BIW_RND_CLIP4(tmp0, tmp1, tmp2, tmp3, + in0, in1, in2, in3, + weight_vec, rnd_vec, offset_vec, + tmp0, tmp1, tmp2, tmp3); + + PCKEV_B2_SH(tmp1, tmp0, tmp3, tmp2, tmp0, tmp1); + ST_W2(tmp0, 0, 2, dst, dst_stride); + ST_H2(tmp0, 2, 6, dst + 4, dst_stride); + ST_W2(tmp1, 0, 2, dst + 2 * dst_stride, dst_stride); + ST_H2(tmp1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); + } } static void hevc_vt_biwgt_4t_8x2_msa(const uint8_t *src0_ptr, @@ -4575,8 +4668,8 @@ static void hevc_hv_biwgt_4t_4x2_msa(const uint8_t *src0_ptr, dst0 = __msa_dpadd_s_w(offset_vec, tmp0, weight_vec); dst1 = __msa_dpadd_s_w(offset_vec, tmp1, weight_vec); SRAR_W2_SW(dst0, dst1, rnd_vec); + CLIP_SW2_0_255(dst0, dst1); tmp = __msa_pckev_h((v8i16) dst1, (v8i16) dst0); - CLIP_SH_0_255(tmp); out = (v16u8) __msa_pckev_b((v16i8) tmp, (v16i8) tmp); ST_W2(out, 0, 1, dst, dst_stride); } @@ -4672,8 +4765,8 @@ static void hevc_hv_biwgt_4t_4x4_msa(const uint8_t *src0_ptr, dst2 = __msa_dpadd_s_w(offset_vec, tmp2, weight_vec); dst3 = __msa_dpadd_s_w(offset_vec, tmp3, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); - CLIP_SH2_0_255(tmp0, tmp1); out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_W4(out, 0, 1, 2, 3, dst, dst_stride); } @@ -4809,9 +4902,10 @@ static void hevc_hv_biwgt_4t_4multx8mult_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); @@ -5007,9 +5101,10 @@ static void hevc_hv_biwgt_4t_6w_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); @@ -5029,9 +5124,9 @@ static void hevc_hv_biwgt_4t_6w_msa(const uint8_t *src0_ptr, dst2 = __msa_dpadd_s_w(offset_vec, tmp2, weight_vec); dst3 = __msa_dpadd_s_w(offset_vec, tmp3, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp4, tmp5); - CLIP_SH2_0_255(tmp4, tmp5); out2 = (v16u8) __msa_pckev_b((v16i8) tmp5, (v16i8) tmp4); ST_H8(out2, 0, 1, 2, 3, 4, 5, 6, 7, dst + 4, dst_stride); } @@ -5126,8 +5221,8 @@ static void hevc_hv_biwgt_4t_8x2_msa(const uint8_t *src0_ptr, dst1_r = __msa_dpadd_s_w(offset_vec, tmp2, weight_vec); dst1_l = __msa_dpadd_s_w(offset_vec, tmp3, weight_vec); SRAR_W4_SW(dst0_r, dst0_l, dst1_r, dst1_l, rnd_vec); + CLIP_SW4_0_255(dst0_r, dst0_l, dst1_r, dst1_l); PCKEV_H2_SH(dst0_l, dst0_r, dst1_l, dst1_r, tmp0, tmp1); - CLIP_SH2_0_255(tmp0, tmp1); out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_D2(out, 0, 1, dst, dst_stride); } @@ -5247,9 +5342,10 @@ static void hevc_hv_biwgt_4t_8multx4_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); dst += 8; @@ -5386,9 +5482,10 @@ static void hevc_hv_biwgt_4t_8x6_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); PCKEV_H2_SW(dst4_l, dst4_r, dst5_l, dst5_r, dst0, dst1); @@ -5399,8 +5496,8 @@ static void hevc_hv_biwgt_4t_8x6_msa(const uint8_t *src0_ptr, dst2 = __msa_dpadd_s_w(offset_vec, tmp2, weight_vec); dst3 = __msa_dpadd_s_w(offset_vec, tmp3, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp4, tmp5); - CLIP_SH2_0_255(tmp4, tmp5); out2 = (v16u8) __msa_pckev_b((v16i8) tmp5, (v16i8) tmp4); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride); @@ -5536,9 +5633,10 @@ static void hevc_hv_biwgt_4t_8multx4mult_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst_tmp, dst_stride); dst_tmp += (4 * dst_stride); @@ -5724,9 +5822,10 @@ static void hevc_hv_biwgt_4t_12w_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst_tmp, dst_stride); dst_tmp += (4 * dst_stride); @@ -5820,9 +5919,10 @@ static void hevc_hv_biwgt_4t_12w_msa(const uint8_t *src0_ptr, dst7 = __msa_dpadd_s_w(offset_vec, tmp7, weight_vec); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); diff --git a/libavcodec/mips/hevc_mc_uni_msa.c b/libavcodec/mips/hevc_mc_uni_msa.c index c0571e1231..e221df7d53 100644 --- a/libavcodec/mips/hevc_mc_uni_msa.c +++ b/libavcodec/mips/hevc_mc_uni_msa.c @@ -908,6 +908,7 @@ static void common_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride, const int8_t *filter, int32_t height) { uint32_t loop_cnt; + uint32_t res = (height & 0x07) >> 1; v16u8 out0, out1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 src11, src12, src13, src14; @@ -970,6 +971,27 @@ static void common_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride, src6554 = src14131312; src6 = src14; } + for (; res--; ) { + LD_SB2(src, src_stride, src7, src8); + src += 2 * src_stride; + ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); + src8776 = (v16i8)__msa_ilvr_d((v2i64) src87_r, (v2i64) src76_r); + src8776 = (v16i8)__msa_xori_b(src8776, 128); + out10 = (v8i16)__msa_dotp_s_h((v16i8) src2110, (v16i8) filt0); + out10 = (v8i16)__msa_dpadd_s_h((v8i16) out10, src4332, filt1); + out10 = (v8i16)__msa_dpadd_s_h((v8i16) out10, src6554, filt2); + out10 = (v8i16)__msa_dpadd_s_h((v8i16) out10, src8776, filt3); + out10 = (v8i16)__msa_srari_h((v8i16) out10, 6); + out10 = (v8i16)__msa_sat_s_h((v8i16) out10, 7); + out0 = (v16u8)__msa_pckev_b((v16i8) out10, (v16i8) out10); + out0 = (v16u8)__msa_xori_b((v16u8) out0, 128); + ST_W2(out0, 0, 1, dst, dst_stride); + dst += 2 * dst_stride; + src2110 = src4332; + src4332 = src6554; + src6554 = src8776; + src6 = src8; + } } static void common_vt_8t_8w_msa(const uint8_t *src, int32_t src_stride, @@ -1341,6 +1363,7 @@ static void hevc_hv_uni_8t_4w_msa(const uint8_t *src, int32_t height) { uint32_t loop_cnt; + uint32_t res = height & 0x07; v16u8 out0, out1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; v16i8 src9, src10, src11, src12, src13, src14; @@ -1464,6 +1487,72 @@ static void hevc_hv_uni_8t_4w_msa(const uint8_t *src, dst65_r = dst1413_r; dst66 = (v8i16) __msa_splati_d((v2i64) dst1410, 1); } + if (res) { + LD_SB8(src, src_stride, src7, src8, src9, src10, src11, src12, src13, + src14); + XORI_B8_128_SB(src7, src8, src9, src10, src11, src12, src13, src14); + + VSHF_B4_SB(src7, src11, mask0, mask1, mask2, mask3, + vec0, vec1, vec2, vec3); + VSHF_B4_SB(src8, src12, mask0, mask1, mask2, mask3, + vec4, vec5, vec6, vec7); + VSHF_B4_SB(src9, src13, mask0, mask1, mask2, mask3, + vec8, vec9, vec10, vec11); + VSHF_B4_SB(src10, src14, mask0, mask1, mask2, mask3, + vec12, vec13, vec14, vec15); + + dst117 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3); + dst128 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3); + dst139 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, + filt2, filt3); + dst1410 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, + filt2, filt3); + + dst76_r = __msa_ilvr_h(dst117, dst66); + ILVRL_H2_SH(dst128, dst117, dst87_r, dst1211_r); + ILVRL_H2_SH(dst139, dst128, dst98_r, dst1312_r); + ILVRL_H2_SH(dst1410, dst139, dst109_r, dst1413_r); + dst117 = (v8i16) __msa_splati_d((v2i64) dst117, 1); + dst1110_r = __msa_ilvr_h(dst117, dst1410); + + dst0_r = HEVC_FILT_8TAP(dst10_r, dst32_r, dst54_r, dst76_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst1_r = HEVC_FILT_8TAP(dst21_r, dst43_r, dst65_r, dst87_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst2_r = HEVC_FILT_8TAP(dst32_r, dst54_r, dst76_r, dst98_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst3_r = HEVC_FILT_8TAP(dst43_r, dst65_r, dst87_r, dst109_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst4_r = HEVC_FILT_8TAP(dst54_r, dst76_r, dst98_r, dst1110_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst5_r = HEVC_FILT_8TAP(dst65_r, dst87_r, dst109_r, dst1211_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst6_r = HEVC_FILT_8TAP(dst76_r, dst98_r, dst1110_r, dst1312_r, filt_h0, + filt_h1, filt_h2, filt_h3); + dst7_r = HEVC_FILT_8TAP(dst87_r, dst109_r, dst1211_r, dst1413_r, + filt_h0, filt_h1, filt_h2, filt_h3); + + SRA_4V(dst0_r, dst1_r, dst2_r, dst3_r, 6); + SRA_4V(dst4_r, dst5_r, dst6_r, dst7_r, 6); + SRARI_W4_SW(dst0_r, dst1_r, dst2_r, dst3_r, 6); + SRARI_W4_SW(dst4_r, dst5_r, dst6_r, dst7_r, 6); + SAT_SW4_SW(dst0_r, dst1_r, dst2_r, dst3_r, 7); + SAT_SW4_SW(dst4_r, dst5_r, dst6_r, dst7_r, 7); + PCKEV_H2_SW(dst1_r, dst0_r, dst3_r, dst2_r, dst0_r, dst1_r); + PCKEV_H2_SW(dst5_r, dst4_r, dst7_r, dst6_r, dst4_r, dst5_r); + out0 = PCKEV_XORI128_UB(dst0_r, dst1_r); + out1 = PCKEV_XORI128_UB(dst4_r, dst5_r); + if (res == 2) { + ST_W2(out0, 0, 1, dst, dst_stride); + } else if(res == 4) { + ST_W4(out0, 0, 1, 2, 3, dst, dst_stride); + } else { + ST_W4(out0, 0, 1, 2, 3, dst, dst_stride); + ST_W2(out1, 0, 1, dst + 4 * dst_stride, dst_stride); + } + } } static void hevc_hv_uni_8t_8multx2mult_msa(const uint8_t *src, diff --git a/libavcodec/mips/hevc_mc_uniw_msa.c b/libavcodec/mips/hevc_mc_uniw_msa.c index 3c3d7a0da2..caf40c34da 100644 --- a/libavcodec/mips/hevc_mc_uniw_msa.c +++ b/libavcodec/mips/hevc_mc_uniw_msa.c @@ -33,15 +33,17 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = { out0_h, out1_h) \ { \ v4i32 in0_r_m, in0_l_m, in1_r_m, in1_l_m; \ + v8i16 zero = { 0 }; \ \ - ILVRL_H2_SW(in0_h, in0_h, in0_r_m, in0_l_m); \ - ILVRL_H2_SW(in1_h, in1_h, in1_r_m, in1_l_m); \ - DOTP_SH4_SW(in0_r_m, in1_r_m, in0_l_m, in1_l_m, wgt_w, wgt_w, wgt_w, \ - wgt_w, in0_r_m, in1_r_m, in0_l_m, in1_l_m); \ - SRAR_W4_SW(in0_r_m, in1_r_m, in0_l_m, in1_l_m, rnd_w); \ + ILVRL_H2_SW(zero, in0_h, in0_r_m, in0_l_m); \ + ILVRL_H2_SW(zero, in1_h, in1_r_m, in1_l_m); \ + MUL4(in0_r_m, wgt_w, in0_l_m, wgt_w, in1_r_m, wgt_w, in1_l_m, wgt_w, \ + in0_r_m, in0_l_m, in1_r_m, in1_l_m); \ + SRAR_W4_SW(in0_r_m, in0_l_m, in1_r_m, in1_l_m, rnd_w); \ + ADD4(in0_r_m, offset_h, in0_l_m, offset_h, in1_r_m, offset_h, in1_l_m, \ + offset_h, in0_r_m, in0_l_m, in1_r_m, in1_l_m); \ + CLIP_SW4_0_255(in0_r_m, in0_l_m, in1_r_m, in1_l_m); \ PCKEV_H2_SH(in0_l_m, in0_r_m, in1_l_m, in1_r_m, out0_h, out1_h); \ - ADDS_SH2_SH(out0_h, offset_h, out1_h, offset_h, out0_h, out1_h); \ - CLIP_SH2_0_255(out0_h, out1_h); \ } #define HEVC_UNIW_RND_CLIP4_MAX_SATU_H(in0_h, in1_h, in2_h, in3_h, wgt_w, \ @@ -54,6 +56,21 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = { out2_h, out3_h); \ } +#define HEVC_FILT_8TAP_4W_SH(in0, in1, in2, in3, filt0, filt1, \ + filt2, filt3, dst0, dst1) \ +{ \ + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; \ + ILVRL_B2_SH(zero, in0, tmp0, tmp4); \ + ILVRL_B2_SH(zero, in1, tmp1, tmp5); \ + ILVRL_B2_SH(zero, in2, tmp2, tmp6); \ + ILVRL_B2_SH(zero, in3, tmp3, tmp7); \ + dst0 = __msa_dotp_s_w((v8i16) tmp0, (v8i16) filt0); \ + dst1 = __msa_dotp_s_w((v8i16) tmp4, (v8i16) filt0); \ + DPADD_SH2_SW(tmp1, tmp5, filt1, filt1, dst0, dst1); \ + DPADD_SH2_SW(tmp2, tmp6, filt2, filt2, dst0, dst1); \ + DPADD_SH2_SW(tmp3, tmp7, filt3, filt3, dst0, dst1); \ +} + static void hevc_uniwgt_copy_4w_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, @@ -70,9 +87,8 @@ static void hevc_uniwgt_copy_4w_msa(const uint8_t *src, v8i16 dst0, dst1, dst2, dst3, offset_vec; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); if (2 == height) { @@ -83,12 +99,13 @@ static void hevc_uniwgt_copy_4w_msa(const uint8_t *src, dst0 = (v8i16) __msa_ilvr_b(zero, src0); dst0 <<= 6; - ILVRL_H2_SW(dst0, dst0, dst0_r, dst0_l); + ILVRL_H2_SW(zero, dst0, dst0_r, dst0_l); DOTP_SH2_SW(dst0_r, dst0_l, weight_vec, weight_vec, dst0_r, dst0_l); SRAR_W2_SW(dst0_r, dst0_l, rnd_vec); + dst0_r += offset_vec; + dst0_l += offset_vec; + CLIP_SW2_0_255(dst0_r, dst0_l); dst0 = __msa_pckev_h((v8i16) dst0_l, (v8i16) dst0_r); - dst0 += offset_vec; - CLIP_SH_0_255(dst0); out0 = (v16u8) __msa_pckev_b((v16i8) dst0, (v16i8) dst0); ST_W2(out0, 0, 1, dst, dst_stride); } else if (4 == height) { @@ -131,6 +148,7 @@ static void hevc_uniwgt_copy_6w_msa(const uint8_t *src, int32_t rnd_val) { uint32_t loop_cnt; + int32_t res = height & 0x07; uint64_t tp0, tp1, tp2, tp3; v16i8 zero = { 0 }; v16u8 out0, out1, out2, out3; @@ -138,9 +156,8 @@ static void hevc_uniwgt_copy_6w_msa(const uint8_t *src, v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, offset_vec; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = (height >> 3); loop_cnt--;) { @@ -181,6 +198,51 @@ static void hevc_uniwgt_copy_6w_msa(const uint8_t *src, ST_H2(out3, 2, 6, dst + 2 * dst_stride + 4, dst_stride); dst += (4 * dst_stride); } + if (res) { + LD4(src, src_stride, tp0, tp1, tp2, tp3); + src += (4 * src_stride); + INSERT_D2_SB(tp0, tp1, src0); + INSERT_D2_SB(tp2, tp3, src1); + LD4(src, src_stride, tp0, tp1, tp2, tp3); + src += (4 * src_stride); + INSERT_D2_SB(tp0, tp1, src2); + INSERT_D2_SB(tp2, tp3, src3); + + ILVRL_B2_SH(zero, src0, dst0, dst1); + ILVRL_B2_SH(zero, src1, dst2, dst3); + ILVRL_B2_SH(zero, src2, dst4, dst5); + ILVRL_B2_SH(zero, src3, dst6, dst7); + + SLLI_4V(dst0, dst1, dst2, dst3, 6); + SLLI_4V(dst4, dst5, dst6, dst7, 6); + + HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, + offset_vec, rnd_vec, dst0, dst1, dst2, + dst3); + HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, + offset_vec, rnd_vec, dst4, dst5, dst6, + dst7); + PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + + if (res == 2) { + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + } else if (res == 4) { + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); + ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); + } else { + ST_W2(out0, 0, 2, dst, dst_stride); + ST_H2(out0, 2, 6, dst + 4, dst_stride); + ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); + ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride); + dst += (4 * dst_stride); + ST_W2(out2, 0, 2, dst, dst_stride); + ST_H2(out2, 2, 6, dst + 4, dst_stride); + } + } } static void hevc_uniwgt_copy_8w_msa(const uint8_t *src, @@ -200,9 +262,8 @@ static void hevc_uniwgt_copy_8w_msa(const uint8_t *src, v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, offset_vec; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); if (2 == height) { @@ -295,9 +356,8 @@ static void hevc_uniwgt_copy_12w_msa(const uint8_t *src, v16i8 zero = { 0 }; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = 4; loop_cnt--;) { @@ -339,9 +399,8 @@ static void hevc_uniwgt_copy_16w_msa(const uint8_t *src, v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, offset_vec; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = height >> 2; loop_cnt--;) { @@ -383,9 +442,8 @@ static void hevc_uniwgt_copy_24w_msa(const uint8_t *src, v8i16 dst8, dst9, dst10, dst11; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = (height >> 2); loop_cnt--;) { @@ -435,9 +493,8 @@ static void hevc_uniwgt_copy_32w_msa(const uint8_t *src, v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, offset_vec; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = (height >> 1); loop_cnt--;) { @@ -482,9 +539,8 @@ static void hevc_uniwgt_copy_48w_msa(const uint8_t *src, v8i16 dst6, dst7, dst8, dst9, dst10, dst11; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = (height >> 1); loop_cnt--;) { @@ -539,9 +595,8 @@ static void hevc_uniwgt_copy_64w_msa(const uint8_t *src, v8i16 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; v4i32 weight_vec, rnd_vec; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); - offset_vec = __msa_fill_h(offset); + offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); for (loop_cnt = (height >> 1); loop_cnt--;) { @@ -596,33 +651,26 @@ static void hevc_hz_uniwgt_8t_4w_msa(const uint8_t *src, int32_t rnd_val) { uint32_t loop_cnt; + uint32_t res = height & 0x07; v16u8 out0, out1; - v8i16 filt0, filt1, filt2, filt3; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; - v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9, vec10; - v16i8 mask0, mask1, mask2, mask3, vec11, vec12, vec13, vec14, vec15; - v8i16 filter_vec, dst01, dst23, dst45, dst67; - v8i16 dst0, dst1, dst2, dst3, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8i16 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; + v16i8 mask0, mask1, mask2, mask3; + v8i16 filter_vec, filt0, filt1, filt2, filt3; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[16]); mask1 = mask0 + 2; @@ -632,8 +680,6 @@ static void hevc_hz_uniwgt_8t_4w_msa(const uint8_t *src, for (loop_cnt = (height >> 3); loop_cnt--;) { LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); src += (8 * src_stride); - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); - VSHF_B4_SB(src0, src1, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); VSHF_B4_SB(src2, src3, mask0, mask1, mask2, mask3, @@ -642,23 +688,78 @@ static void hevc_hz_uniwgt_8t_4w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src6, src7, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst01 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst23 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst45 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst67 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst01, dst23, dst45, dst67, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); } + if (res) { + LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); + VSHF_B4_SB(src0, src1, mask0, mask1, mask2, mask3, + vec0, vec1, vec2, vec3); + VSHF_B4_SB(src2, src3, mask0, mask1, mask2, mask3, + vec4, vec5, vec6, vec7); + VSHF_B4_SB(src4, src5, mask0, mask1, mask2, mask3, + vec8, vec9, vec10, vec11); + VSHF_B4_SB(src6, src7, mask0, mask1, mask2, mask3, + vec12, vec13, vec14, vec15); + + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + + if (res == 2) { + ST_W2(out0, 0, 1, dst, dst_stride); + } else if (res == 4) { + ST_W4(out0, 0, 1, 2, 3, dst, dst_stride); + } else { + ST_W4(out0, 0, 1, 2, 3, dst, dst_stride); + ST_W2(out1, 0, 1, dst + 4 * dst_stride, dst_stride); + } + } } static void hevc_hz_uniwgt_8t_8w_msa(const uint8_t *src, @@ -672,35 +773,27 @@ static void hevc_hz_uniwgt_8t_8w_msa(const uint8_t *src, int32_t rnd_val) { uint32_t loop_cnt; + uint32_t res = height & 0x03; v16u8 out0, out1; v16i8 src0, src1, src2, src3; v8i16 filt0, filt1, filt2, filt3; v16i8 mask0, mask1, mask2, mask3; v8i16 filter_vec; - v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3; - v8i16 weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v8i16 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -710,7 +803,6 @@ static void hevc_hz_uniwgt_8t_8w_msa(const uint8_t *src, for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); - XORI_B4_128_SB(src0, src1, src2, src3); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -720,23 +812,54 @@ static void hevc_hz_uniwgt_8t_8w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); dst += (4 * dst_stride); } + if (res) { + LD_SB2(src, src_stride, src0, src1); + + VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, + vec0, vec1, vec2, vec3); + VSHF_B4_SB(src1, src1, mask0, mask1, mask2, mask3, + vec4, vec5, vec6, vec7); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, vec0, vec1); + out0 = __msa_pckev_b((v16i8) vec1, (v16i8) vec0); + ST_D2(out0, 0, 1, dst, dst_stride); + } } static void hevc_hz_uniwgt_8t_12w_msa(const uint8_t *src, @@ -750,35 +873,26 @@ static void hevc_hz_uniwgt_8t_12w_msa(const uint8_t *src, int32_t rnd_val) { uint32_t loop_cnt; - v16u8 out0, out1, out2; + v16u8 out0, out1; v8i16 filt0, filt1, filt2, filt3; - v16i8 src0, src1, src2, src3, src4, src5, src6, src7; + v16i8 src0, src1, src2, src3; v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; v8i16 filter_vec; - v8i16 dst01, dst23, dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3; + v4i32 dst00, dst01; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -789,47 +903,41 @@ static void hevc_hz_uniwgt_8t_12w_msa(const uint8_t *src, mask6 = mask4 + 4; mask7 = mask4 + 6; - for (loop_cnt = (height >> 2); loop_cnt--;) { - LD_SB4(src, src_stride, src0, src1, src2, src3); - LD_SB4(src + 8, src_stride, src4, src5, src6, src7); - src += (4 * src_stride); - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); + for (loop_cnt = (height >> 1); loop_cnt--;) { + LD_SB2(src, src_stride, src0, src1); + LD_SB2(src + 8, src_stride, src2, src3); + src += (2 * src_stride); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); VSHF_B4_SB(src1, src1, mask0, mask1, mask2, mask3, vec4, vec5, vec6, vec7); - VSHF_B4_SB(src2, src2, mask0, mask1, mask2, mask3, - vec8, vec9, vec10, vec11); - VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, - vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); - VSHF_B4_SB(src4, src5, mask4, mask5, mask6, mask7, + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + VSHF_B4_SB(src2, src3, mask4, mask5, mask6, mask7, vec0, vec1, vec2, vec3); - VSHF_B4_SB(src6, src7, mask4, mask5, mask6, mask7, - vec4, vec5, vec6, vec7); - dst01 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst23 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst00, dst01); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst01, dst23, weight_vec, offset_vec, - rnd_vec, dst4, dst5); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL2(dst00, weight_vec, dst01, weight_vec, dst00, dst01); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W2_SW(dst00, dst01, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD2(dst00, offset_vec, dst01, offset_vec, dst00, dst01); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + CLIP_SW2_0_255(dst00, dst01); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, vec0, vec1); + vec2 = __msa_pckev_h((v8i16) dst01, (v8i16) dst00); + PCKEV_B2_UB(vec1, vec0, zero, vec2, out0, out1); - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); - ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); - ST_W4(out2, 0, 1, 2, 3, dst + 8, dst_stride); - dst += (4 * dst_stride); + ST_D2(out0, 0, 1, dst, dst_stride); + ST_W2(out1, 0, 1, dst + 8, dst_stride); + dst += (2 * dst_stride); } } @@ -851,27 +959,19 @@ static void hevc_hz_uniwgt_8t_16w_msa(const uint8_t *src, v8i16 filter_vec; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3; - v8i16 weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -882,7 +982,6 @@ static void hevc_hz_uniwgt_8t_16w_msa(const uint8_t *src, LD_SB2(src, src_stride, src0, src2); LD_SB2(src + 8, src_stride, src1, src3); src += (2 * src_stride); - XORI_B4_128_SB(src0, src1, src2, src3); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -892,20 +991,30 @@ static void hevc_hz_uniwgt_8t_16w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); ST_UB2(out0, out1, dst, dst_stride); dst += (2 * dst_stride); } @@ -928,27 +1037,21 @@ static void hevc_hz_uniwgt_8t_24w_msa(const uint8_t *src, v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11; + v8i16 filter_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -964,7 +1067,6 @@ static void hevc_hz_uniwgt_8t_24w_msa(const uint8_t *src, src += src_stride; LD_SB2(src, 16, src2, src3); src += src_stride; - XORI_B4_128_SB(src0, src1, src2, src3); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); VSHF_B4_SB(src0, src1, mask4, mask5, mask6, mask7, @@ -973,31 +1075,46 @@ static void hevc_hz_uniwgt_8t_24w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src2, src2, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); VSHF_B4_SB(src2, src3, mask4, mask5, mask6, mask7, vec0, vec1, vec2, vec3); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec4, vec5, vec6, vec7); - dst4 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst5 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, - rnd_vec, dst4, dst5); - - PCKEV_B3_UB(dst1, dst0, dst4, dst3, dst5, dst2, out0, out1, out2); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst8, dst9); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst10, dst11); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11) + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, vec4, vec5); + + PCKEV_B3_UB(vec1, vec0, vec4, vec3, vec5, vec2, out0, out1, out2); ST_UB2(out0, out1, dst, dst_stride); ST_D2(out2, 0, 1, dst + 16, dst_stride); dst += (2 * dst_stride); @@ -1022,27 +1139,20 @@ static void hevc_hz_uniwgt_8t_32w_msa(const uint8_t *src, v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; v8i16 filter_vec; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst10, dst11, dst12, dst13, dst14, dst15, dst16, dst17; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -1054,7 +1164,6 @@ static void hevc_hz_uniwgt_8t_32w_msa(const uint8_t *src, src += src_stride; LD_SB4(src, 8, src4, src5, src6, src7); src += src_stride; - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1064,14 +1173,14 @@ static void hevc_hz_uniwgt_8t_32w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); VSHF_B4_SB(src4, src4, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1081,24 +1190,44 @@ static void hevc_hz_uniwgt_8t_32w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src7, src7, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst4 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst5 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst6 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst7 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, - offset_vec, rnd_vec, dst4, dst5, dst6, - dst7); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst10, dst11); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst12, dst13); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst14, dst15); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst16, dst17); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + MUL4(dst10, weight_vec, dst11, weight_vec, dst12, weight_vec, dst13, + weight_vec, dst10, dst11, dst12, dst13) + MUL4(dst14, weight_vec, dst15, weight_vec, dst16, weight_vec, dst17, + weight_vec, dst14, dst15, dst16, dst17); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + SRAR_W4_SW(dst10, dst11, dst12, dst13, rnd_vec); + SRAR_W4_SW(dst14, dst15, dst16, dst17, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + ADD4(dst10, offset_vec, dst11, offset_vec, dst12, offset_vec, dst13, + offset_vec, dst10, dst11, dst12, dst13); + ADD4(dst14, offset_vec, dst15, offset_vec, dst16, offset_vec, dst17, + offset_vec, dst14, dst15, dst16, dst17); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst10, dst11, dst12, dst13, dst14, dst15, dst16, dst17); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_H4_SH(dst11, dst10, dst13, dst12, dst15, dst14, dst17, dst16, + vec4, vec5, vec6, vec7); + + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + PCKEV_B2_UB(vec5, vec4, vec7, vec6, out2, out3); ST_UB2(out0, out1, dst, 16); dst += dst_stride; ST_UB2(out2, out3, dst, 16); @@ -1123,28 +1252,21 @@ static void hevc_hz_uniwgt_8t_48w_msa(const uint8_t *src, v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11; + v8i16 filter_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -1159,7 +1281,6 @@ static void hevc_hz_uniwgt_8t_48w_msa(const uint8_t *src, LD_SB3(src, 16, src0, src1, src2); src3 = LD_SB(src + 40); src += src_stride; - XORI_B4_128_SB(src0, src1, src2, src3); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1169,31 +1290,46 @@ static void hevc_hz_uniwgt_8t_48w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src1, src2, mask4, mask5, mask6, mask7, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); VSHF_B4_SB(src2, src2, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec4, vec5, vec6, vec7); - dst4 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst5 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, - rnd_vec, dst4, dst5); - - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst8, dst9); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst10, dst11); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11) + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, vec4, vec5); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + out2 = __msa_pckev_b((v16i8) vec5, (v16i8) vec4); ST_UB2(out0, out1, dst, 16); ST_UB(out2, dst + 32); dst += dst_stride; @@ -1219,27 +1355,20 @@ static void hevc_hz_uniwgt_8t_64w_msa(const uint8_t *src, v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 filter_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 3; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -1258,7 +1387,6 @@ static void hevc_hz_uniwgt_8t_64w_msa(const uint8_t *src, LD_SB2(src_tmp, 16, src0, src1); src2 = LD_SB(src_tmp + 24); src_tmp += 32; - XORI_B3_128_SB(src0, src1, src2); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1268,20 +1396,28 @@ static void hevc_hz_uniwgt_8t_64w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src2, src2, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, - filt2, filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, - filt2, filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, - filt2, filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, - dst2, dst3); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst6, dst7); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); ST_UB2(out0, out1, dst_tmp, 16); dst_tmp += 32; } @@ -1302,6 +1438,7 @@ static void hevc_vt_uniwgt_8t_4w_msa(const uint8_t *src, int32_t rnd_val) { int32_t loop_cnt; + int32_t res = height & 0x07; v16u8 out0, out1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; v16i8 src9, src10, src11, src12, src13, src14; @@ -1310,29 +1447,23 @@ static void hevc_vt_uniwgt_8t_4w_msa(const uint8_t *src, v16i8 src1110_r, src1211_r, src1312_r, src1413_r; v16i8 src2110, src4332, src6554, src8776, src10998; v16i8 src12111110, src14131312; - v8i16 filter_vec, dst01, dst23, dst45, dst67; + v8i16 filter_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; v8i16 filt0, filt1, filt2, filt3; - v8i16 dst0, dst1, dst2, dst3, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 vec0, vec1, vec2, vec3; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (3 * src_stride); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); src += (7 * src_stride); @@ -1345,7 +1476,6 @@ static void hevc_vt_uniwgt_8t_4w_msa(const uint8_t *src, ILVR_D3_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src2110, src4332, src6554); - XORI_B3_128_SB(src2110, src4332, src6554); for (loop_cnt = (height >> 3); loop_cnt--;) { LD_SB8(src, src_stride, @@ -1358,21 +1488,30 @@ static void hevc_vt_uniwgt_8t_4w_msa(const uint8_t *src, ILVR_D4_SB(src87_r, src76_r, src109_r, src98_r, src1211_r, src1110_r, src1413_r, src1312_r, src8776, src10998, src12111110, src14131312); - XORI_B4_128_SB(src8776, src10998, src12111110, src14131312); - dst01 = HEVC_FILT_8TAP_SH(src2110, src4332, src6554, src8776, filt0, - filt1, filt2, filt3); - dst23 = HEVC_FILT_8TAP_SH(src4332, src6554, src8776, src10998, filt0, - filt1, filt2, filt3); - dst45 = HEVC_FILT_8TAP_SH(src6554, src8776, src10998, src12111110, - filt0, filt1, filt2, filt3); - dst67 = HEVC_FILT_8TAP_SH(src8776, src10998, src12111110, src14131312, - filt0, filt1, filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst01, dst23, dst45, dst67, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); + HEVC_FILT_8TAP_4W_SH(src2110, src4332, src6554, src8776, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src4332, src6554, src8776, src10998, filt0, + filt1, filt2, filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(src6554, src8776, src10998, src12111110, + filt0, filt1, filt2, filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(src8776, src10998, src12111110, src14131312, + filt0, filt1, filt2, filt3, dst6, dst7); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); @@ -1381,6 +1520,48 @@ static void hevc_vt_uniwgt_8t_4w_msa(const uint8_t *src, src6554 = src14131312; src6 = src14; } + if (res) { + LD_SB8(src, src_stride, + src7, src8, src9, src10, src11, src12, src13, src14); + ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, + src76_r, src87_r, src98_r, src109_r); + ILVR_B4_SB(src11, src10, src12, src11, src13, src12, src14, src13, + src1110_r, src1211_r, src1312_r, src1413_r); + ILVR_D4_SB(src87_r, src76_r, src109_r, src98_r, src1211_r, src1110_r, + src1413_r, src1312_r, + src8776, src10998, src12111110, src14131312); + HEVC_FILT_8TAP_4W_SH(src2110, src4332, src6554, src8776, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src4332, src6554, src8776, src10998, filt0, + filt1, filt2, filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(src6554, src8776, src10998, src12111110, + filt0, filt1, filt2, filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(src8776, src10998, src12111110, src14131312, + filt0, filt1, filt2, filt3, dst6, dst7); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + + if (res == 2) { + ST_W2(out0, 0, 1, dst, dst_stride); + } else if (res == 4) { + ST_W4(out0, 0, 1, 2, 3, dst, dst_stride); + } else { + ST_W4(out0, 0, 1, 2, 3, dst, dst_stride); + ST_W2(out1, 0, 1, dst + 4 * dst_stride, dst_stride); + } + } } static void hevc_vt_uniwgt_8t_8w_msa(const uint8_t *src, @@ -1394,36 +1575,29 @@ static void hevc_vt_uniwgt_8t_8w_msa(const uint8_t *src, int32_t rnd_val) { int32_t loop_cnt; + int32_t res = height & 0x03; v16u8 out0, out1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 src10_r, src32_r, src54_r, src76_r, src98_r; v16i8 src21_r, src43_r, src65_r, src87_r, src109_r; v8i16 filt0, filt1, filt2, filt3; - v8i16 filter_vec; - v8i16 dst0, dst1, dst2, dst3, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, vec0, vec1, vec2, vec3; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (3 * src_stride); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); src += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -1432,23 +1606,30 @@ static void hevc_vt_uniwgt_8t_8w_msa(const uint8_t *src, for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src, src_stride, src7, src8, src9, src10); src += (4 * src_stride); - XORI_B4_128_SB(src7, src8, src9, src10); ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); - dst0 = HEVC_FILT_8TAP_SH(src10_r, src32_r, src54_r, src76_r, filt0, - filt1, filt2, filt3); - dst1 = HEVC_FILT_8TAP_SH(src21_r, src43_r, src65_r, src87_r, filt0, - filt1, filt2, filt3); - dst2 = HEVC_FILT_8TAP_SH(src32_r, src54_r, src76_r, src98_r, filt0, - filt1, filt2, filt3); - dst3 = HEVC_FILT_8TAP_SH(src43_r, src65_r, src87_r, src109_r, filt0, - filt1, filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + HEVC_FILT_8TAP_4W_SH(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(src32_r, src54_r, src76_r, src98_r, + filt0, filt1, filt2, filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(src43_r, src65_r, src87_r, src109_r, + filt0, filt1, filt2, filt3, dst6, dst7); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); dst += (4 * dst_stride); @@ -1460,6 +1641,23 @@ static void hevc_vt_uniwgt_8t_8w_msa(const uint8_t *src, src65_r = src109_r; src6 = src10; } + if (res) { + LD_SB2(src, src_stride, src7, src8); + ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); + HEVC_FILT_8TAP_4W_SH(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3, dst2, dst3); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, vec0, vec1); + out0 = __msa_pckev_b((v16i8) vec1, (v16i8) vec0); + ST_D2(out0, 0, 1, dst, dst_stride); + } } static void hevc_vt_uniwgt_8t_12w_msa(const uint8_t *src, @@ -1481,32 +1679,24 @@ static void hevc_vt_uniwgt_8t_12w_msa(const uint8_t *src, v16i8 src21_l, src43_l, src65_l, src87_l, src109_l; v16i8 src2110, src4332, src6554, src8776, src10998; v8i16 filt0, filt1, filt2, filt3; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 weight_vec_h, offset_vec, denom_vec, filter_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5; + v4i32 dst6, dst7, dst8, dst9, dst10, dst11; + v8i16 filter_vec, vec0, vec1, vec2, vec3, vec4, vec5; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (3 * src_stride); - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); src += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -1520,7 +1710,6 @@ static void hevc_vt_uniwgt_8t_12w_msa(const uint8_t *src, for (loop_cnt = 4; loop_cnt--;) { LD_SB4(src, src_stride, src7, src8, src9, src10); src += (4 * src_stride); - XORI_B4_128_SB(src7, src8, src9, src10); ILVR_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); @@ -1528,26 +1717,40 @@ static void hevc_vt_uniwgt_8t_12w_msa(const uint8_t *src, src76_l, src87_l, src98_l, src109_l); ILVR_D2_SB(src87_l, src76_l, src109_l, src98_l, src8776, src10998); - dst0 = HEVC_FILT_8TAP_SH(src10_r, src32_r, src54_r, src76_r, filt0, - filt1, filt2, filt3); - dst1 = HEVC_FILT_8TAP_SH(src21_r, src43_r, src65_r, src87_r, filt0, - filt1, filt2, filt3); - dst2 = HEVC_FILT_8TAP_SH(src32_r, src54_r, src76_r, src98_r, filt0, - filt1, filt2, filt3); - dst3 = HEVC_FILT_8TAP_SH(src43_r, src65_r, src87_r, src109_r, filt0, - filt1, filt2, filt3); - dst4 = HEVC_FILT_8TAP_SH(src2110, src4332, src6554, src8776, filt0, - filt1, filt2, filt3); - dst5 = HEVC_FILT_8TAP_SH(src4332, src6554, src8776, src10998, filt0, - filt1, filt2, filt3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, - rnd_vec, dst4, dst5); - - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); + HEVC_FILT_8TAP_4W_SH(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(src32_r, src54_r, src76_r, src98_r, + filt0, filt1, filt2, filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(src43_r, src65_r, src87_r, src109_r, + filt0, filt1, filt2, filt3, dst6, dst7); + HEVC_FILT_8TAP_4W_SH(src2110, src4332, src6554, src8776, + filt0, filt1, filt2, filt3, dst8, dst9); + HEVC_FILT_8TAP_4W_SH(src4332, src6554, src8776, src10998, + filt0, filt1, filt2, filt3, dst10, dst11); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, vec4, vec5); + PCKEV_B3_UB(vec1, vec0, vec3, vec2, vec5, vec4, out0, out1, out2); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_W4(out2, 0, 1, 2, 3, dst + 8, dst_stride); dst += (4 * dst_stride); @@ -1579,6 +1782,7 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(const uint8_t *src, const uint8_t *src_tmp; uint8_t *dst_tmp; int32_t loop_cnt, cnt; + int32_t res = height & 0x03; v16u8 out0, out1, out2, out3; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 src10_r, src32_r, src54_r, src76_r; @@ -1587,28 +1791,22 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(const uint8_t *src, v16i8 src21_l, src43_l, src65_l, src87_l; v16i8 src98_r, src109_r, src98_l, src109_l; v8i16 filt0, filt1, filt2, filt3; - v8i16 filter_vec; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (3 * src_stride); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); + offset_vec = __msa_fill_w(offset); - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); filter_vec = LD_SH(filter); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); for (cnt = weightmul16; cnt--;) { src_tmp = src; @@ -1616,12 +1814,10 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(const uint8_t *src, LD_SB7(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6); src_tmp += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src_tmp, src_stride, src7, src8, src9, src10); src_tmp += (4 * src_stride); - XORI_B4_128_SB(src7, src8, src9, src10); ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, src10_r, src32_r, src54_r, src21_r); @@ -1634,31 +1830,52 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(const uint8_t *src, ILVL_B4_SB(src7, src6, src8, src7, src9, src8, src10, src9, src76_l, src87_l, src98_l, src109_l); - dst0 = HEVC_FILT_8TAP_SH(src10_r, src32_r, src54_r, src76_r, filt0, - filt1, filt2, filt3); - dst1 = HEVC_FILT_8TAP_SH(src10_l, src32_l, src54_l, src76_l, filt0, - filt1, filt2, filt3); - dst2 = HEVC_FILT_8TAP_SH(src21_r, src43_r, src65_r, src87_r, filt0, - filt1, filt2, filt3); - dst3 = HEVC_FILT_8TAP_SH(src21_l, src43_l, src65_l, src87_l, filt0, - filt1, filt2, filt3); - dst4 = HEVC_FILT_8TAP_SH(src32_r, src54_r, src76_r, src98_r, filt0, - filt1, filt2, filt3); - dst5 = HEVC_FILT_8TAP_SH(src32_l, src54_l, src76_l, src98_l, filt0, - filt1, filt2, filt3); - dst6 = HEVC_FILT_8TAP_SH(src43_r, src65_r, src87_r, src109_r, filt0, - filt1, filt2, filt3); - dst7 = HEVC_FILT_8TAP_SH(src43_l, src65_l, src87_l, src109_l, filt0, - filt1, filt2, filt3); + HEVC_FILT_8TAP_4W_SH(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src10_l, src32_l, src54_l, src76_l, filt0, + filt1, filt2, filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(src21_l, src43_l, src65_l, src87_l, filt0, + filt1, filt2, filt3, dst6, dst7); + HEVC_FILT_8TAP_4W_SH(src32_r, src54_r, src76_r, src98_r, filt0, + filt1, filt2, filt3, dst8, dst9); + HEVC_FILT_8TAP_4W_SH(src32_l, src54_l, src76_l, src98_l, filt0, + filt1, filt2, filt3, dst10, dst11); + HEVC_FILT_8TAP_4W_SH(src43_r, src65_r, src87_r, src109_r, filt0, + filt1, filt2, filt3, dst12, dst13); + HEVC_FILT_8TAP_4W_SH(src43_l, src65_l, src87_l, src109_l, filt0, + filt1, filt2, filt3, dst14, dst15); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, dst15, + weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, dst15, + offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_H4_SH(dst9, dst8, dst11, dst10, dst13, dst12, dst15, + dst14, vec4, vec5, vec6, vec7); + PCKEV_B4_UB(vec1, vec0, vec3, vec2, vec5, vec4, vec7, vec6, + out0, out1, out2, out3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, - dst2, dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, - offset_vec, rnd_vec, dst4, dst5, - dst6, dst7); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); ST_UB4(out0, out1, out2, out3, dst_tmp, dst_stride); dst_tmp += (4 * dst_stride); @@ -1670,6 +1887,43 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(const uint8_t *src, src5 = src9; src6 = src10; } + if (res) { + LD_SB2(src_tmp, src_stride, src7, src8); + + ILVR_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, + src10_r, src32_r, src54_r, src21_r); + ILVR_B2_SB(src4, src3, src6, src5, src43_r, src65_r); + ILVL_B4_SB(src1, src0, src3, src2, src5, src4, src2, src1, + src10_l, src32_l, src54_l, src21_l); + ILVL_B2_SB(src4, src3, src6, src5, src43_l, src65_l); + ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); + ILVL_B2_SB(src7, src6, src8, src7, src76_l, src87_l); + + HEVC_FILT_8TAP_4W_SH(src10_r, src32_r, src54_r, src76_r, filt0, + filt1, filt2, filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(src10_l, src32_l, src54_l, src76_l, filt0, + filt1, filt2, filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(src21_r, src43_r, src65_r, src87_r, filt0, + filt1, filt2, filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(src21_l, src43_l, src65_l, src87_l, filt0, + filt1, filt2, filt3, dst6, dst7); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3) + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, dst7, + weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + vec0, vec1, vec2, vec3); + PCKEV_B2_UB(vec1, vec0, vec3, vec2, out0, out1); + + ST_UB2(out0, out1, dst_tmp, dst_stride); + } src += 16; dst += 16; @@ -1774,20 +2028,21 @@ static void hevc_hv_uniwgt_8t_4w_msa(const uint8_t *src, v8i16 filter_vec; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst30, dst41, dst52, dst63, dst66, dst97, dst108; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8, dst9, dst10; v8i16 dst10_r, dst32_r, dst54_r, dst76_r, dst98_r; v8i16 dst21_r, dst43_r, dst65_r, dst87_r, dst109_r; v4i32 dst0_r, dst1_r, dst2_r, dst3_r; - v4i32 weight_vec, offset_vec, rnd_vec, const_128, denom_vec; + v4i32 weight_vec, offset_vec, rnd_vec; v16i8 mask0 = LD_SB(ff_hevc_mask_arr + 16); + v8i16 zero = { 0 }; src -= ((3 * src_stride) + 3); filter_vec = LD_SH(filter_x); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W4_SH(filter_vec, filt_h0, filt_h1, filt_h2, filt_h3); mask1 = mask0 + 2; @@ -1797,15 +2052,9 @@ static void hevc_hv_uniwgt_8t_4w_msa(const uint8_t *src, weight_vec = __msa_fill_w(weight); offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); - denom_vec = rnd_vec - 6; - - const_128 = __msa_ldi_w(128); - const_128 *= weight_vec; - offset_vec += __msa_srar_w(const_128, denom_vec); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); src += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); /* row 0 row 1 row 2 row 3 */ VSHF_B4_SB(src0, src3, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1814,39 +2063,41 @@ static void hevc_hv_uniwgt_8t_4w_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src3, src6, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst30 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst41 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst52 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst63 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, - filt3); - - ILVRL_H2_SH(dst41, dst30, dst10_r, dst43_r); - ILVRL_H2_SH(dst52, dst41, dst21_r, dst54_r); - ILVRL_H2_SH(dst63, dst52, dst32_r, dst65_r); - - dst66 = (v8i16) __msa_splati_d((v2i64) dst63, 1); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst3); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst1, dst4); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst2, dst5); + vec0 = __msa_ilvl_b((v16i8) zero, (v16i8) vec12); + vec1 = __msa_ilvl_b((v16i8) zero, (v16i8) vec13); + vec2 = __msa_ilvl_b((v16i8) zero, (v16i8) vec14); + vec3 = __msa_ilvl_b((v16i8) zero, (v16i8) vec15); + dst6 = __msa_dotp_s_w((v8i16) vec0, (v8i16) filt0); + dst6 = __msa_dpadd_s_w((v4i32) dst6, (v8i16) vec1, (v8i16) filt1); + dst6 = __msa_dpadd_s_w((v4i32) dst6, (v8i16) vec2, (v8i16) filt2); + dst6 = __msa_dpadd_s_w((v4i32) dst6, (v8i16) vec3, (v8i16) filt3); + + ILVEV_H2_SH(dst0, dst1, dst3, dst4, dst10_r, dst43_r); + ILVEV_H2_SH(dst1, dst2, dst4, dst5, dst21_r, dst54_r); + ILVEV_H2_SH(dst2, dst3, dst5, dst6, dst32_r, dst65_r); for (loop_cnt = height >> 2; loop_cnt--;) { LD_SB4(src, src_stride, src7, src8, src9, src10); src += (4 * src_stride); - XORI_B4_128_SB(src7, src8, src9, src10); VSHF_B4_SB(src7, src9, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); VSHF_B4_SB(src8, src10, mask0, mask1, mask2, mask3, vec4, vec5, vec6, vec7); - dst97 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst108 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst7, dst9); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst8, dst10); - dst76_r = __msa_ilvr_h(dst97, dst66); - ILVRL_H2_SH(dst108, dst97, dst87_r, dst109_r); - dst66 = (v8i16) __msa_splati_d((v2i64) dst97, 1); - dst98_r = __msa_ilvr_h(dst66, dst108); + dst76_r = __msa_ilvev_h((v8i16) dst7, (v8i16) dst6); + ILVEV_H2_SH(dst7, dst8, dst9, dst10, dst87_r, dst109_r); + dst98_r = __msa_ilvev_h((v8i16) dst9, (v8i16) dst8); dst0_r = HEVC_FILT_8TAP(dst10_r, dst32_r, dst54_r, dst76_r, filt_h0, filt_h1, filt_h2, filt_h3); @@ -1875,7 +2126,7 @@ static void hevc_hv_uniwgt_8t_4w_msa(const uint8_t *src, dst21_r = dst65_r; dst43_r = dst87_r; dst65_r = dst109_r; - dst66 = (v8i16) __msa_splati_d((v2i64) dst108, 1); + dst6 = dst10; } } @@ -1896,33 +2147,32 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src, uint8_t *dst_tmp; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; v8i16 filt0, filt1, filt2, filt3; - v4i32 filt_h0, filt_h1, filt_h2, filt_h3; + v8i16 filt_h0, filt_h1, filt_h2, filt_h3; v16i8 mask1, mask2, mask3; v8i16 filter_vec; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8; v4i32 dst0_r, dst0_l, dst1_r, dst1_l; v8i16 dst10_r, dst32_r, dst54_r, dst76_r; v8i16 dst10_l, dst32_l, dst54_l, dst76_l; v8i16 dst21_r, dst43_r, dst65_r, dst87_r; v8i16 dst21_l, dst43_l, dst65_l, dst87_l; - v4i32 weight_vec, offset_vec, rnd_vec, const_128, denom_vec; + v4i32 weight_vec, offset_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8, dst9, dst10; + v4i32 dst11, dst12, dst13, dst14, dst15; v16i8 mask0 = LD_SB(ff_hevc_mask_arr); + v8i16 zero = { 0 }; src -= ((3 * src_stride) + 3); weight_vec = __msa_fill_w(weight); offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); - denom_vec = rnd_vec - 6; - const_128 = __msa_ldi_w(128); - const_128 *= weight_vec; - offset_vec += __msa_srar_w(const_128, denom_vec); filter_vec = LD_SH(filter_x); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SW(filter_vec, filt0, filt1, filt2, filt3); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); @@ -1938,7 +2188,6 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src, LD_SB7(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6); src_tmp += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1948,14 +2197,14 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src, vec8, vec9, vec10, vec11); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, + filt2, filt3, dst6, dst7); VSHF_B4_SB(src4, src4, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -1963,31 +2212,30 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src, vec4, vec5, vec6, vec7); VSHF_B4_SB(src6, src6, mask0, mask1, mask2, mask3, vec8, vec9, vec10, vec11); - dst4 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst5 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst6 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - - ILVR_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst2, dst1, - dst10_r, dst32_r, dst54_r, dst21_r); - ILVR_H2_SH(dst4, dst3, dst6, dst5, dst43_r, dst65_r); - ILVL_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst2, dst1, - dst10_l, dst32_l, dst54_l, dst21_l); - ILVL_H2_SH(dst4, dst3, dst6, dst5, dst43_l, dst65_l); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst8, dst9); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst10, dst11); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst12, dst13); + + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst21_r, dst21_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst32_r, dst32_l); + ILVEV_H2_SH(dst6, dst8, dst7, dst9, dst43_r, dst43_l); + ILVEV_H2_SH(dst8, dst10, dst9, dst11, dst54_r, dst54_l); + ILVEV_H2_SH(dst10, dst12, dst11, dst13, dst65_r, dst65_l); for (loop_cnt = height >> 1; loop_cnt--;) { LD_SB2(src_tmp, src_stride, src7, src8); src_tmp += 2 * src_stride; - XORI_B2_128_SB(src7, src8); VSHF_B4_SB(src7, src7, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); - dst7 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, + filt2, filt3, dst14, dst15); - ILVRL_H2_SH(dst7, dst6, dst76_r, dst76_l); + ILVEV_H2_SH(dst12, dst14, dst13, dst15, dst76_r, dst76_l); dst0_r = HEVC_FILT_8TAP(dst10_r, dst32_r, dst54_r, dst76_r, filt_h0, filt_h1, filt_h2, filt_h3); dst0_l = HEVC_FILT_8TAP(dst10_l, dst32_l, dst54_l, dst76_l, @@ -1998,10 +2246,10 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src, /* row 8 */ VSHF_B4_SB(src8, src8, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); - dst8 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, + filt2, filt3, dst0, dst1); - ILVRL_H2_SH(dst8, dst7, dst87_r, dst87_l); + ILVEV_H2_SH(dst14, dst0, dst15, dst1, dst87_r, dst87_l); dst1_r = HEVC_FILT_8TAP(dst21_r, dst43_r, dst65_r, dst87_r, filt_h0, filt_h1, filt_h2, filt_h3); dst1_l = HEVC_FILT_8TAP(dst21_l, dst43_l, dst65_l, dst87_l, @@ -2033,7 +2281,8 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src, dst21_l = dst43_l; dst43_l = dst65_l; dst65_l = dst87_l; - dst6 = dst8; + dst12 = dst0; + dst13 = dst1; } src += 8; @@ -2076,19 +2325,21 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 dst30, dst41, dst52, dst63, dst66, dst97, dst108; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; v8i16 filt0, filt1, filt2, filt3, filt_h0, filt_h1, filt_h2, filt_h3; v8i16 dst10_r, dst32_r, dst54_r, dst76_r, dst10_l, dst32_l, dst54_l; v8i16 dst98_r, dst21_r, dst43_r, dst65_r, dst87_r, dst109_r; v8i16 dst76_l, filter_vec; v4i32 dst0_r, dst0_l, dst1_r, dst2_r, dst3_r; - v4i32 weight_vec, offset_vec, rnd_vec, const_128, denom_vec; + v4i32 weight_vec, offset_vec, rnd_vec; + v8i16 zero = { 0 }; src -= ((3 * src_stride) + 3); filter_vec = LD_SH(filter_x); - SPLATI_H4_SH(filter_vec, 0, 1, 2, 3, filt0, filt1, filt2, filt3); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W4_SH(filter_vec, filt0, filt1, filt2, filt3); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); @@ -2098,11 +2349,6 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, weight_vec = __msa_fill_w(weight); offset_vec = __msa_fill_w(offset); rnd_vec = __msa_fill_w(rnd_val); - denom_vec = rnd_vec - 6; - - const_128 = __msa_ldi_w(128); - const_128 *= weight_vec; - offset_vec += __msa_srar_w(const_128, denom_vec); mask0 = LD_SB(ff_hevc_mask_arr); mask1 = mask0 + 2; @@ -2114,7 +2360,6 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, LD_SB7(src_tmp, src_stride, src0, src1, src2, src3, src4, src5, src6); src_tmp += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); /* row 0 row 1 row 2 row 3 */ VSHF_B4_SB(src0, src0, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); @@ -2123,38 +2368,37 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, vec11); VSHF_B4_SB(src3, src3, mask0, mask1, mask2, mask3, vec12, vec13, vec14, vec15); - dst0 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst1 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst2 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst3 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, - filt2, filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst1); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst2, dst3); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst4, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, + filt2, filt3, dst6, dst7); VSHF_B4_SB(src4, src4, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); VSHF_B4_SB(src5, src5, mask0, mask1, mask2, mask3, vec4, vec5, vec6, vec7); VSHF_B4_SB(src6, src6, mask0, mask1, mask2, mask3, vec8, vec9, vec10, vec11); - dst4 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst5 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst6 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst8, dst9); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst10, dst11); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst12, dst13); for (loop_cnt = 16; loop_cnt--;) { src7 = LD_SB(src_tmp); - src7 = (v16i8) __msa_xori_b((v16u8) src7, 128); src_tmp += src_stride; VSHF_B4_SB(src7, src7, mask0, mask1, mask2, mask3, vec0, vec1, vec2, vec3); - dst7 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); - ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); - ILVRL_H2_SH(dst5, dst4, dst54_r, dst54_l); - ILVRL_H2_SH(dst7, dst6, dst76_r, dst76_l); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst14, dst15); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst32_r, dst32_l); + ILVEV_H2_SH(dst8, dst10, dst9, dst11, dst54_r, dst54_l); + ILVEV_H2_SH(dst12, dst14, dst13, dst15, dst76_r, dst76_l); dst0_r = HEVC_FILT_8TAP(dst10_r, dst32_r, dst54_r, dst76_r, filt_h0, filt_h1, filt_h2, filt_h3); @@ -2172,13 +2416,20 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, ST_D1(out, 0, dst_tmp); dst_tmp += dst_stride; - dst0 = dst1; - dst1 = dst2; - dst2 = dst3; - dst3 = dst4; - dst4 = dst5; - dst5 = dst6; - dst6 = dst7; + dst0 = dst2; + dst1 = dst3; + dst2 = dst4; + dst3 = dst5; + dst4 = dst6; + dst5 = dst7; + dst6 = dst8; + dst7 = dst9; + dst8 = dst10; + dst9 = dst11; + dst10 = dst12; + dst11 = dst13; + dst12 = dst14; + dst13 = dst15; } src += 8; @@ -2191,7 +2442,6 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); src += (7 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); VSHF_B4_SB(src0, src3, mask4, mask5, mask6, mask7, vec0, vec1, vec2, vec3); VSHF_B4_SB(src1, src4, mask4, mask5, mask6, mask7, vec4, vec5, vec6, vec7); @@ -2199,38 +2449,33 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, vec11); VSHF_B4_SB(src3, src6, mask4, mask5, mask6, mask7, vec12, vec13, vec14, vec15); - dst30 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst41 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); - dst52 = HEVC_FILT_8TAP_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, - filt3); - dst63 = HEVC_FILT_8TAP_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, - filt3); - ILVRL_H2_SH(dst41, dst30, dst10_r, dst43_r); - ILVRL_H2_SH(dst52, dst41, dst21_r, dst54_r); - ILVRL_H2_SH(dst63, dst52, dst32_r, dst65_r); - - dst66 = (v8i16) __msa_splati_d((v2i64) dst63, 1); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst0, dst3); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst1, dst4); + HEVC_FILT_8TAP_4W_SH(vec8, vec9, vec10, vec11, filt0, filt1, filt2, + filt3, dst2, dst5); + HEVC_FILT_8TAP_4W_SH(vec12, vec13, vec14, vec15, filt0, filt1, filt2, + filt3, dst3, dst6); + ILVEV_H2_SH(dst0, dst1, dst3, dst4, dst10_r, dst43_r); + ILVEV_H2_SH(dst1, dst2, dst4, dst5, dst21_r, dst54_r); + ILVEV_H2_SH(dst2, dst3, dst5, dst6, dst32_r, dst65_r); for (loop_cnt = 4; loop_cnt--;) { LD_SB4(src, src_stride, src7, src8, src9, src10); src += (4 * src_stride); - XORI_B4_128_SB(src7, src8, src9, src10); VSHF_B4_SB(src7, src9, mask4, mask5, mask6, mask7, vec0, vec1, vec2, vec3); VSHF_B4_SB(src8, src10, mask4, mask5, mask6, mask7, vec4, vec5, vec6, vec7); - dst97 = HEVC_FILT_8TAP_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, - filt3); - dst108 = HEVC_FILT_8TAP_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, - filt3); + HEVC_FILT_8TAP_4W_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, + filt3, dst7, dst9); + HEVC_FILT_8TAP_4W_SH(vec4, vec5, vec6, vec7, filt0, filt1, filt2, + filt3, dst8, dst10); - dst76_r = __msa_ilvr_h(dst97, dst66); - ILVRL_H2_SH(dst108, dst97, dst87_r, dst109_r); - dst66 = (v8i16) __msa_splati_d((v2i64) dst97, 1); - dst98_r = __msa_ilvr_h(dst66, dst108); + ILVEV_H2_SH(dst6, dst7, dst7, dst8, dst76_r, dst87_r); + ILVEV_H2_SH(dst9, dst10, dst8, dst9, dst109_r, dst98_r); dst0_r = HEVC_FILT_8TAP(dst10_r, dst32_r, dst54_r, dst76_r, filt_h0, filt_h1, filt_h2, filt_h3); @@ -2259,7 +2504,7 @@ static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src, dst21_r = dst65_r; dst43_r = dst87_r; dst65_r = dst109_r; - dst66 = (v8i16) __msa_splati_d((v2i64) dst108, 1); + dst6 = dst10; } } @@ -2353,50 +2598,41 @@ static void hevc_hz_uniwgt_4t_4x2_msa(const uint8_t *src, int32_t rnd_val) { v16u8 out; - v8i16 filt0, filt1; + v8i16 filt0, filt1, filter_vec; v16i8 src0, src1, vec0, vec1; + v8i16 tmp0, tmp1, tmp2, tmp3; v16i8 mask1; - v8i16 dst0; - v4i32 dst0_r, dst0_l; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1; + v4i32 weight_vec, rnd_vec, offset_vec; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]); + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); mask1 = mask0 + 2; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); LD_SB2(src, src_stride, src0, src1); - XORI_B2_128_SB(src0, src1); VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); - ILVRL_H2_SW(dst0, dst0, dst0_r, dst0_l); - DOTP_SH2_SW(dst0_r, dst0_l, weight_vec, weight_vec, dst0_r, dst0_l); - SRAR_W2_SW(dst0_r, dst0_l, rnd_vec); - dst0 = __msa_pckev_h((v8i16) dst0_l, (v8i16) dst0_r); - dst0 = __msa_adds_s_h(dst0, offset_vec); - CLIP_SH_0_255(dst0); - out = (v16u8) __msa_pckev_b((v16i8) dst0, (v16i8) dst0); + MUL2(dst0, weight_vec, dst1, weight_vec, dst0, dst1); + SRAR_W2_SW(dst0, dst1, rnd_vec); + ADD2(dst0, offset_vec, dst1, offset_vec, dst0, dst1); + CLIP_SW2_0_255(dst0, dst1); + vec0 = __msa_pckev_h((v8i16) dst1, (v8i16) dst0); + out = (v16u8) __msa_pckev_b((v16i8) vec0, (v16i8) vec0); ST_W2(out, 0, 1, dst, dst_stride); dst += (4 * dst_stride); } @@ -2414,48 +2650,49 @@ static void hevc_hz_uniwgt_4t_4x4_msa(const uint8_t *src, v8i16 filt0, filt1; v16i8 src0, src1, src2, src3; v16i8 mask1, vec0, vec1, vec2, vec3; - v8i16 dst0, dst1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3; + v8i16 filter_vec; + v4i32 weight_vec, rnd_vec, offset_vec; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]); + v8i16 zero = { 0 }; src -= 1; /* rearranging filter */ filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - mask1 = mask0 + 2; - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); + mask1 = mask0 + 2; LD_SB4(src, src_stride, src0, src1, src2, src3); - XORI_B4_128_SB(src0, src1, src2, src3); VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1); VSHF_B2_SB(src2, src3, src2, src3, mask0, mask1, vec2, vec3); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst0, dst1, weight_vec, offset_vec, rnd_vec, - dst0, dst1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + tmp0 = __msa_pckev_h((v8i16) dst1, (v8i16) dst0); + tmp1 = __msa_pckev_h((v8i16) dst3, (v8i16) dst2); - out = (v16u8) __msa_pckev_b((v16i8) dst1, (v16i8) dst0); + out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_W4(out, 0, 1, 2, 3, dst, dst_stride); - dst += (4 * dst_stride); } static void hevc_hz_uniwgt_4t_4x8multiple_msa(const uint8_t *src, @@ -2473,31 +2710,22 @@ static void hevc_hz_uniwgt_4t_4x8multiple_msa(const uint8_t *src, v8i16 filt0, filt1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v16i8 mask1, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; v8i16 filter_vec; - v8i16 weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 weight_vec, rnd_vec, offset_vec; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[16]); + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; @@ -2505,22 +2733,43 @@ static void hevc_hz_uniwgt_4t_4x8multiple_msa(const uint8_t *src, LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); src += (8 * src_stride); - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); - VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1); VSHF_B2_SB(src2, src3, src2, src3, mask0, mask1, vec2, vec3); VSHF_B2_SB(src4, src5, src4, src5, mask0, mask1, vec4, vec5); VSHF_B2_SB(src6, src7, src6, src7, mask0, mask1, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + tmp0 = __msa_pckev_h((v8i16) dst1, (v8i16) dst0); + tmp1 = __msa_pckev_h((v8i16) dst3, (v8i16) dst2); + tmp2 = __msa_pckev_h((v8i16) dst5, (v8i16) dst4); + tmp3 = __msa_pckev_h((v8i16) dst7, (v8i16) dst6); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); } @@ -2560,65 +2809,101 @@ static void hevc_hz_uniwgt_4t_6w_msa(const uint8_t *src, int32_t rnd_val) { v16u8 out0, out1, out2, out3; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v16i8 mask0 = LD_SB(ff_hevc_mask_arr); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec2, vec3); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec4, vec5); VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec6, vec7); - dst4 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, - weight_vec, offset_vec, rnd_vec, - dst4, dst5, dst6, dst7); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst12 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); + PCKEV_B2_UB(tmp5, tmp4, tmp7, tmp6, out2, out3); ST_W2(out0, 0, 2, dst, dst_stride); ST_H2(out0, 2, 6, dst + 4, dst_stride); ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); @@ -2640,48 +2925,49 @@ static void hevc_hz_uniwgt_4t_8x2_msa(const uint8_t *src, int32_t rnd_val) { v16u8 out; - v8i16 filt0, filt1, dst0, dst1; + v8i16 filter_vec, filt0, filt1; v16i8 src0, src1; v16i8 mask0 = LD_SB(ff_hevc_mask_arr); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 weight_vec, rnd_vec, offset_vec; + v4i32 dst0, dst1, dst2, dst3; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); - + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; LD_SB2(src, src_stride, src0, src1); - XORI_B2_128_SB(src0, src1); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst0, dst1, weight_vec, offset_vec, rnd_vec, - dst0, dst1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); - out = (v16u8) __msa_pckev_b((v16i8) dst1, (v16i8) dst0); + out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_D2(out, 0, 1, dst, dst_stride); } @@ -2697,48 +2983,63 @@ static void hevc_hz_uniwgt_4t_8x4_msa(const uint8_t *src, v16u8 out0, out1; v16i8 src0, src1, src2, src3; v16i8 mask0, mask1, vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 filt0, filt1, dst0, dst1, dst2, dst3; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; LD_SB4(src, src_stride, src0, src1, src2, src3); - XORI_B4_128_SB(src0, src1, src2, src3); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); } @@ -2752,40 +3053,31 @@ static void hevc_hz_uniwgt_4t_8x6_msa(const uint8_t *src, int32_t rnd_val) { v16u8 out0, out1, out2; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16i8 src0, src1, src2, src3, src4, src5; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[0]); v16i8 mask1; v16i8 vec11; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9, vec10; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; LD_SB6(src, src_stride, src0, src1, src2, src3, src4, src5); - XORI_B6_128_SB(src0, src1, src2, src3, src4, src5); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); @@ -2793,21 +3085,55 @@ static void hevc_hz_uniwgt_4t_8x6_msa(const uint8_t *src, VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec8, vec9); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec10, vec11); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(vec8, vec9, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec10, vec11, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec8, tmp0, tmp1); + ILVRL_B2_SH(zero, vec9, tmp2, tmp3); + ILVRL_B2_SH(zero, vec10, tmp4, tmp5); + ILVRL_B2_SH(zero, vec11, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, rnd_vec, - dst4, dst5); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); + PCKEV_B3_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, out0, out1, out2); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride); } @@ -2823,70 +3149,107 @@ static void hevc_hz_uniwgt_4t_8x8multiple_msa(const uint8_t *src, int32_t rnd_val) { uint32_t loop_cnt; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16u8 out0, out1, out2, out3; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[0]); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; for (loop_cnt = (height >> 3); loop_cnt--;) { LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); src += (8 * src_stride); - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec2, vec3); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec4, vec5); VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec6, vec7); - dst4 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, - weight_vec, offset_vec, rnd_vec, - dst4, dst5, dst6, dst7); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst12 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); + PCKEV_B2_UB(tmp5, tmp4, tmp7, tmp6, out2, out3); ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, dst_stride); dst += (8 * dst_stride); } @@ -2930,37 +3293,29 @@ static void hevc_hz_uniwgt_4t_12w_msa(const uint8_t *src, { uint32_t loop_cnt; v16u8 out0, out1, out2; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16i8 src0, src1, src2, src3; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[0]); v16i8 mask2 = { 8, 9, 9, 10, 10, 11, 11, 12, 24, 25, 25, 26, 26, 27, 27, 28 }; v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9, vec10; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; v16i8 mask3, vec11; - v4i32 weight_vec, rnd_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; mask3 = mask2 + 2; @@ -2969,29 +3324,62 @@ static void hevc_hz_uniwgt_4t_12w_msa(const uint8_t *src, LD_SB4(src, src_stride, src0, src1, src2, src3); src += (4 * src_stride); - XORI_B4_128_SB(src0, src1, src2, src3); - VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); VSHF_B2_SB(src0, src1, src0, src1, mask2, mask3, vec8, vec9); VSHF_B2_SB(src2, src3, src2, src3, mask2, mask3, vec10, vec11); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(vec8, vec9, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec10, vec11, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, - rnd_vec, dst4, dst5); - - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec8, tmp0, tmp1); + ILVRL_B2_SH(zero, vec9, tmp2, tmp3); + ILVRL_B2_SH(zero, vec10, tmp4, tmp5); + ILVRL_B2_SH(zero, vec11, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + + PCKEV_B3_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, out0, out1, out2); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_W4(out2, 0, 1, 2, 3, dst + 8, dst_stride); dst += (4 * dst_stride); @@ -3011,33 +3399,25 @@ static void hevc_hz_uniwgt_4t_16w_msa(const uint8_t *src, uint32_t loop_cnt; v16u8 out0, out1, out2, out3; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[0]); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; @@ -3046,34 +3426,77 @@ static void hevc_hz_uniwgt_4t_16w_msa(const uint8_t *src, LD_SB4(src + 8, src_stride, src1, src3, src5, src7); src += (4 * src_stride); - XORI_B8_128_SB(src0, src1, src2, src3, src4, src5, src6, src7); - VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec0, vec1); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec2, vec3); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec4, vec5); VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec6, vec7); - dst4 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, - weight_vec, offset_vec, rnd_vec, - dst4, dst5, dst6, dst7); - - PCKEV_B4_UB(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst12 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + PCKEV_B4_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, tmp7, tmp6, out0, out1, out2, out3); ST_UB4(out0, out1, out2, out3, dst, dst_stride); @@ -3094,31 +3517,24 @@ static void hevc_hz_uniwgt_4t_24w_msa(const uint8_t *src, uint32_t loop_cnt; v16u8 out0, out1, out2; v16i8 src0, src1, src2, src3; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16i8 mask0, mask1, mask2, mask3; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); - weight = weight & 0x0000FFFF; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask0 = LD_SB(&ff_hevc_mask_arr[0]); mask1 = mask0 + 2; @@ -3130,29 +3546,62 @@ static void hevc_hz_uniwgt_4t_24w_msa(const uint8_t *src, LD_SB2(src + 16, src_stride, src1, src3); src += (2 * src_stride); - XORI_B4_128_SB(src0, src1, src2, src3); - VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src0, src1, src0, src1, mask2, mask3, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src2, src3, src2, src3, mask2, mask3, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec0, vec1); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec2, vec3); - dst4 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, - rnd_vec, dst4, dst5); - - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + + PCKEV_B3_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, out0, out1, out2); ST_UB2(out0, out1, dst, dst_stride); ST_D2(out2, 0, 1, dst + 16, dst_stride); dst += (2 * dst_stride); @@ -3172,33 +3621,25 @@ static void hevc_hz_uniwgt_4t_32w_msa(const uint8_t *src, uint32_t loop_cnt; v16u8 out0, out1, out2, out3; v16i8 src0, src1, src2, src3, src4, src5; - v8i16 filt0, filt1; + v8i16 filter_vec, filt0, filt1; v16i8 mask0 = LD_SB(&ff_hevc_mask_arr[0]); v16i8 mask1, mask2, mask3; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= 1; filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); - - weight = weight & 0x0000FFFF; + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); mask1 = mask0 + 2; mask2 = mask0 + 8; @@ -3211,34 +3652,78 @@ static void hevc_hz_uniwgt_4t_32w_msa(const uint8_t *src, LD_SB2(src, 16, src3, src4); src5 = LD_SB(src + 24); src += src_stride; - XORI_B6_128_SB(src0, src1, src2, src3, src4, src5); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src0, src1, src0, src1, mask2, mask3, vec2, vec3); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec4, vec5); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec6, vec7); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); VSHF_B2_SB(src3, src4, src3, src4, mask2, mask3, vec2, vec3); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec4, vec5); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec6, vec7); - dst4 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, - weight_vec, offset_vec, rnd_vec, - dst4, dst5, dst6, dst7); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst12 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + PCKEV_B4_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, tmp7, tmp6, + out0, out1, out2, out3); ST_UB2(out0, out1, dst, 16); dst += dst_stride; ST_UB2(out2, out3, dst, 16); @@ -3261,42 +3746,36 @@ static void hevc_vt_uniwgt_4t_4x2_msa(const uint8_t *src, v16i8 src2110, src4332; v8i16 dst0; v4i32 dst0_r, dst0_l; - v8i16 filt0, filt1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v8i16 tmp0, tmp1, tmp2, tmp3; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); ILVR_D2_SB(src21_r, src10_r, src43_r, src32_r, src2110, src4332); - XORI_B2_128_SB(src2110, src4332); - dst0 = HEVC_FILT_4TAP_SH(src2110, src4332, filt0, filt1); - ILVRL_H2_SW(dst0, dst0, dst0_r, dst0_l); - DOTP_SH2_SW(dst0_r, dst0_l, weight_vec, weight_vec, dst0_r, dst0_l); + ILVRL_B2_SH(zero, src2110, tmp0, tmp1); + ILVRL_B2_SH(zero, src4332, tmp2, tmp3); + + dst0_r = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst0_l = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + + MUL2(dst0_r, weight_vec, dst0_l, weight_vec, dst0_r, dst0_l); SRAR_W2_SW(dst0_r, dst0_l, rnd_vec); + ADD2(dst0_r, offset_vec, dst0_l, offset_vec, dst0_r, dst0_l); + CLIP_SW2_0_255(dst0_r, dst0_l); dst0 = __msa_pckev_h((v8i16) dst0_l, (v8i16) dst0_r); - dst0 = __msa_adds_s_h(dst0, offset_vec); - CLIP_SH_0_255(dst0); out = (v16u8) __msa_pckev_b((v16i8) dst0, (v16i8) dst0); ST_W2(out, 0, 1, dst, dst_stride); } @@ -3314,30 +3793,21 @@ static void hevc_vt_uniwgt_4t_4x4_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6; v16i8 src10_r, src32_r, src54_r, src21_r, src43_r, src65_r; v16i8 src2110, src4332, src6554; - v8i16 dst0, dst1; - v8i16 filt0, filt1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + v8i16 filter_vec, filt0, filt1; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); @@ -3345,13 +3815,25 @@ static void hevc_vt_uniwgt_4t_4x4_msa(const uint8_t *src, src32_r, src43_r, src54_r, src65_r); ILVR_D3_SB(src21_r, src10_r, src43_r, src32_r, src65_r, src54_r, src2110, src4332, src6554); - XORI_B3_128_SB(src2110, src4332, src6554); - dst0 = HEVC_FILT_4TAP_SH(src2110, src4332, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src4332, src6554, filt0, filt1); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst0, dst1, weight_vec, offset_vec, rnd_vec, - dst0, dst1); - out = (v16u8) __msa_pckev_b((v16i8) dst1, (v16i8) dst0); + ILVRL_B2_SH(zero, src2110, tmp0, tmp1); + ILVRL_B2_SH(zero, src4332, tmp2, tmp3); + ILVRL_B2_SH(zero, src6554, tmp4, tmp5); + + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp4, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp5, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_W4(out, 0, 1, 2, 3, dst, dst_stride); } @@ -3372,35 +3854,26 @@ static void hevc_vt_uniwgt_4t_4x8multiple_msa(const uint8_t *src, v16i8 src21_r, src43_r, src65_r, src87_r, src109_r; v16i8 src2110, src4332, src6554, src8776; v16i8 src10998; - v8i16 dst0, dst1, dst2, dst3, filt0, filt1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 filter_vec, filt0, filt1; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); src2110 = (v16i8) __msa_ilvr_d((v2i64) src21_r, (v2i64) src10_r); - src2110 = (v16i8) __msa_xori_b((v16u8) src2110, 128); for (loop_cnt = (height >> 3); loop_cnt--;) { LD_SB8(src, src_stride, @@ -3412,17 +3885,36 @@ static void hevc_vt_uniwgt_4t_4x8multiple_msa(const uint8_t *src, ILVR_B2_SB(src9, src8, src10, src9, src98_r, src109_r); ILVR_D4_SB(src43_r, src32_r, src65_r, src54_r, src87_r, src76_r, src109_r, src98_r, src4332, src6554, src8776, src10998); - XORI_B4_128_SB(src4332, src6554, src8776, src10998); - dst0 = HEVC_FILT_4TAP_SH(src2110, src4332, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src4332, src6554, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src6554, src8776, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src8776, src10998, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); + ILVRL_B2_SH(zero, src2110, tmp0, tmp1); + ILVRL_B2_SH(zero, src4332, tmp2, tmp3); + ILVRL_B2_SH(zero, src6554, tmp4, tmp5); + ILVRL_B2_SH(zero, src8776, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp4, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp5, filt0, filt1); + ILVRL_B2_SH(zero, src10998, tmp0, tmp1); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp0, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp1, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); @@ -3468,59 +3960,90 @@ static void hevc_vt_uniwgt_4t_6w_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 src10_r, src32_r, src21_r, src43_r; v16i8 src54_r, src65_r, src76_r, src87_r, src98_r, src109_r; - v8i16 filt0, filt1; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); LD_SB8(src, src_stride, src3, src4, src5, src6, src7, src8, src9, src10); - XORI_B3_128_SB(src0, src1, src2); - XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); ILVR_B2_SB(src5, src4, src6, src5, src54_r, src65_r); ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); ILVR_B2_SB(src9, src8, src10, src9, src98_r, src109_r); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src54_r, src76_r, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src65_r, src87_r, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(src76_r, src98_r, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(src87_r, src109_r, filt0, filt1); - - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, - weight_vec, offset_vec, rnd_vec, - dst0, dst1, dst2, dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, - weight_vec, offset_vec, rnd_vec, - dst4, dst5, dst6, dst7); - - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src76_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src87_r, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src98_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src109_r, tmp2, tmp3); + dst12 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); + PCKEV_B2_UB(tmp5, tmp4, tmp7, tmp6, out2, out3); ST_W2(out0, 0, 2, dst, dst_stride); ST_H2(out0, 2, 6, dst + 4, dst_stride); ST_W2(out1, 0, 2, dst + 2 * dst_stride, dst_stride); @@ -3544,42 +4067,44 @@ static void hevc_vt_uniwgt_4t_8x2_msa(const uint8_t *src, v16u8 out; v16i8 src0, src1, src2, src3, src4; v16i8 src10_r, src32_r, src21_r, src43_r; - v8i16 dst0, dst1; - v8i16 filt0, filt1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 filter_vec, filt0, filt1; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); - XORI_B5_128_SB(src0, src1, src2, src3, src4); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst0, dst1, weight_vec, offset_vec, rnd_vec, - dst0, dst1); + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); - out = (v16u8) __msa_pckev_b((v16i8) dst1, (v16i8) dst0); + out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_D2(out, 0, 1, dst, dst_stride); } @@ -3596,45 +4121,56 @@ static void hevc_vt_uniwgt_4t_8x4_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4; v16i8 src10_r, src32_r, src21_r, src43_r; v16i8 src5, src6, src54_r, src65_r; - v8i16 filt0, filt1; - v8i16 dst0, dst1, dst2, dst3; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); - src += (3 * src_stride); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); ILVR_B2_SB(src5, src4, src6, src5, src54_r, src65_r); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); } @@ -3651,52 +4187,74 @@ static void hevc_vt_uniwgt_4t_8x6_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; v16i8 src10_r, src32_r, src54_r, src76_r; v16i8 src21_r, src43_r, src65_r, src87_r; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5; - v8i16 filt0, filt1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 filter_vec, filt0, filt1; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); LD_SB6(src, src_stride, src3, src4, src5, src6, src7, src8); - XORI_B3_128_SB(src0, src1, src2); - XORI_B6_128_SB(src3, src4, src5, src6, src7, src8); ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r, src32_r, src43_r); ILVR_B4_SB(src5, src4, src6, src5, src7, src6, src8, src7, src54_r, src65_r, src76_r, src87_r); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src54_r, src76_r, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src65_r, src87_r, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, dst3); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, rnd_vec, - dst4, dst5); - PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src76_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src87_r, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_B3_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, out0, out1, out2); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride); } @@ -3716,61 +4274,94 @@ static void hevc_vt_uniwgt_4t_8x8mult_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 src10_r, src32_r, src21_r, src43_r; v16i8 src54_r, src65_r, src76_r, src87_r, src98_r, src109_r; - v8i16 filt0, filt1; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); for (loop_cnt = (height >> 3); loop_cnt--;) { LD_SB8(src, src_stride, src3, src4, src5, src6, src7, src8, src9, src10); src += (8 * src_stride); - XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); ILVR_B2_SB(src5, src4, src6, src5, src54_r, src65_r); ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); ILVR_B2_SB(src9, src8, src10, src9, src98_r, src109_r); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src54_r, src76_r, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src65_r, src87_r, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(src76_r, src98_r, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(src87_r, src109_r, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, - offset_vec, rnd_vec, dst4, dst5, dst6, - dst7); - PCKEV_B2_UB(dst1, dst0, dst3, dst2, out0, out1); - PCKEV_B2_UB(dst5, dst4, dst7, dst6, out2, out3); + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src76_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src87_r, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src98_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src109_r, tmp2, tmp3); + dst12 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); + PCKEV_B2_UB(tmp5, tmp4, tmp7, tmp6, out2, out3); ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, dst_stride); dst += (8 * dst_stride); @@ -3824,34 +4415,25 @@ static void hevc_vt_uniwgt_4t_12w_msa(const uint8_t *src, v16i8 src2110, src4332; v16i8 src54_r, src76_r, src98_r, src65_r, src87_r, src109_r; v16i8 src76_l, src98_l, src87_l, src109_l, src6554, src8776, src10998; - v8i16 filt0, filt1; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8; - v8i16 dst9, dst10, dst11, filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8; + v4i32 dst9, dst10, dst11; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (1 * src_stride); - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); src2110 = (v16i8) __msa_ilvr_d((v2i64) src21_l, (v2i64) src10_l); @@ -3859,24 +4441,58 @@ static void hevc_vt_uniwgt_4t_12w_msa(const uint8_t *src, for (loop_cnt = 2; loop_cnt--;) { LD_SB8(src, src_stride, src3, src4, src5, src6, src7, src8, src9, src10); src += (8 * src_stride); - XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); ILVRL_B2_SB(src3, src2, src32_r, src32_l); ILVRL_B2_SB(src4, src3, src43_r, src43_l); ILVRL_B2_SB(src5, src4, src54_r, src54_l); ILVRL_B2_SB(src6, src5, src65_r, src65_l); src4332 = (v16i8) __msa_ilvr_d((v2i64) src43_l, (v2i64) src32_l); src6554 = (v16i8) __msa_ilvr_d((v2i64) src65_l, (v2i64) src54_l); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src2110, src4332, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src4332, src6554, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst4, dst5, weight_vec, offset_vec, - rnd_vec, dst4, dst5); + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src2110, tmp4, tmp5); + ILVRL_B2_SH(zero, src4332, tmp6, tmp7); + ILVRL_B2_SH(zero, src6554, tmp8, tmp9); + dst8 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp6, tmp8, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp7, tmp9, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, dst0, dst1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, dst2, dst3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, dst4, dst5); + PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out0, out1, out2); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_W4(out2, 0, 1, 2, 3, dst + 8, dst_stride); @@ -3888,18 +4504,51 @@ static void hevc_vt_uniwgt_4t_12w_msa(const uint8_t *src, ILVRL_B2_SB(src10, src9, src109_r, src109_l); src8776 = (v16i8) __msa_ilvr_d((v2i64) src87_l, (v2i64) src76_l); src10998 = (v16i8) __msa_ilvr_d((v2i64) src109_l, (v2i64) src98_l); - dst6 = HEVC_FILT_4TAP_SH(src54_r, src76_r, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(src65_r, src87_r, filt0, filt1); - dst8 = HEVC_FILT_4TAP_SH(src76_r, src98_r, filt0, filt1); - dst9 = HEVC_FILT_4TAP_SH(src87_r, src109_r, filt0, filt1); - dst10 = HEVC_FILT_4TAP_SH(src6554, src8776, filt0, filt1); - dst11 = HEVC_FILT_4TAP_SH(src8776, src10998, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst6, dst7, dst8, dst9, weight_vec, - offset_vec, rnd_vec, dst6, dst7, dst8, - dst9); - HEVC_UNIW_RND_CLIP2_MAX_SATU_H(dst10, dst11, weight_vec, offset_vec, - rnd_vec, dst10, dst11); - PCKEV_B3_UB(dst7, dst6, dst9, dst8, dst11, dst10, out3, out4, out5); + + ILVRL_B2_SH(zero, src76_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src87_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src98_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src109_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src8776, tmp4, tmp5); + ILVRL_B2_SH(zero, src10998, tmp6, tmp7); + ILVRL_B2_SH(zero, src6554, tmp8, tmp9); + dst8 = HEVC_FILT_4TAP_SW(tmp8, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp9, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + CLIP_SW4_0_255(dst8, dst9, dst10, dst11); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, dst0, dst1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, dst2, dst3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, dst4, dst5); + + PCKEV_B3_UB(dst1, dst0, dst3, dst2, dst5, dst4, out3, out4, out5); ST_D4(out3, out4, 0, 1, 0, 1, dst, dst_stride); ST_W4(out5, 0, 1, 2, 3, dst + 8, dst_stride); dst += (4 * dst_stride); @@ -3927,60 +4576,94 @@ static void hevc_vt_uniwgt_4t_16w_msa(const uint8_t *src, v16i8 src10_r, src32_r, src21_r, src43_r; v16i8 src10_l, src32_l, src21_l, src43_l; v16i8 src54_r, src54_l, src65_r, src65_l, src6; - v8i16 filt0, filt1; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); for (loop_cnt = (height >> 2); loop_cnt--;) { LD_SB4(src, src_stride, src3, src4, src5, src6); src += (4 * src_stride); - XORI_B4_128_SB(src3, src4, src5, src6); ILVRL_B2_SB(src3, src2, src32_r, src32_l); ILVRL_B2_SB(src4, src3, src43_r, src43_l); ILVRL_B2_SB(src5, src4, src54_r, src54_l); ILVRL_B2_SB(src6, src5, src65_r, src65_l); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src10_l, src32_l, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src21_l, src43_l, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(src32_l, src54_l, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(src43_l, src65_l, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, - offset_vec, rnd_vec, dst4, dst5, dst6, - dst7); - PCKEV_B4_UB(dst4, dst0, dst5, dst1, dst6, dst2, dst7, dst3, out0, out1, + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src10_l, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_l, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_l, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_l, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_l, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_l, tmp2, tmp3); + dst12 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + PCKEV_B4_UB(tmp4, tmp0, tmp5, tmp1, tmp6, tmp2, tmp7, tmp3, out0, out1, out2, out3); ST_UB4(out0, out1, out2, out3, dst, dst_stride); dst += (4 * dst_stride); @@ -4010,36 +4693,27 @@ static void hevc_vt_uniwgt_4t_24w_msa(const uint8_t *src, v16i8 src10_r, src32_r, src54_r, src21_r, src43_r, src65_r; v16i8 src10_l, src32_l, src54_l, src21_l, src43_l, src65_l; v16i8 src87_r, src98_r, src109_r, src1110_r, src1211_r, src1312_r; - v8i16 filt0, filt1; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8, dst9, dst10; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec, dst11; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v4i32 dst16, dst17, dst18, dst19, dst20, dst21, dst22, dst23; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); LD_SB3(src + 16, src_stride, src7, src8, src9); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); - XORI_B3_128_SB(src7, src8, src9); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); ILVR_B2_SB(src8, src7, src9, src8, src87_r, src98_r); @@ -4048,38 +4722,103 @@ static void hevc_vt_uniwgt_4t_24w_msa(const uint8_t *src, LD_SB4(src, src_stride, src3, src4, src5, src6); LD_SB4(src + 16, src_stride, src10, src11, src12, src13); src += (4 * src_stride); - XORI_B4_128_SB(src3, src4, src5, src6); - XORI_B4_128_SB(src10, src11, src12, src13); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); ILVL_B2_SB(src3, src2, src4, src3, src32_l, src43_l); ILVRL_B2_SB(src5, src4, src54_r, src54_l); ILVRL_B2_SB(src6, src5, src65_r, src65_l); ILVR_B2_SB(src10, src9, src11, src10, src109_r, src1110_r); ILVR_B2_SB(src12, src11, src13, src12, src1211_r, src1312_r); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src32_r, src54_r, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src43_r, src65_r, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src10_l, src32_l, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src21_l, src43_l, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(src32_l, src54_l, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(src43_l, src65_l, filt0, filt1); - dst8 = HEVC_FILT_4TAP_SH(src87_r, src109_r, filt0, filt1); - dst9 = HEVC_FILT_4TAP_SH(src98_r, src1110_r, filt0, filt1); - dst10 = HEVC_FILT_4TAP_SH(src109_r, src1211_r, filt0, filt1); - dst11 = HEVC_FILT_4TAP_SH(src1110_r, src1312_r, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, - offset_vec, rnd_vec, dst4, dst5, dst6, - dst7); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst8, dst9, dst10, dst11, weight_vec, - offset_vec, rnd_vec, dst8, dst9, dst10, - dst11); - PCKEV_B4_UB(dst4, dst0, dst5, dst1, dst6, dst2, dst7, dst3, out0, out1, + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_r, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src10_l, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_l, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_l, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_l, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src54_l, tmp0, tmp1); + ILVRL_B2_SH(zero, src65_l, tmp2, tmp3); + dst12 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + ILVRL_B2_SH(zero, src87_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src98_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src109_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src1110_r, tmp6, tmp7); + dst16 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst17 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst18 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst19 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src1211_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src1312_r, tmp2, tmp3); + dst20 = HEVC_FILT_4TAP_SW(tmp4, tmp0, filt0, filt1); + dst21 = HEVC_FILT_4TAP_SW(tmp5, tmp1, filt0, filt1); + dst22 = HEVC_FILT_4TAP_SW(tmp6, tmp2, filt0, filt1); + dst23 = HEVC_FILT_4TAP_SW(tmp7, tmp3, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + MUL4(dst16, weight_vec, dst17, weight_vec, dst18, weight_vec, dst19, + weight_vec, dst16, dst17, dst18, dst19); + MUL4(dst20, weight_vec, dst21, weight_vec, dst22, weight_vec, + dst23, weight_vec, dst20, dst21, dst22, dst23); + SRAR_W4_SW(dst16, dst17, dst18, dst19, rnd_vec); + SRAR_W4_SW(dst20, dst21, dst22, dst23, rnd_vec); + ADD4(dst16, offset_vec, dst17, offset_vec, dst18, offset_vec, dst19, + offset_vec, dst16, dst17, dst18, dst19); + ADD4(dst20, offset_vec, dst21, offset_vec, dst22, offset_vec, + dst23, offset_vec, dst20, dst21, dst22, dst23); + CLIP_SW8_0_255(dst16, dst17, dst18, dst19, dst20, dst21, dst22, dst23); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + PCKEV_B4_UB(tmp4, tmp0, tmp5, tmp1, tmp6, tmp2, tmp7, tmp3, out0, out1, out2, out3); - PCKEV_B2_UB(dst9, dst8, dst11, dst10, out4, out5); + + PCKEV_H2_SH(dst17, dst16, dst19, dst18, tmp0, tmp1); + PCKEV_H2_SH(dst21, dst20, dst23, dst22, tmp2, tmp3); + + PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out4, out5); ST_UB4(out0, out1, out2, out3, dst, dst_stride); ST_D4(out4, out5, 0, 1, 0, 1, dst + 16, dst_stride); dst += (4 * dst_stride); @@ -4110,37 +4849,28 @@ static void hevc_vt_uniwgt_4t_32w_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9; v16i8 src10_r, src32_r, src76_r, src98_r; v16i8 src21_r, src43_r, src65_r, src87_r; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; v16i8 src10_l, src32_l, src76_l, src98_l; v16i8 src21_l, src43_l, src65_l, src87_l; - v8i16 filt0, filt1; - v8i16 filter_vec, weight_vec_h, offset_vec, denom_vec; - v4i32 weight_vec, rnd_vec; + v8i16 filter_vec, filt0, filt1; + v4i32 weight_vec, rnd_vec, offset_vec; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v4i32 dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 zero = { 0 }; src -= src_stride; - weight = weight & 0x0000FFFF; - weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - weight *= 128; - rnd_val -= 6; - - weight_vec_h = __msa_fill_h(weight); - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val); - - weight_vec_h = __msa_srar_h(weight_vec_h, denom_vec); - offset_vec = __msa_adds_s_h(offset_vec, weight_vec_h); + offset_vec = __msa_fill_w(offset); filter_vec = LD_SH(filter); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); LD_SB3(src, src_stride, src0, src1, src2); LD_SB3(src + 16, src_stride, src5, src6, src7); src += (3 * src_stride); - XORI_B6_128_SB(src0, src1, src2, src5, src6, src7); ILVR_B2_SB(src1, src0, src2, src1, src10_r, src21_r); ILVL_B2_SB(src1, src0, src2, src1, src10_l, src21_l); ILVR_B2_SB(src6, src5, src7, src6, src65_r, src76_r); @@ -4150,26 +4880,75 @@ static void hevc_vt_uniwgt_4t_32w_msa(const uint8_t *src, LD_SB2(src, src_stride, src3, src4); LD_SB2(src + 16, src_stride, src8, src9); src += (2 * src_stride); - XORI_B4_128_SB(src3, src4, src8, src9); ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); ILVL_B2_SB(src3, src2, src4, src3, src32_l, src43_l); ILVRL_B2_SB(src8, src7, src87_r, src87_l); ILVRL_B2_SB(src9, src8, src98_r, src98_l); - dst0 = HEVC_FILT_4TAP_SH(src10_r, src32_r, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(src21_r, src43_r, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(src10_l, src32_l, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(src21_l, src43_l, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(src65_r, src87_r, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(src76_r, src98_r, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(src65_l, src87_l, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(src76_l, src98_l, filt0, filt1); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst0, dst1, dst2, dst3, weight_vec, - offset_vec, rnd_vec, dst0, dst1, dst2, - dst3); - HEVC_UNIW_RND_CLIP4_MAX_SATU_H(dst4, dst5, dst6, dst7, weight_vec, - offset_vec, rnd_vec, dst4, dst5, dst6, - dst7); - PCKEV_B4_UB(dst2, dst0, dst3, dst1, dst6, dst4, dst7, dst5, out0, out1, + + ILVRL_B2_SH(zero, src10_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_r, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + + ILVRL_B2_SH(zero, src10_l, tmp0, tmp1); + ILVRL_B2_SH(zero, src21_l, tmp2, tmp3); + ILVRL_B2_SH(zero, src32_l, tmp4, tmp5); + ILVRL_B2_SH(zero, src43_l, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + + ILVRL_B2_SH(zero, src65_r, tmp0, tmp1); + ILVRL_B2_SH(zero, src76_r, tmp2, tmp3); + ILVRL_B2_SH(zero, src87_r, tmp4, tmp5); + ILVRL_B2_SH(zero, src98_r, tmp6, tmp7); + dst8 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst11 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, src65_l, tmp0, tmp1); + ILVRL_B2_SH(zero, src76_l, tmp2, tmp3); + ILVRL_B2_SH(zero, src87_l, tmp4, tmp5); + ILVRL_B2_SH(zero, src98_l, tmp6, tmp7); + dst12 = HEVC_FILT_4TAP_SW(tmp0, tmp4, filt0, filt1); + dst13 = HEVC_FILT_4TAP_SW(tmp1, tmp5, filt0, filt1); + dst14 = HEVC_FILT_4TAP_SW(tmp2, tmp6, filt0, filt1); + dst15 = HEVC_FILT_4TAP_SW(tmp3, tmp7, filt0, filt1); + + MUL4(dst0, weight_vec, dst1, weight_vec, dst2, weight_vec, dst3, + weight_vec, dst0, dst1, dst2, dst3); + MUL4(dst4, weight_vec, dst5, weight_vec, dst6, weight_vec, + dst7, weight_vec, dst4, dst5, dst6, dst7); + SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, + dst7, offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); + + MUL4(dst8, weight_vec, dst9, weight_vec, dst10, weight_vec, dst11, + weight_vec, dst8, dst9, dst10, dst11); + MUL4(dst12, weight_vec, dst13, weight_vec, dst14, weight_vec, + dst15, weight_vec, dst12, dst13, dst14, dst15); + SRAR_W4_SW(dst8, dst9, dst10, dst11, rnd_vec); + SRAR_W4_SW(dst12, dst13, dst14, dst15, rnd_vec); + ADD4(dst8, offset_vec, dst9, offset_vec, dst10, offset_vec, dst11, + offset_vec, dst8, dst9, dst10, dst11); + ADD4(dst12, offset_vec, dst13, offset_vec, dst14, offset_vec, + dst15, offset_vec, dst12, dst13, dst14, dst15); + CLIP_SW8_0_255(dst8, dst9, dst10, dst11, dst12, dst13, dst14, dst15); + + PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); + PCKEV_H2_SH(dst5, dst4, dst7, dst6, tmp2, tmp3); + PCKEV_H2_SH(dst9, dst8, dst11, dst10, tmp4, tmp5); + PCKEV_H2_SH(dst13, dst12, dst15, dst14, tmp6, tmp7); + PCKEV_B4_UB(tmp2, tmp0, tmp3, tmp1, tmp6, tmp4, tmp7, tmp5, out0, out1, out2, out3); ST_UB2(out0, out2, dst, 16); dst += dst_stride; @@ -4206,49 +4985,54 @@ static void hevc_hv_uniwgt_4t_4x2_msa(const uint8_t *src, v16i8 mask1; v8i16 filt_h0, filt_h1, filter_vec, tmp; v16i8 vec0, vec1, vec2, vec3, vec4, vec5; - v8i16 dst20, dst31, dst42, dst10, dst32, dst21, dst43; - v8i16 offset_vec, const_128, denom_vec; - v4i32 dst0, dst1, weight_vec, rnd_vec; + v8i16 dst10, dst21, dst32, dst43; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); - XORI_B5_128_SB(src0, src1, src2, src3, src4); VSHF_B2_SB(src0, src2, src0, src2, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src3, src1, src3, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src4, src2, src4, mask0, mask1, vec4, vec5); - dst20 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst31 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst42 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - ILVRL_H2_SH(dst31, dst20, dst10, dst32); - ILVRL_H2_SH(dst42, dst31, dst21, dst43); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVL_B2_SH(zero, vec4, zero, vec5, tmp1, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + + ILVEV_H2_SH(dst0, dst1, dst2, dst3, dst10, dst32); + ILVEV_H2_SH(dst1, dst2, dst3, dst4, dst21, dst43); dst0 = HEVC_FILT_4TAP(dst10, dst32, filt_h0, filt_h1); dst1 = HEVC_FILT_4TAP(dst21, dst43, filt_h0, filt_h1); dst0 >>= 6; dst1 >>= 6; MUL2(dst0, weight_vec, dst1, weight_vec, dst0, dst1); SRAR_W2_SW(dst0, dst1, rnd_vec); + ADD2(dst0, offset_vec, dst1, offset_vec, dst0, dst1); + CLIP_SW2_0_255(dst0, dst1); tmp = __msa_pckev_h((v8i16) dst1, (v8i16) dst0); - tmp += offset_vec; - CLIP_SH_0_255(tmp); out = (v16u8) __msa_pckev_b((v16i8) tmp, (v16i8) tmp); ST_W2(out, 0, 1, dst, dst_stride); } @@ -4266,47 +5050,55 @@ static void hevc_hv_uniwgt_4t_4x4_msa(const uint8_t *src, v16u8 out; v16i8 src0, src1, src2, src3, src4, src5, src6; v8i16 filt0, filt1; - v8i16 filt_h0, filt_h1, filter_vec, tmp0, tmp1; + v8i16 filt_h0, filt_h1, filter_vec; v16i8 mask0 = LD_SB(ff_hevc_mask_arr + 16); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst30, dst41, dst52, dst63, dst10, dst32, dst54, dst21, dst43, dst65; - v8i16 offset_vec, const_128, denom_vec; - v4i32 dst0, dst1, dst2, dst3, weight_vec, rnd_vec; + v8i16 dst10, dst32, dst54, dst21, dst43, dst65; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); VSHF_B2_SB(src0, src3, src0, src3, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src4, src1, src4, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src5, src2, src5, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src6, src3, src6, mask0, mask1, vec6, vec7); - dst30 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst41 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst52 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst63 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - ILVRL_H2_SH(dst41, dst30, dst10, dst43); - ILVRL_H2_SH(dst52, dst41, dst21, dst54); - ILVRL_H2_SH(dst63, dst52, dst32, dst65); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst4 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVL_B2_SH(zero, vec6, zero, vec7, tmp5, tmp7); + dst2 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst0, dst1, dst3, dst4, dst10, dst43); + ILVEV_H2_SH(dst1, dst2, dst4, dst5, dst21, dst54); + ILVEV_H2_SH(dst2, dst3, dst5, dst6, dst32, dst65); dst0 = HEVC_FILT_4TAP(dst10, dst32, filt_h0, filt_h1); dst1 = HEVC_FILT_4TAP(dst21, dst43, filt_h0, filt_h1); dst2 = HEVC_FILT_4TAP(dst32, dst54, filt_h0, filt_h1); @@ -4315,9 +5107,10 @@ static void hevc_hv_uniwgt_4t_4x4_msa(const uint8_t *src, MUL2(dst0, weight_vec, dst1, weight_vec, dst0, dst1); MUL2(dst2, weight_vec, dst3, weight_vec, dst2, dst3); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + CLIP_SW4_0_255(dst0, dst1, dst2, dst3); PCKEV_H2_SH(dst1, dst0, dst3, dst2, tmp0, tmp1); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - CLIP_SH2_0_255(tmp0, tmp1); out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_W4(out, 0, 1, 2, 3, dst, dst_stride); } @@ -4339,65 +5132,78 @@ static void hevc_hv_uniwgt_4t_4multx8mult_msa(const uint8_t *src, v8i16 filt0, filt1; v16i8 mask0 = LD_SB(ff_hevc_mask_arr + 16); v16i8 mask1; - v8i16 filt_h0, filt_h1, filter_vec, tmp0, tmp1, tmp2, tmp3; + v8i16 filter_vec, filt_h0, filt_h1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst10, dst21, dst22, dst73, dst84, dst95, dst106; v8i16 dst10_r, dst32_r, dst54_r, dst76_r; v8i16 dst21_r, dst43_r, dst65_r, dst87_r; - v8i16 dst98_r, dst109_r, offset_vec, const_128, denom_vec; - v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, weight_vec, rnd_vec; + v8i16 dst98_r, dst109_r; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8, dst9, dst10; + v4i32 offset_vec, weight_vec, rnd_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); VSHF_B2_SB(src0, src1, src0, src1, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src2, src1, src2, mask0, mask1, vec2, vec3); - dst10 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst21 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - ILVRL_H2_SH(dst21, dst10, dst10_r, dst21_r); - dst22 = (v8i16) __msa_splati_d((v2i64) dst21, 1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVL_B2_SH(zero, vec2, zero, vec3, tmp5, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + ILVEV_H2_SH(dst0, dst1, dst1, dst2, dst10_r, dst21_r); for (loop_cnt = height >> 3; loop_cnt--;) { LD_SB8(src, src_stride, src3, src4, src5, src6, src7, src8, src9, src10); src += (8 * src_stride); - XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); VSHF_B2_SB(src3, src7, src3, src7, mask0, mask1, vec0, vec1); VSHF_B2_SB(src4, src8, src4, src8, mask0, mask1, vec2, vec3); VSHF_B2_SB(src5, src9, src5, src9, mask0, mask1, vec4, vec5); VSHF_B2_SB(src6, src10, src6, src10, mask0, mask1, vec6, vec7); - dst73 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst84 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst95 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst106 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - dst32_r = __msa_ilvr_h(dst73, dst22); - ILVRL_H2_SH(dst84, dst73, dst43_r, dst87_r); - ILVRL_H2_SH(dst95, dst84, dst54_r, dst98_r); - ILVRL_H2_SH(dst106, dst95, dst65_r, dst109_r); - dst22 = (v8i16) __msa_splati_d((v2i64) dst73, 1); - dst76_r = __msa_ilvr_h(dst22, dst106); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst3 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst8 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst5 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + dst32_r = __msa_ilvev_h(dst3, dst2); + ILVEV_H2_SH(dst3, dst4, dst7, dst8, dst43_r, dst87_r); + ILVEV_H2_SH(dst4, dst5, dst8, dst9, dst54_r, dst98_r); + ILVEV_H2_SH(dst5, dst6, dst9, dst10, dst65_r, dst109_r); + dst76_r = __msa_ilvev_h(dst7, dst6); dst0 = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst1 = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); dst2 = HEVC_FILT_4TAP(dst32_r, dst54_r, filt_h0, filt_h1); @@ -4414,18 +5220,20 @@ static void hevc_hv_uniwgt_4t_4multx8mult_msa(const uint8_t *src, MUL2(dst6, weight_vec, dst7, weight_vec, dst6, dst7); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD4(dst0, offset_vec, dst1, offset_vec, dst2, offset_vec, dst3, + offset_vec, dst0, dst1, dst2, dst3); + ADD4(dst4, offset_vec, dst5, offset_vec, dst6, offset_vec, dst7, + offset_vec, dst4, dst5, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); dst10_r = dst98_r; dst21_r = dst109_r; - dst22 = (v8i16) __msa_splati_d((v2i64) dst106, 1); + dst2 = dst10; } } @@ -4473,75 +5281,103 @@ static void hevc_hv_uniwgt_4t_6w_msa(const uint8_t *src, v16i8 mask1; v8i16 filt_h0, filt_h1, filter_vec; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dsth0, dsth1, dsth2, dsth3, dsth4, dsth5, dsth6, dsth7, dsth8, dsth9; - v8i16 dsth10, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; + v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8, dst9; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; v8i16 dst10_r, dst32_r, dst54_r, dst76_r, dst98_r, dst21_r, dst43_r; v8i16 dst65_r, dst87_r, dst109_r, dst10_l, dst32_l, dst54_l, dst76_l; v8i16 dst98_l, dst21_l, dst43_l, dst65_l, dst87_l, dst109_l; v8i16 dst1021_l, dst3243_l, dst5465_l, dst7687_l, dst98109_l; - v8i16 offset_vec, const_128, denom_vec; v4i32 dst0_r, dst1_r, dst2_r, dst3_r, dst4_r, dst5_r, dst6_r, dst7_r; - v4i32 dst0_l, dst1_l, dst2_l, dst3_l, weight_vec, rnd_vec; + v4i32 dst0_l, dst1_l, dst2_l, dst3_l, weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); - dsth0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dsth1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dsth2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - ILVRL_H2_SH(dsth1, dsth0, dst10_r, dst10_l); - ILVRL_H2_SH(dsth2, dsth1, dst21_r, dst21_l); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst21_r, dst21_l); LD_SB8(src, src_stride, src3, src4, src5, src6, src7, src8, src9, src10); - XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec2, vec3); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec4, vec5); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec6, vec7); - dsth3 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dsth4 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dsth5 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dsth6 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst6 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst8 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst32_r, dst32_l); + ILVEV_H2_SH(dst6, dst8, dst7, dst9, dst43_r, dst43_l); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst8, dst0, dst9, dst1, dst54_r, dst54_l); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst65_r, dst65_l); VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec0, vec1); VSHF_B2_SB(src8, src8, src8, src8, mask0, mask1, vec2, vec3); VSHF_B2_SB(src9, src9, src9, src9, mask0, mask1, vec4, vec5); VSHF_B2_SB(src10, src10, src10, src10, mask0, mask1, vec6, vec7); - dsth7 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dsth8 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dsth9 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dsth10 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - ILVRL_H2_SH(dsth3, dsth2, dst32_r, dst32_l); - ILVRL_H2_SH(dsth4, dsth3, dst43_r, dst43_l); - ILVRL_H2_SH(dsth5, dsth4, dst54_r, dst54_l); - ILVRL_H2_SH(dsth6, dsth5, dst65_r, dst65_l); - ILVRL_H2_SH(dsth7, dsth6, dst76_r, dst76_l); - ILVRL_H2_SH(dsth8, dsth7, dst87_r, dst87_l); - ILVRL_H2_SH(dsth9, dsth8, dst98_r, dst98_l); - ILVRL_H2_SH(dsth10, dsth9, dst109_r, dst109_l); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst76_r, dst76_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst87_r, dst87_l); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst6, dst0, dst7, dst1, dst98_r, dst98_l); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst109_r, dst109_l); PCKEV_D2_SH(dst21_l, dst10_l, dst43_l, dst32_l, dst1021_l, dst3243_l); PCKEV_D2_SH(dst65_l, dst54_l, dst87_l, dst76_l, dst5465_l, dst7687_l); dst98109_l = (v8i16) __msa_pckev_d((v2i64) dst109_l, (v2i64) dst98_l); @@ -4569,14 +5405,18 @@ static void hevc_hv_uniwgt_4t_6w_msa(const uint8_t *src, SRAR_W4_SW(dst0_r, dst1_r, dst2_r, dst3_r, rnd_vec); SRAR_W4_SW(dst4_r, dst5_r, dst6_r, dst7_r, rnd_vec); SRAR_W4_SW(dst0_l, dst1_l, dst2_l, dst3_l, rnd_vec); + ADD4(dst0_r, offset_vec, dst1_r, offset_vec, dst2_r, offset_vec, dst3_r, + offset_vec, dst0_r, dst1_r, dst2_r, dst3_r); + ADD4(dst4_r, offset_vec, dst5_r, offset_vec, dst6_r, offset_vec, dst7_r, + offset_vec, dst4_r, dst5_r, dst6_r, dst7_r); + ADD4(dst0_l, offset_vec, dst1_l, offset_vec, dst2_l, offset_vec, dst3_l, + offset_vec, dst0_l, dst1_l, dst2_l, dst3_l); + CLIP_SW8_0_255(dst1_r, dst0_r, dst3_r, dst2_r, + dst4_r, dst5_r, dst6_r, dst7_r); + CLIP_SW4_0_255(dst0_l, dst1_l, dst2_l, dst3_l); PCKEV_H2_SH(dst1_r, dst0_r, dst3_r, dst2_r, tmp0, tmp1); PCKEV_H2_SH(dst5_r, dst4_r, dst7_r, dst6_r, tmp2, tmp3); PCKEV_H2_SH(dst1_l, dst0_l, dst3_l, dst2_l, tmp4, tmp5); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - ADD2(tmp4, offset_vec, tmp5, offset_vec, tmp4, tmp5); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); - CLIP_SH2_0_255(tmp4, tmp5); PCKEV_B3_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, out0, out1, out2); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); ST_H8(out2, 0, 1, 2, 3, 4, 5, 6, 7, dst + 4, dst_stride); @@ -4599,50 +5439,63 @@ static void hevc_hv_uniwgt_4t_8x2_msa(const uint8_t *src, v16i8 mask0 = LD_SB(ff_hevc_mask_arr); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9; - v8i16 dst0, dst1, dst2, dst3, dst4; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; v4i32 dst0_r, dst0_l, dst1_r, dst1_l; v8i16 dst10_r, dst32_r, dst21_r, dst43_r; v8i16 dst10_l, dst32_l, dst21_l, dst43_l; - v8i16 tmp0, tmp1; - v8i16 offset_vec, const_128, denom_vec; - v4i32 weight_vec, rnd_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); - XORI_B5_128_SB(src0, src1, src2, src3, src4); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec6, vec7); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec8, vec9); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(vec8, vec9, filt0, filt1); - ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); - ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); - ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); - ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst21_r, dst21_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst32_r, dst32_l); + ILVRL_B2_SH(zero, vec8, tmp0, tmp1); + ILVRL_B2_SH(zero, vec9, tmp2, tmp3); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + ILVEV_H2_SH(dst6, dst0, dst7, dst1, dst43_r, dst43_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); @@ -4651,9 +5504,10 @@ static void hevc_hv_uniwgt_4t_8x2_msa(const uint8_t *src, MUL2(dst0_r, weight_vec, dst1_r, weight_vec, dst0_r, dst1_r); MUL2(dst0_l, weight_vec, dst1_l, weight_vec, dst0_l, dst1_l); SRAR_W4_SW(dst0_r, dst0_l, dst1_r, dst1_l, rnd_vec); + ADD4(dst0_r, offset_vec, dst0_l, offset_vec, dst1_r, offset_vec, + dst1_l, offset_vec, dst0_r, dst0_l, dst1_r, dst1_l); + CLIP_SW4_0_255(dst0_r, dst0_l, dst1_r, dst1_l); PCKEV_H2_SH(dst0_l, dst0_r, dst1_l, dst1_r, tmp0, tmp1); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - CLIP_SH2_0_255(tmp0, tmp1); out = (v16u8) __msa_pckev_b((v16i8) tmp1, (v16i8) tmp0); ST_D2(out, 0, 1, dst, dst_stride); } @@ -4674,21 +5528,22 @@ static void hevc_hv_uniwgt_4t_8multx4_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6, mask0, mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v8i16 filt0, filt1, filt_h0, filt_h1, filter_vec; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, tmp0, tmp1, tmp2, tmp3; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; v8i16 dst10_r, dst32_r, dst54_r, dst21_r, dst43_r, dst65_r; v8i16 dst10_l, dst32_l, dst54_l, dst21_l, dst43_l, dst65_l; - v8i16 offset_vec, const_128, denom_vec; v4i32 dst0_r, dst0_l, dst1_r, dst1_l, dst2_r, dst2_l, dst3_r, dst3_l; - v4i32 weight_vec, rnd_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask0 = LD_SB(ff_hevc_mask_arr); @@ -4696,36 +5551,53 @@ static void hevc_hv_uniwgt_4t_8multx4_msa(const uint8_t *src, weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); for (cnt = width8mult; cnt--;) { LD_SB7(src, src_stride, src0, src1, src2, src3, src4, src5, src6); src += 8; - XORI_B7_128_SB(src0, src1, src2, src3, src4, src5, src6); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); - ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst21_r, dst21_l); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec2, vec3); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec4, vec5); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec6, vec7); - dst3 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); - ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); - ILVRL_H2_SH(dst5, dst4, dst54_r, dst54_l); - ILVRL_H2_SH(dst6, dst5, dst65_r, dst65_l); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst4, dst0, dst5, dst1, dst32_r, dst32_l); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst43_r, dst43_l); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst54_r, dst54_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst65_r, dst65_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); @@ -4742,11 +5614,14 @@ static void hevc_hv_uniwgt_4t_8multx4_msa(const uint8_t *src, MUL2(dst2_l, weight_vec, dst3_l, weight_vec, dst2_l, dst3_l); SRAR_W4_SW(dst0_r, dst0_l, dst1_r, dst1_l, rnd_vec); SRAR_W4_SW(dst2_r, dst2_l, dst3_r, dst3_l, rnd_vec); + ADD2(dst0_r, offset_vec, dst1_r, offset_vec, dst0_r, dst1_r); + ADD2(dst2_r, offset_vec, dst3_r, offset_vec, dst2_r, dst3_r); + ADD2(dst0_l, offset_vec, dst1_l, offset_vec, dst0_l, dst1_l); + ADD2(dst2_l, offset_vec, dst3_l, offset_vec, dst2_l, dst3_l); + CLIP_SW8_0_255(dst0_r, dst0_l, dst1_r, dst1_l, + dst2_r, dst2_l, dst3_r, dst3_l); PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, dst2_l, dst2_r, dst3_l, dst3_r, tmp0, tmp1, tmp2, tmp3); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); dst += 8; @@ -4771,41 +5646,35 @@ static void hevc_hv_uniwgt_4t_8x6_msa(const uint8_t *src, v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9; v16i8 vec10, vec11, vec12, vec13, vec14, vec15, vec16, vec17; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, dst8; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; v4i32 dst0_r, dst0_l, dst1_r, dst1_l, dst2_r, dst2_l, dst3_r, dst3_l; - v4i32 dst4_r, dst4_l, dst5_r, dst5_l, weight_vec, rnd_vec; + v4i32 dst4_r, dst4_l, dst5_r, dst5_l, weight_vec, rnd_vec, offset_vec; v8i16 dst10_r, dst32_r, dst10_l, dst32_l; v8i16 dst21_r, dst43_r, dst21_l, dst43_l; v8i16 dst54_r, dst54_l, dst65_r, dst65_l; v8i16 dst76_r, dst76_l, dst87_r, dst87_l; - v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - v8i16 offset_vec, const_128, denom_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); src += (5 * src_stride); LD_SB4(src, src_stride, src5, src6, src7, src8); - XORI_B5_128_SB(src0, src1, src2, src3, src4); - XORI_B4_128_SB(src5, src6, src7, src8); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); @@ -4815,23 +5684,51 @@ static void hevc_hv_uniwgt_4t_8x6_msa(const uint8_t *src, VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec12, vec13); VSHF_B2_SB(src7, src7, src7, src7, mask0, mask1, vec14, vec15); VSHF_B2_SB(src8, src8, src8, src8, mask0, mask1, vec16, vec17); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst3 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(vec8, vec9, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec10, vec11, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec12, vec13, filt0, filt1); - dst7 = HEVC_FILT_4TAP_SH(vec14, vec15, filt0, filt1); - dst8 = HEVC_FILT_4TAP_SH(vec16, vec17, filt0, filt1); - ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); - ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); - ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); - ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); - ILVRL_H2_SH(dst5, dst4, dst54_r, dst54_l); - ILVRL_H2_SH(dst6, dst5, dst65_r, dst65_l); - ILVRL_H2_SH(dst7, dst6, dst76_r, dst76_l); - ILVRL_H2_SH(dst8, dst7, dst87_r, dst87_l); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst21_r, dst21_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst32_r, dst32_l); + ILVRL_B2_SH(zero, vec8, tmp0, tmp1); + ILVRL_B2_SH(zero, vec9, tmp2, tmp3); + ILVRL_B2_SH(zero, vec10, tmp4, tmp5); + ILVRL_B2_SH(zero, vec11, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst6, dst0, dst7, dst1, dst43_r, dst43_l); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst54_r, dst54_l); + ILVRL_B2_SH(zero, vec12, tmp0, tmp1); + ILVRL_B2_SH(zero, vec13, tmp2, tmp3); + ILVRL_B2_SH(zero, vec14, tmp4, tmp5); + ILVRL_B2_SH(zero, vec15, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst65_r, dst65_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst76_r, dst76_l); + ILVRL_B2_SH(zero, vec16, tmp0, tmp1); + ILVRL_B2_SH(zero, vec17, tmp2, tmp3); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + ILVEV_H2_SH(dst6, dst0, dst7, dst1, dst87_r, dst87_l); dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); @@ -4856,14 +5753,18 @@ static void hevc_hv_uniwgt_4t_8x6_msa(const uint8_t *src, SRAR_W4_SW(dst0_r, dst0_l, dst1_r, dst1_l, rnd_vec); SRAR_W4_SW(dst2_r, dst2_l, dst3_r, dst3_l, rnd_vec); SRAR_W4_SW(dst4_r, dst4_l, dst5_r, dst5_l, rnd_vec); + ADD2(dst0_r, offset_vec, dst1_r, offset_vec, dst0_r, dst1_r); + ADD2(dst2_r, offset_vec, dst3_r, offset_vec, dst2_r, dst3_r); + ADD2(dst4_r, offset_vec, dst5_r, offset_vec, dst4_r, dst5_r); + ADD2(dst0_l, offset_vec, dst1_l, offset_vec, dst0_l, dst1_l); + ADD2(dst2_l, offset_vec, dst3_l, offset_vec, dst2_l, dst3_l); + ADD2(dst4_l, offset_vec, dst5_l, offset_vec, dst4_l, dst5_l); + CLIP_SW8_0_255(dst0_r, dst1_r, dst2_r, dst3_r, + dst4_r, dst5_r, dst0_l, dst1_l); + CLIP_SW4_0_255(dst2_l, dst3_l, dst4_l, dst5_l); PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, dst2_l, dst2_r, dst3_l, dst3_r, tmp0, tmp1, tmp2, tmp3); PCKEV_H2_SH(dst4_l, dst4_r, dst5_l, dst5_r, tmp4, tmp5); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - ADD2(tmp4, offset_vec, tmp5, offset_vec, tmp4, tmp5); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); - CLIP_SH2_0_255(tmp4, tmp5); PCKEV_B3_UB(tmp1, tmp0, tmp3, tmp2, tmp5, tmp4, out0, out1, out2); ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride); ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride); @@ -4891,33 +5792,30 @@ static void hevc_hv_uniwgt_4t_8multx4mult_msa(const uint8_t *src, v16i8 mask0 = LD_SB(ff_hevc_mask_arr); v16i8 mask1; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; - v8i16 dst0, dst1, dst2, dst3, dst4, dst5, dst6, tmp0, tmp1, tmp2, tmp3; + v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; v8i16 dst10_r, dst32_r, dst54_r, dst21_r, dst43_r, dst65_r; v8i16 dst10_l, dst32_l, dst54_l, dst21_l, dst43_l, dst65_l; v4i32 dst0_r, dst0_l, dst1_r, dst1_l; - v8i16 offset_vec, const_128, denom_vec; v4i32 dst2_r, dst2_l, dst3_r, dst3_l; - v4i32 weight_vec, rnd_vec; + v4i32 weight_vec, rnd_vec, offset_vec; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask1 = mask0 + 2; weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); for (cnt = width8mult; cnt--;) { src_tmp = src; @@ -4925,35 +5823,55 @@ static void hevc_hv_uniwgt_4t_8multx4mult_msa(const uint8_t *src, LD_SB3(src_tmp, src_stride, src0, src1, src2); src_tmp += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); - dst0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - ILVRL_H2_SH(dst1, dst0, dst10_r, dst10_l); - ILVRL_H2_SH(dst2, dst1, dst21_r, dst21_l); + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst10_r, dst10_l); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst21_r, dst21_l); for (loop_cnt = height >> 2; loop_cnt--;) { LD_SB4(src_tmp, src_stride, src3, src4, src5, src6); src_tmp += (4 * src_stride); - XORI_B4_128_SB(src3, src4, src5, src6); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec2, vec3); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec4, vec5); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec6, vec7); - dst3 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst4 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst5 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst6 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - ILVRL_H2_SH(dst3, dst2, dst32_r, dst32_l); - ILVRL_H2_SH(dst4, dst3, dst43_r, dst43_l); - ILVRL_H2_SH(dst5, dst4, dst54_r, dst54_l); - ILVRL_H2_SH(dst6, dst5, dst65_r, dst65_l); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst4, dst0, dst5, dst1, dst32_r, dst32_l); + ILVEV_H2_SH(dst0, dst2, dst1, dst3, dst43_r, dst43_l); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dst2, dst4, dst3, dst5, dst54_r, dst54_l); + ILVEV_H2_SH(dst4, dst6, dst5, dst7, dst65_r, dst65_l); dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); @@ -4970,11 +5888,14 @@ static void hevc_hv_uniwgt_4t_8multx4mult_msa(const uint8_t *src, MUL2(dst2_l, weight_vec, dst3_l, weight_vec, dst2_l, dst3_l); SRAR_W4_SW(dst0_r, dst0_l, dst1_r, dst1_l, rnd_vec); SRAR_W4_SW(dst2_r, dst2_l, dst3_r, dst3_l, rnd_vec); + ADD2(dst0_r, offset_vec, dst1_r, offset_vec, dst0_r, dst1_r); + ADD2(dst2_r, offset_vec, dst3_r, offset_vec, dst2_r, dst3_r); + ADD2(dst0_l, offset_vec, dst1_l, offset_vec, dst0_l, dst1_l); + ADD2(dst2_l, offset_vec, dst3_l, offset_vec, dst2_l, dst3_l); + CLIP_SW8_0_255(dst0_r, dst0_l, dst1_r, dst1_l, + dst2_r, dst2_l, dst3_r, dst3_l); PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, dst2_l, dst2_r, dst3_l, dst3_r, tmp0, tmp1, tmp2, tmp3); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst_tmp, dst_stride); dst_tmp += (4 * dst_stride); @@ -4983,7 +5904,8 @@ static void hevc_hv_uniwgt_4t_8multx4mult_msa(const uint8_t *src, dst10_l = dst54_l; dst21_r = dst65_r; dst21_l = dst65_l; - dst2 = dst6; + dst4 = dst6; + dst5 = dst7; } src += 8; @@ -5040,24 +5962,25 @@ static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src, v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10; v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7; v16i8 mask0, mask1, mask2, mask3; - v8i16 filt0, filt1, filt_h0, filt_h1, filter_vec, tmp0, tmp1, tmp2, tmp3; - v8i16 dsth0, dsth1, dsth2, dsth3, dsth4, dsth5, dsth6; - v8i16 dst10, dst21, dst22, dst73, dst84, dst95, dst106; + v8i16 filt0, filt1, filt_h0, filt_h1, filter_vec; + v4i32 dsth0, dsth1, dsth2, dsth3, dsth4, dsth5, dsth6, dsth7; v8i16 dst76_r, dst98_r, dst87_r, dst109_r; v8i16 dst10_r, dst32_r, dst54_r, dst21_r, dst43_r, dst65_r; v8i16 dst10_l, dst32_l, dst54_l, dst21_l, dst43_l, dst65_l; - v8i16 offset_vec, const_128, denom_vec; v4i32 dst0_r, dst0_l, dst1_r, dst1_l, dst2_r, dst2_l, dst3_r, dst3_l; v4i32 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7, weight_vec, rnd_vec; + v4i32 dst8, dst9, dst10, offset_vec; + v8i16 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; + v8i16 zero = { 0 }; src -= (src_stride + 1); filter_vec = LD_SH(filter_x); - SPLATI_H2_SH(filter_vec, 0, 1, filt0, filt1); + UNPCK_R_SB_SH(filter_vec, filter_vec); + SPLATI_W2_SH(filter_vec, 0, filt0, filt1); filter_vec = LD_SH(filter_y); UNPCK_R_SB_SH(filter_vec, filter_vec); - SPLATI_W2_SH(filter_vec, 0, filt_h0, filt_h1); mask0 = LD_SB(ff_hevc_mask_arr); @@ -5065,43 +5988,61 @@ static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src, weight_vec = __msa_fill_w(weight); rnd_vec = __msa_fill_w(rnd_val); - - offset_vec = __msa_fill_h(offset); - denom_vec = __msa_fill_h(rnd_val - 6); - const_128 = __msa_fill_h((128 * weight)); - offset_vec += __msa_srar_h(const_128, denom_vec); + offset_vec = __msa_fill_w(offset); src_tmp = src; dst_tmp = dst; LD_SB3(src_tmp, src_stride, src0, src1, src2); src_tmp += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); VSHF_B2_SB(src0, src0, src0, src0, mask0, mask1, vec0, vec1); VSHF_B2_SB(src1, src1, src1, src1, mask0, mask1, vec2, vec3); VSHF_B2_SB(src2, src2, src2, src2, mask0, mask1, vec4, vec5); - dsth0 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dsth1 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dsth2 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - ILVRL_H2_SH(dsth1, dsth0, dst10_r, dst10_l); - ILVRL_H2_SH(dsth2, dsth1, dst21_r, dst21_l); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dsth0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dsth1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dsth2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dsth3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + dsth4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dsth5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + ILVEV_H2_SH(dsth0, dsth2, dsth1, dsth3, dst10_r, dst10_l); + ILVEV_H2_SH(dsth2, dsth4, dsth3, dsth5, dst21_r, dst21_l); for (loop_cnt = 4; loop_cnt--;) { LD_SB4(src_tmp, src_stride, src3, src4, src5, src6); src_tmp += (4 * src_stride); - XORI_B4_128_SB(src3, src4, src5, src6); VSHF_B2_SB(src3, src3, src3, src3, mask0, mask1, vec0, vec1); VSHF_B2_SB(src4, src4, src4, src4, mask0, mask1, vec2, vec3); VSHF_B2_SB(src5, src5, src5, src5, mask0, mask1, vec4, vec5); VSHF_B2_SB(src6, src6, src6, src6, mask0, mask1, vec6, vec7); - dsth3 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dsth4 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dsth5 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dsth6 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - ILVRL_H2_SH(dsth3, dsth2, dst32_r, dst32_l); - ILVRL_H2_SH(dsth4, dsth3, dst43_r, dst43_l); - ILVRL_H2_SH(dsth5, dsth4, dst54_r, dst54_l); - ILVRL_H2_SH(dsth6, dsth5, dst65_r, dst65_l); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dsth0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dsth1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dsth2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dsth3 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dsth4, dsth0, dsth5, dsth1, dst32_r, dst32_l); + ILVEV_H2_SH(dsth0, dsth2, dsth1, dsth3, dst43_r, dst43_l); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dsth4 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dsth5 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dsth6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dsth7 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVEV_H2_SH(dsth2, dsth4, dsth3, dsth5, dst54_r, dst54_l); + ILVEV_H2_SH(dsth4, dsth6, dsth5, dsth7, dst65_r, dst65_l); + dst0_r = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst0_l = HEVC_FILT_4TAP(dst10_l, dst32_l, filt_h0, filt_h1); dst1_r = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); @@ -5118,11 +6059,14 @@ static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src, MUL2(dst2_l, weight_vec, dst3_l, weight_vec, dst2_l, dst3_l); SRAR_W4_SW(dst0_r, dst0_l, dst1_r, dst1_l, rnd_vec); SRAR_W4_SW(dst2_r, dst2_l, dst3_r, dst3_l, rnd_vec); + ADD2(dst0_r, offset_vec, dst1_r, offset_vec, dst0_r, dst1_r); + ADD2(dst2_r, offset_vec, dst3_r, offset_vec, dst2_r, dst3_r); + ADD2(dst0_l, offset_vec, dst1_l, offset_vec, dst0_l, dst1_l); + ADD2(dst2_l, offset_vec, dst3_l, offset_vec, dst2_l, dst3_l); + CLIP_SW8_0_255(dst0_r, dst0_l, dst1_r, dst1_l, + dst2_r, dst2_l, dst3_r, dst3_l); PCKEV_H4_SH(dst0_l, dst0_r, dst1_l, dst1_r, dst2_l, dst2_r, dst3_l, dst3_r, tmp0, tmp1, tmp2, tmp3); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_D4(out0, out1, 0, 1, 0, 1, dst_tmp, dst_stride); dst_tmp += (4 * dst_stride); @@ -5131,7 +6075,8 @@ static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src, dst10_l = dst54_l; dst21_r = dst65_r; dst21_l = dst65_l; - dsth2 = dsth6; + dsth4 = dsth6; + dsth5 = dsth7; } src += 8; @@ -5142,33 +6087,49 @@ static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src, LD_SB3(src, src_stride, src0, src1, src2); src += (3 * src_stride); - XORI_B3_128_SB(src0, src1, src2); VSHF_B2_SB(src0, src1, src0, src1, mask2, mask3, vec0, vec1); VSHF_B2_SB(src1, src2, src1, src2, mask2, mask3, vec2, vec3); - dst10 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst21 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - ILVRL_H2_SH(dst21, dst10, dst10_r, dst21_r); - dst22 = (v8i16) __msa_splati_d((v2i64) dst21, 1); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVL_B2_SH(zero, vec2, zero, vec3, tmp4, tmp6); + dst0 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst1 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst2 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + + ILVEV_H2_SH(dst0, dst1, dst1, dst2, dst10_r, dst21_r); for (loop_cnt = 2; loop_cnt--;) { LD_SB8(src, src_stride, src3, src4, src5, src6, src7, src8, src9, src10); src += (8 * src_stride); - XORI_B8_128_SB(src3, src4, src5, src6, src7, src8, src9, src10); VSHF_B2_SB(src3, src7, src3, src7, mask2, mask3, vec0, vec1); VSHF_B2_SB(src4, src8, src4, src8, mask2, mask3, vec2, vec3); VSHF_B2_SB(src5, src9, src5, src9, mask2, mask3, vec4, vec5); VSHF_B2_SB(src6, src10, src6, src10, mask2, mask3, vec6, vec7); - dst73 = HEVC_FILT_4TAP_SH(vec0, vec1, filt0, filt1); - dst84 = HEVC_FILT_4TAP_SH(vec2, vec3, filt0, filt1); - dst95 = HEVC_FILT_4TAP_SH(vec4, vec5, filt0, filt1); - dst106 = HEVC_FILT_4TAP_SH(vec6, vec7, filt0, filt1); - dst32_r = __msa_ilvr_h(dst73, dst22); - ILVRL_H2_SH(dst84, dst73, dst43_r, dst87_r); - ILVRL_H2_SH(dst95, dst84, dst54_r, dst98_r); - ILVRL_H2_SH(dst106, dst95, dst65_r, dst109_r); - dst22 = (v8i16) __msa_splati_d((v2i64) dst73, 1); - dst76_r = __msa_ilvr_h(dst22, dst106); + + ILVRL_B2_SH(zero, vec0, tmp0, tmp1); + ILVRL_B2_SH(zero, vec1, tmp2, tmp3); + ILVRL_B2_SH(zero, vec2, tmp4, tmp5); + ILVRL_B2_SH(zero, vec3, tmp6, tmp7); + dst3 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst7 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst4 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst8 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + ILVRL_B2_SH(zero, vec4, tmp0, tmp1); + ILVRL_B2_SH(zero, vec5, tmp2, tmp3); + ILVRL_B2_SH(zero, vec6, tmp4, tmp5); + ILVRL_B2_SH(zero, vec7, tmp6, tmp7); + dst5 = HEVC_FILT_4TAP_SW(tmp0, tmp2, filt0, filt1); + dst9 = HEVC_FILT_4TAP_SW(tmp1, tmp3, filt0, filt1); + dst6 = HEVC_FILT_4TAP_SW(tmp4, tmp6, filt0, filt1); + dst10 = HEVC_FILT_4TAP_SW(tmp5, tmp7, filt0, filt1); + + dst32_r = __msa_ilvev_h(dst3, dst2); + ILVEV_H2_SH(dst3, dst4, dst7, dst8, dst43_r, dst87_r); + ILVEV_H2_SH(dst4, dst5, dst8, dst9, dst54_r, dst98_r); + ILVEV_H2_SH(dst5, dst6, dst9, dst10, dst65_r, dst109_r); + dst76_r = __msa_ilvev_h(dst7, dst6); dst0 = HEVC_FILT_4TAP(dst10_r, dst32_r, filt_h0, filt_h1); dst1 = HEVC_FILT_4TAP(dst21_r, dst43_r, filt_h0, filt_h1); dst2 = HEVC_FILT_4TAP(dst32_r, dst54_r, filt_h0, filt_h1); @@ -5185,18 +6146,21 @@ static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src, MUL2(dst6, weight_vec, dst7, weight_vec, dst6, dst7); SRAR_W4_SW(dst0, dst1, dst2, dst3, rnd_vec); SRAR_W4_SW(dst4, dst5, dst6, dst7, rnd_vec); + ADD2(dst0, offset_vec, dst1, offset_vec, dst0, dst1); + ADD2(dst2, offset_vec, dst3, offset_vec, dst2, dst3); + ADD2(dst4, offset_vec, dst5, offset_vec, dst4, dst5); + ADD2(dst6, offset_vec, dst7, offset_vec, dst6, dst7); + CLIP_SW8_0_255(dst0, dst1, dst2, dst3, + dst4, dst5, dst6, dst7); PCKEV_H4_SH(dst1, dst0, dst3, dst2, dst5, dst4, dst7, dst6, tmp0, tmp1, tmp2, tmp3); - ADD2(tmp0, offset_vec, tmp1, offset_vec, tmp0, tmp1); - ADD2(tmp2, offset_vec, tmp3, offset_vec, tmp2, tmp3); - CLIP_SH4_0_255(tmp0, tmp1, tmp2, tmp3); PCKEV_B2_UB(tmp1, tmp0, tmp3, tmp2, out0, out1); ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, dst_stride); dst += (8 * dst_stride); dst10_r = dst98_r; dst21_r = dst109_r; - dst22 = (v8i16) __msa_splati_d((v2i64) dst106, 1); + dst2 = dst10; } } diff --git a/libavcodec/mips/hevcdsp_msa.c b/libavcodec/mips/hevcdsp_msa.c index 8841a31369..9c12029c1f 100644 --- a/libavcodec/mips/hevcdsp_msa.c +++ b/libavcodec/mips/hevcdsp_msa.c @@ -81,12 +81,13 @@ static void hevc_copy_6w_msa(const uint8_t *src, int32_t src_stride, int16_t *dst, int32_t dst_stride, int32_t height) { - uint32_t loop_cnt; + uint32_t loop_cnt = (height >> 3); + uint32_t res = height & 0x07; v16i8 zero = { 0 }; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v8i16 in0, in1, in2, in3, in4, in5, in6, in7; - for (loop_cnt = (height >> 3); loop_cnt--;) { + for (; loop_cnt--; ) { LD_SB8(src, src_stride, src0, src1, src2, src3, src4, src5, src6, src7); src += (8 * src_stride); @@ -99,6 +100,19 @@ static void hevc_copy_6w_msa(const uint8_t *src, int32_t src_stride, ST12x8_UB(in0, in1, in2, in3, in4, in5, in6, in7, dst, 2 * dst_stride); dst += (8 * dst_stride); } + for (; res--; ) { + uint64_t out0; + uint32_t out1; + src0 = LD_SB(src); + src += src_stride; + in0 = (v8i16)__msa_ilvr_b((v16i8) zero, (v16i8) src0); + in0 = in0 << 6; + out0 = __msa_copy_u_d((v2i64) in0, 0); + out1 = __msa_copy_u_w((v4i32) in0, 2); + SD(out0, dst); + SW(out1, dst + 4); + dst += dst_stride; + } } static void hevc_copy_8w_msa(const uint8_t *src, int32_t src_stride, @@ -167,6 +181,7 @@ static void hevc_copy_12w_msa(const uint8_t *src, int32_t src_stride, int32_t height) { uint32_t loop_cnt; + uint32_t res = height & 0x07; v16i8 zero = { 0 }; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v8i16 in0, in1, in0_r, in1_r, in2_r, in3_r; @@ -197,6 +212,19 @@ static void hevc_copy_12w_msa(const uint8_t *src, int32_t src_stride, ST_D4(in0, in1, 0, 1, 0, 1, dst + 8, dst_stride); dst += (4 * dst_stride); } + for (; res--; ) { + uint64_t out0; + src0 = LD_SB(src); + src += src_stride; + in0_r = (v8i16)__msa_ilvr_b((v16i8) zero, (v16i8) src0); + in0 = (v8i16)__msa_ilvl_b((v16i8) zero, (v16i8) src0); + in0_r = in0_r << 6; + in0 = in0 << 6; + ST_UH(in0_r, dst); + out0 = __msa_copy_u_d((v2i64) in0, 0); + SD(out0, dst + 8); + dst += dst_stride; + } } static void hevc_copy_16w_msa(const uint8_t *src, int32_t src_stride, @@ -450,6 +478,7 @@ static void hevc_hz_8t_4w_msa(const uint8_t *src, int32_t src_stride, const int8_t *filter, int32_t height) { uint32_t loop_cnt; + uint32_t res = (height & 0x07) >> 1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7; v8i16 filt0, filt1, filt2, filt3; v16i8 mask1, mask2, mask3; @@ -498,6 +527,18 @@ static void hevc_hz_8t_4w_msa(const uint8_t *src, int32_t src_stride, ST_D8(dst0, dst1, dst2, dst3, 0, 1, 0, 1, 0, 1, 0, 1, dst, dst_stride); dst += (8 * dst_stride); } + for (; res--; ) { + LD_SB2(src, src_stride, src0, src1); + src += 2 * src_stride; + XORI_B2_128_SB(src0, src1); + VSHF_B4_SB(src0, src1, mask0, mask1, mask2, mask3, + vec0, vec1, vec2, vec3); + dst0 = const_vec; + DPADD_SB4_SH(vec0, vec1, vec2, vec3, filt0, filt1, filt2, filt3, + dst0, dst0, dst0, dst0); + ST_D2(dst0, 0, 1, dst, dst_stride); + dst += 2 * dst_stride; + } } static void hevc_hz_8t_8w_msa(const uint8_t *src, int32_t src_stride, @@ -992,6 +1033,7 @@ static void hevc_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride, const int8_t *filter, int32_t height) { int32_t loop_cnt; + int32_t res = (height & 0x07) >> 1; v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8; v16i8 src9, src10, src11, src12, src13, src14; v16i8 src10_r, src32_r, src54_r, src76_r, src98_r; @@ -1055,6 +1097,22 @@ static void hevc_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride, src6554 = src14131312; src6 = src14; } + for (; res--; ) { + LD_SB2(src, src_stride, src7, src8); + src += 2 * src_stride; + ILVR_B2_SB(src7, src6, src8, src7, src76_r, src87_r); + src8776 = (v16i8)__msa_ilvr_d((v2i64) src87_r, src76_r); + src8776 = (v16i8)__msa_xori_b((v16i8) src8776, 128); + dst10 = const_vec; + DPADD_SB4_SH(src2110, src4332, src6554, src8776, + filt0, filt1, filt2, filt3, dst10, dst10, dst10, dst10); + ST_D2(dst10, 0, 1, dst, dst_stride); + dst += 2 * dst_stride; + src2110 = src4332; + src4332 = src6554; + src6554 = src8776; + src6 = src8; + } } static void hevc_vt_8t_8w_msa(const uint8_t *src, int32_t src_stride, @@ -2661,6 +2719,7 @@ static void hevc_vt_4t_6w_msa(const uint8_t *src, int32_t height) { int32_t loop_cnt; + int32_t res = height & 0x03; uint32_t dst_val_int0, dst_val_int1, dst_val_int2, dst_val_int3; uint64_t dst_val0, dst_val1, dst_val2, dst_val3; v16i8 src0, src1, src2, src3, src4; @@ -2725,6 +2784,29 @@ static void hevc_vt_4t_6w_msa(const uint8_t *src, SW(dst_val_int3, dst + 4); dst += dst_stride; } + if (res) { + LD_SB2(src, src_stride, src3, src4); + XORI_B2_128_SB(src3, src4); + ILVR_B2_SB(src3, src2, src4, src3, src32_r, src43_r); + + dst0_r = const_vec; + DPADD_SB2_SH(src10_r, src32_r, filt0, filt1, dst0_r, dst0_r); + dst1_r = const_vec; + DPADD_SB2_SH(src21_r, src43_r, filt0, filt1, dst1_r, dst1_r); + + dst_val0 = __msa_copy_u_d((v2i64) dst0_r, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst1_r, 0); + + dst_val_int0 = __msa_copy_u_w((v4i32) dst0_r, 2); + dst_val_int1 = __msa_copy_u_w((v4i32) dst1_r, 2); + + SD(dst_val0, dst); + SW(dst_val_int0, dst + 4); + dst += dst_stride; + SD(dst_val1, dst); + SW(dst_val_int1, dst + 4); + dst += dst_stride; + } } static void hevc_vt_4t_8x2_msa(const uint8_t *src, From 43a4854510a3d596e114d899177a5b3b323ca9fb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 12 Sep 2022 19:55:09 +0200 Subject: [PATCH 311/590] avcodec/tiff: Fix loop detection Fixes regression with tickets/4364/L1004220.DNG Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer --- libavcodec/tiff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index beb427e007..226050744f 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1747,7 +1747,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) { TiffContext *const s = avctx->priv_data; - unsigned off, last_off; + unsigned off, last_off = 0; int le, ret, plane, planes; int i, j, entries, stride; unsigned soff, ssize; @@ -1812,7 +1812,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, /** whether we should process this multi-page IFD's next page */ retry_for_page = s->get_page && s->cur_page + 1 < s->get_page; // get_page is 1-indexed - last_off = off; if (retry_for_page) { // set offset to the next IFD off = ff_tget_long(&s->gb, le); @@ -1830,6 +1829,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, avpriv_request_sample(s->avctx, "non increasing IFD offset"); return AVERROR_INVALIDDATA; } + last_off = off; if (off >= UINT_MAX - 14 || avpkt->size < off + 14) { av_log(avctx, AV_LOG_ERROR, "IFD offset is greater than image size\n"); return AVERROR_INVALIDDATA; From ac26712e35f5ebc726d1be14bb4a420949e66604 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 10 Sep 2022 23:54:17 +0200 Subject: [PATCH 312/590] avcodec/exr: Check preview psize Fixes: signed integer overflow: 17121181824 * 538976288 cannot be represented in type 'long long' Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5915330316206080 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/exr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 235f6fa6cd..c924406f13 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1942,9 +1942,12 @@ static int decode_header(EXRContext *s, AVFrame *frame) "preview", 16)) >= 0) { uint32_t pw = bytestream2_get_le32(gb); uint32_t ph = bytestream2_get_le32(gb); - int64_t psize = 4LL * pw * ph; + uint64_t psize = pw * ph; + if (psize > INT64_MAX / 4) + return AVERROR_INVALIDDATA; + psize *= 4; - if (psize >= bytestream2_get_bytes_left(gb)) + if ((int64_t)psize >= bytestream2_get_bytes_left(gb)) return AVERROR_INVALIDDATA; bytestream2_skip(gb, psize); From 677e27a9afa7305a918336699b377fd5b42cc299 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 10 Sep 2022 23:58:36 +0200 Subject: [PATCH 313/590] avcodec/mobiclip: Check quantizer for overflow Fixes: signed integer overflow: 127 + 2147483536 cannot be represented in type 'int' Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOBICLIP_fuzzer-6014034970804224 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mobiclip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c index 5348f3bd6c..aca462428c 100644 --- a/libavcodec/mobiclip.c +++ b/libavcodec/mobiclip.c @@ -330,7 +330,7 @@ static av_cold int mobiclip_init(AVCodecContext *avctx) return 0; } -static int setup_qtables(AVCodecContext *avctx, int quantizer) +static int setup_qtables(AVCodecContext *avctx, int64_t quantizer) { MobiClipContext *s = avctx->priv_data; int qx, qy; @@ -1256,7 +1256,7 @@ static int mobiclip_decode(AVCodecContext *avctx, AVFrame *rframe, frame->key_frame = 0; s->dct_tab_idx = 0; - ret = setup_qtables(avctx, s->quantizer + get_se_golomb(gb)); + ret = setup_qtables(avctx, s->quantizer + (int64_t)get_se_golomb(gb)); if (ret < 0) return ret; From 3993345f915bccceee315f44d412445346990e14 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 11 Sep 2022 00:11:20 +0200 Subject: [PATCH 314/590] avcodec/tta: Check 24bit scaling for overflow Fixes: signed integer overflow: -8427924 * 256 cannot be represented in type 'int' Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5409428670644224 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/tta.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 6fb8d7a74f..d66e25af05 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -377,8 +377,15 @@ static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame, case 3: { // shift samples for 24-bit sample format int32_t *samples = (int32_t *)frame->data[0]; - for (i = 0; i < framelen * s->channels; i++) - *samples++ *= 256; + int overflow = 0; + + for (i = 0; i < framelen * s->channels; i++) { + int scaled = *samples * 256U; + overflow += (scaled >> 8 != *samples); + *samples++ = scaled; + } + if (overflow) + av_log(avctx, AV_LOG_WARNING, "%d overflows occurred on 24bit upscale\n", overflow); // reset decode buffer s->decode_buffer = NULL; break; From 14e99cb47212a9b42956034337a00658bcace1ef Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 11 Sep 2022 13:03:54 +0200 Subject: [PATCH 315/590] avcodec/hdrdec: Update w in inner loop of decompress() Fixes: out of array access Fixes: 50936/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_fuzzer-5423041009549312 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/hdrdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c index 9b262f2ef2..7727826e2a 100644 --- a/libavcodec/hdrdec.c +++ b/libavcodec/hdrdec.c @@ -70,8 +70,8 @@ static int decompress(uint8_t *scanline, int w, GetByteContext *gb, const uint8_ for (int i = run << rshift; i > 0 && w > 0 && scanline >= start + 4; i--) { memcpy(scanline, scanline - 4, 4); scanline += 4; + w -= 4; } - w -= run << rshift; rshift += 8; if (rshift > 16) break; From 67250ee8d22b23818d903f4dab28fe0444a1a625 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 11 Sep 2022 14:31:04 +0200 Subject: [PATCH 316/590] tools/target_dec_fuzzer: Adjust threshold for Jpeg2000 Fixes: Timeout Fixes: 50955/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5148704872464384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 5b335d3130..3d4521887a 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -242,7 +242,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_IFF_ILBM: maxpixels /= 128; break; case AV_CODEC_ID_INDEO4: maxpixels /= 128; break; case AV_CODEC_ID_INTERPLAY_ACM: maxsamples /= 16384; break; - case AV_CODEC_ID_JPEG2000: maxpixels /= 16; break; + case AV_CODEC_ID_JPEG2000: maxpixels /= 4096; break; case AV_CODEC_ID_LAGARITH: maxpixels /= 1024; break; case AV_CODEC_ID_LOCO: maxpixels /= 1024; break; case AV_CODEC_ID_VORBIS: maxsamples /= 1024; break; From f05247f6a4698c14f1cd523daa90188f50dcf6ad Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 11 Sep 2022 00:30:42 +0200 Subject: [PATCH 317/590] avcodec/apedec: Fix integer overflow in filter_3800() Fixes: signed integer overflow: -2147448926 + -198321 cannot be represented in type 'int' Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5739619273015296 Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-6744428485672960 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/apedec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 4e3ddfea01..c08d13d6c2 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -934,7 +934,7 @@ static av_always_inline int filter_3800(APEPredictor *p, p->coeffsB[filter][0] += (((d3 >> 29) & 4) - 2) * sign; p->coeffsB[filter][1] -= (((d4 >> 30) & 2) - 1) * sign; - p->filterB[filter] = p->lastA[filter] + (predictionB >> shift); + p->filterB[filter] = p->lastA[filter] + (unsigned)(predictionB >> shift); p->filterA[filter] = p->filterB[filter] + (unsigned)((int)(p->filterA[filter] * 31U) >> 5); return p->filterA[filter]; From b11813708dc463b678d7e0a2638e47d217a03ed1 Mon Sep 17 00:00:00 2001 From: Yondon Fu Date: Fri, 9 Sep 2022 13:54:02 -0400 Subject: [PATCH 318/590] avfilter/vf_libvmaf: Update ssim, ms_ssim options description Update description for ssim and ms_ssim libvmaf options to specify feature=float_ssim and feature=float_ms_ssim which are used to request ssim and ms_ssim values in the latest versions of libvmaf. Signed-off-by: Yondon Fu --- libavfilter/vf_libvmaf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index 8d5ba4e2d5..8f649c5b02 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -70,8 +70,8 @@ static const AVOption libvmaf_options[] = { {"enable_transform", "use model='enable_transform=true'.", OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, {"phone_model", "use model='enable_transform=true'.", OFFSET(phone_model), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, {"psnr", "use feature='name=psnr'.", OFFSET(psnr), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, - {"ssim", "use feature='name=ssim'.", OFFSET(ssim), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, - {"ms_ssim", "use feature='name=ms_ssim'.", OFFSET(ms_ssim), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, + {"ssim", "use feature='name=float_ssim'.", OFFSET(ssim), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, + {"ms_ssim", "use feature='name=float_ms_ssim'.", OFFSET(ms_ssim), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS|AV_OPT_FLAG_DEPRECATED}, {"pool", "Set the pool method to be used for computing vmaf.", OFFSET(pool), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, {"n_threads", "Set number of threads to be used when computing vmaf.", OFFSET(n_threads), AV_OPT_TYPE_INT, {.i64=0}, 0, UINT_MAX, FLAGS}, {"n_subsample", "Set interval for frame subsampling used when computing vmaf.", OFFSET(n_subsample), AV_OPT_TYPE_INT, {.i64=1}, 1, UINT_MAX, FLAGS}, From 695bf82bfb233fa0e77af4029c88620d943c3cba Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 17 Sep 2022 09:55:47 +0200 Subject: [PATCH 319/590] avcodec/tta: simplify final samples conversion Remove dubious overflow message and counter. --- libavcodec/tta.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libavcodec/tta.c b/libavcodec/tta.c index d66e25af05..e63d08bb44 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -364,28 +364,24 @@ static int tta_decode_frame(AVCodecContext *avctx, AVFrame *frame, switch (s->bps) { case 1: { uint8_t *samples = (uint8_t *)frame->data[0]; - for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++) - *samples++ = *p + 0x80; + p = s->decode_buffer; + for (i = 0; i < framelen * s->channels; i++) + samples[i] = p[i] + 0x80; break; } case 2: { int16_t *samples = (int16_t *)frame->data[0]; - for (p = s->decode_buffer; (int32_t*)p < s->decode_buffer + (framelen * s->channels); p++) - *samples++ = *p; + p = s->decode_buffer; + for (i = 0; i < framelen * s->channels; i++) + samples[i] = p[i]; break; } case 3: { // shift samples for 24-bit sample format int32_t *samples = (int32_t *)frame->data[0]; - int overflow = 0; - for (i = 0; i < framelen * s->channels; i++) { - int scaled = *samples * 256U; - overflow += (scaled >> 8 != *samples); - *samples++ = scaled; - } - if (overflow) - av_log(avctx, AV_LOG_WARNING, "%d overflows occurred on 24bit upscale\n", overflow); + for (i = 0; i < framelen * s->channels; i++) + samples[i] = samples[i] * 256U; // reset decode buffer s->decode_buffer = NULL; break; From 79dcee34dddf7c82d2e865f07b7b9887d3fb16a3 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 16 Sep 2022 12:05:44 +0200 Subject: [PATCH 320/590] avcodec: add XWD parser --- libavcodec/Makefile | 1 + libavcodec/parsers.c | 1 + libavcodec/xwd_parser.c | 103 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 libavcodec/xwd_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index e23b03e5dd..c836252664 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1170,6 +1170,7 @@ OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o OBJS-$(CONFIG_XBM_PARSER) += xbm_parser.o OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o +OBJS-$(CONFIG_XWD_PARSER) += xwd_parser.o # bitstream filters OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index 362f6f8bc6..bcba94ca69 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -76,6 +76,7 @@ extern const AVCodecParser ff_vp9_parser; extern const AVCodecParser ff_webp_parser; extern const AVCodecParser ff_xbm_parser; extern const AVCodecParser ff_xma_parser; +extern const AVCodecParser ff_xwd_parser; #include "libavcodec/parser_list.c" diff --git a/libavcodec/xwd_parser.c b/libavcodec/xwd_parser.c new file mode 100644 index 0000000000..ab5fe86070 --- /dev/null +++ b/libavcodec/xwd_parser.c @@ -0,0 +1,103 @@ +/* + * XWD parser + * Copyright (c) 2022 Paul B Mahol + * + * 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 + */ + +/** + * @file + * XWD parser + **/ + +#include "libavutil/intreadwrite.h" +#include "parser.h" +#include "xwd.h" + +typedef struct XWDParseContext { + ParseContext pc; + int left; + int idx; + uint8_t hdr[XWD_HEADER_SIZE]; +} XWDParseContext; + +static int xwd_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + XWDParseContext *t = s->priv_data; + ParseContext *pc = &t->pc; + int next = END_NOT_FOUND; + + s->pict_type = AV_PICTURE_TYPE_NONE; + + *poutbuf = NULL; + *poutbuf_size = 0; + + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { + for (int i = 0; i < buf_size; i++) { + if (t->left > 0) { + t->left--; + if (t->left == 0) { + next = i; + break; + } + continue; + } + + if (t->idx >= 100) { + t->idx = 99; + memmove(&t->hdr[0], &t->hdr[1], XWD_HEADER_SIZE-1); + } + + t->hdr[t->idx++] = buf[i]; + + if (t->idx >= 100 && AV_RB32(t->hdr + 4) == XWD_VERSION) { + uint32_t header_size = AV_RB32(t->hdr + 0); + uint32_t height = AV_RB32(t->hdr + 20); + uint32_t lsize = AV_RB32(t->hdr + 48); + uint32_t ncolors = AV_RB32(t->hdr + 76); + uint32_t size = header_size + ncolors * XWD_CMAP_SIZE + height * lsize; + pc->frame_start_found = 1; + t->left = size - XWD_HEADER_SIZE + 1; + t->idx = 0; + memset(t->hdr, 0, sizeof(t->hdr)); + } + } + + if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) + return buf_size; + } + + *poutbuf = buf; + *poutbuf_size = buf_size; + + s->pict_type = AV_PICTURE_TYPE_I; + s->key_frame = 1; + s->duration = 1; + + return next; +} + +const AVCodecParser ff_xwd_parser = { + .codec_ids = { AV_CODEC_ID_XWD }, + .priv_data_size = sizeof(XWDParseContext), + .parser_parse = xwd_parse, + .parser_close = ff_parse_close, +}; From e35af6bcef2cc3d370d257ba2466468d9ab3cdb3 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 15 Sep 2022 16:14:08 +0200 Subject: [PATCH 321/590] avcodec/mlpdec: fix decoding of overlapping channels in substreams Fixes #5039 --- libavcodec/mlpdec.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 0a97fae26c..bb72134b09 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -67,6 +67,8 @@ typedef struct SubStream { uint8_t min_channel; /// The index of the last channel coded in this substream. uint8_t max_channel; + /// The coded channels mask in this substream. + uint64_t coded_channels; /// The number of channels input into the rematrix stage. uint8_t max_matrix_channel; /// For each channel output by the matrix, the output channel to map it to @@ -563,6 +565,7 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, s->min_channel = min_channel; s->max_channel = max_channel; + s->coded_channels = ((1LL << (max_channel - min_channel + 1)) - 1) << min_channel; s->max_matrix_channel = max_matrix_channel; s->noise_type = noise_type; @@ -1272,11 +1275,6 @@ static int read_access_unit(AVCodecContext *avctx, AVFrame *frame, for (substr = 0; substr <= m->max_decoded_substream; substr++) { SubStream *s = &m->substream[substr]; - if (substr != m->max_decoded_substream && - m->substream[m->max_decoded_substream].min_channel == 0 && - m->substream[m->max_decoded_substream].max_channel == avctx->ch_layout.nb_channels - 1) - goto skip_substr; - init_get_bits(&gb, buf, substream_data_len[substr] * 8); m->matrix_changed = 0; @@ -1301,6 +1299,22 @@ static int read_access_unit(AVCodecContext *avctx, AVFrame *frame, if (!s->restart_seen) goto next_substr; + if (substr > 0 && substr < m->max_decoded_substream && + (s->min_channel <= m->substream[substr - 1].max_channel)) { + av_log(avctx, AV_LOG_DEBUG, + "Previous substream(%d) channels overlaps current substream(%d) channels, skipping.\n", + substr - 1, substr); + goto next_substr; + } + + if (substr != m->max_decoded_substream && + ((s->coded_channels & m->substream[m->max_decoded_substream].coded_channels) != 0)) { + av_log(avctx, AV_LOG_DEBUG, + "Current substream(%d) channels overlaps final substream(%d) channels, skipping.\n", + substr, m->max_decoded_substream); + goto next_substr; + } + if ((ret = read_block_data(m, &gb, substr)) < 0) return ret; @@ -1350,7 +1364,6 @@ static int read_access_unit(AVCodecContext *avctx, AVFrame *frame, av_log(m->avctx, AV_LOG_ERROR, "No restart header present in substream %d.\n", substr); -skip_substr: buf += substream_data_len[substr]; } From 05066cba1902456a8a269b13a3fbc7d06cc0afe0 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 17 Sep 2022 10:32:16 +0200 Subject: [PATCH 322/590] avcodec/8bps: fix style issue --- libavcodec/8bps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c index 6870e7a938..90d6c96fd1 100644 --- a/libavcodec/8bps.c +++ b/libavcodec/8bps.c @@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, unsigned char *planemap = c->planemap; int ret; - if (buf_size < planes * height *2) + if (buf_size < planes * height * 2) return AVERROR_INVALIDDATA; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) From f80e5815c0a07ac1c0cb74e0f34c3ca9ff083d5b Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 17 Sep 2022 11:01:31 +0200 Subject: [PATCH 323/590] avcodec/exr: remove less usefull log messages --- libavcodec/exr.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index c924406f13..d4182f3fca 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -830,20 +830,16 @@ static int b44_uncompress(const EXRContext *s, const uint8_t *src, int compresse if (s->channels[c].pixel_type == EXR_HALF) {/* B44 only compress half float data */ for (iY = 0; iY < nb_b44_block_h; iY++) { for (iX = 0; iX < nb_b44_block_w; iX++) {/* For each B44 block */ - if (stay_to_uncompress < 3) { - av_log(s->avctx, AV_LOG_ERROR, "Not enough data for B44A block: %d", stay_to_uncompress); + if (stay_to_uncompress < 3) return AVERROR_INVALIDDATA; - } if (src[compressed_size - stay_to_uncompress + 2] == 0xfc) { /* B44A block */ unpack_3(sr, tmp_buffer); sr += 3; stay_to_uncompress -= 3; } else {/* B44 Block */ - if (stay_to_uncompress < 14) { - av_log(s->avctx, AV_LOG_ERROR, "Not enough data for B44 block: %d", stay_to_uncompress); + if (stay_to_uncompress < 14) return AVERROR_INVALIDDATA; - } unpack_14(sr, tmp_buffer); sr += 14; stay_to_uncompress -= 14; @@ -865,10 +861,8 @@ static int b44_uncompress(const EXRContext *s, const uint8_t *src, int compresse } target_channel_offset += 2; } else {/* Float or UINT 32 channel */ - if (stay_to_uncompress < td->ysize * td->xsize * 4) { - av_log(s->avctx, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stay_to_uncompress); + if (stay_to_uncompress < td->ysize * td->xsize * 4) return AVERROR_INVALIDDATA; - } for (y = 0; y < td->ysize; y++) { index_out = target_channel_offset * td->xsize + y * td->channel_line_size; From 7c60badbedf26a6f3c96014697f96befcbbbace3 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 17 Sep 2022 11:21:27 +0200 Subject: [PATCH 324/590] avcodec/exr: recreate offset table outside of packet Packet might not be writable at this point. --- libavcodec/exr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index d4182f3fca..e381e77e3f 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -191,6 +191,8 @@ typedef struct EXRContext { float gamma; union av_intfloat32 gamma_table[65536]; + uint8_t *offset_table; + Half2FloatTables h2f_tables; } EXRContext; @@ -2026,7 +2028,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int nb_blocks; /* nb scanline or nb tile */ uint64_t start_offset_table; uint64_t start_next_scanline; - PutByteContext offset_table_writer; bytestream2_init(gb, avpkt->data, avpkt->size); @@ -2146,11 +2147,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, // check offset table and recreate it if need if (!s->is_tile && bytestream2_peek_le64(gb) == 0) { + PutByteContext offset_table_writer; + av_log(s->avctx, AV_LOG_DEBUG, "recreating invalid scanline offset table\n"); + s->offset_table = av_realloc_f(s->offset_table, nb_blocks, 8); + if (!s->offset_table) + return AVERROR(ENOMEM); + start_offset_table = bytestream2_tell(gb); start_next_scanline = start_offset_table + nb_blocks * 8; - bytestream2_init_writer(&offset_table_writer, &avpkt->data[start_offset_table], nb_blocks * 8); + bytestream2_init_writer(&offset_table_writer, s->offset_table, nb_blocks * 8); for (y = 0; y < nb_blocks; y++) { /* write offset of prev scanline in offset table */ @@ -2160,7 +2167,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, bytestream2_seek(gb, start_next_scanline + 4, SEEK_SET);/* skip line number */ start_next_scanline += (bytestream2_get_le32(gb) + 8); } - bytestream2_seek(gb, start_offset_table, SEEK_SET); + bytestream2_init(gb, s->offset_table, nb_blocks * 8); } // save pointer we are going to use in decode_block @@ -2270,6 +2277,7 @@ static av_cold int decode_end(AVCodecContext *avctx) av_freep(&s->thread_data); av_freep(&s->channels); + av_freep(&s->offset_table); return 0; } From ed83a3a5bddf4c209157dc9f041eda0721b4c3e0 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Wed, 7 Sep 2022 21:03:15 -0700 Subject: [PATCH 325/590] lavu/pixdesc: favour formats where depth and subsampling exactly match Since introducing the various packed formats used by VAAPI (and p012), we've noticed that there's actually a gap in how av_find_best_pix_fmt_of_2 works. It doesn't actually assign any value to having the same bit depth as the source format, when comparing against formats with a higher bit depth. This usually doesn't matter, because av_get_padded_bits_per_pixel() will account for it. However, as many of these formats use padding internally, we find that av_get_padded_bits_per_pixel() actually returns the same value for the 10 bit, 12 bit, 16 bit flavours, etc. In these tied situations, we end up just picking the first of the two provided formats, even if the second one should be preferred because it matches the actual bit depth. This bug already existed if you tried to compare yuv420p10 against p016 and p010, for example, but it simply hadn't come up before so we never noticed. But now, we actually got a situation in the VAAPI VP9 decoder where it offers both p010 and p012 because Profile 3 could be either depth and ends up picking p012 for 10 bit content due to the ordering of the testing. In addition, in the process of testing the fix, I realised we have the same gap when it comes to chroma subsampling - we do not favour a format that has exactly the same subsampling vs one with less subsampling when all else is equal. To fix this, I'm introducing a small score penalty if the bit depth or subsampling doesn't exactly match the source format. This will break the tie in favour of the format with the exact match, but not offset any of the other scoring penalties we already have. I have added a set of tests around these formats which will fail without this fix. --- libavutil/pixdesc.c | 31 +++++++- libavutil/pixdesc.h | 15 ++-- libavutil/tests/pixfmt_best.c | 129 +++++++++++++++++++++++++++++----- libavutil/version.h | 2 +- tests/ref/fate/pixfmt_best | 2 +- 5 files changed, 151 insertions(+), 28 deletions(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index d7c6ebfdc4..b472a94f60 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -3013,9 +3013,16 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, for (i = 0; i < nb_components; i++) { int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : (dst_desc->comp[i].depth - 1); - if (src_desc->comp[i].depth - 1 > depth_minus1 && (consider & FF_LOSS_DEPTH)) { + int depth_delta = src_desc->comp[i].depth - 1 - depth_minus1; + if (depth_delta > 0 && (consider & FF_LOSS_DEPTH)) { loss |= FF_LOSS_DEPTH; score -= 65536 >> depth_minus1; + } else if (depth_delta < 0 && (consider & FF_LOSS_EXCESS_DEPTH)) { + // Favour formats where bit depth exactly matches. If all other + // scoring is equal, we'd rather use the bit depth that most closely + // matches the source. + loss |= FF_LOSS_EXCESS_DEPTH; + score += depth_delta; } } @@ -3035,6 +3042,28 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, } } + if (consider & FF_LOSS_EXCESS_RESOLUTION) { + // Favour formats where chroma subsampling exactly matches. If all other + // scoring is equal, we'd rather use the subsampling that most closely + // matches the source. + if (dst_desc->log2_chroma_w < src_desc->log2_chroma_w) { + loss |= FF_LOSS_EXCESS_RESOLUTION; + score -= 1 << (src_desc->log2_chroma_w - dst_desc->log2_chroma_w); + } + + if (dst_desc->log2_chroma_h < src_desc->log2_chroma_h) { + loss |= FF_LOSS_EXCESS_RESOLUTION; + score -= 1 << (src_desc->log2_chroma_h - dst_desc->log2_chroma_h); + } + + // don't favour 411 over 420, because 420 has much better support on the + // decoder side. + if (dst_desc->log2_chroma_w == 1 && src_desc->log2_chroma_w == 2 && + dst_desc->log2_chroma_h == 1 && src_desc->log2_chroma_h == 2) { + score += 4; + } + } + if(consider & FF_LOSS_COLORSPACE) switch(dst_color) { case FF_COLOR_RGB: diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h index f8a195ffcd..48d9300bfe 100644 --- a/libavutil/pixdesc.h +++ b/libavutil/pixdesc.h @@ -357,12 +357,15 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], */ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt); -#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ -#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ -#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ -#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ -#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ -#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ +#define FF_LOSS_EXCESS_RESOLUTION 0x0040 /**< loss due to unneeded extra resolution */ +#define FF_LOSS_EXCESS_DEPTH 0x0080 /**< loss due to unneeded extra color depth */ + /** * Compute what kind of losses will occur when converting from one specific diff --git a/libavutil/tests/pixfmt_best.c b/libavutil/tests/pixfmt_best.c index 0542af494f..d71b3cc2e8 100644 --- a/libavutil/tests/pixfmt_best.c +++ b/libavutil/tests/pixfmt_best.c @@ -39,32 +39,74 @@ static const enum AVPixelFormat pixfmt_list[] = { AV_PIX_FMT_VAAPI, }; -static enum AVPixelFormat find_best(enum AVPixelFormat pixfmt) +static const enum AVPixelFormat semiplanar_list[] = { + AV_PIX_FMT_P016, + AV_PIX_FMT_P012, + AV_PIX_FMT_P010, + AV_PIX_FMT_NV12, +}; + +static const enum AVPixelFormat packed_list[] = { + AV_PIX_FMT_XV36, + AV_PIX_FMT_XV30, + AV_PIX_FMT_VUYX, + AV_PIX_FMT_Y212, + AV_PIX_FMT_Y210, + AV_PIX_FMT_YUYV422, +}; + +static const enum AVPixelFormat subsampled_list[] = { + AV_PIX_FMT_YUV411P, + AV_PIX_FMT_YUV420P, + AV_PIX_FMT_YUV422P, + AV_PIX_FMT_YUV444P, +}; + +static const enum AVPixelFormat depthchroma_list[] = { + AV_PIX_FMT_YUV420P14, + AV_PIX_FMT_YUV422P14, + AV_PIX_FMT_YUV444P16, +}; + +typedef enum AVPixelFormat (*find_best_t)(enum AVPixelFormat pixfmt); + +#define find_best_wrapper(name, list) \ +static enum AVPixelFormat find_best_ ## name (enum AVPixelFormat pixfmt) \ +{ \ + enum AVPixelFormat best = AV_PIX_FMT_NONE; \ + int i; \ + for (i = 0; i < FF_ARRAY_ELEMS(list); i++) \ + best = av_find_best_pix_fmt_of_2(best, list[i], \ + pixfmt, 0, NULL); \ + return best; \ +} + +find_best_wrapper(base, pixfmt_list) +find_best_wrapper(seminplanar, semiplanar_list) +find_best_wrapper(packed, packed_list) +find_best_wrapper(subsampled, subsampled_list) +find_best_wrapper(depthchroma, depthchroma_list) + +static void test(enum AVPixelFormat input, enum AVPixelFormat expected, + int *pass, int *fail, find_best_t find_best_fn) { - enum AVPixelFormat best = AV_PIX_FMT_NONE; - int i; - for (i = 0; i < FF_ARRAY_ELEMS(pixfmt_list); i++) - best = av_find_best_pix_fmt_of_2(best, pixfmt_list[i], - pixfmt, 0, NULL); - return best; + enum AVPixelFormat output = find_best_fn(input); + if (output != expected) { + printf("Matching %s: got %s, expected %s\n", + av_get_pix_fmt_name(input), + av_get_pix_fmt_name(output), + av_get_pix_fmt_name(expected)); + ++(*fail); + } else + ++(*pass); } int main(void) { - enum AVPixelFormat output; int i, pass = 0, fail = 0; -#define TEST(input, expected) do { \ - output = find_best(input); \ - if (output != expected) { \ - printf("Matching %s: got %s, expected %s\n", \ - av_get_pix_fmt_name(input), \ - av_get_pix_fmt_name(output), \ - av_get_pix_fmt_name(expected)); \ - ++fail; \ - } else \ - ++pass; \ - } while (0) +#define TEST(input, expected) \ + test(input, expected, &pass, &fail, find_best_base) // Same formats. for (i = 0; i < FF_ARRAY_ELEMS(pixfmt_list); i++) @@ -137,6 +179,55 @@ int main(void) // Opaque formats are least unlike each other. TEST(AV_PIX_FMT_DXVA2_VLD, AV_PIX_FMT_VDPAU); +#define TEST_SEMIPLANAR(input, expected) \ + test(input, expected, &pass, &fail, find_best_seminplanar) + + // Same formats. + for (i = 0; i < FF_ARRAY_ELEMS(semiplanar_list); i++) + TEST_SEMIPLANAR(semiplanar_list[i], semiplanar_list[i]); + + // Formats containing the same data in different layouts. + TEST_SEMIPLANAR(AV_PIX_FMT_YUV420P, AV_PIX_FMT_NV12); + TEST_SEMIPLANAR(AV_PIX_FMT_YUV420P10, AV_PIX_FMT_P010); + TEST_SEMIPLANAR(AV_PIX_FMT_YUV420P12, AV_PIX_FMT_P012); + TEST_SEMIPLANAR(AV_PIX_FMT_YUV420P16, AV_PIX_FMT_P016); + TEST_SEMIPLANAR(AV_PIX_FMT_YUV420P9, AV_PIX_FMT_P010); + +#define TEST_PACKED(input, expected) \ + test(input, expected, &pass, &fail, find_best_packed) + + // Same formats. + for (i = 0; i < FF_ARRAY_ELEMS(packed_list); i++) + TEST_PACKED(packed_list[i], packed_list[i]); + + // Formats containing the same data in different layouts. + TEST_PACKED(AV_PIX_FMT_YUV444P, AV_PIX_FMT_VUYX); + TEST_PACKED(AV_PIX_FMT_YUV444P10, AV_PIX_FMT_XV30); + TEST_PACKED(AV_PIX_FMT_YUV444P12, AV_PIX_FMT_XV36); + TEST_PACKED(AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUYV422); + TEST_PACKED(AV_PIX_FMT_YUV422P10, AV_PIX_FMT_Y210); + TEST_PACKED(AV_PIX_FMT_YUV422P12, AV_PIX_FMT_Y212); + +#define TEST_SUBSAMPLED(input, expected) \ + test(input, expected, &pass, &fail, find_best_subsampled) + + // Same formats. + for (i = 0; i < FF_ARRAY_ELEMS(subsampled_list); i++) + TEST_SUBSAMPLED(subsampled_list[i], subsampled_list[i]); + + TEST_SUBSAMPLED(AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV420P); + +#define TEST_DEPTH_CHROMA(input, expected) \ + test(input, expected, &pass, &fail, find_best_depthchroma) + + // Same formats. + for (i = 0; i < FF_ARRAY_ELEMS(depthchroma_list); i++) + TEST_DEPTH_CHROMA(depthchroma_list[i], depthchroma_list[i]); + + TEST_DEPTH_CHROMA(AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV444P16); + TEST_DEPTH_CHROMA(AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16); + + printf("%d tests passed, %d tests failed.\n", pass, fail); return !!fail; } diff --git a/libavutil/version.h b/libavutil/version.h index 9b8462c705..0585fa7b80 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 57 #define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MICRO 102 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ diff --git a/tests/ref/fate/pixfmt_best b/tests/ref/fate/pixfmt_best index 783c5fe640..1bdc0e83f0 100644 --- a/tests/ref/fate/pixfmt_best +++ b/tests/ref/fate/pixfmt_best @@ -1 +1 @@ -75 tests passed, 0 tests failed. +106 tests passed, 0 tests failed. From adaa06581c5444c94eef72d61b8166f096e2687a Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 17 Sep 2022 14:08:58 +0200 Subject: [PATCH 326/590] avcodec/mlpdec: relax channels checking Internal TrueHD decoder channel rematrix can mix 2 stereo substreams into single mono stream. Fixes #1726 --- libavcodec/mlpdec.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index bb72134b09..092344b69a 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -425,6 +425,7 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) mh.stream_type); return AVERROR_PATCHWELCOME; } + m->substream[1].mask = mh.channel_layout_thd_stream1; if (mh.channels_thd_stream1 == 2 && mh.channels_thd_stream2 == 2 && m->avctx->ch_layout.nb_channels == 2) @@ -438,16 +439,6 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) m->substream[2].mask = mh.channel_layout_thd_stream1; if (m->avctx->ch_layout.nb_channels > 2) m->substream[mh.num_substreams > 1].mask = mh.channel_layout_thd_stream1; - - if (m->avctx->ch_layout.nb_channels <= 2 && - m->substream[substr].mask == AV_CH_LAYOUT_MONO && m->max_decoded_substream == 1) { - av_log(m->avctx, AV_LOG_DEBUG, "Mono stream with 2 substreams, ignoring 2nd\n"); - m->max_decoded_substream = 0; - if (m->avctx->ch_layout.nb_channels == 2) { - av_channel_layout_uninit(&m->avctx->ch_layout); - m->avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; - } - } } m->needs_reordering = mh.channel_arrangement >= 18 && mh.channel_arrangement <= 20; @@ -541,12 +532,6 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, return AVERROR_INVALIDDATA; } - if (max_channel != max_matrix_channel) { - av_log(m->avctx, AV_LOG_ERROR, - "Max channel must be equal max matrix channel.\n"); - return AVERROR_INVALIDDATA; - } - /* This should happen for TrueHD streams with >6 channels and MLP's noise * type. It is not yet known if this is allowed. */ if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) { @@ -557,12 +542,6 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp, return AVERROR_PATCHWELCOME; } - if (min_channel > max_channel) { - av_log(m->avctx, AV_LOG_ERROR, - "Substream min channel cannot be greater than max channel.\n"); - return AVERROR_INVALIDDATA; - } - s->min_channel = min_channel; s->max_channel = max_channel; s->coded_channels = ((1LL << (max_channel - min_channel + 1)) - 1) << min_channel; From c12a6fd227735e9d56c653dfa12bfd9f73ef222a Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 17 Sep 2022 16:28:05 +0200 Subject: [PATCH 327/590] avcodec/mlpenc: rename some variables to better alternatives --- libavcodec/mlpenc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 80dc03a0ca..99b05476ad 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -153,8 +153,8 @@ typedef struct MLPEncodeContext { unsigned int min_restart_interval; ///< Min interval of access units in between two major frames. unsigned int restart_intervals; ///< Number of possible major frame sizes. - uint16_t timestamp; ///< Timestamp of current access unit. - uint16_t dts; ///< Decoding timestamp of current access unit. + uint16_t output_timing; ///< Timestamp of current access unit. + uint16_t input_timing; ///< Decoding timestamp of current access unit. uint8_t channel_arrangement; ///< channel arrangement for MLP streams @@ -559,7 +559,7 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) } ctx->coded_sample_fmt[1] = -1 & 0xf; - ctx->dts = -avctx->frame_size; + ctx->input_timing = -avctx->frame_size; ctx->num_channels = avctx->ch_layout.nb_channels + 2; /* +2 noise channels */ ctx->one_sample_buffer_size = avctx->frame_size @@ -765,7 +765,7 @@ static void write_restart_header(MLPEncodeContext *ctx, PutBitContext *pb) uint8_t checksum; put_bits(pb, 14, 0x31ea ); /* TODO 0x31eb */ - put_bits(pb, 16, ctx->timestamp ); + put_bits(pb, 16, ctx->output_timing ); put_bits(pb, 4, rh->min_channel ); put_bits(pb, 4, rh->max_channel ); put_bits(pb, 4, rh->max_matrix_channel); @@ -1092,7 +1092,7 @@ static void write_frame_headers(MLPEncodeContext *ctx, uint8_t *frame_header, uint16_t access_unit_header = 0; uint16_t parity_nibble = 0; - parity_nibble = ctx->dts; + parity_nibble = ctx->input_timing; parity_nibble ^= length; for (unsigned int substr = 0; substr < ctx->num_substreams; substr++) { @@ -1118,7 +1118,7 @@ static void write_frame_headers(MLPEncodeContext *ctx, uint8_t *frame_header, access_unit_header |= length & 0xFFF; AV_WB16(frame_header , access_unit_header); - AV_WB16(frame_header+2, ctx->dts ); + AV_WB16(frame_header+2, ctx->input_timing ); } /** Writes an entire access unit to the bitstream. */ @@ -2117,8 +2117,8 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, bytes_written = write_access_unit(ctx, avpkt->data, avpkt->size, restart_frame); - ctx->timestamp += avctx->frame_size; - ctx->dts += avctx->frame_size; + ctx->output_timing += avctx->frame_size; + ctx->input_timing += avctx->frame_size; input_and_return: From b0579cc298519653406be5ae3d4d9358c0cb46fb Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 18 Sep 2022 14:44:27 +0200 Subject: [PATCH 328/590] avcodec/mlpenc: improve encoding of stereo TrueHD and add mono support --- libavcodec/mlpenc.c | 72 +++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 99b05476ad..b66f3a3067 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -122,6 +122,7 @@ typedef struct MLPEncodeContext { /* channel_meaning */ int substream_info; + int thd_substream_info; int fs; int wordlength; int channel_occupancy; @@ -536,9 +537,8 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) } ctx->substream_info |= SUBSTREAM_INFO_ALWAYS_SET; - if (avctx->ch_layout.nb_channels <= 2) { + if (avctx->ch_layout.nb_channels <= 2) ctx->substream_info |= SUBSTREAM_INFO_MAX_2_CHAN; - } switch (avctx->sample_fmt) { case AV_SAMPLE_FMT_S16: @@ -614,23 +614,33 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) } else { /* TrueHD */ if (!av_channel_layout_compare(&avctx->ch_layout, + &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) { + ctx->ch_modifier_thd0 = 3; + ctx->ch_modifier_thd1 = 3; + ctx->ch_modifier_thd2 = 3; + ctx->channel_arrangement = 2; + ctx->thd_substream_info = 0x14; + } else if (!av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) { - ctx->ch_modifier_thd0 = 0; - ctx->ch_modifier_thd1 = 0; - ctx->ch_modifier_thd2 = 0; + ctx->ch_modifier_thd0 = 1; + ctx->ch_modifier_thd1 = 1; + ctx->ch_modifier_thd2 = 1; ctx->channel_arrangement = 1; + ctx->thd_substream_info = 0x14; } else if (!av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK)) { ctx->ch_modifier_thd0 = 1; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 1; ctx->channel_arrangement = 11; + ctx->thd_substream_info = 0x104; } else if (!av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK)) { ctx->ch_modifier_thd0 = 2; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 2; ctx->channel_arrangement = 15; + ctx->thd_substream_info = 0x104; } else { av_log(avctx, AV_LOG_ERROR, "Unsupported channel arrangement\n"); return AVERROR(EINVAL); @@ -718,7 +728,9 @@ static void write_major_sync(MLPEncodeContext *ctx, uint8_t *buf, int buf_size) } else if (ctx->avctx->codec_id == AV_CODEC_ID_TRUEHD) { put_bits(&pb, 8, SYNC_TRUEHD ); put_bits(&pb, 4, ctx->coded_sample_rate[0]); - put_bits(&pb, 4, 0 ); /* ignored */ + put_bits(&pb, 1, 0 ); /* 6ch multichannel type */ + put_bits(&pb, 1, 0 ); /* 8ch multichannel type */ + put_bits(&pb, 2, 0 ); /* ignored */ put_bits(&pb, 2, ctx->ch_modifier_thd0 ); put_bits(&pb, 2, ctx->ch_modifier_thd1 ); put_bits(&pb, 5, ctx->channel_arrangement ); @@ -732,20 +744,41 @@ static void write_major_sync(MLPEncodeContext *ctx, uint8_t *buf, int buf_size) put_bits(&pb, 1, 1 ); /* is_vbr */ put_bits(&pb, 15, ctx->coded_peak_bitrate ); put_bits(&pb, 4, 1 ); /* num_substreams */ - put_bits(&pb, 4, 0x1 ); /* ignored */ + put_bits(&pb, 2, 0 ); /* ignored */ + put_bits(&pb, 2, 0 ); /* extended substream info */ /* channel_meaning */ - put_bits(&pb, 8, ctx->substream_info ); - put_bits(&pb, 5, ctx->fs ); - put_bits(&pb, 5, ctx->wordlength ); - put_bits(&pb, 6, ctx->channel_occupancy ); - put_bits(&pb, 3, 0 ); /* ignored */ - put_bits(&pb, 10, 0 ); /* speaker_layout */ - put_bits(&pb, 3, 0 ); /* copy_protection */ - put_bits(&pb, 16, 0x8080 ); /* ignored */ - put_bits(&pb, 7, 0 ); /* ignored */ - put_bits(&pb, 4, 0 ); /* source_format */ - put_bits(&pb, 5, ctx->summary_info ); + if (ctx->avctx->codec_id == AV_CODEC_ID_MLP) { + put_bits(&pb, 8, ctx->substream_info ); + put_bits(&pb, 5, ctx->fs ); + put_bits(&pb, 5, ctx->wordlength ); + put_bits(&pb, 6, ctx->channel_occupancy ); + put_bits(&pb, 3, 0 ); /* ignored */ + put_bits(&pb, 10, 0 ); /* speaker_layout */ + put_bits(&pb, 3, 0 ); /* copy_protection */ + put_bits(&pb, 16, 0x8080 ); /* ignored */ + put_bits(&pb, 7, 0 ); /* ignored */ + put_bits(&pb, 4, 0 ); /* source_format */ + put_bits(&pb, 5, ctx->summary_info ); + } else if (ctx->avctx->codec_id == AV_CODEC_ID_TRUEHD) { + put_bits(&pb, 8, ctx->thd_substream_info ); + put_bits(&pb, 6, 0 ); /* reserved */ + put_bits(&pb, 1, 0 ); /* 2ch control enabled */ + put_bits(&pb, 1, 0 ); /* 6ch control enabled */ + put_bits(&pb, 1, 0 ); /* 8ch control enabled */ + put_bits(&pb, 1, 0 ); /* reserved */ + put_bits(&pb, 7, 0 ); /* drc start up gain */ + put_bits(&pb, 6, 0 ); /* 2ch dialogue norm */ + put_bits(&pb, 6, 0 ); /* 2ch mix level */ + put_bits(&pb, 5, 0 ); /* 6ch dialogue norm */ + put_bits(&pb, 6, 0 ); /* 6ch mix level */ + put_bits(&pb, 5, 0 ); /* 6ch source format */ + put_bits(&pb, 5, 0 ); /* 8ch dialogue norm */ + put_bits(&pb, 6, 0 ); /* 8ch mix level */ + put_bits(&pb, 6, 0 ); /* 8ch source format */ + put_bits(&pb, 1, 0 ); /* reserved */ + put_bits(&pb, 1, 0 ); /* extra channel meaning present */ + } flush_put_bits(&pb); @@ -2244,9 +2277,10 @@ const FFCodec ff_truehd_encoder = { .p.sample_fmts = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .p.supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, #if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) {AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0}, + .p.channel_layouts = (const uint64_t[]) {AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0}, #endif .p.ch_layouts = (const AVChannelLayout[]) { + AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, AV_CHANNEL_LAYOUT_5POINT0_BACK, AV_CHANNEL_LAYOUT_5POINT1_BACK, From 2069894bc15931795aa02ed40aea4159b5daf55c Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 18 Sep 2022 14:58:58 +0200 Subject: [PATCH 329/590] avcodec/mlpdec: unbreak TrueHD single substream mono decoding --- libavcodec/mlpdec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 092344b69a..635f92895c 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -432,6 +432,11 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) m->substream[0].mask = AV_CH_LAYOUT_STEREO; if ((substr = (mh.num_substreams > 1))) m->substream[0].mask = AV_CH_LAYOUT_STEREO; + if (mh.num_substreams == 1 && + mh.channels_thd_stream1 == 1 && + mh.channels_thd_stream2 == 1 && + m->avctx->ch_layout.nb_channels == 1) + m->substream[0].mask = AV_CH_LAYOUT_MONO; if (mh.num_substreams > 2) if (mh.channel_layout_thd_stream2) m->substream[2].mask = mh.channel_layout_thd_stream2; From fc5aef59bfbc5e90f0397acf441633238af4e4e9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 16 Sep 2022 02:58:26 +0200 Subject: [PATCH 330/590] fate/lavf-audio: Add dfpwm test Signed-off-by: Andreas Rheinhardt --- tests/fate/lavf-audio.mak | 2 ++ tests/ref/lavf/dfpwm | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 tests/ref/lavf/dfpwm diff --git a/tests/fate/lavf-audio.mak b/tests/fate/lavf-audio.mak index 68fca35298..edbd872b11 100644 --- a/tests/fate/lavf-audio.mak +++ b/tests/fate/lavf-audio.mak @@ -14,6 +14,7 @@ FATE_LAVF_AUDIO-$(call ENCDEC, PCM_S16LE, W64) += w64 FATE_LAVF_AUDIO-$(call ENCDEC, TTA, TTA) += tta FATE_LAVF_AUDIO-$(call ENCMUX, TTA, MATROSKA_AUDIO) += mka FATE_LAVF_AUDIO_RESAMPLE-$(call ENCDEC, PCM_S16BE_PLANAR, AST) += ast +FATE_LAVF_AUDIO_RESAMPLE-$(call ENCDEC, DFPWM, DFPWM) += dfpwm FATE_LAVF_AUDIO_RESAMPLE-$(call ENCDEC, PCM_U8, RSO) += rso FATE_LAVF_AUDIO_RESAMPLE-$(call ENCDEC, PCM_S16LE, SOX) += sox FATE_LAVF_AUDIO_RESAMPLE-$(call ENCDEC, PCM_U8, VOC) += voc @@ -28,6 +29,7 @@ $(FATE_LAVF_AUDIO): REF = $(SRC_PATH)/tests/ref/lavf/$(@:fate-lavf-%=%) $(FATE_LAVF_AUDIO): $(AREF) fate-lavf-al fate-lavf-ul: CMD = lavf_audio "" "" "-ar 44100" +fate-lavf-dfpwm: CMD = lavf_audio "" "" "-sample_rate 44100" fate-lavf-ogg: CMD = lavf_audio "" "-c:a flac" fate-lavf-s16.voc: CMD = lavf_audio "-ac 2" "-c:a pcm_s16le" fate-lavf-ast: CMD = lavf_audio "-ac 2" "-loopstart 1 -loopend 10" diff --git a/tests/ref/lavf/dfpwm b/tests/ref/lavf/dfpwm new file mode 100644 index 0000000000..b9423bc1c1 --- /dev/null +++ b/tests/ref/lavf/dfpwm @@ -0,0 +1,3 @@ +c216a2b5576f3e7f31516854bbb41eb8 *tests/data/lavf/lavf.dfpwm +5513 tests/data/lavf/lavf.dfpwm +tests/data/lavf/lavf.dfpwm CRC=0x226be6b3 From 7f27ce68822a4ef3bdcc42df8ee07c0fe0a08f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Fri, 16 Sep 2022 23:59:02 +0300 Subject: [PATCH 331/590] lavc/fmtconvert: remove dead int32_to_float This is no longer used since 46089967722f74e794865a044f5f682f26628802. It also has no implementations other than the plain C one. Signed-off-by: Andreas Rheinhardt --- libavcodec/fmtconvert.c | 9 --------- libavcodec/fmtconvert.h | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c index fd56a63c77..00f55f8f1e 100644 --- a/libavcodec/fmtconvert.c +++ b/libavcodec/fmtconvert.c @@ -33,14 +33,6 @@ static void int32_to_float_fmul_scalar_c(float *dst, const int32_t *src, dst[i] = src[i] * mul; } -static void int32_to_float_c(float *dst, const int32_t *src, intptr_t len) -{ - int i; - - for (i = 0; i < len; i++) - dst[i] = (float)src[i]; -} - static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst, const int32_t *src, const float *mul, int len) @@ -52,7 +44,6 @@ static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst, av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) { - c->int32_to_float = int32_to_float_c; c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; c->int32_to_float_fmul_array8 = int32_to_float_fmul_array8_c; diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h index a1b17e4f04..b2df7a9629 100644 --- a/libavcodec/fmtconvert.h +++ b/libavcodec/fmtconvert.h @@ -37,16 +37,6 @@ typedef struct FmtConvertContext { */ void (*int32_to_float_fmul_scalar)(float *dst, const int32_t *src, float mul, int len); - /** - * Convert an array of int32_t to float. - * @param dst destination array of float. - * constraints: 32-byte aligned - * @param src source array of int32_t. - * constraints: 32-byte aligned - * @param len number of elements to convert. - * constraints: multiple of 8 - */ - void (*int32_to_float)(float *dst, const int32_t *src, intptr_t len); /** * Convert an array of int32_t to float and multiply by a float value from another array, From 9ac777234eb474cf6960d62eaabb7ecac4e057d5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 18 Sep 2022 19:30:27 +0200 Subject: [PATCH 332/590] avfilter/af_dynaudnorm: fix parameter for copy samples function --- libavfilter/af_dynaudnorm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c index 4fe1a9ce1b..9505c33b49 100644 --- a/libavfilter/af_dynaudnorm.c +++ b/libavfilter/af_dynaudnorm.c @@ -707,7 +707,7 @@ static int analyze_frame(DynamicAudioNormalizerContext *s, AVFilterLink *outlink analyze_frame = s->window; } else { av_samples_copy(s->window->extended_data, (*frame)->extended_data, 0, 0, - s->frame_len, (*frame)->ch_layout.nb_channels, (*frame)->format); + FFMIN(s->frame_len, (*frame)->nb_samples), (*frame)->ch_layout.nb_channels, (*frame)->format); analyze_frame = *frame; } From 1af005197715630daafb2890f780d580cb1d10ec Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 18 Sep 2022 19:40:25 +0200 Subject: [PATCH 333/590] doc/filters: add speechnorm examples --- doc/filters.texi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 6aa350a63c..d0f718678c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6330,6 +6330,40 @@ is enabled the minimum of all possible gains for each filtered channel is used. This filter supports the all above options as @ref{commands}. +@subsection Examples + +@itemize +@item +Weak and slow amplification: +@example +speechnorm=e=3:r=0.00001:l=1 +@end example + +@item +Moderate and slow amplification: +@example +speechnorm=e=6.25:r=0.00001:l=1 +@end example + +@item +Strong and fast amplification: +@example +speechnorm=e=12.5:r=0.0001:l=1 +@end example + +@item +Very strong and fast amplification: +@example +speechnorm=e=25:r=0.0001:l=1 +@end example + +@item +Extreme and fast amplification: +@example +speechnorm=e=50:r=0.0001:l=1 +@end example +@end itemize + @section stereotools This filter has some handy utilities to manage stereo signals, for converting From 1f9f0dc6ee19f4861d91f4a1a853bd8439e98dce Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 18 Sep 2022 22:30:48 +0200 Subject: [PATCH 334/590] avfilter/af_afftdn: add double sample format support --- libavfilter/af_afftdn.c | 222 +++++++++++++++++++++++++++++++--------- 1 file changed, 172 insertions(+), 50 deletions(-) diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c index cdb256fa10..2b465afcef 100644 --- a/libavfilter/af_afftdn.c +++ b/libavfilter/af_afftdn.c @@ -81,8 +81,8 @@ typedef struct DeNoiseChannel { double *abs_var; double *rel_var; double *min_abs_var; - float *fft_in; - AVComplexFloat *fft_out; + void *fft_in; + void *fft_out; AVTXContext *fft, *ifft; av_tx_fn tx_fn, itx_fn; @@ -105,6 +105,9 @@ typedef struct DeNoiseChannel { typedef struct AudioFFTDeNoiseContext { const AVClass *class; + int format; + size_t sample_size; + float noise_reduction; float noise_floor; int noise_type; @@ -347,7 +350,6 @@ static double floor_offset(const double *S, int size, double mean) static void process_frame(AVFilterContext *ctx, AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, - AVComplexFloat *fft_data, double *prior, double *prior_band_excit, int track_noise) { AVFilterLink *outlink = ctx->outputs[0]; @@ -359,12 +361,22 @@ static void process_frame(AVFilterContext *ctx, double *band_excit = dnch->band_excit; double *band_amt = dnch->band_amt; double *smoothed_gain = dnch->smoothed_gain; + AVComplexDouble *fft_data_dbl = dnch->fft_out; + AVComplexFloat *fft_data_flt = dnch->fft_out; double *gain = dnch->gain; for (int i = 0; i < s->bin_count; i++) { double sqr_new_gain, new_gain, power, mag, mag_abs_var, new_mag_abs_var; - noisy_data[i] = mag = hypot(fft_data[i].re, fft_data[i].im); + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + noisy_data[i] = mag = hypot(fft_data_flt[i].re, fft_data_flt[i].im); + break; + case AV_SAMPLE_FMT_DBLP: + noisy_data[i] = mag = hypot(fft_data_dbl[i].re, fft_data_dbl[i].im); + break; + } + power = mag * mag; mag_abs_var = power / abs_var[i]; new_mag_abs_var = ratio * prior[i] + rratio * fmax(mag_abs_var - 1.0, 0.0); @@ -446,11 +458,23 @@ static void process_frame(AVFilterContext *ctx, } } - for (int i = 0; i < s->bin_count; i++) { - const double new_gain = smoothed_gain[i]; + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int i = 0; i < s->bin_count; i++) { + const float new_gain = smoothed_gain[i]; + + fft_data_flt[i].re *= new_gain; + fft_data_flt[i].im *= new_gain; + } + break; + case AV_SAMPLE_FMT_DBLP: + for (int i = 0; i < s->bin_count; i++) { + const double new_gain = smoothed_gain[i]; - fft_data[i].re *= new_gain; - fft_data[i].im *= new_gain; + fft_data_dbl[i].re *= new_gain; + fft_data_dbl[i].im *= new_gain; + } + break; } } @@ -603,8 +627,29 @@ static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; AudioFFTDeNoiseContext *s = ctx->priv; + size_t complex_sample_size; double wscale, sar, sum, sdiv; - int i, j, k, m, n, ret; + int i, j, k, m, n, ret, tx_type; + double dscale = 1.; + float fscale = 1.f; + void *scale; + + s->format = inlink->format; + + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + s->sample_size = sizeof(float); + complex_sample_size = sizeof(AVComplexFloat); + tx_type = AV_TX_FLOAT_RDFT; + scale = &fscale; + break; + case AV_SAMPLE_FMT_DBLP: + s->sample_size = sizeof(double); + complex_sample_size = sizeof(AVComplexDouble); + tx_type = AV_TX_DOUBLE_RDFT; + scale = &dscale; + break; + } s->dnch = av_calloc(inlink->ch_layout.nb_channels, sizeof(*s->dnch)); if (!s->dnch) @@ -671,7 +716,6 @@ static int config_input(AVFilterLink *inlink) for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { DeNoiseChannel *dnch = &s->dnch[ch]; - float scale = 1.f; switch (s->noise_type) { case WHITE_NOISE: @@ -708,12 +752,12 @@ static int config_input(AVFilterLink *inlink) dnch->abs_var = av_calloc(s->bin_count, sizeof(*dnch->abs_var)); dnch->rel_var = av_calloc(s->bin_count, sizeof(*dnch->rel_var)); dnch->min_abs_var = av_calloc(s->bin_count, sizeof(*dnch->min_abs_var)); - dnch->fft_in = av_calloc(s->fft_length2, sizeof(*dnch->fft_in)); - dnch->fft_out = av_calloc(s->fft_length2 + 1, sizeof(*dnch->fft_out)); - ret = av_tx_init(&dnch->fft, &dnch->tx_fn, AV_TX_FLOAT_RDFT, 0, s->fft_length2, &scale, 0); + dnch->fft_in = av_calloc(s->fft_length2, s->sample_size); + dnch->fft_out = av_calloc(s->fft_length2 + 1, complex_sample_size); + ret = av_tx_init(&dnch->fft, &dnch->tx_fn, tx_type, 0, s->fft_length2, scale, 0); if (ret < 0) return ret; - ret = av_tx_init(&dnch->ifft, &dnch->itx_fn, AV_TX_FLOAT_RDFT, 1, s->fft_length2, &scale, 0); + ret = av_tx_init(&dnch->ifft, &dnch->itx_fn, tx_type, 1, s->fft_length2, scale, 0); if (ret < 0) return ret; dnch->spread_function = av_calloc(s->number_of_bands * s->number_of_bands, @@ -861,17 +905,33 @@ static void sample_noise_block(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVFrame *in, int ch) { - float *src = (float *)in->extended_data[ch]; + double *src_dbl = (double *)in->extended_data[ch]; + float *src_flt = (float *)in->extended_data[ch]; double mag2, var = 0.0, avr = 0.0, avi = 0.0; + AVComplexDouble *fft_out_dbl = dnch->fft_out; + AVComplexFloat *fft_out_flt = dnch->fft_out; + double *fft_in_dbl = dnch->fft_in; + float *fft_in_flt = dnch->fft_in; int edge, j, k, n, edgemax; - for (int i = 0; i < s->window_length; i++) - dnch->fft_in[i] = s->window[i] * src[i] * (1LL << 23); - - for (int i = s->window_length; i < s->fft_length2; i++) - dnch->fft_in[i] = 0.0; + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int i = 0; i < s->window_length; i++) + fft_in_flt[i] = s->window[i] * src_flt[i] * (1LL << 23); + + for (int i = s->window_length; i < s->fft_length2; i++) + fft_in_flt[i] = 0.f; + break; + case AV_SAMPLE_FMT_DBLP: + for (int i = 0; i < s->window_length; i++) + fft_in_dbl[i] = s->window[i] * src_dbl[i] * (1LL << 23); + + for (int i = s->window_length; i < s->fft_length2; i++) + fft_in_dbl[i] = 0.; + break; + } - dnch->tx_fn(dnch->fft, dnch->fft_out, dnch->fft_in, sizeof(float)); + dnch->tx_fn(dnch->fft, dnch->fft_out, dnch->fft_in, sizeof(s->sample_size)); edge = s->noise_band_edge[0]; j = edge; @@ -896,10 +956,21 @@ static void sample_noise_block(AudioFFTDeNoiseContext *s, avr = 0.0; avi = 0.0; } - avr += dnch->fft_out[n].re; - avi += dnch->fft_out[n].im; - mag2 = dnch->fft_out[n].re * dnch->fft_out[n].re + - dnch->fft_out[n].im * dnch->fft_out[n].im; + + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + avr += fft_out_flt[n].re; + avi += fft_out_flt[n].im; + mag2 = fft_out_flt[n].re * fft_out_flt[n].re + + fft_out_flt[n].im * fft_out_flt[n].im; + break; + case AV_SAMPLE_FMT_DBLP: + avr += fft_out_dbl[n].re; + avi += fft_out_dbl[n].im; + mag2 = fft_out_dbl[n].re * fft_out_dbl[n].re + + fft_out_dbl[n].im * fft_out_dbl[n].im; + break; + } mag2 = fmax(mag2, s->sample_floor); @@ -980,27 +1051,48 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_job for (int ch = start; ch < end; ch++) { DeNoiseChannel *dnch = &s->dnch[ch]; - const float *src = (const float *)in->extended_data[ch]; + const double *src_dbl = (const double *)in->extended_data[ch]; + const float *src_flt = (const float *)in->extended_data[ch]; double *dst = dnch->out_samples; - float *fft_in = dnch->fft_in; + double *fft_in_dbl = dnch->fft_in; + float *fft_in_flt = dnch->fft_in; - for (int m = 0; m < window_length; m++) - fft_in[m] = window[m] * src[m] * (1LL << 23); + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int m = 0; m < window_length; m++) + fft_in_flt[m] = window[m] * src_flt[m] * (1LL << 23); - for (int m = window_length; m < s->fft_length2; m++) - fft_in[m] = 0; + for (int m = window_length; m < s->fft_length2; m++) + fft_in_flt[m] = 0.f; + break; + case AV_SAMPLE_FMT_DBLP: + for (int m = 0; m < window_length; m++) + fft_in_dbl[m] = window[m] * src_dbl[m] * (1LL << 23); - dnch->tx_fn(dnch->fft, dnch->fft_out, fft_in, sizeof(float)); + for (int m = window_length; m < s->fft_length2; m++) + fft_in_dbl[m] = 0.; + break; + } - process_frame(ctx, s, dnch, dnch->fft_out, + dnch->tx_fn(dnch->fft, dnch->fft_out, dnch->fft_in, sizeof(s->sample_size)); + + process_frame(ctx, s, dnch, dnch->prior, dnch->prior_band_excit, s->track_noise); - dnch->itx_fn(dnch->ifft, fft_in, dnch->fft_out, sizeof(float)); + dnch->itx_fn(dnch->ifft, dnch->fft_in, dnch->fft_out, sizeof(s->sample_size)); - for (int m = 0; m < window_length; m++) - dst[m] += s->window[m] * fft_in[m] / (1LL << 23); + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int m = 0; m < window_length; m++) + dst[m] += s->window[m] * fft_in_flt[m] / (1LL << 23); + break; + case AV_SAMPLE_FMT_DBLP: + for (int m = 0; m < window_length; m++) + dst[m] += s->window[m] * fft_in_dbl[m] / (1LL << 23); + break; + } } return 0; @@ -1016,11 +1108,14 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in) AVFrame *out; for (int ch = 0; ch < s->channels; ch++) { - float *src = (float *)s->winframe->extended_data[ch]; - - memmove(src, &src[s->sample_advance], offset * sizeof(float)); - memcpy(&src[offset], in->extended_data[ch], in->nb_samples * sizeof(float)); - memset(&src[offset + in->nb_samples], 0, (s->sample_advance - in->nb_samples) * sizeof(float)); + uint8_t *src = (uint8_t *)s->winframe->extended_data[ch]; + + memmove(src, src + s->sample_advance * s->sample_size, + offset * s->sample_size); + memcpy(src + offset * s->sample_size, in->extended_data[ch], + in->nb_samples * s->sample_size); + memset(src + s->sample_size * (offset + in->nb_samples), 0, + (s->sample_advance - in->nb_samples) * s->sample_size); } if (s->track_noise) { @@ -1107,21 +1202,47 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in) for (int ch = 0; ch < inlink->ch_layout.nb_channels; ch++) { DeNoiseChannel *dnch = &s->dnch[ch]; double *src = dnch->out_samples; - const float *orig = (const float *)s->winframe->extended_data[ch]; - float *dst = (float *)out->extended_data[ch]; + const double *orig_dbl = (const double *)s->winframe->extended_data[ch]; + const float *orig_flt = (const float *)s->winframe->extended_data[ch]; + double *dst_dbl = (double *)out->extended_data[ch]; + float *dst_flt = (float *)out->extended_data[ch]; switch (output_mode) { case IN_MODE: - for (int m = 0; m < out->nb_samples; m++) - dst[m] = orig[m]; + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int m = 0; m < out->nb_samples; m++) + dst_flt[m] = orig_flt[m]; + break; + case AV_SAMPLE_FMT_DBLP: + for (int m = 0; m < out->nb_samples; m++) + dst_dbl[m] = orig_dbl[m]; + break; + } break; case OUT_MODE: - for (int m = 0; m < out->nb_samples; m++) - dst[m] = src[m]; + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int m = 0; m < out->nb_samples; m++) + dst_flt[m] = src[m]; + break; + case AV_SAMPLE_FMT_DBLP: + for (int m = 0; m < out->nb_samples; m++) + dst_dbl[m] = src[m]; + break; + } break; case NOISE_MODE: - for (int m = 0; m < out->nb_samples; m++) - dst[m] = orig[m] - src[m]; + switch (s->format) { + case AV_SAMPLE_FMT_FLTP: + for (int m = 0; m < out->nb_samples; m++) + dst_flt[m] = orig_flt[m] - src[m]; + break; + case AV_SAMPLE_FMT_DBLP: + for (int m = 0; m < out->nb_samples; m++) + dst_dbl[m] = orig_dbl[m] - src[m]; + break; + } break; default: if (in != out) @@ -1129,6 +1250,7 @@ static int output_frame(AVFilterLink *inlink, AVFrame *in) av_frame_free(&out); return AVERROR_BUG; } + memmove(src, src + s->sample_advance, (s->window_length - s->sample_advance) * sizeof(*src)); memset(src + (s->window_length - s->sample_advance), 0, s->sample_advance * sizeof(*src)); } @@ -1251,7 +1373,7 @@ const AVFilter ff_af_afftdn = { .uninit = uninit, FILTER_INPUTS(inputs), FILTER_OUTPUTS(outputs), - FILTER_SINGLE_SAMPLEFMT(AV_SAMPLE_FMT_FLTP), + FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP), .process_command = process_command, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, From 2ec59d29734ff01bae1f63184db54ddcd7d6aadc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 16 Sep 2022 02:09:39 +0200 Subject: [PATCH 335/590] configure: Remove obsolete APTX decoder dependencies Forgotten in 18e55de45a4d0ea197eaeae3a3a9daea186159b9. Signed-off-by: Andreas Rheinhardt --- configure | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure b/configure index 240ae942d1..c157338b1f 100755 --- a/configure +++ b/configure @@ -2775,9 +2775,7 @@ amv_encoder_select="jpegtables mpegvideoenc" ape_decoder_select="bswapdsp llauddsp" apng_decoder_select="inflate_wrapper" apng_encoder_select="deflate_wrapper llvidencdsp" -aptx_decoder_select="audio_frame_queue" aptx_encoder_select="audio_frame_queue" -aptx_hd_decoder_select="audio_frame_queue" aptx_hd_encoder_select="audio_frame_queue" asv1_decoder_select="blockdsp bswapdsp idctdsp" asv1_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp" From af42bb3d61c82da0c82631b07b329a280ae83d17 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 19 Sep 2022 02:35:46 +0200 Subject: [PATCH 336/590] x86/tx_float: simplify and describe the intra-asm call convention --- libavutil/x86/tx_float.asm | 43 ++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index dbb04e8b4d..3b3e26ebcb 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -21,6 +21,13 @@ ; Open `doc/transforms.md` to see the code upon which the transforms here were ; based upon and compare. +; Intra-asm call convention: +; 272 bytes of stack available +; First 10 GPRs available +; All vector regs available +; Don't clobber ctx, len, lut +; in and out must point to the end + ; TODO: ; carry over registers from smaller transforms to save on ~8 loads/stores ; check if vinsertf could be faster than verpm2f128 for duplication @@ -737,6 +744,8 @@ cglobal fft8_float, 4, 4, 6, ctx, out, in, tmp movups [outq + 3*mmsize], m1 %if %1 + add inq, mmsize*4 + add outq, mmsize*4 ret %else RET @@ -777,6 +786,8 @@ cglobal fft8_float, 4, 4, 4, ctx, out, in, tmp vextractf128 [outq + 16*3], m0, 1 %if %1 + add inq, mmsize*2 + add outq, mmsize*2 ret %else RET @@ -826,6 +837,8 @@ cglobal fft16_float, 4, 4, 8, ctx, out, in, tmp vextractf128 [outq + 16*7], m1, 1 %if %2 + add inq, mmsize*4 + add outq, mmsize*4 ret %else RET @@ -910,6 +923,8 @@ cglobal fft32_float, 4, 4, 16, ctx, out, in, tmp vextractf128 [outq + 16*15], m5, 1 %if %2 + add inq, mmsize*8 + add outq, mmsize*8 ret %else RET @@ -970,13 +985,13 @@ ALIGN 16 %macro FFT_SPLIT_RADIX_FN 2 INIT_YMM %1 %if %2 -cglobal fft_sr_asm_float, 0, 0, 0, ctx, out, in, tmp, len, lut, itab, rtab, tgt +cglobal fft_sr_asm_float, 0, 0, 0, ctx, out, in, tmp, len, lut, itab, rtab, tgt, off %else -cglobal fft_sr_float, 4, 9, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, tgt +cglobal fft_sr_float, 4, 10, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, tgt, off movsxd lenq, dword [ctxq + AVTXContext.len] mov lutq, [ctxq + AVTXContext.map] - mov tgtq, lenq %endif + mov tgtq, lenq ; Bottom-most/32-point transform =============================================== ALIGN 16 @@ -1238,11 +1253,12 @@ FFT_SPLIT_RADIX_DEF 131072 ; Final synthesis + deinterleaving code ;=============================================================================== .deinterleave: + mov tgtq, lenq imul tmpq, lenq, 2 - lea lutq, [4*lenq + tmpq] + lea offq, [4*lenq + tmpq] .synth_deinterleave: - SPLIT_RADIX_COMBINE_DEINTERLEAVE_FULL tmpq, lutq + SPLIT_RADIX_COMBINE_DEINTERLEAVE_FULL tmpq, offq add outq, 8*mmsize add rtabq, 4*mmsize sub itabq, 4*mmsize @@ -1250,6 +1266,8 @@ FFT_SPLIT_RADIX_DEF 131072 jg .synth_deinterleave %if %2 + mov lenq, tgtq + add outq, offq ret %else RET @@ -1331,16 +1349,16 @@ FFT_SPLIT_RADIX_DEF 131072 vextractf128 [outq + 15*mmsize + 16], tx2_e1, 1 %if %2 + add outq, 16*mmsize ret %else RET %endif %if %2 -cglobal fft_sr_ns_float, 4, 9, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, tgt +cglobal fft_sr_ns_float, 4, 10, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab, tgt, off movsxd lenq, dword [ctxq + AVTXContext.len] mov lutq, [ctxq + AVTXContext.map] - mov tgtq, lenq call mangle(ff_tx_fft_sr_asm_float_ %+ %1) RET @@ -1358,16 +1376,15 @@ FFT_SPLIT_RADIX_FN avx2, 1 %macro IMDCT_FN 1 INIT_YMM %1 -cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, stride, len, lut, exp, t1, t2, t3, t4, t5 +cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, t1, t2, t3, t4, t5, bctx movsxd lenq, dword [ctxq + AVTXContext.len] mov expq, [ctxq + AVTXContext.exp] lea t1d, [lend - 1] imul t1d, strided - PUSH outq ; backup original output + mov bctxq, ctxq ; backup original context mov t5q, [ctxq + AVTXContext.fn] ; subtransform's jump point - PUSH ctxq ; backup original context mov ctxq, [ctxq + AVTXContext.sub] ; load subtransform's context mov lutq, [ctxq + AVTXContext.map] ; load subtransform's map @@ -1487,11 +1504,10 @@ cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, stride, len, lut, exp, .transform: movsxd lenq, dword [ctxq + AVTXContext.len] - mov t2q, lenq ; target length (for ptwo transforms) mov inq, outq ; in-place transform call t5q ; call the FFT - POP ctxq ; restore original context + mov ctxq, bctxq ; restore original context movsxd lenq, dword [ctxq + AVTXContext.len] mov expq, [ctxq + AVTXContext.exp] lea expq, [expq + lenq*4] @@ -1499,7 +1515,8 @@ cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, stride, len, lut, exp, lea t1q, [lenq*2] ; high lea t2q, [lenq*2 - mmsize] ; low - POP outq + neg lenq + lea outq, [outq + lenq*4] .post: movaps m2, [expq + t1q] ; tab h From 892548e6a1a514fc23c5bb42e549b1a0bb604b6a Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 19 Sep 2022 04:13:04 +0200 Subject: [PATCH 337/590] x86/tx_float: fully support 128bit regs in LOAD64_LUT The gather path didn't support 128bit registers. It's not faster on Zen 3, but it's here for completeness. --- libavutil/x86/tx_float.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 3b3e26ebcb..b644db49be 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -107,19 +107,19 @@ SECTION .text ; %7 - temporary register (for avx only, enables vgatherdpd (AVX2) if FMA3 is set) %macro LOAD64_LUT 5-7 %if %0 > 6 && cpuflag(avx2) - pcmpeqd %6, %6 ; pcmpeqq has a 0.5 throughput on Zen 3, this has 0.25 - movapd xmm%7, [%3 + %4] ; float mov since vgatherdpd is a float instruction - vgatherdpd %1, [%2 + xmm%7*8], %6 ; must use separate registers for args + pcmpeqd %7, %7 ; pcmpeqq has a 0.5 throughput on Zen 3, this has 0.25 + movupd xmm%6, [%3 + %4] ; float mov since vgatherdpd is a float instruction + vgatherdpd %1, [%2 + xmm%6*8], %7 ; must use separate registers for args %else mov %5d, [%3 + %4 + 0] movsd xmm%1, [%2 + %5q*8] -%if mmsize == 32 +%if sizeof%1 > 16 && %0 > 5 mov %5d, [%3 + %4 + 8] movsd xmm%6, [%2 + %5q*8] %endif mov %5d, [%3 + %4 + 4] movhps xmm%1, [%2 + %5q*8] -%if mmsize == 32 +%if sizeof%1 > 16 && %0 > 5 mov %5d, [%3 + %4 + 12] movhps xmm%6, [%2 + %5q*8] vinsertf128 %1, %1, xmm%6, 1 From 4ba68639cabfc56ffe62d4e776a8af040e551ff3 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 19 Sep 2022 04:14:52 +0200 Subject: [PATCH 338/590] x86/tx_float: add asm call versions of the 2pt and 4pt transforms Verified to be working. --- libavutil/x86/tx_float.asm | 26 +++++++++++++++++++++++--- libavutil/x86/tx_float_init.c | 9 +++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index b644db49be..b3a85a7cb9 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -682,15 +682,27 @@ SECTION .text %endmacro INIT_XMM sse3 +cglobal fft2_asm_float, 0, 0, 0, ctx, out, in, stride + movaps m0, [inq] + FFT2 m0, m1 + movaps [outq], m0 + add inq, mmsize*1 + add outq, mmsize*1 + ret + cglobal fft2_float, 4, 4, 2, ctx, out, in, stride movaps m0, [inq] FFT2 m0, m1 movaps [outq], m0 RET -%macro FFT4 2 +%macro FFT4_FN 3 INIT_XMM sse2 +%if %3 +cglobal fft4_ %+ %1 %+ _asm_float, 0, 0, 0, ctx, out, in, stride +%else cglobal fft4_ %+ %1 %+ _float, 4, 4, 3, ctx, out, in, stride +%endif movaps m0, [inq + 0*mmsize] movaps m1, [inq + 1*mmsize] @@ -708,11 +720,19 @@ cglobal fft4_ %+ %1 %+ _float, 4, 4, 3, ctx, out, in, stride movaps [outq + 0*mmsize], m2 movaps [outq + 1*mmsize], m0 +%if %3 + add inq, mmsize*2 + add outq, mmsize*2 + ret +%else RET +%endif %endmacro -FFT4 fwd, 0 -FFT4 inv, 1 +FFT4_FN fwd, 0, 0 +FFT4_FN fwd, 0, 1 +FFT4_FN inv, 1, 0 +FFT4_FN inv, 1, 1 %macro FFT8_SSE_FN 1 INIT_XMM sse3 diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c index 25de7b3ec6..06df749fa9 100644 --- a/libavutil/x86/tx_float_init.c +++ b/libavutil/x86/tx_float_init.c @@ -45,6 +45,9 @@ TX_DECL_FN(fft_sr_ns, avx2) TX_DECL_FN(mdct_sr_inv, avx2) +TX_DECL_FN(fft2_asm, sse3) +TX_DECL_FN(fft4_fwd_asm, sse2) +TX_DECL_FN(fft4_inv_asm, sse2) TX_DECL_FN(fft8_asm, sse3) TX_DECL_FN(fft8_asm, avx) TX_DECL_FN(fft16_asm, avx) @@ -101,8 +104,14 @@ static av_cold int m_inv_init(AVTXContext *s, const FFTXCodelet *cd, const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { TX_DEF(fft2, FFT, 2, 2, 2, 0, 128, NULL, sse3, SSE3, AV_TX_INPLACE, 0), + TX_DEF(fft2_asm, FFT, 2, 2, 2, 0, 192, b8_i0, sse3, SSE3, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 0), TX_DEF(fft2, FFT, 2, 2, 2, 0, 192, b8_i0, sse3, SSE3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 128, NULL, sse2, SSE2, AV_TX_INPLACE | FF_TX_FORWARD_ONLY, 0), + TX_DEF(fft4_fwd_asm, FFT, 4, 4, 2, 0, 192, b8_i0, sse2, SSE2, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, 0), + TX_DEF(fft4_inv_asm, FFT, 4, 4, 2, 0, 128, NULL, sse2, SSE2, + AV_TX_INPLACE | FF_TX_INVERSE_ONLY | FF_TX_ASM_CALL, 0), TX_DEF(fft4_fwd, FFT, 4, 4, 2, 0, 192, b8_i0, sse2, SSE2, AV_TX_INPLACE | FF_TX_PRESHUFFLE, 0), TX_DEF(fft4_inv, FFT, 4, 4, 2, 0, 128, NULL, sse2, SSE2, AV_TX_INPLACE | FF_TX_INVERSE_ONLY, 0), TX_DEF(fft8, FFT, 8, 8, 2, 0, 128, b8_i0, sse3, SSE3, AV_TX_INPLACE, 0), From d7f4ad88a0df3c1339e142957bf2c40cd056b8ce Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 15 Sep 2022 14:53:36 +0200 Subject: [PATCH 339/590] lavc/videotoolbox: do not pass AVCodecContext to decoder output callback The opaque parameter for the callback is set in videotoolbox_start(), called when the hwaccel is initialized. When frame threading is used, avctx will be the context corresponding to the frame thread currently doing the decoding. Using this same codec context in all subsequent invocations of the decoder callback (even those triggered by a different frame thread) is unsafe, and broken after cc867f2c09d2b69cee8a0eccd62aff002cbbfe11, since each frame thread now cleans up its hwaccel state after decoding each frame. Fix this by passing hwaccel_priv_data as the opaque parameter, which exists in a single instance forwarded between all frame threads. The only other use of AVCodecContext in the decoder output callback is as a logging context. For this purpose, store a logging context in hwaccel_priv_data. --- libavcodec/videotoolbox.c | 10 ++++++---- libavcodec/vt_internal.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index ce83c2594a..d61d310600 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -690,8 +690,7 @@ static void videotoolbox_decoder_callback(void *opaque, CMTime pts, CMTime duration) { - AVCodecContext *avctx = opaque; - VTContext *vtctx = avctx->internal->hwaccel_priv_data; + VTContext *vtctx = opaque; if (vtctx->frame) { CVPixelBufferRelease(vtctx->frame); @@ -699,7 +698,8 @@ static void videotoolbox_decoder_callback(void *opaque, } if (!image_buffer) { - av_log(avctx, status ? AV_LOG_WARNING : AV_LOG_DEBUG, "vt decoder cb: output image buffer is null: %i\n", status); + av_log(vtctx->logctx, status ? AV_LOG_WARNING : AV_LOG_DEBUG, + "vt decoder cb: output image buffer is null: %i\n", status); return; } @@ -949,7 +949,7 @@ static int videotoolbox_start(AVCodecContext *avctx) videotoolbox->cv_pix_fmt_type); decoder_cb.decompressionOutputCallback = videotoolbox_decoder_callback; - decoder_cb.decompressionOutputRefCon = avctx; + decoder_cb.decompressionOutputRefCon = avctx->internal->hwaccel_priv_data; status = VTDecompressionSessionCreate(NULL, // allocator videotoolbox->cm_fmt_desc, // videoFormatDescription @@ -1179,6 +1179,8 @@ int ff_videotoolbox_common_init(AVCodecContext *avctx) AVHWFramesContext *hw_frames; int err; + vtctx->logctx = avctx; + // Old API - do nothing. if (avctx->hwaccel_context) return 0; diff --git a/libavcodec/vt_internal.h b/libavcodec/vt_internal.h index 54a11fd1b5..9502d7c7dc 100644 --- a/libavcodec/vt_internal.h +++ b/libavcodec/vt_internal.h @@ -45,6 +45,8 @@ typedef struct VTContext { // Current H264 parameters (used to trigger decoder restart on SPS changes). uint8_t sps[3]; bool reconfig_needed; + + void *logctx; } VTContext; int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame); From 8576c3c5d82188c1313f20666b8760fe4a29444c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 15 Sep 2022 15:53:12 +0200 Subject: [PATCH 340/590] lavc/videotoolbox: deprecate write-only output_callback This field has never been used for anything, so stop setting it and deprecate it. --- libavcodec/version_major.h | 1 + libavcodec/videotoolbox.c | 2 -- libavcodec/videotoolbox.h | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h index 1ec815a7bc..d9386792de 100644 --- a/libavcodec/version_major.h +++ b/libavcodec/version_major.h @@ -51,5 +51,6 @@ #define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 60) #endif /* AVCODEC_VERSION_MAJOR_H */ diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index d61d310600..1b1be8ddb4 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -1377,8 +1377,6 @@ static AVVideotoolboxContext *av_videotoolbox_alloc_context_with_pix_fmt(enum AV AVVideotoolboxContext *ret = av_mallocz(sizeof(*ret)); if (ret) { - ret->output_callback = videotoolbox_decoder_callback; - OSType cv_pix_fmt_type = av_map_videotoolbox_format_from_pixfmt2(pix_fmt, full_range); if (cv_pix_fmt_type == 0) { cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; diff --git a/libavcodec/videotoolbox.h b/libavcodec/videotoolbox.h index af2db0d580..fd8a5b7982 100644 --- a/libavcodec/videotoolbox.h +++ b/libavcodec/videotoolbox.h @@ -37,6 +37,8 @@ #include "libavcodec/avcodec.h" +#include "libavutil/attributes.h" + /** * This struct holds all the information that needs to be passed * between the caller and libavcodec for initializing Videotoolbox decoding. @@ -50,11 +52,14 @@ typedef struct AVVideotoolboxContext { */ VTDecompressionSessionRef session; +#if FF_API_VT_OUTPUT_CALLBACK /** * The output callback that must be passed to the session. * Set by av_videottoolbox_default_init() */ + attribute_deprecated VTDecompressionOutputCallback output_callback; +#endif /** * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames. From 33cdf51a065c568bfe3811846095f8d8ac73fe6d Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 16 Sep 2022 11:49:17 -0300 Subject: [PATCH 341/590] avcodec/avcodec: Use the new API fields to validate the layout returned by decoders This block was scheduled for removal, which means that no validation would have taken place after the old API was removed. It was algo going to mistakenly remove an unrelated bits_per_coded_sample check. Signed-off-by: James Almer --- libavcodec/avcodec.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 29643199be..1f8ab37abb 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -321,24 +321,12 @@ FF_DISABLE_DEPRECATION_WARNINGS avctx->channels = avctx->ch_layout.nb_channels; avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? avctx->ch_layout.u.mask : 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif /* validate channel layout from the decoder */ - if (avctx->channel_layout) { - int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); - if (!avctx->channels) - avctx->channels = channels; - else if (channels != avctx->channels) { - char buf[512]; - av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout); - av_log(avctx, AV_LOG_WARNING, - "Channel layout '%s' with %d channels does not match specified number of channels %d: " - "ignoring specified channel layout\n", - buf, channels, avctx->channels); - avctx->channel_layout = 0; - } - } - if (avctx->channels && avctx->channels < 0 || - avctx->channels > FF_SANE_NB_CHANNELS) { + if ((avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) || + avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) { ret = AVERROR(EINVAL); goto free_and_end; } @@ -346,8 +334,6 @@ FF_DISABLE_DEPRECATION_WARNINGS ret = AVERROR(EINVAL); goto free_and_end; } -FF_ENABLE_DEPRECATION_WARNINGS -#endif #if FF_API_AVCTX_TIMEBASE if (avctx->framerate.num > 0 && avctx->framerate.den > 0) From 9884d14711e7a36743861afedd949b5f32ac5e3c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 18:06:25 +0200 Subject: [PATCH 342/590] fate/audio: Add tests for APTX (HD) We have de- and encoders for APTX and APTX HD, yet not FATE tests. This commit therefore adds a transcoding test to utilize them. Furthermore, during creating these tests it turned out that the duration is set incorrectly for APTX HD. This will be fixed in a future commit. (Thanks to Andriy Gelman for finding an issue in an earlier version that used a 192kHz input sample which does not work reliably accross platforms.) Signed-off-by: Andreas Rheinhardt --- tests/fate/audio.mak | 7 +++++++ tests/ref/fate/aptx | 18 ++++++++++++++++++ tests/ref/fate/aptx-hd | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/ref/fate/aptx create mode 100644 tests/ref/fate/aptx-hd diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak index fd9905ca0a..9d39eeace3 100644 --- a/tests/fate/audio.mak +++ b/tests/fate/audio.mak @@ -1,3 +1,10 @@ +FATE_SAMPLES_AUDIO-$(call TRANSCODE, APTX, APTX, WAV_DEMUXER PCM_S16LE_DECODER ARESAMPLE_FILTER) += fate-aptx +fate-aptx: CMD = transcode wav $(TARGET_SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav aptx "-af aresample -c aptx" "-af aresample -c:a pcm_s16le -t 0.25" "" "" "-f aptx -sample_rate 44100" + +FATE_SAMPLES_AUDIO-$(call TRANSCODE, APTX_HD, APTX_HD, WAV_DEMUXER PCM_S16LE_DECODER \ + ARESAMPLE_FILTER PCM_S32LE_ENCODER) += fate-aptx-hd +fate-aptx-hd: CMD = transcode wav $(TARGET_SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav aptx_hd "-af aresample -c aptx_hd" "-af aresample -c:a pcm_s32le -t 0.25" "" "" "-f aptx_hd -sample_rate 44100" + FATE_BINKAUDIO-$(call DEMDEC, BINK, BINKAUDIO_DCT) += fate-binkaudio-dct fate-binkaudio-dct: CMD = pcm -i $(TARGET_SAMPLES)/bink/binkaudio_dct.bik fate-binkaudio-dct: REF = $(SAMPLES)/bink/binkaudio_dct.pcm diff --git a/tests/ref/fate/aptx b/tests/ref/fate/aptx new file mode 100644 index 0000000000..4d20b7df9a --- /dev/null +++ b/tests/ref/fate/aptx @@ -0,0 +1,18 @@ +b5d8a297c0e8d9854f19d9d3e8b82859 *tests/data/fate/aptx.aptx +418950 tests/data/fate/aptx.aptx +#tb 0: 1/44100 +#media_type 0: audio +#codec_id 0: pcm_s16le +#sample_rate 0: 44100 +#channel_layout_name 0: 2 channels +0, 0, 0, 1024, 4096, 0xcbb4ceff +0, 1024, 1024, 1024, 4096, 0xa66533e7 +0, 2048, 2048, 1024, 4096, 0x4f22ec39 +0, 3072, 3072, 1024, 4096, 0x45f117f9 +0, 4096, 4096, 1024, 4096, 0xad6c0b7a +0, 5120, 5120, 1024, 4096, 0x611618fd +0, 6144, 6144, 1024, 4096, 0x0ec02f2b +0, 7168, 7168, 1024, 4096, 0x2cf9ae5c +0, 8192, 8192, 1024, 4096, 0xfb008ac0 +0, 9216, 9216, 1024, 4096, 0x25068495 +0, 10240, 10240, 785, 3140, 0x5a260589 diff --git a/tests/ref/fate/aptx-hd b/tests/ref/fate/aptx-hd new file mode 100644 index 0000000000..0691f33c86 --- /dev/null +++ b/tests/ref/fate/aptx-hd @@ -0,0 +1,15 @@ +48ecaa81ee5adaaa62ed3ff6574b6666 *tests/data/fate/aptx-hd.aptx_hd +628425 tests/data/fate/aptx-hd.aptx_hd +#tb 0: 1/44100 +#media_type 0: audio +#codec_id 0: pcm_s32le +#sample_rate 0: 44100 +#channel_layout_name 0: 2 channels +0, 0, 0, 1024, 8192, 0xa99888c6 +0, 1536, 1536, 1024, 8192, 0xc3e03a3c +0, 3072, 3072, 1024, 8192, 0x3f06e090 +0, 4608, 4608, 1024, 8192, 0x92fb18f3 +0, 6144, 6144, 1024, 8192, 0x3d5603a2 +0, 7680, 7680, 1024, 8192, 0xcc3d3101 +0, 9216, 9216, 1024, 8192, 0xbcc022ef +0, 10752, 10752, 273, 2184, 0x9873af57 From 6f22d1965eeab80544ecbb190bc4c379063fa481 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 18:29:34 +0200 Subject: [PATCH 343/590] avcodec/utils: Support APTX (HD) in av_get_audio_frame_duration() APTX decodes four bytes of input to four stereo samples; APTX HD does the same with six bytes of input. So it can be easily supported in av_get_audio_frame_duration(). This fixes invalid durations and (derived) timestamps of demuxed APTX HD packets and therefore fixed the timestamp in the aptx-hd FATE test. Signed-off-by: Andreas Rheinhardt --- libavcodec/utils.c | 4 ++++ tests/ref/fate/aptx-hd | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 2f57418ff7..ba64aaf32d 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -682,6 +682,10 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, return 256 * (frame_bytes / 64); if (id == AV_CODEC_ID_RA_144) return 160 * (frame_bytes / 20); + if (id == AV_CODEC_ID_APTX) + return 4 * (frame_bytes / 4); + if (id == AV_CODEC_ID_APTX_HD) + return 4 * (frame_bytes / 6); if (bps > 0) { /* calc from frame_bytes and bits_per_coded_sample */ diff --git a/tests/ref/fate/aptx-hd b/tests/ref/fate/aptx-hd index 0691f33c86..498b9131a6 100644 --- a/tests/ref/fate/aptx-hd +++ b/tests/ref/fate/aptx-hd @@ -6,10 +6,13 @@ #sample_rate 0: 44100 #channel_layout_name 0: 2 channels 0, 0, 0, 1024, 8192, 0xa99888c6 -0, 1536, 1536, 1024, 8192, 0xc3e03a3c -0, 3072, 3072, 1024, 8192, 0x3f06e090 -0, 4608, 4608, 1024, 8192, 0x92fb18f3 -0, 6144, 6144, 1024, 8192, 0x3d5603a2 -0, 7680, 7680, 1024, 8192, 0xcc3d3101 -0, 9216, 9216, 1024, 8192, 0xbcc022ef -0, 10752, 10752, 273, 2184, 0x9873af57 +0, 1024, 1024, 1024, 8192, 0xc3e03a3c +0, 2048, 2048, 1024, 8192, 0x3f06e090 +0, 3072, 3072, 1024, 8192, 0x92fb18f3 +0, 4096, 4096, 1024, 8192, 0x3d5603a2 +0, 5120, 5120, 1024, 8192, 0xcc3d3101 +0, 6144, 6144, 1024, 8192, 0xbcc022ef +0, 7168, 7168, 1024, 8192, 0x600cbb73 +0, 8192, 8192, 1024, 8192, 0xdc938cbb +0, 9216, 9216, 1024, 8192, 0x37d968bc +0, 10240, 10240, 785, 6280, 0x48243144 From c0d483cecb3ca31574f850c031d66a34a4f2d140 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 20:25:18 +0200 Subject: [PATCH 344/590] avcodec/aptx: Use AVCodecContext.frame_size according to the API Currently the APTX (HD) codecs set frame_size if unset and check whether it is divisible by block_size (corresponding to block_align as used by other codecs). But this is based upon a misunderstanding of the API: frame_size is not in bytes, but in samples. Said value is also not intended to be set by the user at all, but set by encoders and (possibly) decoders if the number of channels in a frame is constant. The latter condition is not fulfilled here, so only set it for encoders. Given that the encoder can handle any number of samples as long as it is divisible by four and given that it worked to set a custom frame size before, the encoders accept any multiple of four; otherwise the value is set to the value that it already had for APTX: 1024 samples (per channel). Signed-off-by: Andreas Rheinhardt --- libavcodec/aptx.c | 9 --------- libavcodec/aptxenc.c | 3 +++ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/libavcodec/aptx.c b/libavcodec/aptx.c index 8e110acc97..ed814ad1c0 100644 --- a/libavcodec/aptx.c +++ b/libavcodec/aptx.c @@ -516,15 +516,6 @@ av_cold int ff_aptx_init(AVCodecContext *avctx) s->hd = avctx->codec->id == AV_CODEC_ID_APTX_HD; s->block_size = s->hd ? 6 : 4; - if (avctx->frame_size == 0) - avctx->frame_size = 256 * s->block_size; - - if (avctx->frame_size % s->block_size) { - av_log(avctx, AV_LOG_ERROR, - "Frame size must be a multiple of %d samples\n", s->block_size); - return AVERROR(EINVAL); - } - for (chan = 0; chan < NB_CHANNELS; chan++) { Channel *channel = &s->channels[chan]; for (subband = 0; subband < NB_SUBBANDS; subband++) { diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index f9347853d2..434a9abf0f 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -257,6 +257,9 @@ static av_cold int aptx_encode_init(AVCodecContext *avctx) ff_af_queue_init(avctx, &s->afq); + if (!avctx->frame_size || avctx->frame_size % 4) + avctx->frame_size = 1024; + return ff_aptx_init(avctx); } From 9d10d3a4ee7ccf3742c4d9dd26a781aaf2ab8ae9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 21:55:30 +0200 Subject: [PATCH 345/590] avformat/aptxdec: Don't set AVCodecParameters.frame_size This field was misunderstood: It gives the number of samples in a packet, not the number of bytes. Its usage was wrong for APTX HD. Signed-off-by: Andreas Rheinhardt --- libavformat/aptxdec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c index 693316eeb0..aa86bfe330 100644 --- a/libavformat/aptxdec.c +++ b/libavformat/aptxdec.c @@ -58,7 +58,6 @@ static int aptx_read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_APTX; st->codecpar->bits_per_coded_sample = 4; st->codecpar->block_align = APTX_BLOCK_SIZE; - st->codecpar->frame_size = APTX_PACKET_SIZE; return 0; } @@ -70,7 +69,6 @@ static int aptx_hd_read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_APTX_HD; st->codecpar->bits_per_coded_sample = 6; st->codecpar->block_align = APTX_HD_BLOCK_SIZE; - st->codecpar->frame_size = APTX_HD_PACKET_SIZE; return 0; } From c8707c105fc7cf3cd2ca59a5f2e645d129369d98 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 22:01:16 +0200 Subject: [PATCH 346/590] avformat/aptxdec: Don't set AV_PKT_FLAG_CORRUPT mistakenly Just because we try to put multiple units of block_align bytes (the atomic units for APTX and APTX HD) into one packet does not mean that packets with fewer units than the one we wanted are corrupt; only those packets that are not a multiple of block_align are. Signed-off-by: Andreas Rheinhardt --- libavformat/aptxdec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/aptxdec.c b/libavformat/aptxdec.c index aa86bfe330..0637a8afde 100644 --- a/libavformat/aptxdec.c +++ b/libavformat/aptxdec.c @@ -74,12 +74,18 @@ static int aptx_hd_read_header(AVFormatContext *s) static int aptx_read_packet(AVFormatContext *s, AVPacket *pkt) { - return av_get_packet(s->pb, pkt, APTX_PACKET_SIZE); + int ret = av_get_packet(s->pb, pkt, APTX_PACKET_SIZE); + if (ret >= 0 && !(ret % APTX_BLOCK_SIZE)) + pkt->flags &= ~AV_PKT_FLAG_CORRUPT; + return ret >= 0 ? 0 : ret; } static int aptx_hd_read_packet(AVFormatContext *s, AVPacket *pkt) { - return av_get_packet(s->pb, pkt, APTX_HD_PACKET_SIZE); + int ret = av_get_packet(s->pb, pkt, APTX_HD_PACKET_SIZE); + if (ret >= 0 && !(ret % APTX_HD_BLOCK_SIZE)) + pkt->flags &= ~AV_PKT_FLAG_CORRUPT; + return ret >= 0 ? 0 : ret; } static const AVOption aptx_options[] = { From e6bfb14223e44b4110c1d171d1ecffe9c80302a8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 22:18:52 +0200 Subject: [PATCH 347/590] avcodec/aptxdec: Process data in complete blocks only The APTX (HD) decoder decodes blocks of four (six) bytes to four output samples. It makes no sense to handle incomplete blocks: They would just lead to synchronization errors, in which case the complete frame is discarded. So only handle complete blocks. This also avoids reading from the packet's padding and writing into the frame's padding. Signed-off-by: Andreas Rheinhardt --- libavcodec/aptxdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c index 878c9ffe1b..d254b3026b 100644 --- a/libavcodec/aptxdec.c +++ b/libavcodec/aptxdec.c @@ -151,7 +151,7 @@ static int aptx_decode_frame(AVCodecContext *avctx, AVFrame *frame, /* get output buffer */ frame->ch_layout.nb_channels = NB_CHANNELS; frame->format = AV_SAMPLE_FMT_S32P; - frame->nb_samples = 4 * avpkt->size / s->block_size; + frame->nb_samples = 4 * (avpkt->size / s->block_size); if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; From dc7b6645575aa431d1d49744a17f60ee415ebc8b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 15 Sep 2022 16:57:18 +0200 Subject: [PATCH 348/590] avcodec/encode: Redo checks for small last audio frame In particular, check that there is only one small last frame in case the encoder has the AV_CODEC_CAP_SMALL_LAST_FRAME set. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 21 +++++++++------------ libavcodec/internal.h | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index ade4d458e7..9bd9f9bc08 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -157,6 +157,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src) fail: av_frame_unref(frame); + s->internal->last_audio_frame = 0; return ret; } @@ -392,28 +393,24 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) avctx->audio_service_type = *(enum AVAudioServiceType*)sd->data; /* check for valid frame size */ - if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) { - if (src->nb_samples > avctx->frame_size) { - av_log(avctx, AV_LOG_ERROR, "more samples than frame size\n"); - return AVERROR(EINVAL); - } - } else if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { + if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { /* if we already got an undersized frame, that must have been the last */ if (avctx->internal->last_audio_frame) { av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame\n", avctx->frame_size); return AVERROR(EINVAL); } - + if (src->nb_samples > avctx->frame_size) { + av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) > frame_size (%d)\n", src->nb_samples, avctx->frame_size); + return AVERROR(EINVAL); + } if (src->nb_samples < avctx->frame_size) { + avctx->internal->last_audio_frame = 1; + if (!(avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)) { ret = pad_last_frame(avctx, dst, src); if (ret < 0) return ret; - - avctx->internal->last_audio_frame = 1; goto finish; - } else if (src->nb_samples > avctx->frame_size) { - av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d)\n", src->nb_samples, avctx->frame_size); - return AVERROR(EINVAL); + } } } } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 35e3dd303a..45aec38a60 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -57,8 +57,8 @@ typedef struct AVCodecInternal { int is_copy; /** - * An audio frame with less than required samples has been submitted and - * padded with silence. Reject all subsequent frames. + * An audio frame with less than required samples has been submitted (and + * potentially padded with silence). Reject all subsequent frames. */ int last_audio_frame; From 017d976629ea272965ea67201543c8b5538cbf09 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 15 Sep 2022 19:20:11 +0200 Subject: [PATCH 349/590] avcodec/encode: Enable encoders to control padding of last frame Some audio codecs work with atomic units that decode to a fixed number of audio samples with this number being so small that it is common to put multiple of these atoms into one packet. In these cases it makes no sense to pad the last frame to the big frame_size, so allow encoders to set the number of samples that they want the last frame to be padded to instead. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 17 +++++++++++------ libavcodec/internal.h | 6 ++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 9bd9f9bc08..049b71c6f4 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -127,12 +127,12 @@ static int encode_make_refcounted(AVCodecContext *avctx, AVPacket *avpkt) /** * Pad last frame with silence. */ -static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src) +static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src, int out_samples) { int ret; frame->format = src->format; - frame->nb_samples = s->frame_size; + frame->nb_samples = out_samples; ret = av_channel_layout_copy(&frame->ch_layout, &s->ch_layout); if (ret < 0) goto fail; @@ -406,10 +406,15 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) if (src->nb_samples < avctx->frame_size) { avctx->internal->last_audio_frame = 1; if (!(avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)) { - ret = pad_last_frame(avctx, dst, src); - if (ret < 0) - return ret; - goto finish; + int pad_samples = avci->pad_samples ? avci->pad_samples : avctx->frame_size; + int out_samples = (src->nb_samples + pad_samples - 1) / pad_samples * pad_samples; + + if (out_samples != src->nb_samples) { + ret = pad_last_frame(avctx, dst, src, out_samples); + if (ret < 0) + return ret; + goto finish; + } } } } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 45aec38a60..76a6ea6bc6 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -62,6 +62,12 @@ typedef struct AVCodecInternal { */ int last_audio_frame; + /** + * Audio encoders can set this flag during init to indicate that they + * want the small last frame to be padded to a multiple of pad_samples. + */ + int pad_samples; + AVBufferRef *pool; void *thread_ctx; From 129cbbd7be16fc0c396cfbb291794174735dbaf7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 29 Aug 2021 22:44:36 +0200 Subject: [PATCH 350/590] avcodec/aptxenc: Process data in complete blocks of four samples only Do this by setting AVCodecInternal.pad_samples. This prevents reading into the frame's padding and writing into the packet's padding. This actually happened in our FATE tests (where the number of samples is 2 mod 4), which therefore needed to be updated. Signed-off-by: Andreas Rheinhardt --- libavcodec/aptxenc.c | 6 ++++-- tests/ref/fate/aptx | 4 ++-- tests/ref/fate/aptx-hd | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index 434a9abf0f..114e286fe2 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -27,6 +27,7 @@ #include "audio_frame_queue.h" #include "codec_internal.h" #include "encode.h" +#include "internal.h" typedef struct AptXEncContext { AptXContext common; @@ -259,6 +260,7 @@ static av_cold int aptx_encode_init(AVCodecContext *avctx) if (!avctx->frame_size || avctx->frame_size % 4) avctx->frame_size = 1024; + avctx->internal->pad_samples = 4; return ff_aptx_init(avctx); } @@ -269,7 +271,7 @@ const FFCodec ff_aptx_encoder = { CODEC_LONG_NAME("aptX (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(AptXEncContext), .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), @@ -290,7 +292,7 @@ const FFCodec ff_aptx_hd_encoder = { CODEC_LONG_NAME("aptX HD (Audio Processing Technology for Bluetooth)"), .p.type = AVMEDIA_TYPE_AUDIO, .p.id = AV_CODEC_ID_APTX_HD, - .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, + .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(AptXEncContext), .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), diff --git a/tests/ref/fate/aptx b/tests/ref/fate/aptx index 4d20b7df9a..7917399297 100644 --- a/tests/ref/fate/aptx +++ b/tests/ref/fate/aptx @@ -1,5 +1,5 @@ -b5d8a297c0e8d9854f19d9d3e8b82859 *tests/data/fate/aptx.aptx -418950 tests/data/fate/aptx.aptx +97dfd7f32d34fb74337c0f6c66e26e2d *tests/data/fate/aptx.aptx +418952 tests/data/fate/aptx.aptx #tb 0: 1/44100 #media_type 0: audio #codec_id 0: pcm_s16le diff --git a/tests/ref/fate/aptx-hd b/tests/ref/fate/aptx-hd index 498b9131a6..d74c1059c2 100644 --- a/tests/ref/fate/aptx-hd +++ b/tests/ref/fate/aptx-hd @@ -1,5 +1,5 @@ -48ecaa81ee5adaaa62ed3ff6574b6666 *tests/data/fate/aptx-hd.aptx_hd -628425 tests/data/fate/aptx-hd.aptx_hd +6126e414af1acb193e24fdf33c7cac2e *tests/data/fate/aptx-hd.aptx_hd +628428 tests/data/fate/aptx-hd.aptx_hd #tb 0: 1/44100 #media_type 0: audio #codec_id 0: pcm_s32le From bbf045aa592f7bec895907c8878fd734a0e8713b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 19 Sep 2022 19:10:42 +0300 Subject: [PATCH 351/590] lavc/vorbisdec: use ptrdiff_t to iterate over intptr_t While this probably never overflows, we are better safe than sorry. The callback prototype should probably also use ptrdiff_t or size_t, but I diggress (this would affect the DSP callback prototype). --- libavcodec/ppc/vorbisdsp_altivec.c | 4 ++-- libavcodec/vorbisdec.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/ppc/vorbisdsp_altivec.c b/libavcodec/ppc/vorbisdsp_altivec.c index 4dabf2dc7d..c298d8cae3 100644 --- a/libavcodec/ppc/vorbisdsp_altivec.c +++ b/libavcodec/ppc/vorbisdsp_altivec.c @@ -31,12 +31,12 @@ static void vorbis_inverse_coupling_altivec(float *mag, float *ang, intptr_t blocksize) { - int i; vector float m, a; vector bool int t0, t1; const vector unsigned int v_31 = //XXX vec_add(vec_add(vec_splat_u32(15),vec_splat_u32(15)),vec_splat_u32(1)); - for (i = 0; i < blocksize; i += 4) { + + for (ptrdiff_t i = 0; i < blocksize; i += 4) { m = vec_ld(0, mag+i); a = vec_ld(0, ang+i); t0 = vec_cmple(m, (vector float)vec_splat_u32(0)); diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 38a5367be3..bfc4be6fc6 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1581,8 +1581,7 @@ static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, void ff_vorbis_inverse_coupling(float *mag, float *ang, intptr_t blocksize) { - int i; - for (i = 0; i < blocksize; i++) { + for (ptrdiff_t i = 0; i < blocksize; i++) { if (mag[i] > 0.0) { if (ang[i] > 0.0) { ang[i] = mag[i] - ang[i]; From b52034270a82ffc4aa584945c8a18aa8e58e741b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 19 Sep 2022 19:10:43 +0300 Subject: [PATCH 352/590] lavc/vorbisdsp: use ptrdiff_t rather than intptr_t ... for a difference between pointers. --- libavcodec/aarch64/vorbisdsp_init.c | 2 +- libavcodec/arm/vorbisdsp_init_arm.c | 2 +- libavcodec/ppc/vorbisdsp_altivec.c | 2 +- libavcodec/vorbis.h | 2 +- libavcodec/vorbisdec.c | 2 +- libavcodec/vorbisdsp.h | 4 ++-- libavcodec/x86/vorbisdsp_init.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/aarch64/vorbisdsp_init.c b/libavcodec/aarch64/vorbisdsp_init.c index c796f95e61..969343934b 100644 --- a/libavcodec/aarch64/vorbisdsp_init.c +++ b/libavcodec/aarch64/vorbisdsp_init.c @@ -22,7 +22,7 @@ #include "libavcodec/vorbisdsp.h" void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, - intptr_t blocksize); + ptrdiff_t blocksize); av_cold void ff_vorbisdsp_init_aarch64(VorbisDSPContext *c) { diff --git a/libavcodec/arm/vorbisdsp_init_arm.c b/libavcodec/arm/vorbisdsp_init_arm.c index f4b3d80ef6..acda34f468 100644 --- a/libavcodec/arm/vorbisdsp_init_arm.c +++ b/libavcodec/arm/vorbisdsp_init_arm.c @@ -25,7 +25,7 @@ #include "libavcodec/vorbisdsp.h" void ff_vorbis_inverse_coupling_neon(float *mag, float *ang, - intptr_t blocksize); + ptrdiff_t blocksize); av_cold void ff_vorbisdsp_init_arm(VorbisDSPContext *c) { diff --git a/libavcodec/ppc/vorbisdsp_altivec.c b/libavcodec/ppc/vorbisdsp_altivec.c index c298d8cae3..8f301705e9 100644 --- a/libavcodec/ppc/vorbisdsp_altivec.c +++ b/libavcodec/ppc/vorbisdsp_altivec.c @@ -29,7 +29,7 @@ #if HAVE_ALTIVEC static void vorbis_inverse_coupling_altivec(float *mag, float *ang, - intptr_t blocksize) + ptrdiff_t blocksize) { vector float m, a; vector bool int t0, t1; diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h index f80187feee..270855da04 100644 --- a/libavcodec/vorbis.h +++ b/libavcodec/vorbis.h @@ -45,7 +45,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num); void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint16_t *y_list, int *flag, int multiplier, float * out, int samples); -void ff_vorbis_inverse_coupling(float *mag, float *ang, intptr_t blocksize); +void ff_vorbis_inverse_coupling(float *mag, float *ang, ptrdiff_t blocksize); #define ilog(i) av_log2(2*(i)) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index bfc4be6fc6..10d187b82a 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1579,7 +1579,7 @@ static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, } } -void ff_vorbis_inverse_coupling(float *mag, float *ang, intptr_t blocksize) +void ff_vorbis_inverse_coupling(float *mag, float *ang, ptrdiff_t blocksize) { for (ptrdiff_t i = 0; i < blocksize; i++) { if (mag[i] > 0.0) { diff --git a/libavcodec/vorbisdsp.h b/libavcodec/vorbisdsp.h index 7abec4e4b7..1775a92cf2 100644 --- a/libavcodec/vorbisdsp.h +++ b/libavcodec/vorbisdsp.h @@ -19,12 +19,12 @@ #ifndef AVCODEC_VORBISDSP_H #define AVCODEC_VORBISDSP_H -#include +#include typedef struct VorbisDSPContext { /* assume len is a multiple of 4, and arrays are 16-byte aligned */ void (*vorbis_inverse_coupling)(float *mag, float *ang, - intptr_t blocksize); + ptrdiff_t blocksize); } VorbisDSPContext; void ff_vorbisdsp_init(VorbisDSPContext *dsp); diff --git a/libavcodec/x86/vorbisdsp_init.c b/libavcodec/x86/vorbisdsp_init.c index da9f9e685e..08a3bb2965 100644 --- a/libavcodec/x86/vorbisdsp_init.c +++ b/libavcodec/x86/vorbisdsp_init.c @@ -25,7 +25,7 @@ #include "libavcodec/vorbisdsp.h" void ff_vorbis_inverse_coupling_sse(float *mag, float *ang, - intptr_t blocksize); + ptrdiff_t blocksize); av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp) { From 5c15cb138eb1292bc16e64d3cb39953f1c09ce97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 19 Sep 2022 19:10:44 +0300 Subject: [PATCH 353/590] lavc/vorbisdec: use intermediate variables The compiler cannot infer that the two float vectors do not alias, causing unnecessary extra loads and serialisation. This patch caches the two input values in local variables so that compiler can optimise individual loop iterations. --- libavcodec/vorbisdec.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 10d187b82a..72b8e8e15b 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1581,22 +1581,22 @@ static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, void ff_vorbis_inverse_coupling(float *mag, float *ang, ptrdiff_t blocksize) { - for (ptrdiff_t i = 0; i < blocksize; i++) { - if (mag[i] > 0.0) { - if (ang[i] > 0.0) { - ang[i] = mag[i] - ang[i]; + for (ptrdiff_t i = 0; i < blocksize; i++) { + float angi = ang[i], magi = mag[i]; + + if (magi > 0.f) { + if (angi > 0.f) { + ang[i] = magi - angi; } else { - float temp = ang[i]; - ang[i] = mag[i]; - mag[i] += temp; + ang[i] = magi; + mag[i] = magi + angi; } } else { - if (ang[i] > 0.0) { - ang[i] += mag[i]; + if (angi > 0.f) { + ang[i] = magi + angi; } else { - float temp = ang[i]; - ang[i] = mag[i]; - mag[i] -= temp; + ang[i] = magi; + mag[i] = magi - angi; } } } From 32129d64953da1502a200e850ac0a559791824b9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 19 Sep 2022 19:13:28 +0200 Subject: [PATCH 354/590] avcodec/vorbisdec: Move ff_vorbis_inverse_coupling() to vorbisdsp.c Only used there. Also make it static. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt --- libavcodec/vorbis.h | 1 - libavcodec/vorbisdec.c | 23 ----------------------- libavcodec/vorbisdsp.c | 26 ++++++++++++++++++++++++-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h index 270855da04..0dd109dd2e 100644 --- a/libavcodec/vorbis.h +++ b/libavcodec/vorbis.h @@ -45,7 +45,6 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num); void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values, uint16_t *y_list, int *flag, int multiplier, float * out, int samples); -void ff_vorbis_inverse_coupling(float *mag, float *ang, ptrdiff_t blocksize); #define ilog(i) av_log2(2*(i)) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 72b8e8e15b..0d04e7c2c4 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1579,29 +1579,6 @@ static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr, } } -void ff_vorbis_inverse_coupling(float *mag, float *ang, ptrdiff_t blocksize) -{ - for (ptrdiff_t i = 0; i < blocksize; i++) { - float angi = ang[i], magi = mag[i]; - - if (magi > 0.f) { - if (angi > 0.f) { - ang[i] = magi - angi; - } else { - ang[i] = magi; - mag[i] = magi + angi; - } - } else { - if (angi > 0.f) { - ang[i] = magi + angi; - } else { - ang[i] = magi; - mag[i] = magi - angi; - } - } - } -} - // Decode the audio packet using the functions above static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr) diff --git a/libavcodec/vorbisdsp.c b/libavcodec/vorbisdsp.c index e94b65cb7b..693c44dfcb 100644 --- a/libavcodec/vorbisdsp.c +++ b/libavcodec/vorbisdsp.c @@ -19,11 +19,33 @@ #include "config.h" #include "libavutil/attributes.h" #include "vorbisdsp.h" -#include "vorbis.h" + +static void vorbis_inverse_coupling_c(float *mag, float *ang, ptrdiff_t blocksize) +{ + for (ptrdiff_t i = 0; i < blocksize; i++) { + float angi = ang[i], magi = mag[i]; + + if (magi > 0.f) { + if (angi > 0.f) { + ang[i] = magi - angi; + } else { + ang[i] = magi; + mag[i] = magi + angi; + } + } else { + if (angi > 0.f) { + ang[i] = magi + angi; + } else { + ang[i] = magi; + mag[i] = magi - angi; + } + } + } +} av_cold void ff_vorbisdsp_init(VorbisDSPContext *dsp) { - dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling; + dsp->vorbis_inverse_coupling = vorbis_inverse_coupling_c; #if ARCH_AARCH64 ff_vorbisdsp_init_aarch64(dsp); From 187cd278325ae2fc6d533141e7d6c557b669932a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 14 Sep 2022 21:03:15 +0200 Subject: [PATCH 355/590] avutil/dict: Error out in case of key == NULL Up until now, using NULL as key in av_dict_get() on a non-empty AVDictionary would crash; using NULL as key in av_dict_set() would also crash for a non-empty AVDictionary unless AV_DICT_MULTIKEY was set; in case the dictionary was initially empty or AV_DICT_MULTIKEY was set, it was even possible for av_dict_set() to succeed when adding a NULL key, namely when one uses a value != NULL and the AV_DICT_DONT_STRDUP_VAL flag. Using av_dict_get() on such an AVDictionary will usually lead to crashes, though. Fix this by actually checking for key in both functions; error out if they are NULL. While just at it, also stop relying on av_strdup(NULL) to return NULL in av_dict_set(). Signed-off-by: Andreas Rheinhardt --- libavutil/dict.c | 27 +++++++++++++++++---------- libavutil/tests/dict.c | 12 +++++++++--- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/libavutil/dict.c b/libavutil/dict.c index 4bba041d0a..14ad780a79 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -43,7 +43,7 @@ AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, { unsigned int i, j; - if (!m) + if (!m || !key) return NULL; if (prev) @@ -74,7 +74,16 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, AVDictionary *m = *pm; AVDictionaryEntry *tag = NULL; char *copy_key = NULL, *copy_value = NULL; + int err; + if (flags & AV_DICT_DONT_STRDUP_VAL) + copy_value = (void *)value; + else if (value) + copy_value = av_strdup(value); + if (!key) { + err = AVERROR(EINVAL); + goto err_out; + } if (!(flags & AV_DICT_MULTIKEY)) { tag = av_dict_get(m, key, NULL, flags); } @@ -82,14 +91,10 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, copy_key = (void *)key; else copy_key = av_strdup(key); - if (flags & AV_DICT_DONT_STRDUP_VAL) - copy_value = (void *)value; - else if (copy_key) - copy_value = av_strdup(value); if (!m) m = *pm = av_mallocz(sizeof(*m)); - if (!m || (key && !copy_key) || (value && !copy_value)) - goto err_out; + if (!m || !copy_key || (value && !copy_value)) + goto enomem; if (tag) { if (flags & AV_DICT_DONT_OVERWRITE) { @@ -103,7 +108,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, size_t len = oldlen + new_part_len + 1; char *newval = av_realloc(tag->value, len); if (!newval) - goto err_out; + goto enomem; memcpy(newval + oldlen, copy_value, new_part_len + 1); av_freep(©_value); copy_value = newval; @@ -115,7 +120,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, AVDictionaryEntry *tmp = av_realloc_array(m->elems, m->count + 1, sizeof(*m->elems)); if (!tmp) - goto err_out; + goto enomem; m->elems = tmp; } if (copy_value) { @@ -132,6 +137,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, return 0; +enomem: + err = AVERROR(ENOMEM); err_out: if (m && !m->count) { av_freep(&m->elems); @@ -139,7 +146,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, } av_free(copy_key); av_free(copy_value); - return AVERROR(ENOMEM); + return err; } int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c index 56e98557a7..d053545f4d 100644 --- a/libavutil/tests/dict.c +++ b/libavutil/tests/dict.c @@ -91,14 +91,20 @@ int main(void) av_dict_set(&dict, "f", NULL, 0); av_dict_set(&dict, "ff", "f", 0); av_dict_set(&dict, "ff", "f", AV_DICT_APPEND); + if (av_dict_get(dict, NULL, NULL, 0)) + printf("av_dict_get() does not correctly handle NULL key.\n"); e = NULL; while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) printf("%s %s\n", e->key, e->value); av_dict_free(&dict); - av_dict_set(&dict, NULL, "a", 0); - av_dict_set(&dict, NULL, "b", 0); - av_dict_get(dict, NULL, NULL, 0); + if (av_dict_set(&dict, NULL, "a", 0) >= 0 || + av_dict_set(&dict, NULL, "b", 0) >= 0 || + av_dict_set(&dict, NULL, NULL, AV_DICT_DONT_STRDUP_KEY) >= 0 || + av_dict_set(&dict, NULL, av_strdup("b"), AV_DICT_DONT_STRDUP_VAL) >= 0 || + av_dict_count(dict)) + printf("av_dict_set does not correctly handle NULL key\n"); + e = NULL; while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) printf("'%s' '%s'\n", e->key, e->value); From 4d7a1a4619c9ed89c5f6dbf8a0ae85b9a8aa056b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 8 Sep 2022 03:45:12 +0200 Subject: [PATCH 356/590] swscale/input: Avoid calls to av_pix_fmt_desc_get() Up until now, libswscale/input.c used a macro to read an input pixel which involved a call to av_pix_fmt_desc_get() to find out whether the input pixel format is BE or LE despite this being known at compile-time (there are templates per pixfmt). Even worse, these calls are made in a loop, so that e.g. there are six calls to av_pix_fmt_desc_get() for every pair of UV pixel processed in rgb64ToUV_half_c_template(). This commit modifies these macros to ensure that isBE() is evaluated at compile-time. This saved 9743B of .text for me (GCC 11.2, -O3). For a simple RGB64LE->YUV420P transformation like ffmpeg -f lavfi -i haldclutsrc,format=rgba64le -pix_fmt yuv420p \ -threads 1 -t 1:00 -f null - the amount of decicycles spent in rgb64LEToUV_half_c (which is created via the template mentioned above) decreases from 19751 to 5341; for RGBA64BE the number went down from 11945 to 5393. For shared builds (where the call to av_pix_fmt_desc_get() is indirect) the old numbers are 15230 for RGBA64BE and 27502 for RGBA64LE, whereas the numbers with this patch are indistinguishable from the numbers from a static build. Also make the macros that are touched conform to the usual convention of using uppercase names while just at it. Reviewed-by: Anton Khirnov Reviewed-by: Paul B Mahol Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt --- libswscale/input.c | 122 +++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 54 deletions(-) diff --git a/libswscale/input.c b/libswscale/input.c index 88e318e664..7ff7bfaa01 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -28,14 +28,21 @@ #include "config.h" #include "swscale_internal.h" -#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos)) +#define input_pixel(pos) (is_be ? AV_RB16(pos) : AV_RL16(pos)) + +#define IS_BE_LE 0 +#define IS_BE_BE 1 +#define IS_BE_ 0 +/* ENDIAN_IDENTIFIER needs to be "BE", "LE" or "". The latter is intended + * for single-byte cases where the concept of endianness does not apply. */ +#define IS_BE(ENDIAN_IDENTIFIER) IS_BE_ ## ENDIAN_IDENTIFIER #define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? b_r : r_b) #define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE || origin == AV_PIX_FMT_BGRA64BE || origin == AV_PIX_FMT_BGRA64LE) ? r_b : b_r) static av_always_inline void rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width, - enum AVPixelFormat origin, int32_t *rgb2yuv) + enum AVPixelFormat origin, int32_t *rgb2yuv, int is_be) { int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX]; int i; @@ -51,7 +58,7 @@ rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width, static av_always_inline void rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV, const uint16_t *src1, const uint16_t *src2, - int width, enum AVPixelFormat origin, int32_t *rgb2yuv) + int width, enum AVPixelFormat origin, int32_t *rgb2yuv, int is_be) { int i; int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; @@ -70,7 +77,7 @@ rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV, static av_always_inline void rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV, const uint16_t *src1, const uint16_t *src2, - int width, enum AVPixelFormat origin, int32_t *rgb2yuv) + int width, enum AVPixelFormat origin, int32_t *rgb2yuv, int is_be) { int i; int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; @@ -86,13 +93,13 @@ rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV, } } -#define rgb64funcs(pattern, BE_LE, origin) \ +#define RGB64FUNCS_EXT(pattern, BE_LE, origin, is_be) \ static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\ int width, uint32_t *rgb2yuv, void *opq) \ { \ const uint16_t *src = (const uint16_t *) _src; \ uint16_t *dst = (uint16_t *) _dst; \ - rgb64ToY_c_template(dst, src, width, origin, rgb2yuv); \ + rgb64ToY_c_template(dst, src, width, origin, rgb2yuv, is_be); \ } \ \ static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ @@ -102,7 +109,7 @@ static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ const uint16_t *src1 = (const uint16_t *) _src1, \ *src2 = (const uint16_t *) _src2; \ uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ - rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \ + rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \ } \ \ static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \ @@ -112,18 +119,20 @@ static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV const uint16_t *src1 = (const uint16_t *) _src1, \ *src2 = (const uint16_t *) _src2; \ uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \ - rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \ + rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \ } +#define RGB64FUNCS(pattern, endianness, base_fmt) \ + RGB64FUNCS_EXT(pattern, endianness, base_fmt ## endianness, IS_BE(endianness)) -rgb64funcs(rgb, LE, AV_PIX_FMT_RGBA64LE) -rgb64funcs(rgb, BE, AV_PIX_FMT_RGBA64BE) -rgb64funcs(bgr, LE, AV_PIX_FMT_BGRA64LE) -rgb64funcs(bgr, BE, AV_PIX_FMT_BGRA64BE) +RGB64FUNCS(rgb, LE, AV_PIX_FMT_RGBA64) +RGB64FUNCS(rgb, BE, AV_PIX_FMT_RGBA64) +RGB64FUNCS(bgr, LE, AV_PIX_FMT_BGRA64) +RGB64FUNCS(bgr, BE, AV_PIX_FMT_BGRA64) static av_always_inline void rgb48ToY_c_template(uint16_t *dst, const uint16_t *src, int width, enum AVPixelFormat origin, - int32_t *rgb2yuv) + int32_t *rgb2yuv, int is_be) { int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX]; int i; @@ -142,7 +151,7 @@ static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU, const uint16_t *src2, int width, enum AVPixelFormat origin, - int32_t *rgb2yuv) + int32_t *rgb2yuv, int is_be) { int i; int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; @@ -164,7 +173,7 @@ static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU, const uint16_t *src2, int width, enum AVPixelFormat origin, - int32_t *rgb2yuv) + int32_t *rgb2yuv, int is_be) { int i; int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX]; @@ -187,7 +196,7 @@ static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU, #undef b #undef input_pixel -#define rgb48funcs(pattern, BE_LE, origin) \ +#define RGB48FUNCS_EXT(pattern, BE_LE, origin, is_be) \ static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \ const uint8_t *_src, \ const uint8_t *unused0, const uint8_t *unused1,\ @@ -197,7 +206,7 @@ static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \ { \ const uint16_t *src = (const uint16_t *)_src; \ uint16_t *dst = (uint16_t *)_dst; \ - rgb48ToY_c_template(dst, src, width, origin, rgb2yuv); \ + rgb48ToY_c_template(dst, src, width, origin, rgb2yuv, is_be); \ } \ \ static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \ @@ -213,7 +222,7 @@ static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \ *src2 = (const uint16_t *)_src2; \ uint16_t *dstU = (uint16_t *)_dstU, \ *dstV = (uint16_t *)_dstV; \ - rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \ + rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \ } \ \ static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \ @@ -229,13 +238,15 @@ static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \ *src2 = (const uint16_t *)_src2; \ uint16_t *dstU = (uint16_t *)_dstU, \ *dstV = (uint16_t *)_dstV; \ - rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv); \ + rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin, rgb2yuv, is_be); \ } +#define RGB48FUNCS(pattern, endianness, base_fmt) \ + RGB48FUNCS_EXT(pattern, endianness, base_fmt ## endianness, IS_BE(endianness)) -rgb48funcs(rgb, LE, AV_PIX_FMT_RGB48LE) -rgb48funcs(rgb, BE, AV_PIX_FMT_RGB48BE) -rgb48funcs(bgr, LE, AV_PIX_FMT_BGR48LE) -rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE) +RGB48FUNCS(rgb, LE, AV_PIX_FMT_RGB48) +RGB48FUNCS(rgb, BE, AV_PIX_FMT_RGB48) +RGB48FUNCS(bgr, LE, AV_PIX_FMT_BGR48) +RGB48FUNCS(bgr, BE, AV_PIX_FMT_BGR48) #define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \ origin == AV_PIX_FMT_BGRA || \ @@ -245,7 +256,7 @@ rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE) : ((origin == AV_PIX_FMT_X2RGB10LE || \ origin == AV_PIX_FMT_X2BGR10LE) \ ? AV_RL32(&src[(i) * 4]) \ - : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \ + : (is_be ? AV_RB16(&src[(i) * 2]) \ : AV_RL16(&src[(i) * 2])))) static av_always_inline void rgb16_32ToY_c_template(int16_t *dst, @@ -257,7 +268,7 @@ static av_always_inline void rgb16_32ToY_c_template(int16_t *dst, int maskr, int maskg, int maskb, int rsh, int gsh, int bsh, int S, - int32_t *rgb2yuv) + int32_t *rgb2yuv, int is_be) { const int ry = rgb2yuv[RY_IDX]< Date: Thu, 8 Sep 2022 05:10:16 +0200 Subject: [PATCH 357/590] swscale/output: Don't call av_pix_fmt_desc_get() in a loop Up until now, libswscale/output.c used a macro to write an output pixel which involved a call to av_pix_fmt_desc_get() to find out whether the input pixel format is BE or LE despite this being known at compile-time (there are templates per pixfmt). Even worse, these calls are made in a loop, so that e.g. there are eight calls to av_pix_fmt_desc_get() for every pixel processed in yuv2rgba64_X_c_template() for 64bit RGB formats. This commit modifies these macros to ensure that isBE() is evaluated at compile-time. This saved 41184B of .text for me (GCC 11.2, -O3). Of course, it also improved performance. E.g. ffmpeg_g -f lavfi -i testsrc2,format=yuva420p -pix_fmt rgba64le \ -threads 1 -t 1:00 -f null - (which uses yuv2rgba64le_X_c, which is an invocation of yuv2rgba64_X_c_template() mentioned above), performance improved from 95589 to 41387 decicycles for one call to yuv2packedX; for the be variant the numbers went down from 76087 to 43024 decicycles. Reviewed-by: Anton Khirnov Reviewed-by: Paul B Mahol Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt --- libswscale/output.c | 100 +++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/libswscale/output.c b/libswscale/output.c index 2f599698e9..0e1c1225a0 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -133,6 +133,11 @@ DECLARE_ALIGNED(8, const uint8_t, ff_dither_8x8_220)[][8] = { }; #endif +#define IS_BE_LE 0 +#define IS_BE_BE 1 +/* ENDIAN_IDENTIFIER needs to be "BE" or "LE". */ +#define IS_BE(ENDIAN_IDENTIFIER) IS_BE_ ## ENDIAN_IDENTIFIER + #define output_pixel(pos, val, bias, signedness) \ if (big_endian) { \ AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \ @@ -935,7 +940,7 @@ YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422) #define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? R : B) #define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE || target == AV_PIX_FMT_RGBA64LE || target == AV_PIX_FMT_RGBA64BE) ? B : R) #define output_pixel(pos, val) \ - if (isBE(target)) { \ + if (is_be) { \ AV_WB16(pos, val); \ } else { \ AV_WL16(pos, val); \ @@ -947,7 +952,8 @@ yuv2ya16_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int32_t **unused_chrUSrc, const int32_t **unused_chrVSrc, int unused_chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, - int y, enum AVPixelFormat target, int unused_hasAlpha, int unused_eightbytes) + int y, enum AVPixelFormat target, + int unused_hasAlpha, int unused_eightbytes, int is_be) { int hasAlpha = !!alpSrc; int i; @@ -984,7 +990,8 @@ yuv2ya16_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int unused_uvalpha, int y, - enum AVPixelFormat target, int unused_hasAlpha, int unused_eightbytes) + enum AVPixelFormat target, int unused_hasAlpha, + int unused_eightbytes, int is_be) { int hasAlpha = abuf && abuf[0] && abuf[1]; const int32_t *buf0 = buf[0], *buf1 = buf[1], @@ -1015,7 +1022,8 @@ static av_always_inline void yuv2ya16_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, - int unused_uvalpha, int y, enum AVPixelFormat target, int unused_hasAlpha, int unused_eightbytes) + int unused_uvalpha, int y, enum AVPixelFormat target, + int unused_hasAlpha, int unused_eightbytes, int is_be) { int hasAlpha = !!abuf0; int i; @@ -1043,7 +1051,8 @@ yuv2rgba64_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, - int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) + int y, enum AVPixelFormat target, int hasAlpha, int eightbytes, + int is_be) { int i; int A1 = 0xffff<<14, A2 = 0xffff<<14; @@ -1124,7 +1133,8 @@ yuv2rgba64_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, - enum AVPixelFormat target, int hasAlpha, int eightbytes) + enum AVPixelFormat target, int hasAlpha, int eightbytes, + int is_be) { const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], @@ -1188,7 +1198,8 @@ static av_always_inline void yuv2rgba64_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, - int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) + int uvalpha, int y, enum AVPixelFormat target, + int hasAlpha, int eightbytes, int is_be) { const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; int i; @@ -1293,7 +1304,8 @@ yuv2rgba64_full_X_c_template(SwsContext *c, const int16_t *lumFilter, const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest, int dstW, - int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) + int y, enum AVPixelFormat target, int hasAlpha, + int eightbytes, int is_be) { int i; int A = 0xffff<<14; @@ -1356,7 +1368,8 @@ yuv2rgba64_full_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, int yalpha, int uvalpha, int y, - enum AVPixelFormat target, int hasAlpha, int eightbytes) + enum AVPixelFormat target, int hasAlpha, int eightbytes, + int is_be) { const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], @@ -1407,7 +1420,8 @@ static av_always_inline void yuv2rgba64_full_1_c_template(SwsContext *c, const int32_t *buf0, const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf0, uint16_t *dest, int dstW, - int uvalpha, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) + int uvalpha, int y, enum AVPixelFormat target, + int hasAlpha, int eightbytes, int is_be) { const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0]; int i; @@ -1484,7 +1498,7 @@ yuv2rgba64_full_1_c_template(SwsContext *c, const int32_t *buf0, #undef r_b #undef b_r -#define YUV2PACKED16WRAPPER(name, base, ext, fmt, hasAlpha, eightbytes) \ +#define YUV2PACKED16WRAPPER_EXT(name, base, ext, fmt, is_be, hasAlpha, eightbytes) \ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ const int16_t **_lumSrc, int lumFilterSize, \ const int16_t *chrFilter, const int16_t **_chrUSrc, \ @@ -1499,7 +1513,7 @@ static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \ uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes); \ + alpSrc, dest, dstW, y, fmt, hasAlpha, eightbytes, is_be); \ } \ \ static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \ @@ -1513,7 +1527,7 @@ static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \ **abuf = (const int32_t **) _abuf; \ uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \ - dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes); \ + dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \ } \ \ static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ @@ -1527,36 +1541,38 @@ static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \ *abuf0 = (const int32_t *) _abuf0; \ uint16_t *dest = (uint16_t *) _dest; \ name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \ - dstW, uvalpha, y, fmt, hasAlpha, eightbytes); \ + dstW, uvalpha, y, fmt, hasAlpha, eightbytes, is_be); \ } - -YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48be, AV_PIX_FMT_RGB48BE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48le, AV_PIX_FMT_RGB48LE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48be, AV_PIX_FMT_BGR48BE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48le, AV_PIX_FMT_BGR48LE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64be, AV_PIX_FMT_RGBA64BE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64le, AV_PIX_FMT_RGBA64LE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64be, AV_PIX_FMT_RGBA64BE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64le, AV_PIX_FMT_RGBA64LE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64BE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64LE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64BE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64LE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, ya16, ya16be, AV_PIX_FMT_YA16BE, 1, 0) -YUV2PACKED16WRAPPER(yuv2, ya16, ya16le, AV_PIX_FMT_YA16LE, 1, 0) - -YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48be_full, AV_PIX_FMT_RGB48BE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48le_full, AV_PIX_FMT_RGB48LE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48be_full, AV_PIX_FMT_BGR48BE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48le_full, AV_PIX_FMT_BGR48LE, 0, 0) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64be_full, AV_PIX_FMT_RGBA64BE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64le_full, AV_PIX_FMT_RGBA64LE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64be_full, AV_PIX_FMT_RGBA64BE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64le_full, AV_PIX_FMT_RGBA64LE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64be_full, AV_PIX_FMT_BGRA64BE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64le_full, AV_PIX_FMT_BGRA64LE, 1, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64be_full, AV_PIX_FMT_BGRA64BE, 0, 1) -YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64le_full, AV_PIX_FMT_BGRA64LE, 0, 1) +#define YUV2PACKED16WRAPPER(name, base, ext, base_fmt, endianness, hasAlpha, eightbytes) \ + YUV2PACKED16WRAPPER_EXT(name, base, ext, base_fmt ## endianness, IS_BE(endianness), hasAlpha, eightbytes) + +YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48be, AV_PIX_FMT_RGB48, BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgb48le, AV_PIX_FMT_RGB48, LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48be, AV_PIX_FMT_BGR48, BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgr48le, AV_PIX_FMT_BGR48, LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64be, AV_PIX_FMT_RGBA64, BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgba64le, AV_PIX_FMT_RGBA64, LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64be, AV_PIX_FMT_RGBA64, BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, rgbx64le, AV_PIX_FMT_RGBA64, LE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64be, AV_PIX_FMT_BGRA64, BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgra64le, AV_PIX_FMT_BGRA64, LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64be, AV_PIX_FMT_BGRA64, BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64, bgrx64le, AV_PIX_FMT_BGRA64, LE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, ya16, ya16be, AV_PIX_FMT_YA16, BE, 1, 0) +YUV2PACKED16WRAPPER(yuv2, ya16, ya16le, AV_PIX_FMT_YA16, LE, 1, 0) + +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48be_full, AV_PIX_FMT_RGB48, BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgb48le_full, AV_PIX_FMT_RGB48, LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48be_full, AV_PIX_FMT_BGR48, BE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgr48le_full, AV_PIX_FMT_BGR48, LE, 0, 0) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64be_full, AV_PIX_FMT_RGBA64, BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgba64le_full, AV_PIX_FMT_RGBA64, LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64be_full, AV_PIX_FMT_RGBA64, BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, rgbx64le_full, AV_PIX_FMT_RGBA64, LE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64be_full, AV_PIX_FMT_BGRA64, BE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgra64le_full, AV_PIX_FMT_BGRA64, LE, 1, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64be_full, AV_PIX_FMT_BGRA64, BE, 0, 1) +YUV2PACKED16WRAPPER(yuv2, rgba64_full, bgrx64le_full, AV_PIX_FMT_BGRA64, LE, 0, 1) /* * Write out 2 RGB pixels in the target pixel format. This function takes a From 118b36f418fb050aebecd0c868b04bdc45293012 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 14 Apr 2022 16:43:53 +0200 Subject: [PATCH 358/590] avcodec/mjpegdec: Avoid copying data when flipping image Basically reverts af15c17daa5d8d2940c0263ba4d3ecec761c11ee. Flipping a picture by modifying the pointers is so common that even users of direct rendering should take it into account. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 65337360b0..ca7e752f16 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2770,28 +2770,18 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) } } if (s->flipped && !s->rgb) { - int j; ret = av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift); if (ret) return ret; - av_assert0(s->nb_components == av_pix_fmt_count_planes(s->picture_ptr->format)); + av_assert0(s->nb_components == av_pix_fmt_count_planes(frame->format)); for (index=0; indexnb_components; index++) { - uint8_t *dst = s->picture_ptr->data[index]; - int w = s->picture_ptr->width; - int h = s->picture_ptr->height; - if(index && index<3){ - w = AV_CEIL_RSHIFT(w, hshift); + int h = frame->height; + if (index && index < 3) h = AV_CEIL_RSHIFT(h, vshift); - } - if(dst){ - uint8_t *dst2 = dst + s->picture_ptr->linesize[index]*(h-1); - for (i=0; ipicture_ptr->linesize[index]; - dst2 -= s->picture_ptr->linesize[index]; - } + if (frame->data[index]) { + frame->data[index] += (h - 1) * frame->linesize[index]; + frame->linesize[index] *= -1; } } } From 8f119b501eaa1d813ea57b2dfc545d1e114f19a1 Mon Sep 17 00:00:00 2001 From: James Almer Date: Mon, 19 Sep 2022 13:56:34 -0300 Subject: [PATCH 359/590] tests/checkasm: add a test for VorbisDSPContext Signed-off-by: James Almer --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/vorbisdsp.c | 87 ++++++++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 93 insertions(+) create mode 100644 tests/checkasm/vorbisdsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 1ac170491b..ac02670e64 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -31,6 +31,7 @@ AVCODECOBJS-$(CONFIG_HEVC_DECODER) += hevc_add_res.o hevc_idct.o hevc_sao.o AVCODECOBJS-$(CONFIG_UTVIDEO_DECODER) += utvideodsp.o AVCODECOBJS-$(CONFIG_V210_DECODER) += v210dec.o AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o +AVCODECOBJS-$(CONFIG_VORBIS_DECODER) += vorbisdsp.o AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9dsp.o CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e56fd3850e..6b4a0f22b2 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -165,6 +165,9 @@ static const struct { #if CONFIG_VIDEODSP { "videodsp", checkasm_check_videodsp }, #endif + #if CONFIG_VORBIS_DECODER + { "vorbisdsp", checkasm_check_vorbisdsp }, + #endif #endif #if CONFIG_AVFILTER #if CONFIG_AFIR_FILTER diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index d7645d3730..171dd06b47 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -88,6 +88,7 @@ void checkasm_check_vf_threshold(void); void checkasm_check_vp8dsp(void); void checkasm_check_vp9dsp(void); void checkasm_check_videodsp(void); +void checkasm_check_vorbisdsp(void); struct CheckasmPerf; diff --git a/tests/checkasm/vorbisdsp.c b/tests/checkasm/vorbisdsp.c new file mode 100644 index 0000000000..b055742519 --- /dev/null +++ b/tests/checkasm/vorbisdsp.c @@ -0,0 +1,87 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include + +#include "libavutil/mem_internal.h" + +#include "libavcodec/vorbisdsp.h" + +#include "checkasm.h" + +#define LEN 512 + +#define randomize_buffer(buf) \ +do { \ + double bmg[2], stddev = 10.0, mean = 0.0; \ + \ + for (int i = 0; i < LEN; i += 2) { \ + av_bmg_get(&checkasm_lfg, bmg); \ + buf[i] = bmg[0] * stddev + mean; \ + buf[i + 1] = bmg[1] * stddev + mean; \ + } \ +} while(0); + +static void test_inverse_coupling(void) +{ + LOCAL_ALIGNED_16(float, src0, [LEN]); + LOCAL_ALIGNED_16(float, src1, [LEN]); + LOCAL_ALIGNED_16(float, cdst, [LEN]); + LOCAL_ALIGNED_16(float, odst, [LEN]); + LOCAL_ALIGNED_16(float, cdst1, [LEN]); + LOCAL_ALIGNED_16(float, odst1, [LEN]); + + declare_func(void, float *av_restrict mag, float *av_restrict ang, + ptrdiff_t blocksize); + + randomize_buffer(src0); + randomize_buffer(src1); + + memcpy(cdst, src0, LEN * sizeof(*src0)); + memcpy(cdst1, src1, LEN * sizeof(*src1)); + memcpy(odst, src0, LEN * sizeof(*src0)); + memcpy(odst1, src1, LEN * sizeof(*src1)); + + call_ref(cdst, cdst1, LEN); + call_new(odst, odst1, LEN); + for (int i = 0; i < LEN; i++) { + if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON) || + !float_near_abs_eps(cdst1[i], odst1[i], FLT_EPSILON)) { + fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", + i, cdst[i], odst[i], cdst[i] - odst[i]); + fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", + i, cdst1[i], odst1[i], cdst1[i] - odst1[i]); + fail(); + break; + } + } + bench_new(src0, src1, LEN); +} + +void checkasm_check_vorbisdsp(void) +{ + VorbisDSPContext dsp; + + ff_vorbisdsp_init(&dsp); + + if (check_func(dsp.vorbis_inverse_coupling, "inverse_coupling")) + test_inverse_coupling(); + report("inverse_coupling"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 4d2f321e84..fbba0b5b8f 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -43,6 +43,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ fate-checkasm-vf_nlmeans \ fate-checkasm-vf_threshold \ fate-checkasm-videodsp \ + fate-checkasm-vorbisdsp \ fate-checkasm-vp8dsp \ fate-checkasm-vp9dsp \ From 56e29fcac2c8ea320a60543accbaf8c23697f020 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 7 Sep 2022 15:06:49 +0200 Subject: [PATCH 360/590] tests/mxf: Fix test requirements Signed-off-by: Andreas Rheinhardt --- tests/fate/mxf.mak | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/tests/fate/mxf.mak b/tests/fate/mxf.mak index 3ab936b5de..3f13170eb9 100644 --- a/tests/fate/mxf.mak +++ b/tests/fate/mxf.mak @@ -1,17 +1,15 @@ -FATE_MXF += fate-mxf-missing-index-demux +FATE_MXF-$(call DEMMUX, MXF, CRC, PIPE_PROTOCOL) += fate-mxf-missing-index-demux fate-mxf-missing-index-demux: CMD = crc -i $(TARGET_SAMPLES)/mxf/opatom_missing_index.mxf -c:a copy -FATE_MXF += fate-mxf-essencegroup-demux +FATE_MXF-$(call FRAMECRC, MXF,) += fate-mxf-essencegroup-demux fate-mxf-essencegroup-demux: CMD = framecrc -i $(TARGET_SAMPLES)/mxf/opatom_essencegroup_alpha_raw.mxf -c:v copy -FATE_MXF += fate-mxf-multiple-components-demux +FATE_MXF-$(call FRAMECRC, MXF,) += fate-mxf-multiple-components-demux fate-mxf-multiple-components-demux: CMD = framecrc -i $(TARGET_SAMPLES)/mxf/multiple_components.mxf -c:v copy -FATE_MXF += fate-mxf-metadata-source-ref1 +FATE_MXF-$(call DEMMUX, MXF, FFMETADATA, PIPE_PROTOCOL) += fate-mxf-metadata-source-ref1 fate-mxf-metadata-source-ref2 fate-mxf-metadata-source-ref1: CMD = fmtstdout ffmetadata -i $(TARGET_SAMPLES)/mxf/track_01_v02.mxf -fflags +bitexact -flags +bitexact -map 0:0 -map 0:2 -map 0:3 -map_metadata:g -1 - -FATE_MXF += fate-mxf-metadata-source-ref2 fate-mxf-metadata-source-ref2: CMD = fmtstdout ffmetadata -i $(TARGET_SAMPLES)/mxf/track_02_a01.mxf -fflags +bitexact -flags +bitexact -map 0:0 -map 0:1 -map 0:3 -map_metadata:g -1 # @@ -21,42 +19,34 @@ PROBE_FORMAT_STREAMS_COMMAND = \ ffprobe$(PROGSSUF)$(EXESUF) -show_entries format=format_name,duration,bit_rate:format_tags:streams:stream_tags \ -print_format default -bitexact -v 0 -FATE_MXF_PROBE-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += fate-mxf-probe-d10 +FATE_MXF_PROBE-$(call DEMDEC, MXF, MPEG2VIDEO PCM_S16LE, MPEGVIDEO_PARSER EXTRACT_EXTRADATA_BSF) += fate-mxf-probe-d10 fate-mxf-probe-d10: SRC = $(TARGET_SAMPLES)/mxf/Sony-00001.mxf fate-mxf-probe-d10: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" -FATE_MXF_PROBE-$(call ENCDEC, DNXHD, MXF) += fate-mxf-probe-dnxhd +FATE_MXF_PROBE-$(call DEMDEC, MXF, DNXHD) += fate-mxf-probe-dnxhd fate-mxf-probe-dnxhd: SRC = $(TARGET_SAMPLES)/mxf/multiple_components.mxf fate-mxf-probe-dnxhd: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" -FATE_MXF_PROBE-$(call ENCDEC2, DVVIDEO, PCM_S16LE, MXF) += fate-mxf-probe-dv25 +FATE_MXF_PROBE-$(call DEMDEC, MXF, DVVIDEO PCM_S16LE) += fate-mxf-probe-dv25 fate-mxf-probe-dv25: SRC = $(TARGET_SAMPLES)/mxf/Avid-00005.mxf fate-mxf-probe-dv25: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" -FATE_MXF_PROBE-$(call ENCDEC2, PRORES, PCM_S24LE, MXF) += fate-mxf-probe-applehdr10 +FATE_MXF_PROBE-$(call DEMDEC, MXF, PRORES PCM_S24LE) += fate-mxf-probe-applehdr10 fate-mxf-probe-applehdr10: SRC = $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf fate-mxf-probe-applehdr10: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" | sed -e "s/yuv422p10../yuv422p10/" -FATE_MXF_REEL_NAME-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += fate-mxf-reel_name -fate-mxf-reel_name: $(SAMPLES)/mxf/Sony-00001.mxf +FATE_MXF-$(call DEMMUX, MXF, MXF, MPEGVIDEO_PARSER MPEG2VIDEO_DECODER) += fate-mxf-reel_name fate-mxf-user-comments fate-mxf-reel_name: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -c copy -timecode 00:00:00:00 -metadata "reel_name=test_reel" -fflags +bitexact -f mxf - -FATE_MXF_USER_COMMENTS-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += fate-mxf-user-comments -fate-mxf-user-comments: $(SAMPLES)/mxf/Sony-00001.mxf fate-mxf-user-comments: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -c copy -metadata "comment_test=value" -fflags +bitexact -f mxf -FATE_MXF_D10_USER_COMMENTS-$(call ALLYES, FILE_PROTOCOL MXF_DEMUXER DVVIDEO_DECODER SCALE_FILTER MPEG2VIDEO_ENCODER MXF_D10_MUXER EXTRACT_EXTRADATA_BSF MPEGVIDEO_PARSER PIPE_PROTOCOL FRAMECRC_MUXER) += fate-mxf-d10-user-comments +FATE_MXF_FFMPEG_FFPROBE-$(call REMUX, MXF_D10 MXF, DVVIDEO_DECODER SCALE_FILTER MPEG2VIDEO_ENCODER EXTRACT_EXTRADATA_BSF MPEGVIDEO_PARSER) += fate-mxf-d10-user-comments fate-mxf-d10-user-comments: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Avid-00005.mxf mxf_d10 "-c:v mpeg2video -b:v 30000k -minrate:v 30000k -maxrate:v 30000k -bufsize:v 30000k -rc_init_occupancy 30000k -vf scale=w=1280:h=720 -an -metadata comment_test=value -metadata company_name=FATE-company -metadata product_name=FATE-test -metadata product_version=3.14159 -store_user_comments 1" "-c copy -frames:v 5" "-show_entries format_tags" -FATE_MXF_OPATOM_USER_COMMENTS-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += fate-mxf-opatom-user-comments -fate-mxf-opatom-user-comments: $(SAMPLES)/mxf/Sony-00001.mxf +FATE_MXF-$(call DEMMUX, MXF, MXF_OPATOM, MPEGVIDEO_PARSER MPEG2VIDEO_DECODER) += fate-mxf-opatom-user-comments fate-mxf-opatom-user-comments: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -an -vcodec copy -metadata "comment_test=value" -fflags +bitexact -f mxf_opatom -FATE_MXF-$(CONFIG_MXF_DEMUXER) += $(FATE_MXF) - -FATE_SAMPLES_AVCONV += $(FATE_MXF-yes) $(FATE_MXF_REEL_NAME-yes) -FATE_SAMPLES_AVCONV += $(FATE_MXF_USER_COMMENTS-yes) $(FATE_MXF_OPATOM_USER_COMMENTS-yes) -FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MXF_D10_USER_COMMENTS-yes) +FATE_SAMPLES_FFMPEG += $(FATE_MXF-yes) +FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_MXF_FFMPEG_FFPROBE-yes) FATE_SAMPLES_FFPROBE += $(FATE_MXF_PROBE-yes) -fate-mxf: $(FATE_MXF-yes) $(FATE_MXF_PROBE-yes) $(FATE_MXF_REEL_NAME-yes) $(FATE_MXF_USER_COMMENTS-yes) $(FATE_MXF_D10_USER_COMMENTS-yes) $(FATE_MXF_OPATOM_USER_COMMENTS-yes) +fate-mxf: $(FATE_MXF-yes) $(FATE_MXF_PROBE-yes) $(FATE_MXF_FFMPEG_FFPROBE-yes) From f08d529e1110e3afc59a941706a13658211dd3a3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 8 Nov 2021 16:54:14 +0100 Subject: [PATCH 361/590] fate/mxf: Add ProRes remux test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also covers writing mastering display metadata. Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- tests/fate/mxf.mak | 4 ++ tests/ref/fate/mxf-remux-applehdr10 | 67 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/ref/fate/mxf-remux-applehdr10 diff --git a/tests/fate/mxf.mak b/tests/fate/mxf.mak index 3f13170eb9..41c47f84f8 100644 --- a/tests/fate/mxf.mak +++ b/tests/fate/mxf.mak @@ -35,6 +35,10 @@ FATE_MXF_PROBE-$(call DEMDEC, MXF, PRORES PCM_S24LE) += fate-mxf-probe-applehdr1 fate-mxf-probe-applehdr10: SRC = $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf fate-mxf-probe-applehdr10: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" | sed -e "s/yuv422p10../yuv422p10/" +# Tests remuxing ProRes as well as writing mastering display metadata. +FATE_MXF_FFMPEG_FFPROBE-$(call REMUX, MXF, PRORES_DECODER) += fate-mxf-remux-applehdr10 +fate-mxf-remux-applehdr10: CMD = transcode mxf $(TARGET_SAMPLES)/mxf/Meridian-Apple_ProResProxy-HDR10.mxf mxf "-map 0 -c copy" "-c copy -t 0.3" "-show_entries format_tags:stream_side_data_list:stream=index,codec_name,codec_tag:stream_tags" + FATE_MXF-$(call DEMMUX, MXF, MXF, MPEGVIDEO_PARSER MPEG2VIDEO_DECODER) += fate-mxf-reel_name fate-mxf-user-comments fate-mxf-reel_name: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -c copy -timecode 00:00:00:00 -metadata "reel_name=test_reel" -fflags +bitexact -f mxf fate-mxf-user-comments: CMD = md5 -y -i $(TARGET_SAMPLES)/mxf/Sony-00001.mxf -c copy -metadata "comment_test=value" -fflags +bitexact -f mxf diff --git a/tests/ref/fate/mxf-remux-applehdr10 b/tests/ref/fate/mxf-remux-applehdr10 new file mode 100644 index 0000000000..29e0e03a72 --- /dev/null +++ b/tests/ref/fate/mxf-remux-applehdr10 @@ -0,0 +1,67 @@ +5e03bad42adeb396b6614890f30aefba *tests/data/fate/mxf-remux-applehdr10.mxf +323641 tests/data/fate/mxf-remux-applehdr10.mxf +#tb 0: 1001/60000 +#media_type 0: video +#codec_id 0: prores +#dimensions 0: 1280x720 +#sar 0: 1/1 +#tb 1: 1/48000 +#media_type 1: audio +#codec_id 1: pcm_s24le +#sample_rate 1: 48000 +#channel_layout_name 1: mono +0, 0, 0, 1, 57008, 0x43416399, S=1, 88 +1, 0, 0, 801, 2403, 0x00000000 +0, 1, 1, 1, 57248, 0xa06cd7b5 +1, 801, 801, 801, 2403, 0x00000000 +0, 2, 2, 1, 57200, 0x5623da10 +1, 1602, 1602, 800, 2400, 0x00000000 +1, 2402, 2402, 801, 2403, 0x00000000 +0, 3, 3, 1, 57152, 0x52d89d3f +1, 3203, 3203, 801, 2403, 0x00000000 +0, 4, 4, 1, 56960, 0x431d5189 +[STREAM] +index=0 +codec_name=prores +codec_tag=0x6f637061 +TAG:file_package_umid=0x060A2B340101010501010D001300000000000000000000000000000000000001 +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=34000/50000 +red_y=16000/50000 +green_x=13250/50000 +green_y=34500/50000 +blue_x=7500/50000 +blue_y=3000/50000 +white_point_x=15635/50000 +white_point_y=16450/50000 +min_luminance=0/10000 +max_luminance=10000000/10000 +[/SIDE_DATA] +[/STREAM] +[STREAM] +index=1 +codec_name=pcm_s24le +codec_tag=0x0000 +TAG:file_package_umid=0x060A2B340101010501010D001300000000000000000000000000000000000001 +[/STREAM] +[STREAM] +index=2 +codec_name=pcm_s24le +codec_tag=0x0000 +TAG:file_package_umid=0x060A2B340101010501010D001300000000000000000000000000000000000001 +[/STREAM] +[FORMAT] +TAG:operational_pattern_ul=060e2b34.04010101.0d010201.01010900 +TAG:uid=adab4424-2f25-4dc7-92ff-000c00000000 +TAG:generation_uid=adab4424-2f25-4dc7-92ff-000c00000001 +TAG:company_name=FFmpeg +TAG:product_name=OP1a Muxer +TAG:product_version_num=0.0.0.0.0 +TAG:product_version=0.0.0 +TAG:application_platform=Lavf +TAG:product_uid=adab4424-2f25-4dc7-92ff-29bd000c0002 +TAG:toolkit_version_num=0.0.0.0.0 +TAG:material_package_umid=0x060A2B340101010501010D001300000000000000000000000000000000000000 +TAG:timecode=00:01:15;26 +[/FORMAT] From 48fa27e77a6d71be89f216cee13ae7e99d2b5003 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Tue, 6 Sep 2022 14:51:44 -0700 Subject: [PATCH 362/590] avformat/mxf: set stream frame rates for ST 422 essence containers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MXF demuxer does not currently set AVStream::avg_frame_rate and ::r_frame_rate when J2K essence is wrapped according to SMPTE ST 422. Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- libavformat/mxfdec.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index e63e803aa5..19cddf08d3 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2141,6 +2141,13 @@ static int mxf_compute_index_tables(MXFContext *mxf) return ret; } +static int mxf_is_st_422(const UID *essence_container_ul) { + static const uint8_t st_422_essence_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0c }; + + return essence_container_ul && mxf_match_uid(*essence_container_ul, st_422_essence_container_ul, + sizeof(st_422_essence_container_ul)); +} + static int mxf_is_intra_only(MXFDescriptor *descriptor) { return mxf_get_codec_ul(mxf_intra_only_essence_container_uls, @@ -2893,6 +2900,24 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) av_log(mxf->fc, AV_LOG_INFO, "Unknown frame layout type: %d\n", descriptor->frame_layout); } + if (mxf_is_st_422(essence_container_ul)) { + switch ((*essence_container_ul)[14]) { + case 2: /* Cn: Clip- wrapped Picture Element */ + case 3: /* I1: Interlaced Frame, 1 field/KLV */ + case 4: /* I2: Interlaced Frame, 2 fields/KLV */ + case 6: /* P1: Frame- wrapped Picture Element */ + st->avg_frame_rate = source_track->edit_rate; + st->r_frame_rate = st->avg_frame_rate; + break; + case 5: /* F1: Field-wrapped Picture Element */ + st->avg_frame_rate = av_mul_q(av_make_q(2, 1), source_track->edit_rate); + st->r_frame_rate = st->avg_frame_rate; + break; + default: + break; + } + } + if (st->codecpar->codec_id == AV_CODEC_ID_PRORES) { switch (descriptor->essence_codec_ul[14]) { case 1: st->codecpar->codec_tag = MKTAG('a','p','c','o'); break; From 79845ce6cf4d0192ebe99bf57b3f7e9b94726667 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Tue, 6 Sep 2022 14:51:45 -0700 Subject: [PATCH 363/590] fate/mxf: add JPEG 2000 test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- tests/fate/mxf.mak | 4 ++ tests/ref/fate/mxf-probe-j2k | 78 ++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 tests/ref/fate/mxf-probe-j2k diff --git a/tests/fate/mxf.mak b/tests/fate/mxf.mak index 41c47f84f8..8430b01d51 100644 --- a/tests/fate/mxf.mak +++ b/tests/fate/mxf.mak @@ -27,6 +27,10 @@ FATE_MXF_PROBE-$(call DEMDEC, MXF, DNXHD) += fate-mxf-probe-dnxhd fate-mxf-probe-dnxhd: SRC = $(TARGET_SAMPLES)/mxf/multiple_components.mxf fate-mxf-probe-dnxhd: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" +FATE_MXF_PROBE-$(call DEMDEC, MXF, JPEG2000) += fate-mxf-probe-j2k +fate-mxf-probe-j2k: SRC = $(TARGET_SAMPLES)/imf/countdown/countdown-small.mxf +fate-mxf-probe-j2k: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" + FATE_MXF_PROBE-$(call DEMDEC, MXF, DVVIDEO PCM_S16LE) += fate-mxf-probe-dv25 fate-mxf-probe-dv25: SRC = $(TARGET_SAMPLES)/mxf/Avid-00005.mxf fate-mxf-probe-dv25: CMD = run $(PROBE_FORMAT_STREAMS_COMMAND) -i "$(SRC)" diff --git a/tests/ref/fate/mxf-probe-j2k b/tests/ref/fate/mxf-probe-j2k new file mode 100644 index 0000000000..2dbf2ac37d --- /dev/null +++ b/tests/ref/fate/mxf-probe-j2k @@ -0,0 +1,78 @@ +[STREAM] +index=0 +codec_name=jpeg2000 +profile=1798 +codec_type=video +codec_tag_string=[0][0][0][0] +codec_tag=0x0000 +width=640 +height=360 +coded_width=640 +coded_height=360 +closed_captions=0 +film_grain=0 +has_b_frames=0 +sample_aspect_ratio=1:1 +display_aspect_ratio=16:9 +pix_fmt=rgb48le +level=-99 +color_range=unknown +color_space=unknown +color_transfer=bt709 +color_primaries=bt709 +chroma_location=unspecified +field_order=progressive +refs=1 +id=N/A +r_frame_rate=24/1 +avg_frame_rate=24/1 +time_base=1/24 +start_pts=0 +start_time=0.000000 +duration_ts=24 +duration=1.000000 +bit_rate=N/A +max_bit_rate=N/A +bits_per_raw_sample=16 +nb_frames=N/A +nb_read_frames=N/A +nb_read_packets=N/A +DISPOSITION:default=0 +DISPOSITION:dub=0 +DISPOSITION:original=0 +DISPOSITION:comment=0 +DISPOSITION:lyrics=0 +DISPOSITION:karaoke=0 +DISPOSITION:forced=0 +DISPOSITION:hearing_impaired=0 +DISPOSITION:visual_impaired=0 +DISPOSITION:clean_effects=0 +DISPOSITION:attached_pic=0 +DISPOSITION:timed_thumbnails=0 +DISPOSITION:captions=0 +DISPOSITION:descriptions=0 +DISPOSITION:metadata=0 +DISPOSITION:dependent=0 +DISPOSITION:still_image=0 +TAG:file_package_umid=0x060A2B340101010501010F201300000035E05073878E4B2FB69D2369F25ADFC9 +TAG:file_package_name=File Package: SMPTE ST 422 / ST 2067-5 frame wrapping of JPEG 2000 codestreams +TAG:track_name=Image Track +[/STREAM] +[FORMAT] +format_name=mxf +duration=1.000000 +bit_rate=577792 +TAG:operational_pattern_ul=060e2b34.04010101.0d010201.01010100 +TAG:uid=f1994e51-a844-49e4-9459-1ddd622eb65d +TAG:generation_uid=1be151ac-cc95-4314-b09f-7420eda9932b +TAG:company_name=Sandflow Consulting LLC +TAG:product_name=dcdm2imf +TAG:product_version_num=0.0.0.0.0 +TAG:product_version=1.0-beta1 +TAG:product_uid=927fc4d1-89a3-4f88-88bb-d363ed33084a +TAG:modification_date=2022-01-07T22:05:01.000000Z +TAG:toolkit_version_num=2.10.38.27240.1 +TAG:application_platform=win32 +TAG:material_package_umid=0x060A2B340101010501010F201300000072BAF0557DA749308C14738BCD4FA116 +TAG:material_package_name=Material Package +[/FORMAT] From 71364c54d418da142a3353db293dce91555f2c12 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 18:41:13 +0200 Subject: [PATCH 364/590] fate/ffmpeg: Use transcode instead of enc_dec in shortest-sub test enc_dec is designed for raw input and output and computes the PSNR between these two. The input of the shortest-sub test is the idx file of a vobsub sub+idx combination and the output is the output of framecrc of said vobsub subtitle muxed into Matroska together with a synthesized video. Calculating the PSNR between these two files makes no sense, therefore switch to a transcode test, where the ref file file contains the output of framecrc directly, making the interleavement better visible in the ref file at the cost of a larger ref file (>400 lines). Signed-off-by: Andreas Rheinhardt --- tests/fate/ffmpeg.mak | 4 +- tests/ref/fate/shortest-sub | 417 +++++++++++++++++++++++++++++++++++- 2 files changed, 417 insertions(+), 4 deletions(-) diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak index 38a1ae7ed5..c14eaa4c8a 100644 --- a/tests/fate/ffmpeg.mak +++ b/tests/fate/ffmpeg.mak @@ -102,10 +102,10 @@ fate-shortest: CMD = framecrc -auto_conversion_filters -f lavfi -i "sine=3000:d= # test interleaving video with a sparse subtitle stream FATE_SAMPLES_FFMPEG-$(call ALLYES, COLOR_FILTER, VOBSUB_DEMUXER, MATROSKA_DEMUXER,, \ RAWVIDEO_ENCODER, MATROSKA_MUXER, FRAMECRC_MUXER) += fate-shortest-sub -fate-shortest-sub: CMD = enc_dec \ +fate-shortest-sub: CMD = transcode \ vobsub $(TARGET_SAMPLES)/sub/vobsub.idx matroska \ "-filter_complex 'color=s=1x1:rate=1:duration=400' -pix_fmt rgb24 -allow_raw_vfw 1 -c:s copy -c:v rawvideo" \ - framecrc "-map 0 -c copy -shortest -shortest_buf_duration 40" + "-map 0 -c copy -shortest -shortest_buf_duration 40" # Basic test for fix_sub_duration, which calculates duration based on the # following subtitle's pts. diff --git a/tests/ref/fate/shortest-sub b/tests/ref/fate/shortest-sub index 0da4ba2e95..53f89925b9 100644 --- a/tests/ref/fate/shortest-sub +++ b/tests/ref/fate/shortest-sub @@ -1,4 +1,417 @@ 145b9b48d56f9c966bf41657f7569954 *tests/data/fate/shortest-sub.matroska 139232 tests/data/fate/shortest-sub.matroska -876ac3fa52e467050ab843969d4cf343 *tests/data/fate/shortest-sub.out.framecrc -stddev:11541.12 PSNR: 15.08 MAXDIFF:22854 bytes: 2591/ 23735 +#extradata 1: 167, 0xf7272d5f +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 1x1 +#sar 0: 1/1 +#tb 1: 1/1000 +#media_type 1: subtitle +#codec_id 1: dvd_subtitle +0, 0, 0, 1000, 3, 0x00000000 +0, 1000, 1000, 1000, 3, 0x00000000 +0, 2000, 2000, 1000, 3, 0x00000000 +0, 3000, 3000, 1000, 3, 0x00000000 +0, 4000, 4000, 1000, 3, 0x00000000 +0, 5000, 5000, 1000, 3, 0x00000000 +0, 6000, 6000, 1000, 3, 0x00000000 +0, 7000, 7000, 1000, 3, 0x00000000 +0, 8000, 8000, 1000, 3, 0x00000000 +0, 9000, 9000, 1000, 3, 0x00000000 +0, 10000, 10000, 1000, 3, 0x00000000 +0, 11000, 11000, 1000, 3, 0x00000000 +0, 12000, 12000, 1000, 3, 0x00000000 +0, 13000, 13000, 1000, 3, 0x00000000 +0, 14000, 14000, 1000, 3, 0x00000000 +0, 15000, 15000, 1000, 3, 0x00000000 +0, 16000, 16000, 1000, 3, 0x00000000 +0, 17000, 17000, 1000, 3, 0x00000000 +0, 18000, 18000, 1000, 3, 0x00000000 +0, 19000, 19000, 1000, 3, 0x00000000 +0, 20000, 20000, 1000, 3, 0x00000000 +0, 21000, 21000, 1000, 3, 0x00000000 +0, 22000, 22000, 1000, 3, 0x00000000 +0, 23000, 23000, 1000, 3, 0x00000000 +0, 24000, 24000, 1000, 3, 0x00000000 +0, 25000, 25000, 1000, 3, 0x00000000 +0, 26000, 26000, 1000, 3, 0x00000000 +0, 27000, 27000, 1000, 3, 0x00000000 +0, 28000, 28000, 1000, 3, 0x00000000 +0, 29000, 29000, 1000, 3, 0x00000000 +0, 30000, 30000, 1000, 3, 0x00000000 +0, 31000, 31000, 1000, 3, 0x00000000 +0, 32000, 32000, 1000, 3, 0x00000000 +0, 33000, 33000, 1000, 3, 0x00000000 +0, 34000, 34000, 1000, 3, 0x00000000 +0, 35000, 35000, 1000, 3, 0x00000000 +0, 36000, 36000, 1000, 3, 0x00000000 +0, 37000, 37000, 1000, 3, 0x00000000 +0, 38000, 38000, 1000, 3, 0x00000000 +0, 39000, 39000, 1000, 3, 0x00000000 +0, 40000, 40000, 1000, 3, 0x00000000 +0, 41000, 41000, 1000, 3, 0x00000000 +0, 42000, 42000, 1000, 3, 0x00000000 +0, 43000, 43000, 1000, 3, 0x00000000 +0, 44000, 44000, 1000, 3, 0x00000000 +0, 45000, 45000, 1000, 3, 0x00000000 +0, 46000, 46000, 1000, 3, 0x00000000 +0, 47000, 47000, 1000, 3, 0x00000000 +0, 48000, 48000, 1000, 3, 0x00000000 +0, 49000, 49000, 1000, 3, 0x00000000 +0, 50000, 50000, 1000, 3, 0x00000000 +0, 51000, 51000, 1000, 3, 0x00000000 +0, 52000, 52000, 1000, 3, 0x00000000 +0, 53000, 53000, 1000, 3, 0x00000000 +0, 54000, 54000, 1000, 3, 0x00000000 +0, 55000, 55000, 1000, 3, 0x00000000 +0, 56000, 56000, 1000, 3, 0x00000000 +0, 57000, 57000, 1000, 3, 0x00000000 +0, 58000, 58000, 1000, 3, 0x00000000 +0, 59000, 59000, 1000, 3, 0x00000000 +0, 60000, 60000, 1000, 3, 0x00000000 +0, 61000, 61000, 1000, 3, 0x00000000 +0, 62000, 62000, 1000, 3, 0x00000000 +0, 63000, 63000, 1000, 3, 0x00000000 +0, 64000, 64000, 1000, 3, 0x00000000 +0, 65000, 65000, 1000, 3, 0x00000000 +0, 66000, 66000, 1000, 3, 0x00000000 +0, 67000, 67000, 1000, 3, 0x00000000 +0, 68000, 68000, 1000, 3, 0x00000000 +0, 69000, 69000, 1000, 3, 0x00000000 +0, 70000, 70000, 1000, 3, 0x00000000 +0, 71000, 71000, 1000, 3, 0x00000000 +0, 72000, 72000, 1000, 3, 0x00000000 +0, 73000, 73000, 1000, 3, 0x00000000 +0, 74000, 74000, 1000, 3, 0x00000000 +0, 75000, 75000, 1000, 3, 0x00000000 +0, 76000, 76000, 1000, 3, 0x00000000 +0, 77000, 77000, 1000, 3, 0x00000000 +0, 78000, 78000, 1000, 3, 0x00000000 +0, 79000, 79000, 1000, 3, 0x00000000 +0, 80000, 80000, 1000, 3, 0x00000000 +0, 81000, 81000, 1000, 3, 0x00000000 +0, 82000, 82000, 1000, 3, 0x00000000 +0, 83000, 83000, 1000, 3, 0x00000000 +0, 84000, 84000, 1000, 3, 0x00000000 +0, 85000, 85000, 1000, 3, 0x00000000 +0, 86000, 86000, 1000, 3, 0x00000000 +0, 87000, 87000, 1000, 3, 0x00000000 +0, 88000, 88000, 1000, 3, 0x00000000 +0, 89000, 89000, 1000, 3, 0x00000000 +0, 90000, 90000, 1000, 3, 0x00000000 +0, 91000, 91000, 1000, 3, 0x00000000 +0, 92000, 92000, 1000, 3, 0x00000000 +0, 93000, 93000, 1000, 3, 0x00000000 +0, 94000, 94000, 1000, 3, 0x00000000 +0, 95000, 95000, 1000, 3, 0x00000000 +0, 96000, 96000, 1000, 3, 0x00000000 +0, 97000, 97000, 1000, 3, 0x00000000 +0, 98000, 98000, 1000, 3, 0x00000000 +0, 99000, 99000, 1000, 3, 0x00000000 +0, 100000, 100000, 1000, 3, 0x00000000 +0, 101000, 101000, 1000, 3, 0x00000000 +0, 102000, 102000, 1000, 3, 0x00000000 +0, 103000, 103000, 1000, 3, 0x00000000 +0, 104000, 104000, 1000, 3, 0x00000000 +0, 105000, 105000, 1000, 3, 0x00000000 +0, 106000, 106000, 1000, 3, 0x00000000 +0, 107000, 107000, 1000, 3, 0x00000000 +0, 108000, 108000, 1000, 3, 0x00000000 +0, 109000, 109000, 1000, 3, 0x00000000 +0, 110000, 110000, 1000, 3, 0x00000000 +0, 111000, 111000, 1000, 3, 0x00000000 +0, 112000, 112000, 1000, 3, 0x00000000 +0, 113000, 113000, 1000, 3, 0x00000000 +0, 114000, 114000, 1000, 3, 0x00000000 +0, 115000, 115000, 1000, 3, 0x00000000 +0, 116000, 116000, 1000, 3, 0x00000000 +0, 117000, 117000, 1000, 3, 0x00000000 +0, 118000, 118000, 1000, 3, 0x00000000 +0, 119000, 119000, 1000, 3, 0x00000000 +0, 120000, 120000, 1000, 3, 0x00000000 +0, 121000, 121000, 1000, 3, 0x00000000 +0, 122000, 122000, 1000, 3, 0x00000000 +0, 123000, 123000, 1000, 3, 0x00000000 +0, 124000, 124000, 1000, 3, 0x00000000 +0, 125000, 125000, 1000, 3, 0x00000000 +0, 126000, 126000, 1000, 3, 0x00000000 +0, 127000, 127000, 1000, 3, 0x00000000 +0, 128000, 128000, 1000, 3, 0x00000000 +0, 129000, 129000, 1000, 3, 0x00000000 +0, 130000, 130000, 1000, 3, 0x00000000 +0, 131000, 131000, 1000, 3, 0x00000000 +0, 132000, 132000, 1000, 3, 0x00000000 +1, 132499, 132499, 0, 2238, 0xf8f81348 +0, 133000, 133000, 1000, 3, 0x00000000 +0, 134000, 134000, 1000, 3, 0x00000000 +0, 135000, 135000, 1000, 3, 0x00000000 +0, 136000, 136000, 1000, 3, 0x00000000 +0, 137000, 137000, 1000, 3, 0x00000000 +0, 138000, 138000, 1000, 3, 0x00000000 +0, 139000, 139000, 1000, 3, 0x00000000 +0, 140000, 140000, 1000, 3, 0x00000000 +0, 141000, 141000, 1000, 3, 0x00000000 +0, 142000, 142000, 1000, 3, 0x00000000 +0, 143000, 143000, 1000, 3, 0x00000000 +0, 144000, 144000, 1000, 3, 0x00000000 +0, 145000, 145000, 1000, 3, 0x00000000 +0, 146000, 146000, 1000, 3, 0x00000000 +0, 147000, 147000, 1000, 3, 0x00000000 +1, 147355, 147355, 0, 3320, 0x7091f477 +0, 148000, 148000, 1000, 3, 0x00000000 +0, 149000, 149000, 1000, 3, 0x00000000 +0, 150000, 150000, 1000, 3, 0x00000000 +0, 151000, 151000, 1000, 3, 0x00000000 +0, 152000, 152000, 1000, 3, 0x00000000 +0, 153000, 153000, 1000, 3, 0x00000000 +0, 154000, 154000, 1000, 3, 0x00000000 +0, 155000, 155000, 1000, 3, 0x00000000 +0, 156000, 156000, 1000, 3, 0x00000000 +0, 157000, 157000, 1000, 3, 0x00000000 +0, 158000, 158000, 1000, 3, 0x00000000 +0, 159000, 159000, 1000, 3, 0x00000000 +0, 160000, 160000, 1000, 3, 0x00000000 +0, 161000, 161000, 1000, 3, 0x00000000 +0, 162000, 162000, 1000, 3, 0x00000000 +0, 163000, 163000, 1000, 3, 0x00000000 +0, 164000, 164000, 1000, 3, 0x00000000 +0, 165000, 165000, 1000, 3, 0x00000000 +0, 166000, 166000, 1000, 3, 0x00000000 +0, 167000, 167000, 1000, 3, 0x00000000 +0, 168000, 168000, 1000, 3, 0x00000000 +0, 169000, 169000, 1000, 3, 0x00000000 +0, 170000, 170000, 1000, 3, 0x00000000 +0, 171000, 171000, 1000, 3, 0x00000000 +0, 172000, 172000, 1000, 3, 0x00000000 +0, 173000, 173000, 1000, 3, 0x00000000 +0, 174000, 174000, 1000, 3, 0x00000000 +0, 175000, 175000, 1000, 3, 0x00000000 +0, 176000, 176000, 1000, 3, 0x00000000 +0, 177000, 177000, 1000, 3, 0x00000000 +0, 178000, 178000, 1000, 3, 0x00000000 +0, 179000, 179000, 1000, 3, 0x00000000 +0, 180000, 180000, 1000, 3, 0x00000000 +1, 180797, 180797, 0, 3626, 0xe4ff6eab +0, 181000, 181000, 1000, 3, 0x00000000 +0, 182000, 182000, 1000, 3, 0x00000000 +0, 183000, 183000, 1000, 3, 0x00000000 +1, 183433, 183433, 0, 4156, 0xc73645fe +0, 184000, 184000, 1000, 3, 0x00000000 +0, 185000, 185000, 1000, 3, 0x00000000 +1, 185919, 185919, 0, 2019, 0xe9a5f34f +1, 185919, 185919, 0, 1213, 0x8a62d853 +0, 186000, 186000, 1000, 3, 0x00000000 +0, 187000, 187000, 1000, 3, 0x00000000 +0, 188000, 188000, 1000, 3, 0x00000000 +1, 188663, 188663, 0, 2184, 0xfdcd0323 +0, 189000, 189000, 1000, 3, 0x00000000 +0, 190000, 190000, 1000, 3, 0x00000000 +1, 190014, 190014, 0, 2172, 0xb479f0a1 +0, 191000, 191000, 1000, 3, 0x00000000 +0, 192000, 192000, 1000, 3, 0x00000000 +0, 193000, 193000, 1000, 3, 0x00000000 +0, 194000, 194000, 1000, 3, 0x00000000 +0, 195000, 195000, 1000, 3, 0x00000000 +0, 196000, 196000, 1000, 3, 0x00000000 +0, 197000, 197000, 1000, 3, 0x00000000 +0, 198000, 198000, 1000, 3, 0x00000000 +0, 199000, 199000, 1000, 3, 0x00000000 +1, 199724, 199724, 0, 2080, 0xe8e7c3a2 +0, 200000, 200000, 1000, 3, 0x00000000 +0, 201000, 201000, 1000, 3, 0x00000000 +1, 201175, 201175, 0, 1972, 0xd2c87cd0 +0, 202000, 202000, 1000, 3, 0x00000000 +1, 202819, 202819, 0, 2856, 0xc9a42a11 +0, 203000, 203000, 1000, 3, 0x00000000 +0, 204000, 204000, 1000, 3, 0x00000000 +1, 204762, 204762, 0, 3570, 0x02035220 +0, 205000, 205000, 1000, 3, 0x00000000 +0, 206000, 206000, 1000, 3, 0x00000000 +1, 206806, 206806, 0, 3270, 0x9a39c179 +0, 207000, 207000, 1000, 3, 0x00000000 +0, 208000, 208000, 1000, 3, 0x00000000 +1, 208716, 208716, 0, 2968, 0x6c0b46de +0, 209000, 209000, 1000, 3, 0x00000000 +0, 210000, 210000, 1000, 3, 0x00000000 +1, 210051, 210051, 0, 2142, 0x9e64e867 +0, 211000, 211000, 1000, 3, 0x00000000 +1, 211644, 211644, 0, 4060, 0x274516cc +0, 212000, 212000, 1000, 3, 0x00000000 +0, 213000, 213000, 1000, 3, 0x00000000 +0, 214000, 214000, 1000, 3, 0x00000000 +1, 214380, 214380, 0, 4214, 0xa6a068cb +0, 215000, 215000, 1000, 3, 0x00000000 +0, 216000, 216000, 1000, 3, 0x00000000 +0, 217000, 217000, 1000, 3, 0x00000000 +1, 217225, 217225, 0, 3770, 0x3d3aaf6c +0, 218000, 218000, 1000, 3, 0x00000000 +0, 219000, 219000, 1000, 3, 0x00000000 +1, 219652, 219652, 0, 1862, 0xaa9a5a30 +0, 220000, 220000, 1000, 3, 0x00000000 +0, 221000, 221000, 1000, 3, 0x00000000 +0, 222000, 222000, 1000, 3, 0x00000000 +0, 223000, 223000, 1000, 3, 0x00000000 +1, 223531, 223531, 0, 3222, 0x390690fb +0, 224000, 224000, 1000, 3, 0x00000000 +0, 225000, 225000, 1000, 3, 0x00000000 +0, 226000, 226000, 1000, 3, 0x00000000 +0, 227000, 227000, 1000, 3, 0x00000000 +1, 227510, 227510, 0, 4064, 0x13e132a4 +0, 228000, 228000, 1000, 3, 0x00000000 +0, 229000, 229000, 1000, 3, 0x00000000 +0, 230000, 230000, 1000, 3, 0x00000000 +1, 230872, 230872, 0, 3010, 0xc4a07cbd +0, 231000, 231000, 1000, 3, 0x00000000 +0, 232000, 232000, 1000, 3, 0x00000000 +0, 233000, 233000, 1000, 3, 0x00000000 +1, 233124, 233124, 0, 4950, 0xd30b9b64 +0, 234000, 234000, 1000, 3, 0x00000000 +0, 235000, 235000, 1000, 3, 0x00000000 +0, 236000, 236000, 1000, 3, 0x00000000 +0, 237000, 237000, 1000, 3, 0x00000000 +1, 237303, 237303, 0, 4184, 0x5115659c +0, 238000, 238000, 1000, 3, 0x00000000 +0, 239000, 239000, 1000, 3, 0x00000000 +0, 240000, 240000, 1000, 3, 0x00000000 +1, 240106, 240106, 0, 3554, 0x14804a6c +0, 241000, 241000, 1000, 3, 0x00000000 +0, 242000, 242000, 1000, 3, 0x00000000 +0, 243000, 243000, 1000, 3, 0x00000000 +0, 244000, 244000, 1000, 3, 0x00000000 +0, 245000, 245000, 1000, 3, 0x00000000 +0, 246000, 246000, 1000, 3, 0x00000000 +0, 247000, 247000, 1000, 3, 0x00000000 +0, 248000, 248000, 1000, 3, 0x00000000 +0, 249000, 249000, 1000, 3, 0x00000000 +0, 250000, 250000, 1000, 3, 0x00000000 +0, 251000, 251000, 1000, 3, 0x00000000 +0, 252000, 252000, 1000, 3, 0x00000000 +0, 253000, 253000, 1000, 3, 0x00000000 +0, 254000, 254000, 1000, 3, 0x00000000 +0, 255000, 255000, 1000, 3, 0x00000000 +0, 256000, 256000, 1000, 3, 0x00000000 +0, 257000, 257000, 1000, 3, 0x00000000 +0, 258000, 258000, 1000, 3, 0x00000000 +0, 259000, 259000, 1000, 3, 0x00000000 +0, 260000, 260000, 1000, 3, 0x00000000 +0, 261000, 261000, 1000, 3, 0x00000000 +0, 262000, 262000, 1000, 3, 0x00000000 +0, 263000, 263000, 1000, 3, 0x00000000 +0, 264000, 264000, 1000, 3, 0x00000000 +0, 265000, 265000, 1000, 3, 0x00000000 +0, 266000, 266000, 1000, 3, 0x00000000 +0, 267000, 267000, 1000, 3, 0x00000000 +0, 268000, 268000, 1000, 3, 0x00000000 +0, 269000, 269000, 1000, 3, 0x00000000 +0, 270000, 270000, 1000, 3, 0x00000000 +0, 271000, 271000, 1000, 3, 0x00000000 +0, 272000, 272000, 1000, 3, 0x00000000 +0, 273000, 273000, 1000, 3, 0x00000000 +1, 273556, 273556, 0, 2300, 0x53d23a41 +0, 274000, 274000, 1000, 3, 0x00000000 +0, 275000, 275000, 1000, 3, 0x00000000 +0, 276000, 276000, 1000, 3, 0x00000000 +0, 277000, 277000, 1000, 3, 0x00000000 +0, 278000, 278000, 1000, 3, 0x00000000 +0, 279000, 279000, 1000, 3, 0x00000000 +0, 280000, 280000, 1000, 3, 0x00000000 +0, 281000, 281000, 1000, 3, 0x00000000 +0, 282000, 282000, 1000, 3, 0x00000000 +0, 283000, 283000, 1000, 3, 0x00000000 +0, 284000, 284000, 1000, 3, 0x00000000 +0, 285000, 285000, 1000, 3, 0x00000000 +0, 286000, 286000, 1000, 3, 0x00000000 +0, 287000, 287000, 1000, 3, 0x00000000 +0, 288000, 288000, 1000, 3, 0x00000000 +0, 289000, 289000, 1000, 3, 0x00000000 +0, 290000, 290000, 1000, 3, 0x00000000 +0, 291000, 291000, 1000, 3, 0x00000000 +0, 292000, 292000, 1000, 3, 0x00000000 +0, 293000, 293000, 1000, 3, 0x00000000 +0, 294000, 294000, 1000, 3, 0x00000000 +0, 295000, 295000, 1000, 3, 0x00000000 +1, 295445, 295445, 0, 1544, 0x4e4ed1a0 +0, 296000, 296000, 1000, 3, 0x00000000 +0, 297000, 297000, 1000, 3, 0x00000000 +0, 298000, 298000, 1000, 3, 0x00000000 +0, 299000, 299000, 1000, 3, 0x00000000 +0, 300000, 300000, 1000, 3, 0x00000000 +1, 300049, 300049, 0, 2478, 0x6e3e7b4d +0, 301000, 301000, 1000, 3, 0x00000000 +0, 302000, 302000, 1000, 3, 0x00000000 +1, 302018, 302018, 0, 2019, 0x5eb7c3d9 +1, 302035, 302035, 0, 405, 0x98a58922 +0, 303000, 303000, 1000, 3, 0x00000000 +0, 304000, 304000, 1000, 3, 0x00000000 +1, 304203, 304203, 0, 2998, 0xee7c6a15 +0, 305000, 305000, 1000, 3, 0x00000000 +1, 305947, 305947, 0, 2640, 0xf426b974 +0, 306000, 306000, 1000, 3, 0x00000000 +0, 307000, 307000, 1000, 3, 0x00000000 +1, 307957, 307957, 0, 2174, 0x40340514 +0, 308000, 308000, 1000, 3, 0x00000000 +0, 309000, 309000, 1000, 3, 0x00000000 +0, 310000, 310000, 1000, 3, 0x00000000 +0, 311000, 311000, 1000, 3, 0x00000000 +0, 312000, 312000, 1000, 3, 0x00000000 +0, 313000, 313000, 1000, 3, 0x00000000 +0, 314000, 314000, 1000, 3, 0x00000000 +0, 315000, 315000, 1000, 3, 0x00000000 +0, 316000, 316000, 1000, 3, 0x00000000 +0, 317000, 317000, 1000, 3, 0x00000000 +0, 318000, 318000, 1000, 3, 0x00000000 +0, 319000, 319000, 1000, 3, 0x00000000 +0, 320000, 320000, 1000, 3, 0x00000000 +0, 321000, 321000, 1000, 3, 0x00000000 +1, 321295, 321295, 0, 2760, 0x4ae1e9ad +0, 322000, 322000, 1000, 3, 0x00000000 +0, 323000, 323000, 1000, 3, 0x00000000 +1, 323356, 323356, 0, 2688, 0xdec1c1d6 +0, 324000, 324000, 1000, 3, 0x00000000 +1, 324640, 324640, 0, 3694, 0x3b5d80de +0, 325000, 325000, 1000, 3, 0x00000000 +0, 326000, 326000, 1000, 3, 0x00000000 +0, 327000, 327000, 1000, 3, 0x00000000 +1, 327193, 327193, 0, 2276, 0x0dae2c53 +0, 328000, 328000, 1000, 3, 0x00000000 +1, 328369, 328369, 0, 2019, 0x4d9cd2f2 +1, 328369, 328369, 0, 847, 0x1d3f4a3d +0, 329000, 329000, 1000, 3, 0x00000000 +1, 329946, 329946, 0, 1974, 0xb63e71b1 +0, 330000, 330000, 1000, 3, 0x00000000 +0, 331000, 331000, 1000, 3, 0x00000000 +1, 331230, 331230, 0, 3004, 0x69a86a37 +0, 332000, 332000, 1000, 3, 0x00000000 +1, 332924, 332924, 0, 2124, 0xf5c6dc9a +0, 333000, 333000, 1000, 3, 0x00000000 +0, 334000, 334000, 1000, 3, 0x00000000 +0, 335000, 335000, 1000, 3, 0x00000000 +0, 336000, 336000, 1000, 3, 0x00000000 +0, 337000, 337000, 1000, 3, 0x00000000 +0, 338000, 338000, 1000, 3, 0x00000000 +0, 339000, 339000, 1000, 3, 0x00000000 +0, 340000, 340000, 1000, 3, 0x00000000 +0, 341000, 341000, 1000, 3, 0x00000000 +0, 342000, 342000, 1000, 3, 0x00000000 +1, 342600, 342600, 0, 1876, 0x3ed26066 +0, 343000, 343000, 1000, 3, 0x00000000 +0, 344000, 344000, 1000, 3, 0x00000000 +0, 345000, 345000, 1000, 3, 0x00000000 +0, 346000, 346000, 1000, 3, 0x00000000 +1, 346771, 346771, 0, 2426, 0xccae6c39 +0, 347000, 347000, 1000, 3, 0x00000000 +0, 348000, 348000, 1000, 3, 0x00000000 +0, 349000, 349000, 1000, 3, 0x00000000 +0, 350000, 350000, 1000, 3, 0x00000000 +0, 351000, 351000, 1000, 3, 0x00000000 +0, 352000, 352000, 1000, 3, 0x00000000 +0, 353000, 353000, 1000, 3, 0x00000000 +0, 354000, 354000, 1000, 3, 0x00000000 +0, 355000, 355000, 1000, 3, 0x00000000 +0, 356000, 356000, 1000, 3, 0x00000000 +0, 357000, 357000, 1000, 3, 0x00000000 +1, 357640, 357640, 0, 3240, 0x90cb9fd1 +0, 358000, 358000, 1000, 3, 0x00000000 +0, 359000, 359000, 1000, 3, 0x00000000 +1, 359834, 359834, 0, 2482, 0xc68e6a8a From 6a8b3e7eb1ac05b539740c5c1e9f9d41d22c7f76 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 18:53:50 +0200 Subject: [PATCH 365/590] fate/ffmpeg: Set max_delay for shortest-sub The aim of this test is to show the interleavement of the file generated in the first pass; so make the interleavement queue in the framecrc muxer in the second pass as small as possible so that the framecrc muxer does not fix wrong interleavement of the input file behind our backs. Signed-off-by: Andreas Rheinhardt --- tests/fate/ffmpeg.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak index c14eaa4c8a..d87639c596 100644 --- a/tests/fate/ffmpeg.mak +++ b/tests/fate/ffmpeg.mak @@ -105,7 +105,7 @@ FATE_SAMPLES_FFMPEG-$(call ALLYES, COLOR_FILTER, VOBSUB_DEMUXER, MATROSKA_DEMUXE fate-shortest-sub: CMD = transcode \ vobsub $(TARGET_SAMPLES)/sub/vobsub.idx matroska \ "-filter_complex 'color=s=1x1:rate=1:duration=400' -pix_fmt rgb24 -allow_raw_vfw 1 -c:s copy -c:v rawvideo" \ - "-map 0 -c copy -shortest -shortest_buf_duration 40" + "-map 0 -c copy -shortest -shortest_buf_duration 40 -max_delay 1" # Basic test for fix_sub_duration, which calculates duration based on the # following subtitle's pts. From 353108bfab46903b06343fb6f0e4d32fb0fdfb1e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 12:54:53 +0200 Subject: [PATCH 366/590] avcodec/smc: Move transient GetByteContext from context to stack Signed-off-by: Andreas Rheinhardt --- libavcodec/smc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/smc.c b/libavcodec/smc.c index e6d01791c2..2b10e74386 100644 --- a/libavcodec/smc.c +++ b/libavcodec/smc.c @@ -46,8 +46,6 @@ typedef struct SmcContext { AVCodecContext *avctx; AVFrame *frame; - GetByteContext gb; - /* SMC color tables */ uint8_t color_pairs[COLORS_PER_TABLE * CPAIR]; uint8_t color_quads[COLORS_PER_TABLE * CQUAD]; @@ -75,9 +73,8 @@ typedef struct SmcContext { } \ } -static int smc_decode_stream(SmcContext *s) +static int smc_decode_stream(SmcContext *s, GetByteContext *gb) { - GetByteContext *gb = &s->gb; int width = s->avctx->width; int height = s->avctx->height; int stride = s->frame->linesize[0]; @@ -430,20 +427,20 @@ static int smc_decode_frame(AVCodecContext *avctx, AVFrame *rframe, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; SmcContext *s = avctx->priv_data; + GetByteContext gb; int ret; int total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4); if (total_blocks / 1024 > avpkt->size) return AVERROR_INVALIDDATA; - bytestream2_init(&s->gb, buf, buf_size); - if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) return ret; s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx); - ret = smc_decode_stream(s); + bytestream2_init(&gb, buf, buf_size); + ret = smc_decode_stream(s, &gb); if (ret < 0) return ret; From e27d67b24ce4061bff1bfd8590acf2b49911b4b3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 13:33:07 +0200 Subject: [PATCH 367/590] avcodec/rpzaenc: Avoid useless intermediate variable Signed-off-by: Andreas Rheinhardt --- libavcodec/rpzaenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c index 0084a271c6..d710eb4f82 100644 --- a/libavcodec/rpzaenc.c +++ b/libavcodec/rpzaenc.c @@ -773,10 +773,9 @@ static int rpza_encode_init(AVCodecContext *avctx) } static int rpza_encode_frame(AVCodecContext *avctx, AVPacket *pkt, - const AVFrame *frame, int *got_packet) + const AVFrame *pict, int *got_packet) { RpzaContext *s = avctx->priv_data; - const AVFrame *pict = frame; uint8_t *buf; int ret = ff_alloc_packet(avctx, pkt, 6LL * avctx->height * avctx->width); From 2e9fd627ede0911326e925e07117ba2c396abdc0 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 02:02:55 +0200 Subject: [PATCH 368/590] fate/segafilm: Add tests for segafilm (de)muxer Signed-off-by: Andreas Rheinhardt --- tests/Makefile | 1 + tests/fate/segafilm.mak | 15 + tests/ref/fate/segafilm-adx-remux | 1055 ++++++++++++++++++++++++++ tests/ref/fate/segafilm-cinepak-mux | 159 ++++ tests/ref/fate/segafilm-rawvideo-mux | 98 +++ tests/ref/fate/segafilm-s8-remux | 151 ++++ 6 files changed, 1479 insertions(+) create mode 100644 tests/fate/segafilm.mak create mode 100644 tests/ref/fate/segafilm-adx-remux create mode 100644 tests/ref/fate/segafilm-cinepak-mux create mode 100644 tests/ref/fate/segafilm-rawvideo-mux create mode 100644 tests/ref/fate/segafilm-s8-remux diff --git a/tests/Makefile b/tests/Makefile index 06494a9cc4..1d50e1d175 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -229,6 +229,7 @@ include $(SRC_PATH)/tests/fate/qt.mak include $(SRC_PATH)/tests/fate/qtrle.mak include $(SRC_PATH)/tests/fate/real.mak include $(SRC_PATH)/tests/fate/screen.mak +include $(SRC_PATH)/tests/fate/segafilm.mak include $(SRC_PATH)/tests/fate/segment.mak include $(SRC_PATH)/tests/fate/source.mak include $(SRC_PATH)/tests/fate/spdif.mak diff --git a/tests/fate/segafilm.mak b/tests/fate/segafilm.mak new file mode 100644 index 0000000000..7634034154 --- /dev/null +++ b/tests/fate/segafilm.mak @@ -0,0 +1,15 @@ +FATE_SEGAFILM-$(call REMUX, SEGAFILM, CINEPAK_DECODER ADX_PARSER) += fate-segafilm-adx-remux +fate-segafilm-adx-remux: CMD = transcode film_cpk $(TARGET_SAMPLES)/film/op-partial.cak film_cpk "-c copy" "-c copy" + +FATE_SEGAFILM-$(call REMUX, SEGAFILM, CINEPAK_DECODER) += fate-segafilm-s8-remux +fate-segafilm-s8-remux: CMD = transcode film_cpk $(TARGET_SAMPLES)/film/logo-capcom.cpk film_cpk "-c copy" "-c copy" + +# This tests muxing non-segafilm cinepak into segafilm. +FATE_SEGAFILM-$(call REMUX, SEGAFILM, AVI_DEMUXER CINEPAK_DECODER) += fate-segafilm-cinepak-mux +fate-segafilm-cinepak-mux: CMD = transcode avi $(TARGET_SAMPLES)/cvid/pcitva15.avi film_cpk "-map 0:v -c copy" "-c copy" + +FATE_SEGAFILM-$(call TRANSCODE, RAWVIDEO CINEPAK, SEGAFILM, AVI_DEMUXER PCM_U8_DECODER ARESAMPLE_FILTER PCM_S16BE_PLANAR_ENCODER) += fate-segafilm-rawvideo-mux +fate-segafilm-rawvideo-mux: CMD = transcode avi $(TARGET_SAMPLES)/cvid/laracroft-cinepak-partial.avi film_cpk "-c:v rawvideo -pix_fmt rgb24 -af aresample -c:a pcm_s16be_planar" "-c copy" + +FATE_SAMPLES_FFMPEG += $(FATE_SEGAFILM-yes) +fate-segafilm: $(FATE_SEGAFILM-yes) diff --git a/tests/ref/fate/segafilm-adx-remux b/tests/ref/fate/segafilm-adx-remux new file mode 100644 index 0000000000..8eb8eaa4e0 --- /dev/null +++ b/tests/ref/fate/segafilm-adx-remux @@ -0,0 +1,1055 @@ +1195dfa231831759746d5f4f765fbd05 *tests/data/fate/segafilm-adx-remux.film_cpk +101888 tests/data/fate/segafilm-adx-remux.film_cpk +#tb 0: 1/6000 +#media_type 0: video +#codec_id 0: cinepak +#dimensions 0: 296x216 +#sar 0: 0/1 +#tb 1: 1/44100 +#media_type 1: audio +#codec_id 1: adpcm_adx +#sample_rate 1: 44100 +#channel_layout_name 1: stereo +0, 0, 0, 250, 19240, 0x11e74615 +1, 0, 0, 32, 72, 0xc0d20edc +1, 64, 64, 32, 36, 0xe2f40ced +1, 96, 96, 32, 36, 0x1baa10a8 +1, 128, 128, 32, 36, 0xdee70c72 +1, 160, 160, 32, 36, 0x00990d50 +1, 192, 192, 32, 36, 0x3bea0f01 +1, 224, 224, 32, 36, 0x00320e59 +1, 256, 256, 32, 36, 0xdb720df9 +1, 288, 288, 32, 36, 0x01e00f7b +1, 320, 320, 32, 36, 0x9f790ad3 +1, 352, 352, 32, 36, 0xdee80c66 +1, 384, 384, 32, 36, 0xbc6e0a89 +1, 416, 416, 32, 36, 0x270e11da +1, 448, 448, 32, 36, 0xb5ae0985 +1, 480, 480, 32, 36, 0x3dff131c +1, 512, 512, 32, 36, 0x0d1a0cbb +1, 544, 544, 32, 36, 0x32df0fd0 +1, 576, 576, 32, 36, 0x9ae909ee +1, 608, 608, 32, 36, 0xd38e0c8a +1, 640, 640, 32, 36, 0x96d01703 +1, 672, 672, 32, 36, 0xf5ff0d6a +1, 704, 704, 32, 36, 0xf46d0dbb +1, 736, 736, 32, 36, 0x03460e89 +1, 768, 768, 32, 36, 0xd4ce0e77 +1, 800, 800, 32, 36, 0xd6090b2d +1, 832, 832, 32, 36, 0x1c7911b8 +1, 864, 864, 32, 36, 0x377113fb +1, 896, 896, 32, 36, 0x0bf50e23 +1, 928, 928, 32, 36, 0xc1420d33 +1, 960, 960, 32, 36, 0x0a660fe4 +1, 992, 992, 32, 36, 0x3192125c +1, 1024, 1024, 32, 36, 0x3c9712cc +1, 1056, 1056, 32, 36, 0x6351126a +1, 1088, 1088, 32, 36, 0xca7b0b7f +1, 1120, 1120, 32, 36, 0xe5650cda +1, 1152, 1152, 32, 36, 0x242a1146 +1, 1184, 1184, 32, 36, 0x9c680974 +1, 1216, 1216, 32, 36, 0x1bd80e5f +1, 1248, 1248, 32, 36, 0x07bc0ef2 +1, 1280, 1280, 32, 36, 0x16f51030 +1, 1312, 1312, 32, 36, 0x49901397 +1, 1344, 1344, 32, 36, 0xe7db0c6e +1, 1376, 1376, 32, 36, 0xef990cf3 +1, 1408, 1408, 32, 36, 0xf73e0e1f +1, 1440, 1440, 32, 36, 0x2c5a10f0 +1, 1472, 1472, 32, 36, 0x7e3b06ea +1, 1504, 1504, 32, 36, 0xd7050df4 +1, 1536, 1536, 32, 36, 0x5db8130b +1, 1568, 1568, 32, 36, 0x206e102c +1, 1600, 1600, 32, 36, 0xf60c0db0 +1, 1632, 1632, 32, 36, 0x17fc0ff4 +1, 1664, 1664, 32, 36, 0x00731026 +1, 1696, 1696, 32, 36, 0xf23d0e80 +1, 1728, 1728, 32, 36, 0x74871484 +1, 1760, 1760, 32, 36, 0x09d60fb2 +1, 1792, 1792, 32, 36, 0xe57d0e39 +1, 1824, 1824, 32, 36, 0xf7c20ea8 +0, 250, 250, 250, 692, 0x19670524, F=0x0 +1, 1856, 1856, 32, 36, 0xe05d0c77 +1, 1888, 1888, 32, 36, 0xe6510db4 +1, 1920, 1920, 32, 36, 0x55f1155b +1, 1952, 1952, 32, 36, 0xac5c0901 +1, 1984, 1984, 32, 36, 0xed0a0d2b +1, 2016, 2016, 32, 36, 0x9abb1864 +1, 2048, 2048, 32, 36, 0x140e0e5d +1, 2080, 2080, 32, 36, 0xab560a68 +1, 2112, 2112, 32, 36, 0x4642127e +1, 2144, 2144, 32, 36, 0xdf410da1 +1, 2176, 2176, 32, 36, 0x58541481 +1, 2208, 2208, 32, 36, 0x967a09bb +1, 2240, 2240, 32, 36, 0x020f0ef2 +1, 2272, 2272, 32, 36, 0x2fda10fd +1, 2304, 2304, 32, 36, 0x12400ed7 +1, 2336, 2336, 32, 36, 0x3205111f +1, 2368, 2368, 32, 36, 0xe89d0d14 +1, 2400, 2400, 32, 36, 0x095b0d69 +1, 2432, 2432, 32, 36, 0xb622098b +1, 2464, 2464, 32, 36, 0x627414b9 +1, 2496, 2496, 32, 36, 0xfe901071 +1, 2528, 2528, 32, 36, 0x5c061409 +1, 2560, 2560, 32, 36, 0xd7cc0ba1 +1, 2592, 2592, 32, 36, 0x3837137e +1, 2624, 2624, 32, 36, 0x9bd308f2 +1, 2656, 2656, 32, 36, 0xb4e20abc +1, 2688, 2688, 32, 36, 0x5b1913f8 +1, 2720, 2720, 32, 36, 0xa66b16ff +1, 2752, 2752, 32, 36, 0xecba0a93 +1, 2784, 2784, 32, 36, 0x6e46061c +1, 2816, 2816, 32, 36, 0x55541297 +1, 2848, 2848, 32, 36, 0x190311b4 +1, 2880, 2880, 32, 36, 0xbe401a3d +1, 2912, 2912, 32, 36, 0x16460e0f +1, 2944, 2944, 32, 36, 0xcd320c60 +1, 2976, 2976, 32, 36, 0x375c1154 +1, 3008, 3008, 32, 36, 0xd7170c60 +1, 3040, 3040, 32, 36, 0x660513b0 +1, 3072, 3072, 32, 36, 0x1247107b +1, 3104, 3104, 32, 36, 0x71171598 +1, 3136, 3136, 32, 36, 0xcb7a0d45 +1, 3168, 3168, 32, 36, 0xf59e0c7f +1, 3200, 3200, 32, 36, 0xc64e09c6 +1, 3232, 3232, 32, 36, 0x5ce91503 +1, 3264, 3264, 32, 36, 0x0bbf0e62 +1, 3296, 3296, 32, 36, 0x46c9124f +1, 3328, 3328, 32, 36, 0xfa9a0f26 +1, 3360, 3360, 32, 36, 0x26661106 +1, 3392, 3392, 32, 36, 0x58a311f5 +1, 3424, 3424, 32, 36, 0x07720f5d +1, 3456, 3456, 32, 36, 0x5af11158 +1, 3488, 3488, 32, 36, 0x2d341243 +1, 3520, 3520, 32, 36, 0x28851163 +1, 3552, 3552, 32, 36, 0x8803096e +1, 3584, 3584, 32, 36, 0xdfe60da7 +1, 3616, 3616, 32, 36, 0x6a911484 +1, 3648, 3648, 32, 36, 0x06990f6e +0, 500, 500, 250, 692, 0x19670524, F=0x0 +1, 3680, 3680, 32, 36, 0xb52309fb +1, 3712, 3712, 32, 36, 0x22751176 +1, 3744, 3744, 32, 36, 0xe6160d90 +1, 3776, 3776, 32, 36, 0x256910b3 +1, 3808, 3808, 32, 36, 0x2a771244 +1, 3840, 3840, 32, 36, 0x9ad50922 +1, 3872, 3872, 32, 36, 0x49701347 +1, 3904, 3904, 32, 36, 0x49c61186 +1, 3936, 3936, 32, 36, 0x91bd0793 +1, 3968, 3968, 32, 36, 0xa68409ce +1, 4000, 4000, 32, 36, 0x7483142d +1, 4032, 4032, 32, 36, 0x7a951701 +1, 4064, 4064, 32, 36, 0xd6380b6c +1, 4096, 4096, 32, 36, 0xe5d00c8f +1, 4128, 4128, 32, 36, 0x031b0fda +1, 4160, 4160, 32, 36, 0x04820ed5 +1, 4192, 4192, 32, 36, 0x6dca1417 +1, 4224, 4224, 32, 36, 0xc7190c5b +1, 4256, 4256, 32, 36, 0xc5750ac6 +1, 4288, 4288, 32, 36, 0xfdcd0f1e +1, 4320, 4320, 32, 36, 0xab06177d +1, 4352, 4352, 32, 36, 0x187e127c +1, 4384, 4384, 32, 36, 0x48760496 +1, 4416, 4416, 32, 36, 0xd62e0abc +1, 4448, 4448, 32, 36, 0x40041158 +1, 4480, 4480, 32, 36, 0xc0f10bfa +1, 4512, 4512, 32, 36, 0x29d00ffc +1, 4544, 4544, 32, 36, 0x2cf111d9 +1, 4576, 4576, 32, 36, 0x116a1053 +1, 4608, 4608, 32, 36, 0x9c2e0829 +1, 4640, 4640, 32, 36, 0xd1de0cd9 +1, 4672, 4672, 32, 36, 0x9f1517e7 +1, 4704, 4704, 32, 36, 0x31630f78 +1, 4736, 4736, 32, 36, 0xece00d79 +1, 4768, 4768, 32, 36, 0xe3570f37 +1, 4800, 4800, 32, 36, 0x822f1655 +1, 4832, 4832, 32, 36, 0x0112116d +1, 4864, 4864, 32, 36, 0x1bc80f3e +1, 4896, 4896, 32, 36, 0x958e08a3 +1, 4928, 4928, 32, 36, 0xc58a0c49 +1, 4960, 4960, 32, 36, 0x08671029 +1, 4992, 4992, 32, 36, 0x74d414e0 +1, 5024, 5024, 32, 36, 0x52691356 +1, 5056, 5056, 32, 36, 0xf97a0fce +1, 5088, 5088, 32, 36, 0x2da610cc +1, 5120, 5120, 32, 36, 0x22bc0fc2 +1, 5152, 5152, 32, 36, 0x743906b8 +1, 5184, 5184, 32, 36, 0x356910bd +1, 5216, 5216, 32, 36, 0x331611bb +1, 5248, 5248, 32, 36, 0x20a6115d +1, 5280, 5280, 32, 36, 0xd01c0d22 +1, 5312, 5312, 32, 36, 0xd6740ab4 +1, 5344, 5344, 32, 36, 0xa28309e9 +1, 5376, 5376, 32, 36, 0x2e6d1160 +1, 5408, 5408, 32, 36, 0x2dcb0ec1 +1, 5440, 5440, 32, 36, 0x3f7c10d7 +1, 5472, 5472, 32, 36, 0xe14e0ec0 +1, 5504, 5504, 32, 36, 0x459b1173 +0, 750, 750, 250, 692, 0x19670524, F=0x0 +1, 5536, 5536, 32, 36, 0xfe950eb3 +1, 5568, 5568, 32, 36, 0x7665075a +1, 5600, 5600, 32, 36, 0x7ca1084c +1, 5632, 5632, 32, 36, 0x29b910ce +1, 5664, 5664, 32, 36, 0xec180e15 +1, 5696, 5696, 32, 36, 0x2bd810c5 +1, 5728, 5728, 32, 36, 0xd2bd0c06 +1, 5760, 5760, 32, 36, 0xd6a30a4d +1, 5792, 5792, 32, 36, 0x1cbe118b +1, 5824, 5824, 32, 36, 0x2505108d +1, 5856, 5856, 32, 36, 0xfb220cfc +1, 5888, 5888, 32, 36, 0x14741035 +1, 5920, 5920, 32, 36, 0x89ca080a +1, 5952, 5952, 32, 36, 0xfcb80fdb +1, 5984, 5984, 32, 36, 0x30e310b3 +1, 6016, 6016, 32, 36, 0x635e1387 +1, 6048, 6048, 32, 36, 0x1bb71086 +1, 6080, 6080, 32, 36, 0xb4760bb3 +1, 6112, 6112, 32, 36, 0x5e901511 +1, 6144, 6144, 32, 36, 0xa2450813 +1, 6176, 6176, 32, 36, 0xf3580e70 +1, 6208, 6208, 32, 36, 0x0ed90f35 +1, 6240, 6240, 32, 36, 0x3343105c +1, 6272, 6272, 32, 36, 0x046c0f67 +1, 6304, 6304, 32, 36, 0x08770f71 +1, 6336, 6336, 32, 36, 0xb7c30c45 +1, 6368, 6368, 32, 36, 0xeb340bf0 +1, 6400, 6400, 32, 36, 0x514f12ff +1, 6432, 6432, 32, 36, 0x3b41135c +1, 6464, 6464, 32, 36, 0x22581023 +1, 6496, 6496, 32, 36, 0xebe20d46 +1, 6528, 6528, 32, 36, 0xf8af0d6b +1, 6560, 6560, 32, 36, 0xa5c51790 +1, 6592, 6592, 32, 36, 0xeb2b0df6 +1, 6624, 6624, 32, 36, 0xcfec0b92 +1, 6656, 6656, 32, 36, 0xe33b0c4a +1, 6688, 6688, 32, 36, 0xc9590be3 +1, 6720, 6720, 32, 36, 0xf4120d34 +1, 6752, 6752, 32, 36, 0x0a240d49 +1, 6784, 6784, 32, 36, 0x50c712fe +1, 6816, 6816, 32, 36, 0xf4020e27 +1, 6848, 6848, 32, 36, 0x01620f8f +1, 6880, 6880, 32, 36, 0x2cef11de +1, 6912, 6912, 32, 36, 0x09210ffa +1, 6944, 6944, 32, 36, 0xa81108f5 +1, 6976, 6976, 32, 36, 0x222f112c +1, 7008, 7008, 32, 36, 0xfb890ed4 +1, 7040, 7040, 32, 36, 0xe4400c34 +1, 7072, 7072, 32, 36, 0xae0708ea +1, 7104, 7104, 32, 36, 0xb55a086e +1, 7136, 7136, 32, 36, 0xa40b0a96 +1, 7168, 7168, 32, 36, 0x3d981253 +1, 7200, 7200, 32, 36, 0x21b61068 +1, 7232, 7232, 32, 36, 0x63361522 +1, 7264, 7264, 32, 36, 0xc86b0a27 +1, 7296, 7296, 32, 36, 0x109d0ee7 +1, 7328, 7328, 32, 36, 0x28bf0f53 +0, 1000, 1000, 250, 692, 0x19670524, F=0x0 +1, 7360, 7360, 32, 36, 0x236410f9 +1, 7392, 7392, 32, 36, 0xfdd20ee7 +1, 7424, 7424, 32, 36, 0x1eef0f2f +1, 7456, 7456, 32, 36, 0x03b40f8a +1, 7488, 7488, 32, 36, 0xe5830e04 +1, 7520, 7520, 32, 36, 0x29070fb1 +1, 7552, 7552, 32, 36, 0x6fa8150e +1, 7584, 7584, 32, 36, 0xbe0a0b5b +1, 7616, 7616, 32, 36, 0xd80c0bb9 +1, 7648, 7648, 32, 36, 0xed7f0d8b +1, 7680, 7680, 32, 36, 0xa9e90974 +1, 7712, 7712, 32, 36, 0x2728117c +1, 7744, 7744, 32, 36, 0x4834143d +1, 7776, 7776, 32, 36, 0x665413e9 +1, 7808, 7808, 32, 36, 0xdc480c88 +1, 7840, 7840, 32, 36, 0xf45a0d62 +1, 7872, 7872, 32, 36, 0x968e0928 +1, 7904, 7904, 32, 36, 0xf26d0d20 +1, 7936, 7936, 32, 36, 0x65b01343 +1, 7968, 7968, 32, 36, 0x73441438 +1, 8000, 8000, 32, 36, 0x314310f8 +1, 8032, 8032, 32, 36, 0xe3890c44 +1, 8064, 8064, 32, 36, 0xf1630d6f +1, 8096, 8096, 32, 36, 0x0f100fc1 +1, 8128, 8128, 32, 36, 0x5c5914ca +1, 8160, 8160, 32, 36, 0xdc000c55 +1, 8192, 8192, 32, 36, 0xdeab0d10 +1, 8224, 8224, 32, 36, 0x12661035 +1, 8256, 8256, 32, 36, 0x17b5105e +1, 8288, 8288, 32, 36, 0x39f71177 +1, 8320, 8320, 32, 36, 0xd1200b9e +1, 8352, 8352, 32, 36, 0xdc3d0d57 +1, 8384, 8384, 32, 36, 0x027c0f35 +1, 8416, 8416, 32, 36, 0x3f3d10eb +1, 8448, 8448, 32, 36, 0x493111d6 +1, 8480, 8480, 32, 36, 0x22a5106a +1, 8512, 8512, 32, 36, 0xfc7b0dbf +1, 8544, 8544, 32, 36, 0x6ea71312 +1, 8576, 8576, 32, 36, 0xd1a30b94 +1, 8608, 8608, 32, 36, 0x45f71213 +1, 8640, 8640, 32, 36, 0xd0c50d1a +1, 8672, 8672, 32, 36, 0x1e79102a +1, 8704, 8704, 32, 36, 0x35cf107c +1, 8736, 8736, 32, 36, 0x5f6706d0 +1, 8768, 8768, 32, 36, 0x1c4c1022 +1, 8800, 8800, 32, 36, 0xf7a10db0 +1, 8832, 8832, 32, 36, 0x14d00fa0 +1, 8864, 8864, 32, 36, 0x92241780 +1, 8896, 8896, 32, 36, 0x0bc80d9a +1, 8928, 8928, 32, 36, 0xcbb20a97 +1, 8960, 8960, 32, 36, 0xe1d00d8b +1, 8992, 8992, 32, 36, 0x09e10e8e +1, 9024, 9024, 32, 36, 0x16cd0d21 +1, 9056, 9056, 32, 36, 0xf67b0f57 +1, 9088, 9088, 32, 36, 0x862116fc +1, 9120, 9120, 32, 36, 0xb1010934 +1, 9152, 9152, 32, 36, 0x12020f82 +1, 9184, 9184, 32, 36, 0x46451261 +0, 1250, 1250, 250, 692, 0x19670524, F=0x0 +1, 9216, 9216, 32, 36, 0x59ed135e +1, 9248, 9248, 32, 36, 0x1bcd0fe6 +1, 9280, 9280, 32, 36, 0xc4c80b83 +1, 9312, 9312, 32, 36, 0x4799118b +1, 9344, 9344, 32, 36, 0x32e31191 +1, 9376, 9376, 32, 36, 0x829e0787 +1, 9408, 9408, 32, 36, 0x06a50f11 +1, 9440, 9440, 32, 36, 0x0ccd0e9a +1, 9472, 9472, 32, 36, 0x022f0d58 +1, 9504, 9504, 32, 36, 0x0bf91078 +1, 9536, 9536, 32, 36, 0x002b0e8c +1, 9568, 9568, 32, 36, 0x075f0de8 +1, 9600, 9600, 32, 36, 0x16ba0e9c +1, 9632, 9632, 32, 36, 0x479b1218 +1, 9664, 9664, 32, 36, 0xf6fd0ecd +1, 9696, 9696, 32, 36, 0x2e3e104a +1, 9728, 9728, 32, 36, 0xe12f0dab +1, 9760, 9760, 32, 36, 0xeaad0c5c +1, 9792, 9792, 32, 36, 0x05650e27 +1, 9824, 9824, 32, 36, 0x0f6f0f58 +1, 9856, 9856, 32, 36, 0x564213ae +1, 9888, 9888, 32, 36, 0x07810d71 +1, 9920, 9920, 32, 36, 0x2ad30f8a +1, 9952, 9952, 32, 36, 0x2da30ffd +1, 9984, 9984, 32, 36, 0x136b0f0e +1, 10016, 10016, 32, 36, 0x1f710eb7 +1, 10048, 10048, 32, 36, 0xf4850fb3 +1, 10080, 10080, 32, 36, 0xcdc40a85 +1, 10112, 10112, 32, 36, 0x0c400d07 +1, 10144, 10144, 32, 36, 0x38001061 +1, 10176, 10176, 32, 36, 0xa5400993 +1, 10208, 10208, 32, 36, 0x0d000eea +1, 10240, 10240, 32, 36, 0x4a68140b +1, 10272, 10272, 32, 36, 0x3e221193 +1, 10304, 10304, 32, 36, 0xdca00c8d +1, 10336, 10336, 32, 36, 0x0faf0e66 +1, 10368, 10368, 32, 36, 0xfc100f37 +1, 10400, 10400, 32, 36, 0x31d1111b +1, 10432, 10432, 32, 36, 0x9fcd082c +1, 10464, 10464, 32, 36, 0xd6c10a20 +1, 10496, 10496, 32, 36, 0xcbd30c77 +1, 10528, 10528, 32, 36, 0x3c7711ab +1, 10560, 10560, 32, 36, 0x3b651155 +1, 10592, 10592, 32, 36, 0xec1b0d84 +1, 10624, 10624, 32, 36, 0xa02308e4 +1, 10656, 10656, 32, 36, 0xd6310b90 +1, 10688, 10688, 32, 36, 0x31d4106e +1, 10720, 10720, 32, 36, 0x1fa70fd3 +1, 10752, 10752, 32, 36, 0x432f10f5 +1, 10784, 10784, 32, 36, 0xf5110f2f +1, 10816, 10816, 32, 36, 0x18a80fb8 +1, 10848, 10848, 32, 36, 0xf4e30c7b +1, 10880, 10880, 32, 36, 0xba900bd4 +1, 10912, 10912, 32, 36, 0xf79f0ead +1, 10944, 10944, 32, 36, 0x3c81123a +1, 10976, 10976, 32, 36, 0xeb4b0cb6 +1, 11008, 11008, 32, 36, 0x722713ee +0, 1500, 1500, 250, 4132, 0x17980a95 +1, 11040, 11040, 32, 36, 0x3cfa1162 +1, 11072, 11072, 32, 36, 0xe4500df7 +1, 11104, 11104, 32, 36, 0x1d800f9b +1, 11136, 11136, 32, 36, 0xe2e80c61 +1, 11168, 11168, 32, 36, 0x20e6115f +1, 11200, 11200, 32, 36, 0x00090f1f +1, 11232, 11232, 32, 36, 0x1cf10ef8 +1, 11264, 11264, 32, 36, 0xccd40cd1 +1, 11296, 11296, 32, 36, 0x4b5312b5 +1, 11328, 11328, 32, 36, 0xd52c0d69 +1, 11360, 11360, 32, 36, 0xf3270b75 +1, 11392, 11392, 32, 36, 0xef5b0cff +1, 11424, 11424, 32, 36, 0xe1810d5d +1, 11456, 11456, 32, 36, 0x5498137d +1, 11488, 11488, 32, 36, 0xcf880e2f +1, 11520, 11520, 32, 36, 0x1f9410ef +1, 11552, 11552, 32, 36, 0xfb350f29 +1, 11584, 11584, 32, 36, 0x0d2b0f8c +1, 11616, 11616, 32, 36, 0xd1220b45 +1, 11648, 11648, 32, 36, 0xe0470bfc +1, 11680, 11680, 32, 36, 0x4402115a +1, 11712, 11712, 32, 36, 0xf6420f2d +1, 11744, 11744, 32, 36, 0x00551064 +1, 11776, 11776, 32, 36, 0xf4680f2d +1, 11808, 11808, 32, 36, 0x234f111a +1, 11840, 11840, 32, 36, 0x3a6711ee +1, 11872, 11872, 32, 36, 0x4bab129b +1, 11904, 11904, 32, 36, 0x953308fb +1, 11936, 11936, 32, 36, 0x88a10832 +1, 11968, 11968, 32, 36, 0xd1640ba7 +1, 12000, 12000, 32, 36, 0xf6b80dfa +1, 12032, 12032, 32, 36, 0x345e0fd0 +1, 12064, 12064, 32, 36, 0x7b7b169f +1, 12096, 12096, 32, 36, 0x610e1512 +1, 12128, 12128, 32, 36, 0x6d5e1574 +1, 12160, 12160, 32, 36, 0x64931474 +1, 12192, 12192, 32, 36, 0x59151209 +1, 12224, 12224, 32, 36, 0xfc370d3f +1, 12256, 12256, 32, 36, 0xc747099f +1, 12288, 12288, 32, 36, 0xb6440913 +1, 12320, 12320, 32, 36, 0xba8f09ce +1, 12352, 12352, 32, 36, 0x053e0ebd +1, 12384, 12384, 32, 36, 0x11a20f40 +1, 12416, 12416, 32, 36, 0x24711378 +1, 12448, 12448, 32, 36, 0x78bf162c +1, 12480, 12480, 32, 36, 0xd3291a80 +1, 12512, 12512, 32, 36, 0x861a17aa +1, 12544, 12544, 32, 36, 0x440b132b +1, 12576, 12576, 32, 36, 0x16521134 +1, 12608, 12608, 32, 36, 0x0bf90ef5 +1, 12640, 12640, 32, 36, 0xa5a80a32 +1, 12672, 12672, 32, 36, 0xf89d0d25 +1, 12704, 12704, 32, 36, 0x9941081e +1, 12736, 12736, 32, 36, 0xaf8c0958 +1, 12768, 12768, 32, 36, 0x7f2c06f1 +1, 12800, 12800, 32, 36, 0xa49c0908 +1, 12832, 12832, 32, 36, 0xd2140b31 +0, 1750, 1750, 250, 15856, 0xa8544433, F=0x0 +1, 12864, 12864, 32, 36, 0x2ce911fe +1, 12896, 12896, 32, 36, 0x8b1f173e +1, 12928, 12928, 32, 36, 0x7cfa1735 +1, 12960, 12960, 32, 36, 0x7aa016b3 +1, 12992, 12992, 32, 36, 0x623216ea +1, 13024, 13024, 32, 36, 0x8acb1769 +1, 13056, 13056, 32, 36, 0x1837110a +1, 13088, 13088, 32, 36, 0x2403109e +1, 13120, 13120, 32, 36, 0x42bf11ce +1, 13152, 13152, 32, 36, 0xf6120d7f +1, 13184, 13184, 32, 36, 0x24f50e9a +1, 13216, 13216, 32, 36, 0xd0a20a2a +1, 13248, 13248, 32, 36, 0xc2630944 +1, 13280, 13280, 32, 36, 0xf6470af5 +1, 13312, 13312, 32, 36, 0xc2dd09f5 +1, 13344, 13344, 32, 36, 0x821d06fa +1, 13376, 13376, 32, 36, 0xde0b0b39 +1, 13408, 13408, 32, 36, 0x1d601056 +1, 13440, 13440, 32, 36, 0xd0560daa +1, 13472, 13472, 32, 36, 0x23df114a +1, 13504, 13504, 32, 36, 0x4571106a +1, 13536, 13536, 32, 36, 0xd7dc0bac +1, 13568, 13568, 32, 36, 0x685b13ca +1, 13600, 13600, 32, 36, 0xf42c0f4c +1, 13632, 13632, 32, 36, 0x3c341108 +1, 13664, 13664, 32, 36, 0x216c0fad +1, 13696, 13696, 32, 36, 0x0d57103d +1, 13728, 13728, 32, 36, 0x12450f28 +1, 13760, 13760, 32, 36, 0x50951099 +1, 13792, 13792, 32, 36, 0x471c125e +1, 13824, 13824, 32, 36, 0x44da1227 +1, 13856, 13856, 32, 36, 0xe99e0e50 +1, 13888, 13888, 32, 36, 0x120a1194 +1, 13920, 13920, 32, 36, 0x378d1085 +1, 13952, 13952, 32, 36, 0xb7c009c2 +1, 13984, 13984, 32, 36, 0x3a9c0e78 +1, 14016, 14016, 32, 36, 0x27f20f6c +1, 14048, 14048, 32, 36, 0xd2020d12 +1, 14080, 14080, 32, 36, 0x49fb0ed4 +1, 14112, 14112, 32, 36, 0x30731031 +1, 14144, 14144, 32, 36, 0xb2950d01 +1, 14176, 14176, 32, 36, 0xd4a40cdb +1, 14208, 14208, 32, 36, 0xf59c0bd8 +1, 14240, 14240, 32, 36, 0xcd020a0e +1, 14272, 14272, 32, 36, 0xdab80b5d +1, 14304, 14304, 32, 36, 0xf50d0bdf +1, 14336, 14336, 32, 36, 0x36c210b2 +1, 14368, 14368, 32, 36, 0x5eee137a +1, 14400, 14400, 32, 36, 0x49e413b8 +1, 14432, 14432, 32, 36, 0xfc130e85 +1, 14464, 14464, 32, 36, 0x1bfc0ef6 +1, 14496, 14496, 32, 36, 0x4f2c1360 +1, 14528, 14528, 32, 36, 0x97570b31 +1, 14560, 14560, 32, 36, 0xccda0cb9 +1, 14592, 14592, 32, 36, 0xb03909bf +1, 14624, 14624, 32, 36, 0xadb708ed +1, 14656, 14656, 32, 36, 0xd3250b3b +1, 14688, 14688, 32, 36, 0xdd8f0acc +0, 2000, 2000, 250, 5188, 0xa62b9e22, F=0x0 +1, 14720, 14720, 32, 36, 0x3e9c11a6 +1, 14752, 14752, 32, 36, 0x225d1011 +1, 14784, 14784, 32, 36, 0x42040ebb +1, 14816, 14816, 32, 36, 0x0dbf0f33 +1, 14848, 14848, 32, 36, 0x91d81647 +1, 14880, 14880, 32, 36, 0x09d20ff1 +1, 14912, 14912, 32, 36, 0xfce60ef2 +1, 14944, 14944, 32, 36, 0x1aa30f99 +1, 14976, 14976, 32, 36, 0x7d861571 +1, 15008, 15008, 32, 36, 0x6ff6130c +1, 15040, 15040, 32, 36, 0x4d18131e +1, 15072, 15072, 32, 36, 0x22aa0fe4 +1, 15104, 15104, 32, 36, 0x05310ec6 +1, 15136, 15136, 32, 36, 0x15a00f13 +1, 15168, 15168, 32, 36, 0xd88f0db6 +1, 15200, 15200, 32, 36, 0xa24e0aa8 +1, 15232, 15232, 32, 36, 0xde2c0b32 +1, 15264, 15264, 32, 36, 0xf3fb0dba +1, 15296, 15296, 32, 36, 0x01390d97 +1, 15328, 15328, 32, 36, 0xb4e20cfa +1, 15360, 15360, 32, 36, 0xb4cb0a40 +1, 15392, 15392, 32, 36, 0x16060ec7 +1, 15424, 15424, 32, 36, 0xba880d81 +1, 15456, 15456, 32, 36, 0x28b41135 +1, 15488, 15488, 32, 36, 0xf6da0dab +1, 15520, 15520, 32, 36, 0xfb810e94 +1, 15552, 15552, 32, 36, 0x321c0f95 +1, 15584, 15584, 32, 36, 0x31250ffe +1, 15616, 15616, 32, 36, 0x2db9124e +1, 15648, 15648, 32, 36, 0x6495131b +1, 15680, 15680, 32, 36, 0x7b2c15c4 +1, 15712, 15712, 32, 36, 0x3d59110a +1, 15744, 15744, 32, 36, 0x7b261531 +1, 15776, 15776, 32, 36, 0x2312100f +1, 15808, 15808, 32, 36, 0x10c20f3d +1, 15840, 15840, 32, 36, 0x40fa1186 +1, 15872, 15872, 32, 36, 0xf7000e57 +1, 15904, 15904, 32, 36, 0xf3e10ee3 +1, 15936, 15936, 32, 36, 0x176c0ece +1, 15968, 15968, 32, 36, 0x1c720f69 +1, 16000, 16000, 32, 36, 0xee220e1d +1, 16032, 16032, 32, 36, 0xea8e0cf7 +1, 16064, 16064, 32, 36, 0xd4c20bf1 +1, 16096, 16096, 32, 36, 0xc6570db0 +1, 16128, 16128, 32, 36, 0xde310f99 +1, 16160, 16160, 32, 36, 0x0a191004 +1, 16192, 16192, 32, 36, 0x2e2d1314 +1, 16224, 16224, 32, 36, 0x09a21155 +1, 16256, 16256, 32, 36, 0x4b920fba +1, 16288, 16288, 32, 36, 0x669410d4 +1, 16320, 16320, 32, 36, 0x0e9f0d80 +1, 16352, 16352, 32, 36, 0x3c800fe6 +1, 16384, 16384, 32, 36, 0x499a0ff4 +1, 16416, 16416, 32, 36, 0x49541083 +1, 16448, 16448, 32, 36, 0x6d891200 +1, 16480, 16480, 32, 36, 0x8f0215d9 +1, 16512, 16512, 32, 36, 0x4b2e114a +1, 16544, 16544, 32, 36, 0x3c2612aa +1, 16576, 16576, 32, 36, 0xfa91105e +1, 16608, 16608, 32, 36, 0x28e412db +1, 16640, 16640, 32, 36, 0xe82f0f43 +1, 16672, 16672, 32, 36, 0xd8010dc9 +1, 16704, 16704, 32, 36, 0xf06f0e2e +1, 16736, 16736, 32, 36, 0x11000fd2 +1, 16768, 16768, 32, 36, 0xb5540d40 +1, 16800, 16800, 32, 36, 0xd3570d74 +1, 16832, 16832, 32, 36, 0x38411083 +1, 16864, 16864, 32, 36, 0x034a0dfb +1, 16896, 16896, 32, 36, 0x15d20f0b +1, 16928, 16928, 32, 36, 0xd1e40c30 +1, 16960, 16960, 32, 36, 0x9d5c164c +1, 16992, 16992, 32, 36, 0x56231320 +1, 17024, 17024, 32, 36, 0x02740e7e +1, 17056, 17056, 32, 36, 0x455a11f6 +1, 17088, 17088, 32, 36, 0x01290e6b +1, 17120, 17120, 32, 36, 0xea900e9f +1, 17152, 17152, 32, 36, 0x93180932 +1, 17184, 17184, 32, 36, 0xe9680dee +1, 17216, 17216, 32, 36, 0xf33a0d07 +1, 17248, 17248, 32, 36, 0xeaef0d65 +1, 17280, 17280, 32, 36, 0xf6a80e5d +1, 17312, 17312, 32, 36, 0x24d21239 +1, 17344, 17344, 32, 36, 0x6c9a1618 +1, 17376, 17376, 32, 36, 0x20be0fb2 +1, 17408, 17408, 32, 36, 0xec0a0d7d +1, 17440, 17440, 32, 36, 0xf1da0d29 +1, 17472, 17472, 32, 36, 0xef790c6c +1, 17504, 17504, 32, 36, 0x072b0c5e +1, 17536, 17536, 32, 36, 0xf7690cfb +1, 17568, 17568, 32, 36, 0x182d0e73 +1, 17600, 17600, 32, 36, 0x0f9a0dc9 +1, 17632, 17632, 32, 36, 0x66de13dc +1, 17664, 17664, 32, 36, 0x00f00f99 +1, 17696, 17696, 32, 36, 0xe4ef0edd +1, 17728, 17728, 32, 36, 0x55b211e1 +1, 17760, 17760, 32, 36, 0x0aee1017 +1, 17792, 17792, 32, 36, 0xd1cc0d16 +1, 17824, 17824, 32, 36, 0xcd600bf3 +1, 17856, 17856, 32, 36, 0x1bc20f4f +1, 17888, 17888, 32, 36, 0x91000860 +1, 17920, 17920, 32, 36, 0xbc920b07 +1, 17952, 17952, 32, 36, 0xe22e0d3c +1, 17984, 17984, 32, 36, 0xeac30c80 +1, 18016, 18016, 32, 36, 0x07f10eb0 +1, 18048, 18048, 32, 36, 0xe5ec0d04 +1, 18080, 18080, 32, 36, 0xea870eab +1, 18112, 18112, 32, 36, 0x213f1033 +1, 18144, 18144, 32, 36, 0x3bf911b1 +1, 18176, 18176, 32, 36, 0xe5890ee7 +1, 18208, 18208, 32, 36, 0x6ae0141f +1, 18240, 18240, 32, 36, 0x465c130a +1, 18272, 18272, 32, 36, 0x1aa50fca +1, 18304, 18304, 32, 36, 0xf2150d3c +1, 18336, 18336, 32, 36, 0x1deb0e27 +1, 18368, 18368, 32, 36, 0x29740ff8 +1, 18400, 18400, 32, 36, 0x080c0e6c +1, 18432, 18432, 32, 36, 0x0bd10ee8 +1, 18464, 18464, 32, 36, 0x0f141063 +1, 18496, 18496, 32, 36, 0x34901083 +1, 18528, 18528, 32, 36, 0xd5c00bb2 +1, 18560, 18560, 32, 36, 0x10ff0e3a +1, 18592, 18592, 32, 36, 0x46ff1150 +1, 18624, 18624, 32, 36, 0x4f4e12ca +1, 18656, 18656, 32, 36, 0x90bf15aa +1, 18688, 18688, 32, 36, 0x74ed13f9 +1, 18720, 18720, 32, 36, 0x0e220f0d +1, 18752, 18752, 32, 36, 0x04ee10b1 +1, 18784, 18784, 32, 36, 0xf1021000 +1, 18816, 18816, 32, 36, 0x31121108 +1, 18848, 18848, 32, 36, 0x35d1125f +1, 18880, 18880, 32, 36, 0x04131073 +1, 18912, 18912, 32, 36, 0xdef90d1a +1, 18944, 18944, 32, 36, 0xdcaa0c95 +1, 18976, 18976, 32, 36, 0x27d0107e +1, 19008, 19008, 32, 36, 0xeb7d0e4e +1, 19040, 19040, 32, 36, 0xbb990b11 +1, 19072, 19072, 32, 36, 0xdac50c08 +1, 19104, 19104, 32, 36, 0xf8620e32 +1, 19136, 19136, 32, 36, 0x33b7113a +1, 19168, 19168, 32, 36, 0x09b71170 +1, 19200, 19200, 32, 36, 0x0bc70f13 +1, 19232, 19232, 32, 36, 0x14191199 +1, 19264, 19264, 32, 36, 0xbc950aa2 +1, 19296, 19296, 32, 36, 0xecde0def +1, 19328, 19328, 32, 36, 0xf69b0e79 +1, 19360, 19360, 32, 36, 0x46b60f9a +1, 19392, 19392, 32, 36, 0x164b0ff6 +1, 19424, 19424, 32, 36, 0x17da1062 +1, 19456, 19456, 32, 36, 0x237e1073 +1, 19488, 19488, 32, 36, 0xe3de0efa +1, 19520, 19520, 32, 36, 0xf10c0e27 +1, 19552, 19552, 32, 36, 0xfed6102c +1, 19584, 19584, 32, 36, 0x3c711105 +1, 19616, 19616, 32, 36, 0x5611120d +1, 19648, 19648, 32, 36, 0x0ce50e43 +1, 19680, 19680, 32, 36, 0x17430eef +1, 19712, 19712, 32, 36, 0x1e091083 +1, 19744, 19744, 32, 36, 0x356a1129 +1, 19776, 19776, 32, 36, 0x41bb10dd +1, 19808, 19808, 32, 36, 0x2b3d10ac +1, 19840, 19840, 32, 36, 0x00d60c94 +1, 19872, 19872, 32, 36, 0x232c0f44 +1, 19904, 19904, 32, 36, 0xdb240b6f +1, 19936, 19936, 32, 36, 0xfcfd0e5e +1, 19968, 19968, 32, 36, 0x89eb07a0 +1, 20000, 20000, 32, 36, 0x28ac0fc7 +1, 20032, 20032, 32, 36, 0x0c640e8c +1, 20064, 20064, 32, 36, 0x29031046 +1, 20096, 20096, 32, 36, 0x0d781021 +1, 20128, 20128, 32, 36, 0x4fa114db +1, 20160, 20160, 32, 36, 0x37be11ff +1, 20192, 20192, 32, 36, 0x568612f3 +1, 20224, 20224, 32, 36, 0x0b380def +1, 20256, 20256, 32, 36, 0x349f1224 +1, 20288, 20288, 32, 36, 0x65f6128a +1, 20320, 20320, 32, 36, 0x1e030ec1 +1, 20352, 20352, 32, 36, 0x1db60ea9 +1, 20384, 20384, 32, 36, 0xeb020e1a +1, 20416, 20416, 32, 36, 0xc9e90b24 +1, 20448, 20448, 32, 36, 0x189e1138 +1, 20480, 20480, 32, 36, 0xd3540a81 +1, 20512, 20512, 32, 36, 0x33601087 +1, 20544, 20544, 32, 36, 0xe8ff0d9d +1, 20576, 20576, 32, 36, 0xca8a0ae5 +1, 20608, 20608, 32, 36, 0x38e7132c +1, 20640, 20640, 32, 36, 0x03650ebd +1, 20672, 20672, 32, 36, 0x5f7012f3 +1, 20704, 20704, 32, 36, 0x18d110dc +1, 20736, 20736, 32, 36, 0xf7450e08 +1, 20768, 20768, 32, 36, 0x11b00e6f +1, 20800, 20800, 32, 36, 0xc0670af1 +1, 20832, 20832, 32, 36, 0x49371251 +1, 20864, 20864, 32, 36, 0x3cf712a9 +1, 20896, 20896, 32, 36, 0x524712d1 +1, 20928, 20928, 32, 36, 0x387110db +1, 20960, 20960, 32, 36, 0x601912fd +1, 20992, 20992, 32, 36, 0x0c5b0eee +1, 21024, 21024, 32, 36, 0x12670ec3 +1, 21056, 21056, 32, 36, 0xf7100deb +1, 21088, 21088, 32, 36, 0x38b710f3 +1, 21120, 21120, 32, 36, 0x2ca31130 +1, 21152, 21152, 32, 36, 0x3532107a +1, 21184, 21184, 32, 36, 0x39aa113c +1, 21216, 21216, 32, 36, 0x023c0f36 +1, 21248, 21248, 32, 36, 0x1a9c1098 +1, 21280, 21280, 32, 36, 0x303c1058 +1, 21312, 21312, 32, 36, 0x24e910fc +1, 21344, 21344, 32, 36, 0x2df11162 +1, 21376, 21376, 32, 36, 0xef520d7c +1, 21408, 21408, 32, 36, 0x0a000f30 +1, 21440, 21440, 32, 36, 0x09b30e47 +1, 21472, 21472, 32, 36, 0xf1e90d08 +1, 21504, 21504, 32, 36, 0x576c128a +1, 21536, 21536, 32, 36, 0x1f640f97 +1, 21568, 21568, 32, 36, 0x195b0eac +1, 21600, 21600, 32, 36, 0xe47e0d05 +1, 21632, 21632, 32, 36, 0xda1c0caa +1, 21664, 21664, 32, 36, 0x20da0ef5 +1, 21696, 21696, 32, 36, 0xd1ef0d80 +1, 21728, 21728, 32, 36, 0x85271574 +1, 21760, 21760, 32, 36, 0xef860df7 +1, 21792, 21792, 32, 36, 0x394f1112 +1, 21824, 21824, 32, 36, 0x33ea1140 +1, 21856, 21856, 32, 36, 0x238f10e1 +1, 21888, 21888, 32, 36, 0x26d3105a +1, 21920, 21920, 32, 36, 0x3e3a114a +1, 21952, 21952, 32, 36, 0x0a890ff3 +1, 21984, 21984, 32, 36, 0xc5190bfc +1, 22016, 22016, 32, 36, 0x6d1413a7 +1, 22048, 22048, 32, 36, 0xfadb0deb +1, 22080, 22080, 32, 36, 0x3a80139f +1, 22112, 22112, 32, 36, 0x18b110ae +1, 22144, 22144, 32, 36, 0x12141063 +1, 22176, 22176, 32, 36, 0x2dc61085 +1, 22208, 22208, 32, 36, 0xd3b50c13 +1, 22240, 22240, 32, 36, 0x2d931174 +1, 22272, 22272, 32, 36, 0x28f810bf +1, 22304, 22304, 32, 36, 0x0c010fb3 +1, 22336, 22336, 32, 36, 0xfe300e3e +1, 22368, 22368, 32, 36, 0xd1220b81 +1, 22400, 22400, 32, 36, 0x021f0f3b +1, 22432, 22432, 32, 36, 0x3a0910a9 +1, 22464, 22464, 32, 36, 0x4e8912ec +1, 22496, 22496, 32, 36, 0x645b13e4 +1, 22528, 22528, 32, 36, 0x6fc414d6 +1, 22560, 22560, 32, 36, 0x374c1027 +1, 22592, 22592, 32, 36, 0x376b122f +1, 22624, 22624, 32, 36, 0x4a2111b8 +1, 22656, 22656, 32, 36, 0x2def108e +1, 22688, 22688, 32, 36, 0xcbc50b71 +1, 22720, 22720, 32, 36, 0x106f0f82 +1, 22752, 22752, 32, 36, 0xed0b0d09 +1, 22784, 22784, 32, 36, 0x25b81060 +1, 22816, 22816, 32, 36, 0xfef90e5a +1, 22848, 22848, 32, 36, 0x9aeb0bad +1, 22880, 22880, 32, 36, 0x11250eeb +1, 22912, 22912, 32, 36, 0xfb350cc7 +1, 22944, 22944, 32, 36, 0x001e0d8f +1, 22976, 22976, 32, 36, 0x38a10ff0 +1, 23008, 23008, 32, 36, 0x09cd0de7 +1, 23040, 23040, 32, 36, 0x1810102d +1, 23072, 23072, 32, 36, 0xc3760bcd +1, 23104, 23104, 32, 36, 0x13220ff9 +1, 23136, 23136, 32, 36, 0x03400c60 +1, 23168, 23168, 32, 36, 0x17710efe +1, 23200, 23200, 32, 36, 0x4df8115d +1, 23232, 23232, 32, 36, 0x13260fd9 +1, 23264, 23264, 32, 36, 0x21c2105f +1, 23296, 23296, 32, 36, 0xd0370c8f +1, 23328, 23328, 32, 36, 0x5640131a +1, 23360, 23360, 32, 36, 0x434c1129 +1, 23392, 23392, 32, 36, 0x8e4516e7 +1, 23424, 23424, 32, 36, 0x2fd11270 +1, 23456, 23456, 32, 36, 0x79b9134a +1, 23488, 23488, 32, 36, 0x00350d66 +1, 23520, 23520, 32, 36, 0x60c812b2 +1, 23552, 23552, 32, 36, 0xd6ed0cac +1, 23584, 23584, 32, 36, 0xdd370b85 +1, 23616, 23616, 32, 36, 0x9ffe09d7 +1, 23648, 23648, 32, 36, 0x0b6a0f6c +1, 23680, 23680, 32, 36, 0xf4a20dc5 +1, 23712, 23712, 32, 36, 0x30191180 +1, 23744, 23744, 32, 36, 0x66a11363 +1, 23776, 23776, 32, 36, 0x3b9210a7 +1, 23808, 23808, 32, 36, 0x7796153b +1, 23840, 23840, 32, 36, 0x1cd01031 +1, 23872, 23872, 32, 36, 0x0dbb0eac +1, 23904, 23904, 32, 36, 0x1d0e101a +1, 23936, 23936, 32, 36, 0x2cf61125 +1, 23968, 23968, 32, 36, 0xeccc0d17 +1, 24000, 24000, 32, 36, 0x38e911fc +1, 24032, 24032, 32, 36, 0xdb390c0a +1, 24064, 24064, 32, 36, 0xd7c50c26 +1, 24096, 24096, 32, 36, 0x22f910c0 +1, 24128, 24128, 32, 36, 0xec740e58 +1, 24160, 24160, 32, 36, 0x26ac120c +1, 24192, 24192, 32, 36, 0x0d970fe5 +1, 24224, 24224, 32, 36, 0xe3f10e27 +1, 24256, 24256, 32, 36, 0x357212c1 +1, 24288, 24288, 32, 36, 0x203110c8 +1, 24320, 24320, 32, 36, 0xe35e0d9c +1, 24352, 24352, 32, 36, 0xfac00d57 +1, 24384, 24384, 32, 36, 0x3f5510a0 +1, 24416, 24416, 32, 36, 0x26cc0fa7 +1, 24448, 24448, 32, 36, 0x891914a1 +1, 24480, 24480, 32, 36, 0x147b0e72 +1, 24512, 24512, 32, 36, 0x580313fd +1, 24544, 24544, 32, 36, 0x28ee1091 +1, 24576, 24576, 32, 36, 0x5f541255 +1, 24608, 24608, 32, 36, 0xcdcc0b68 +1, 24640, 24640, 32, 36, 0x167e1147 +1, 24672, 24672, 32, 36, 0x3d5d10e5 +1, 24704, 24704, 32, 36, 0xdc3f0b04 +1, 24736, 24736, 32, 36, 0x00d10db8 +1, 24768, 24768, 32, 36, 0x0f6410da +1, 24800, 24800, 32, 36, 0xd7570cd9 +1, 24832, 24832, 32, 36, 0x40f31110 +1, 24864, 24864, 32, 36, 0x0ad60ff0 +1, 24896, 24896, 32, 36, 0x3389117f +1, 24928, 24928, 32, 36, 0xec5b0dfd +1, 24960, 24960, 32, 36, 0x122b0f70 +1, 24992, 24992, 32, 36, 0x32fb1147 +1, 25024, 25024, 32, 36, 0x405f11f1 +1, 25056, 25056, 32, 36, 0xe3040c2a +1, 25088, 25088, 32, 36, 0xe1a90c7e +1, 25120, 25120, 32, 36, 0x4483125c +1, 25152, 25152, 32, 36, 0x1456103d +1, 25184, 25184, 32, 36, 0x1d4d100d +1, 25216, 25216, 32, 36, 0x5f011259 +1, 25248, 25248, 32, 36, 0x426c1260 +1, 25280, 25280, 32, 36, 0x14d90ebf +1, 25312, 25312, 32, 36, 0x15a00f9d +1, 25344, 25344, 32, 36, 0x14a00ee3 +1, 25376, 25376, 32, 36, 0x01130fb8 +1, 25408, 25408, 32, 36, 0x00c90ecc +1, 25440, 25440, 32, 36, 0xe5ec0d47 +1, 25472, 25472, 32, 36, 0xa81e085b +1, 25504, 25504, 32, 36, 0xf3720d0d +1, 25536, 25536, 32, 36, 0x253e0e75 +1, 25568, 25568, 32, 36, 0xf87c0ef2 +1, 25600, 25600, 32, 36, 0xf8820e8e +1, 25632, 25632, 32, 36, 0x14d60f49 +1, 25664, 25664, 32, 36, 0x52191295 +1, 25696, 25696, 32, 36, 0x2e851128 +1, 25728, 25728, 32, 36, 0x31a81068 +1, 25760, 25760, 32, 36, 0x3b0d0f7a +1, 25792, 25792, 32, 36, 0x1f9c1143 +1, 25824, 25824, 32, 36, 0x3a6c0ebc +1, 25856, 25856, 32, 36, 0x1f530ebf +1, 25888, 25888, 32, 36, 0x1be90feb +1, 25920, 25920, 32, 36, 0xceea0dfc +1, 25952, 25952, 32, 36, 0xe7f70d9b +1, 25984, 25984, 32, 36, 0x06ca0ef7 +1, 26016, 26016, 32, 36, 0x4305109a +1, 26048, 26048, 32, 36, 0x2f6b0fd1 +1, 26080, 26080, 32, 36, 0x335b11b7 +1, 26112, 26112, 32, 36, 0x438d139a +1, 26144, 26144, 32, 36, 0x38f110e4 +1, 26176, 26176, 32, 36, 0x06750f86 +1, 26208, 26208, 32, 36, 0x59b212be +1, 26240, 26240, 32, 36, 0x08730da2 +1, 26272, 26272, 32, 36, 0xd34b0cdc +1, 26304, 26304, 32, 36, 0x19b21045 +1, 26336, 26336, 32, 36, 0x1b84103c +1, 26368, 26368, 32, 36, 0x0e760e8c +1, 26400, 26400, 32, 36, 0xf9da0ca1 +1, 26432, 26432, 32, 36, 0x1aec0f89 +1, 26464, 26464, 32, 36, 0xcfd30cd3 +1, 26496, 26496, 32, 36, 0x966a0ae4 +1, 26528, 26528, 32, 36, 0x582b1279 +1, 26560, 26560, 32, 36, 0x072b0ec5 +1, 26592, 26592, 32, 36, 0x3a6e1254 +1, 26624, 26624, 32, 36, 0xd0b40d2f +1, 26656, 26656, 32, 36, 0xbc210b58 +1, 26688, 26688, 32, 36, 0xcc470b9e +1, 26720, 26720, 32, 36, 0x04d10e1c +1, 26752, 26752, 32, 36, 0x0c550e89 +1, 26784, 26784, 32, 36, 0xf4400d7c +1, 26816, 26816, 32, 36, 0x00490d42 +1, 26848, 26848, 32, 36, 0x44ab11a4 +1, 26880, 26880, 32, 36, 0x88dc16ab +1, 26912, 26912, 32, 36, 0x8a351656 +1, 26944, 26944, 32, 36, 0x13fc0fa2 +1, 26976, 26976, 32, 36, 0x03b2114c +1, 27008, 27008, 32, 36, 0x1ea30f37 +1, 27040, 27040, 32, 36, 0x248e1131 +1, 27072, 27072, 32, 36, 0xf36f0fc8 +1, 27104, 27104, 32, 36, 0x22fb0ed5 +1, 27136, 27136, 32, 36, 0x2465121a +1, 27168, 27168, 32, 36, 0x2fe8109b +1, 27200, 27200, 32, 36, 0x3a84101e +1, 27232, 27232, 32, 36, 0x00270ea4 +1, 27264, 27264, 32, 36, 0x002e0d36 +1, 27296, 27296, 32, 36, 0x2a9010ac +1, 27328, 27328, 32, 36, 0xf25d0d38 +1, 27360, 27360, 32, 36, 0x6e3812fd +1, 27392, 27392, 32, 36, 0xcec20c58 +1, 27424, 27424, 32, 36, 0xe6ea0d7d +1, 27456, 27456, 32, 36, 0x0f490f49 +1, 27488, 27488, 32, 36, 0xe04c0f0f +1, 27520, 27520, 32, 36, 0x12880f2d +1, 27552, 27552, 32, 36, 0xf2e40e3d +1, 27584, 27584, 32, 36, 0x14021021 +1, 27616, 27616, 32, 36, 0x2b421024 +1, 27648, 27648, 32, 36, 0x1a521125 +1, 27680, 27680, 32, 36, 0x26a110db +1, 27712, 27712, 32, 36, 0x213d0f31 +1, 27744, 27744, 32, 36, 0x34c40fe8 +1, 27776, 27776, 32, 36, 0x3ed4123d +1, 27808, 27808, 32, 36, 0x01ca0e66 +1, 27840, 27840, 32, 36, 0x01a50e71 +1, 27872, 27872, 32, 36, 0x35e10fce +1, 27904, 27904, 32, 36, 0xe19a0d1a +1, 27936, 27936, 32, 36, 0x3b551396 +1, 27968, 27968, 32, 36, 0xe1b30db8 +1, 28000, 28000, 32, 36, 0x09e20e40 +1, 28032, 28032, 32, 36, 0xfb3c0db0 +1, 28064, 28064, 32, 36, 0xf6d90d85 +1, 28096, 28096, 32, 36, 0x476c122c +1, 28128, 28128, 32, 36, 0x3fbb11af +1, 28160, 28160, 32, 36, 0x457012eb +1, 28192, 28192, 32, 36, 0x0fa80e34 +1, 28224, 28224, 32, 36, 0x4de710da +1, 28256, 28256, 32, 36, 0x5f741202 +1, 28288, 28288, 32, 36, 0x41161405 +1, 28320, 28320, 32, 36, 0x5b6a1308 +1, 28352, 28352, 32, 36, 0xf42f0e6a +1, 28384, 28384, 32, 36, 0x34021184 +1, 28416, 28416, 32, 36, 0xfdbb0daa +1, 28448, 28448, 32, 36, 0xd9750d88 +1, 28480, 28480, 32, 36, 0x1fd1102e +1, 28512, 28512, 32, 36, 0x3dc01141 +1, 28544, 28544, 32, 36, 0x0a540f5a +1, 28576, 28576, 32, 36, 0xfc5a0d8f +1, 28608, 28608, 32, 36, 0xfae80dd9 +1, 28640, 28640, 32, 36, 0xf54b0dd2 +1, 28672, 28672, 32, 36, 0x16da0fa8 +1, 28704, 28704, 32, 36, 0x496e1205 +1, 28736, 28736, 32, 36, 0x375e11a0 +1, 28768, 28768, 32, 36, 0x4e911358 +1, 28800, 28800, 32, 36, 0x04840f60 +1, 28832, 28832, 32, 36, 0x2ff8107f +1, 28864, 28864, 32, 36, 0xf5fe0e9a +1, 28896, 28896, 32, 36, 0xe99a0e44 +1, 28928, 28928, 32, 36, 0x3ea411b8 +1, 28960, 28960, 32, 36, 0xf5ef0f01 +1, 28992, 28992, 32, 36, 0x18311074 +1, 29024, 29024, 32, 36, 0x16a30f28 +1, 29056, 29056, 32, 36, 0x1ced0dc1 +1, 29088, 29088, 32, 36, 0xdb570b00 +1, 29120, 29120, 32, 36, 0x1bb20ebf +1, 29152, 29152, 32, 36, 0x0bca0fcd +1, 29184, 29184, 32, 36, 0x064c104a +1, 29216, 29216, 32, 36, 0x30f6105c +1, 29248, 29248, 32, 36, 0x30f40fee +1, 29280, 29280, 32, 36, 0x0c1010c0 +1, 29312, 29312, 32, 36, 0x709514a5 +1, 29344, 29344, 32, 36, 0x24ac1187 +1, 29376, 29376, 32, 36, 0x2431106f +1, 29408, 29408, 32, 36, 0x1e5e1094 +1, 29440, 29440, 32, 36, 0x03a30cf8 +1, 29472, 29472, 32, 36, 0xf2fc0db6 +1, 29504, 29504, 32, 36, 0xdeba0b80 +1, 29536, 29536, 32, 36, 0x13db0fd8 +1, 29568, 29568, 32, 36, 0x400511dc +1, 29600, 29600, 32, 36, 0x00910fc0 +1, 29632, 29632, 32, 36, 0x245010f8 +1, 29664, 29664, 32, 36, 0x31db1356 +1, 29696, 29696, 32, 36, 0x78bb14d1 +1, 29728, 29728, 32, 36, 0x75151509 +1, 29760, 29760, 32, 36, 0xfb060c50 +1, 29792, 29792, 32, 36, 0xbb52096b +1, 29824, 29824, 32, 36, 0xe2780ba4 +1, 29856, 29856, 32, 36, 0xd8000c05 +1, 29888, 29888, 32, 36, 0xe3ea0cad +1, 29920, 29920, 32, 36, 0xd80d0c08 +1, 29952, 29952, 32, 36, 0x2032108a +1, 29984, 29984, 32, 36, 0xe4460d02 +1, 30016, 30016, 32, 36, 0x26771220 +1, 30048, 30048, 32, 36, 0x4e641311 +1, 30080, 30080, 32, 36, 0x16371141 +1, 30112, 30112, 32, 36, 0x2e481227 +1, 30144, 30144, 32, 36, 0xfb9b0e44 +1, 30176, 30176, 32, 36, 0x48131233 +1, 30208, 30208, 32, 36, 0x0ee50f68 +1, 30240, 30240, 32, 36, 0xff3f0ce0 +1, 30272, 30272, 32, 36, 0xfdcb0dfe +1, 30304, 30304, 32, 36, 0xbb080b5d +1, 30336, 30336, 32, 36, 0x15020dab +1, 30368, 30368, 32, 36, 0xfdc50e31 +1, 30400, 30400, 32, 36, 0x022f0efd +1, 30432, 30432, 32, 36, 0x0a9b0eea +1, 30464, 30464, 32, 36, 0x108110ca +1, 30496, 30496, 32, 36, 0xf9160f2a +1, 30528, 30528, 32, 36, 0x6246134f +1, 30560, 30560, 32, 36, 0x11630fc9 +1, 30592, 30592, 32, 36, 0x08b21010 +1, 30624, 30624, 32, 36, 0xd3d20e1e +1, 30656, 30656, 32, 36, 0x41711301 +1, 30688, 30688, 32, 36, 0x34031105 +1, 30720, 30720, 32, 36, 0xba0c0a3b +1, 30752, 30752, 32, 36, 0x23cd0f29 +1, 30784, 30784, 32, 36, 0x11f90d34 +1, 30816, 30816, 32, 36, 0x00e80da0 +1, 30848, 30848, 32, 36, 0xe5620c64 +1, 30880, 30880, 32, 36, 0x13340eab +1, 30912, 30912, 32, 36, 0x04510f06 +1, 30944, 30944, 32, 36, 0x086a0de5 +1, 30976, 30976, 32, 36, 0x13c31039 +1, 31008, 31008, 32, 36, 0x17e310ee +1, 31040, 31040, 32, 36, 0x9797149c +1, 31072, 31072, 32, 36, 0x50c01394 +1, 31104, 31104, 32, 36, 0x40bf10a5 +1, 31136, 31136, 32, 36, 0x558212b4 +1, 31168, 31168, 32, 36, 0x055a0eff +1, 31200, 31200, 32, 36, 0xff290ff9 +1, 31232, 31232, 32, 36, 0x105b0e8b +1, 31264, 31264, 32, 36, 0xfcae0f2a +1, 31296, 31296, 32, 36, 0xfe930cb8 +1, 31328, 31328, 32, 36, 0xe7d60b9c +1, 31360, 31360, 32, 36, 0xd6d20bbe +1, 31392, 31392, 32, 36, 0xfd1d0e4b +1, 31424, 31424, 32, 36, 0xdbe10ddb +1, 31456, 31456, 32, 36, 0xdb4f0d1b +1, 31488, 31488, 32, 36, 0x55a013bf +1, 31520, 31520, 32, 36, 0x04a21087 +1, 31552, 31552, 32, 36, 0x50e913c2 +1, 31584, 31584, 32, 36, 0x153610a6 +1, 31616, 31616, 32, 36, 0x1a981068 +1, 31648, 31648, 32, 36, 0x24c010fe +1, 31680, 31680, 32, 36, 0x17b40dde +1, 31712, 31712, 32, 36, 0x445d116d +1, 31744, 31744, 32, 36, 0x2cd01015 +1, 31776, 31776, 32, 36, 0x3db0114d +1, 31808, 31808, 32, 36, 0xeb0a0c43 +1, 31840, 31840, 32, 36, 0xc01b0c19 +1, 31872, 31872, 32, 36, 0xca500bd8 +1, 31904, 31904, 32, 36, 0x06180e6c +1, 31936, 31936, 32, 36, 0x3e0110da +1, 31968, 31968, 32, 36, 0xedf00d6d +1, 32000, 32000, 32, 36, 0x4d1d1193 +1, 32032, 32032, 32, 36, 0x84a5137b +1, 32064, 32064, 32, 36, 0x41c711e1 +1, 32096, 32096, 32, 36, 0x1ee21042 +1, 32128, 32128, 32, 36, 0x497d1171 +1, 32160, 32160, 32, 36, 0x77561569 +1, 32192, 32192, 32, 36, 0x4e1111ab +1, 32224, 32224, 32, 36, 0x608012e5 +1, 32256, 32256, 32, 36, 0x1e1a10de +1, 32288, 32288, 32, 36, 0x5a7b131c +1, 32320, 32320, 32, 36, 0x60be1388 +1, 32352, 32352, 32, 36, 0xf8940ee9 +1, 32384, 32384, 32, 36, 0x3afd12de +1, 32416, 32416, 32, 36, 0x0ae80ef0 +1, 32448, 32448, 32, 36, 0xe1af0d5d +1, 32480, 32480, 32, 36, 0xf6440f3a +1, 32512, 32512, 32, 36, 0x02ce0f51 +1, 32544, 32544, 32, 36, 0x1d790f61 +1, 32576, 32576, 32, 36, 0xe7960e64 +1, 32608, 32608, 32, 36, 0xcc1e0ae6 +1, 32640, 32640, 32, 36, 0xf9df0dab +1, 32672, 32672, 32, 36, 0x26d10fb1 +1, 32704, 32704, 32, 36, 0xfea60fd9 +1, 32736, 32736, 32, 36, 0x39c710e4 +1, 32768, 32768, 32, 36, 0x21a91079 +1, 32800, 32800, 32, 36, 0x1a940f44 +1, 32832, 32832, 32, 36, 0x14910fca +1, 32864, 32864, 32, 36, 0xd75f0cac +1, 32896, 32896, 32, 36, 0xe68e0fc0 +1, 32928, 32928, 32, 36, 0x597f1181 +1, 32960, 32960, 32, 36, 0x34a51046 +1, 32992, 32992, 32, 36, 0x2dac0e5e +1, 33024, 33024, 32, 36, 0x41da1224 +1, 33056, 33056, 32, 36, 0x3b1c0f81 +1, 33088, 33088, 32, 36, 0x10740eba diff --git a/tests/ref/fate/segafilm-cinepak-mux b/tests/ref/fate/segafilm-cinepak-mux new file mode 100644 index 0000000000..ae39fdd12e --- /dev/null +++ b/tests/ref/fate/segafilm-cinepak-mux @@ -0,0 +1,159 @@ +1316f0df8a8afb34b15218149bb29252 *tests/data/fate/segafilm-cinepak-mux.film_cpk +173220 tests/data/fate/segafilm-cinepak-mux.film_cpk +#tb 0: 1/5 +#media_type 0: video +#codec_id 0: cinepak +#dimensions 0: 100x75 +#sar 0: 0/1 +0, 0, 0, 1, 1222, 0x71c12b5f +0, 1, 1, 1, 1126, 0x758fabe5, F=0x0 +0, 2, 2, 1, 1138, 0xf28daaf9, F=0x0 +0, 3, 3, 1, 1130, 0x08d1fd4e, F=0x0 +0, 4, 4, 1, 1118, 0x33351228, F=0x0 +0, 5, 5, 1, 1130, 0x6e101ed2, F=0x0 +0, 6, 6, 1, 1122, 0x39d225ac, F=0x0 +0, 7, 7, 1, 1126, 0x32ae4cb6, F=0x0 +0, 8, 8, 1, 1126, 0xa3ac5a10, F=0x0 +0, 9, 9, 1, 1126, 0x66185561, F=0x0 +0, 10, 10, 1, 1134, 0x2bf85f4e, F=0x0 +0, 11, 11, 1, 1134, 0xe4db7b64, F=0x0 +0, 12, 12, 1, 1130, 0x87e9793e, F=0x0 +0, 13, 13, 1, 1118, 0x8d346c2e, F=0x0 +0, 14, 14, 1, 1126, 0x447d6abb, F=0x0 +0, 15, 15, 1, 1130, 0x090c763a, F=0x0 +0, 16, 16, 1, 1134, 0x11ef80f1, F=0x0 +0, 17, 17, 1, 1126, 0xe9b68fc3, F=0x0 +0, 18, 18, 1, 1126, 0x89c696da, F=0x0 +0, 19, 19, 1, 1114, 0xe6d1a98e, F=0x0 +0, 20, 20, 1, 1126, 0xd35daee7, F=0x0 +0, 21, 21, 1, 1114, 0x25b1a557, F=0x0 +0, 22, 22, 1, 1130, 0x17e69d3e, F=0x0 +0, 23, 23, 1, 1126, 0x8dc88007, F=0x0 +0, 24, 24, 1, 1130, 0x577b7137, F=0x0 +0, 25, 25, 1, 1130, 0x4b887d7e, F=0x0 +0, 26, 26, 1, 1134, 0x144a85b3, F=0x0 +0, 27, 27, 1, 1126, 0xb556722e, F=0x0 +0, 28, 28, 1, 1130, 0xe3db9173, F=0x0 +0, 29, 29, 1, 1138, 0x6e127c53, F=0x0 +0, 30, 30, 1, 1126, 0x0cbf77ad, F=0x0 +0, 31, 31, 1, 1134, 0x110c8f29, F=0x0 +0, 32, 32, 1, 1134, 0xd9e38471, F=0x0 +0, 33, 33, 1, 1138, 0xb177947e, F=0x0 +0, 34, 34, 1, 1130, 0x9a9da5f9, F=0x0 +0, 35, 35, 1, 1102, 0x65e5d1b2, F=0x0 +0, 36, 36, 1, 1098, 0x9d020bdb, F=0x0 +0, 37, 37, 1, 1098, 0xbbcb2c90, F=0x0 +0, 38, 38, 1, 1122, 0x0b6eb28a, F=0x0 +0, 39, 39, 1, 1130, 0x86dec1ac, F=0x0 +0, 40, 40, 1, 1126, 0x2926b05c, F=0x0 +0, 41, 41, 1, 1126, 0x37daa041, F=0x0 +0, 42, 42, 1, 1130, 0xb2859897, F=0x0 +0, 43, 43, 1, 1130, 0xdfdaa4a7, F=0x0 +0, 44, 44, 1, 1126, 0xd83fa84e, F=0x0 +0, 45, 45, 1, 1126, 0x6738a41d, F=0x0 +0, 46, 46, 1, 1122, 0xbff7b2ff, F=0x0 +0, 47, 47, 1, 1126, 0x0bccc0a3, F=0x0 +0, 48, 48, 1, 1126, 0x4083cc7a, F=0x0 +0, 49, 49, 1, 1126, 0x7d5bd199, F=0x0 +0, 50, 50, 1, 1126, 0xf1a6d890, F=0x0 +0, 51, 51, 1, 1118, 0xad19b80a, F=0x0 +0, 52, 52, 1, 1126, 0x8a61d10e, F=0x0 +0, 53, 53, 1, 1118, 0xdafdd4f3, F=0x0 +0, 54, 54, 1, 1122, 0xd171d3b4, F=0x0 +0, 55, 55, 1, 1118, 0xf78adab4, F=0x0 +0, 56, 56, 1, 1122, 0x9e2ad511, F=0x0 +0, 57, 57, 1, 1126, 0x065a94b0, F=0x0 +0, 58, 58, 1, 1130, 0x2c31a378, F=0x0 +0, 59, 59, 1, 1122, 0xe0248cbc, F=0x0 +0, 60, 60, 1, 1370, 0x731b081a, F=0x0 +0, 61, 61, 1, 1126, 0x71f4e747, F=0x0 +0, 62, 62, 1, 1126, 0x5597ec42, F=0x0 +0, 63, 63, 1, 1126, 0xdf25e98a, F=0x0 +0, 64, 64, 1, 1126, 0x70b20e6d, F=0x0 +0, 65, 65, 1, 1130, 0x80291c49 +0, 66, 66, 1, 1130, 0x36312605 +0, 67, 67, 1, 1130, 0x340c32f8, F=0x0 +0, 68, 68, 1, 1138, 0xe39d4da6, F=0x0 +0, 69, 69, 1, 1162, 0x926055c2, F=0x0 +0, 70, 70, 1, 1150, 0x23636430, F=0x0 +0, 71, 71, 1, 1162, 0xa9585bf0, F=0x0 +0, 72, 72, 1, 1182, 0x31aa69f1, F=0x0 +0, 73, 73, 1, 1138, 0x01fe67d0, F=0x0 +0, 74, 74, 1, 1186, 0x19e27b72, F=0x0 +0, 75, 75, 1, 1166, 0xc6308226, F=0x0 +0, 76, 76, 1, 1158, 0xef1d92de, F=0x0 +0, 77, 77, 1, 1178, 0xf330cc25, F=0x0 +0, 78, 78, 1, 1182, 0xa0aed70e, F=0x0 +0, 79, 79, 1, 1126, 0xb572d975, F=0x0 +0, 80, 80, 1, 1162, 0x824bdf60, F=0x0 +0, 81, 81, 1, 1110, 0x0f4be7ec, F=0x0 +0, 82, 82, 1, 1118, 0x87fcd9bf, F=0x0 +0, 83, 83, 1, 1118, 0x33c0d913, F=0x0 +0, 84, 84, 1, 1106, 0x6bf1d24a, F=0x0 +0, 85, 85, 1, 1130, 0xf9d8d39b, F=0x0 +0, 86, 86, 1, 1130, 0x2c98d6c7, F=0x0 +0, 87, 87, 1, 1126, 0xd6dbc72e, F=0x0 +0, 88, 88, 1, 1126, 0xb28cc81b, F=0x0 +0, 89, 89, 1, 1122, 0x6d6dba62, F=0x0 +0, 90, 90, 1, 1126, 0x0e15bf6c, F=0x0 +0, 91, 91, 1, 1118, 0x3bf8b739, F=0x0 +0, 92, 92, 1, 1130, 0xa85ad726, F=0x0 +0, 93, 93, 1, 1126, 0x167fd993, F=0x0 +0, 94, 94, 1, 1118, 0x0f6ad267, F=0x0 +0, 95, 95, 1, 1114, 0x9ad0dfda, F=0x0 +0, 96, 96, 1, 1122, 0x2f7dde25, F=0x0 +0, 97, 97, 1, 1122, 0xb4e2e1bf, F=0x0 +0, 98, 98, 1, 1126, 0x6443e4dd, F=0x0 +0, 99, 99, 1, 1122, 0x7de1dceb, F=0x0 +0, 100, 100, 1, 1094, 0x0422f641, F=0x0 +0, 101, 101, 1, 1126, 0x2bf8e36e, F=0x0 +0, 102, 102, 1, 1126, 0x6215cc8d, F=0x0 +0, 103, 103, 1, 1122, 0xbdd8e81e, F=0x0 +0, 104, 104, 1, 1126, 0x5fa4e361, F=0x0 +0, 105, 105, 1, 1114, 0x02dedc5a, F=0x0 +0, 106, 106, 1, 1122, 0x4807e5ef, F=0x0 +0, 107, 107, 1, 1126, 0x9165d802, F=0x0 +0, 108, 108, 1, 1114, 0xb389d4a2, F=0x0 +0, 109, 109, 1, 1126, 0xbbb4d58e, F=0x0 +0, 110, 110, 1, 1106, 0x0f44e337, F=0x0 +0, 111, 111, 1, 1106, 0x57bae452, F=0x0 +0, 112, 112, 1, 1382, 0x4ef2281a, F=0x0 +0, 113, 113, 1, 1126, 0x79dedd9e, F=0x0 +0, 114, 114, 1, 1114, 0xfa8bf80f, F=0x0 +0, 115, 115, 1, 1110, 0x5f9e122e, F=0x0 +0, 116, 116, 1, 1114, 0x85aa480c, F=0x0 +0, 117, 117, 1, 1122, 0xf7c87737, F=0x0 +0, 118, 118, 1, 1122, 0x2ff57bc7, F=0x0 +0, 119, 119, 1, 1134, 0x1723b925, F=0x0 +0, 120, 120, 1, 1154, 0x1768acf5 +0, 121, 121, 1, 1206, 0xe2f2e7e7, F=0x0 +0, 122, 122, 1, 1130, 0x30a0deb4, F=0x0 +0, 123, 123, 1, 1130, 0x9d8fdff7, F=0x0 +0, 124, 124, 1, 1126, 0xefcbd959, F=0x0 +0, 125, 125, 1, 1130, 0xac08d48b, F=0x0 +0, 126, 126, 1, 1130, 0xd0c0c1e4, F=0x0 +0, 127, 127, 1, 1130, 0x0ecbab42, F=0x0 +0, 128, 128, 1, 1130, 0x85ddb0e9, F=0x0 +0, 129, 129, 1, 1126, 0xb6c29be4, F=0x0 +0, 130, 130, 1, 1130, 0x21e196e0, F=0x0 +0, 131, 131, 1, 1130, 0xd4f7a15e, F=0x0 +0, 132, 132, 1, 1118, 0x35dbacf7, F=0x0 +0, 133, 133, 1, 1126, 0x31a5b4fe, F=0x0 +0, 134, 134, 1, 1122, 0x699cbc4b, F=0x0 +0, 135, 135, 1, 1114, 0x3446b299, F=0x0 +0, 136, 136, 1, 1122, 0xd228ad0a, F=0x0 +0, 137, 137, 1, 1118, 0x9161dd42, F=0x0 +0, 138, 138, 1, 1122, 0x9055ce23, F=0x0 +0, 139, 139, 1, 1114, 0x0d41ddef, F=0x0 +0, 140, 140, 1, 1110, 0x9a6ee6d9, F=0x0 +0, 141, 141, 1, 1110, 0x88b4fbed, F=0x0 +0, 142, 142, 1, 1118, 0x6b4ff2e0, F=0x0 +0, 143, 143, 1, 1118, 0x58cae506, F=0x0 +0, 144, 144, 1, 1114, 0x2e08fbf8, F=0x0 +0, 145, 145, 1, 1110, 0x2329f247, F=0x0 +0, 146, 146, 1, 1114, 0x7c56f7bb, F=0x0 +0, 147, 147, 1, 1118, 0x10b9f719, F=0x0 +0, 148, 148, 1, 1126, 0xda626ba7, F=0x0 +0, 149, 149, 1, 1382, 0x33b21846, F=0x0 +0, 150, 150, 1, 586, 0x12808f58, F=0x0 +0, 151, 151, 1, 190, 0xa9f408c3, F=0x0 diff --git a/tests/ref/fate/segafilm-rawvideo-mux b/tests/ref/fate/segafilm-rawvideo-mux new file mode 100644 index 0000000000..59c5f2e515 --- /dev/null +++ b/tests/ref/fate/segafilm-rawvideo-mux @@ -0,0 +1,98 @@ +c4b24005b314b70783ebb007f50b6c6c *tests/data/fate/segafilm-rawvideo-mux.film_cpk +17841040 tests/data/fate/segafilm-rawvideo-mux.film_cpk +#tb 0: 1/12 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 400x187 +#sar 0: 0/1 +#tb 1: 1/8000 +#media_type 1: audio +#codec_id 1: pcm_s16be_planar +#sample_rate 1: 8000 +#channel_layout_name 1: mono +0, 0, 0, 1, 224400, 0xd8f2f310 +1, 0, 0, 8000, 16000, 0x7ec2d894 +0, 1, 1, 1, 224400, 0xe38676c2 +0, 2, 2, 1, 224400, 0x7163b6ad +0, 3, 3, 1, 224400, 0xa514b0f7 +0, 4, 4, 1, 224400, 0xeed48b96 +0, 5, 5, 1, 224400, 0x5e9f02b2 +0, 6, 6, 1, 224400, 0x70822c53 +0, 7, 7, 1, 224400, 0x93101067 +0, 8, 8, 1, 224400, 0x0710e900 +0, 9, 9, 1, 224400, 0x0e8add6a +0, 10, 10, 1, 224400, 0x53fb2c5a +0, 11, 11, 1, 224400, 0xa58cc02f +0, 12, 12, 1, 224400, 0x0a5cc76b +1, 8000, 8000, 8000, 16000, 0x1fb8d7fa +0, 13, 13, 1, 224400, 0xfa551631 +0, 14, 14, 1, 224400, 0xde9f99bf +0, 15, 15, 1, 224400, 0xe66a8690 +0, 16, 16, 1, 224400, 0xd9e6f3d1 +0, 17, 17, 1, 224400, 0xa479a5c6 +0, 18, 18, 1, 224400, 0xdaa3531f +0, 19, 19, 1, 224400, 0xde3e6843 +0, 20, 20, 1, 224400, 0x181adafd +0, 21, 21, 1, 224400, 0x784b6429 +0, 22, 22, 1, 224400, 0x91cdc30e +0, 23, 23, 1, 224400, 0x6e78be49 +0, 24, 24, 1, 224400, 0x7515644c +1, 16000, 16000, 8000, 16000, 0xb1d7d062 +0, 25, 25, 1, 224400, 0xcc32a91b +0, 26, 26, 1, 224400, 0xc63e3831 +0, 27, 27, 1, 224400, 0xfb53b651 +0, 28, 28, 1, 224400, 0x12ec8a01 +0, 29, 29, 1, 224400, 0x136fcb2c +0, 30, 30, 1, 224400, 0x827fa546 +0, 31, 31, 1, 224400, 0x1773b7f5 +0, 32, 32, 1, 224400, 0x732defc1 +0, 33, 33, 1, 224400, 0x84292372 +0, 34, 34, 1, 224400, 0x20f22365 +0, 35, 35, 1, 224400, 0xb39a0700 +0, 36, 36, 1, 224400, 0xf245706c +1, 24000, 24000, 8000, 16000, 0x831174ae +0, 37, 37, 1, 224400, 0xdb702ae7 +0, 38, 38, 1, 224400, 0xadfefe5b +0, 39, 39, 1, 224400, 0xa667adcb +0, 40, 40, 1, 224400, 0x4d645191 +0, 41, 41, 1, 224400, 0x33802f58 +0, 42, 42, 1, 224400, 0x24eff4b8 +0, 43, 43, 1, 224400, 0x4dc817a6 +0, 44, 44, 1, 224400, 0x9a891d35 +0, 45, 45, 1, 224400, 0x2d0bb83b +0, 46, 46, 1, 224400, 0xd13469c1 +0, 47, 47, 1, 224400, 0xd2e6302a +0, 48, 48, 1, 224400, 0xc7594ee1 +1, 32000, 32000, 8000, 16000, 0x88c62b9f +0, 49, 49, 1, 224400, 0xc6da714c +0, 50, 50, 1, 224400, 0xf675e838 +0, 51, 51, 1, 224400, 0xdc047c76 +0, 52, 52, 1, 224400, 0xe5727de5 +0, 53, 53, 1, 224400, 0x153b0f62 +0, 54, 54, 1, 224400, 0x65922f68 +0, 55, 55, 1, 224400, 0x04e04bfb +0, 56, 56, 1, 224400, 0x1dde6c88 +0, 57, 57, 1, 224400, 0xed3905f2 +0, 58, 58, 1, 224400, 0x211a5996 +0, 59, 59, 1, 224400, 0xd010baaf +0, 60, 60, 1, 224400, 0xcbc9f272 +1, 40000, 40000, 8000, 16000, 0x48c7c649 +0, 61, 61, 1, 224400, 0x7380d6f0 +0, 62, 62, 1, 224400, 0xfd0bf084 +0, 63, 63, 1, 224400, 0xc4d671d9 +0, 64, 64, 1, 224400, 0x84236aa5 +0, 65, 65, 1, 224400, 0x9c584ede +0, 66, 66, 1, 224400, 0xdb0c6029 +0, 67, 67, 1, 224400, 0x775ae560 +0, 68, 68, 1, 224400, 0xe3800916 +0, 69, 69, 1, 224400, 0x9313a8e8 +0, 70, 70, 1, 224400, 0x3a5d07cc +0, 71, 71, 1, 224400, 0x4651a10b +0, 72, 72, 1, 224400, 0xc2d72183 +1, 48000, 48000, 8000, 16000, 0x2e7a742a +0, 73, 73, 1, 224400, 0xcd971625 +0, 74, 74, 1, 224400, 0x9fb0f3c2 +0, 75, 75, 1, 224400, 0x920ee561 +0, 76, 76, 1, 224400, 0x8a2c1bbf +0, 77, 77, 1, 224400, 0x6150c072 +0, 78, 78, 1, 224400, 0x499dc869 diff --git a/tests/ref/fate/segafilm-s8-remux b/tests/ref/fate/segafilm-s8-remux new file mode 100644 index 0000000000..8175d05618 --- /dev/null +++ b/tests/ref/fate/segafilm-s8-remux @@ -0,0 +1,151 @@ +3b5854365d74f6194d3b09e040507370 *tests/data/fate/segafilm-s8-remux.film_cpk +1955240 tests/data/fate/segafilm-s8-remux.film_cpk +#tb 0: 1/30 +#media_type 0: video +#codec_id 0: cinepak +#dimensions 0: 320x224 +#sar 0: 0/1 +#tb 1: 1/44100 +#media_type 1: audio +#codec_id 1: pcm_s8_planar +#sample_rate 1: 44100 +#channel_layout_name 1: stereo +0, 0, 0, 2, 21612, 0x12f0b3c8 +1, 0, 0, 22048, 44096, 0xafd250ae +0, 2, 2, 2, 11080, 0xac3a462b, F=0x0 +0, 4, 4, 2, 11300, 0xd8ee7f3e, F=0x0 +0, 6, 6, 2, 21612, 0x73c3a3f9 +0, 8, 8, 2, 21628, 0x00a5b4b9 +0, 10, 10, 2, 14772, 0x1332b44f, F=0x0 +0, 12, 12, 2, 14744, 0x5ce5d59b, F=0x0 +0, 14, 14, 2, 14736, 0xd5ac2877, F=0x0 +1, 22048, 22048, 11028, 22056, 0xe08a0f01 +0, 16, 16, 2, 16908, 0x90fb4402 +0, 18, 18, 2, 21636, 0x30f36b66 +0, 20, 20, 2, 21648, 0x3ba6ea31 +0, 22, 22, 2, 14744, 0x5c35b960, F=0x0 +1, 33076, 33076, 11024, 22048, 0x4798f7aa +0, 24, 24, 2, 14164, 0xe7c63eaa, F=0x0 +0, 26, 26, 2, 14644, 0x158c7e80, F=0x0 +0, 28, 28, 2, 14760, 0x423e575d, F=0x0 +0, 30, 30, 2, 14784, 0xe56277f8, F=0x0 +1, 44100, 44100, 11028, 22056, 0x8cefd048 +0, 32, 32, 2, 14788, 0x451e0bae, F=0x0 +0, 34, 34, 2, 14784, 0x1a05cb5a, F=0x0 +0, 36, 36, 2, 14784, 0x9898d518, F=0x0 +1, 55128, 55128, 11028, 22056, 0xda5e35ef +0, 38, 38, 2, 14768, 0x7de83ded, F=0x0 +0, 40, 40, 2, 14760, 0x4fbe044b, F=0x0 +0, 42, 42, 2, 14772, 0x246488b7, F=0x0 +0, 44, 44, 2, 14784, 0x4a8e927d, F=0x0 +1, 66156, 66156, 11028, 22056, 0xecb354d5 +0, 46, 46, 2, 14768, 0x0a78d401, F=0x0 +0, 48, 48, 2, 14724, 0x99b092fc, F=0x0 +0, 50, 50, 2, 17424, 0xed3215f7 +0, 52, 52, 2, 14760, 0x936b54f2, F=0x0 +1, 77184, 77184, 11016, 22032, 0x4f023ee7 +0, 54, 54, 2, 14788, 0x512f061b, F=0x0 +0, 56, 56, 2, 14752, 0x8697f416, F=0x0 +0, 58, 58, 2, 14752, 0xf113edc3, F=0x0 +0, 60, 60, 2, 14792, 0xc79a8eff, F=0x0 +1, 88200, 88200, 11028, 22056, 0x00959d91 +0, 62, 62, 2, 14748, 0x9906aeb0, F=0x0 +0, 64, 64, 2, 14752, 0x5d0035fb, F=0x0 +0, 66, 66, 2, 14756, 0x1a18611b, F=0x0 +1, 99228, 99228, 11028, 22056, 0xef42522d +0, 68, 68, 2, 14792, 0x03ecb407, F=0x0 +0, 70, 70, 2, 14792, 0x0b3f8a55, F=0x0 +0, 72, 72, 2, 14788, 0x4db424ef, F=0x0 +0, 74, 74, 2, 14784, 0xe86937be, F=0x0 +1, 110256, 110256, 11028, 22056, 0x344eb013 +0, 76, 76, 2, 14756, 0xdf30850f, F=0x0 +0, 78, 78, 2, 14764, 0x8ba301b0, F=0x0 +0, 80, 80, 2, 16816, 0x019829a4 +0, 82, 82, 2, 14704, 0x28451122, F=0x0 +1, 121284, 121284, 11016, 22032, 0xaad8d420 +0, 84, 84, 2, 14540, 0x4767a033, F=0x0 +0, 86, 86, 2, 14144, 0xa7cff806, F=0x0 +0, 88, 88, 2, 14372, 0x66da8c46, F=0x0 +0, 90, 90, 2, 14296, 0xc98a2efd, F=0x0 +1, 132300, 132300, 11028, 22056, 0xfc76c3d9 +0, 92, 92, 2, 16396, 0xd6235b32 +0, 94, 94, 2, 12464, 0x519c57c9, F=0x0 +0, 96, 96, 2, 12628, 0xf3d3e179, F=0x0 +1, 143328, 143328, 11028, 22056, 0x44073824 +0, 98, 98, 2, 10604, 0x93c6a3d1, F=0x0 +0, 100, 100, 2, 8936, 0xcb92de8c, F=0x0 +0, 102, 102, 2, 8340, 0x7698372b, F=0x0 +0, 104, 104, 2, 7324, 0x782ebf51, F=0x0 +1, 154356, 154356, 11028, 22056, 0x3d7d1aef +0, 106, 106, 2, 6332, 0x23291828, F=0x0 +0, 108, 108, 2, 5448, 0x2426feae, F=0x0 +0, 110, 110, 2, 624, 0x3f9c04b2, F=0x0 +0, 112, 112, 2, 624, 0x3f9c04b2, F=0x0 +1, 165384, 165384, 11016, 22032, 0x91257dfb +0, 114, 114, 2, 624, 0x3f9c04b2, F=0x0 +0, 116, 116, 2, 624, 0x3f9c04b2, F=0x0 +0, 118, 118, 2, 624, 0x3f9c04b2, F=0x0 +0, 120, 120, 2, 624, 0x3f9c04b2, F=0x0 +1, 176400, 176400, 11028, 22056, 0x254d5274 +0, 122, 122, 2, 21540, 0x6a391e7e +0, 124, 124, 2, 6832, 0x4023eaac, F=0x0 +0, 126, 126, 2, 7540, 0xbfc4e26e, F=0x0 +1, 187428, 187428, 11028, 22056, 0x85bf05d4 +0, 128, 128, 2, 7444, 0x37976e60, F=0x0 +0, 130, 130, 2, 7440, 0x5995e2b0, F=0x0 +0, 132, 132, 2, 7620, 0x96c3f568, F=0x0 +0, 134, 134, 2, 7544, 0x185643e7, F=0x0 +1, 198456, 198456, 11028, 22056, 0xe9b89025 +0, 136, 136, 2, 7440, 0x7c67dd22, F=0x0 +0, 138, 138, 2, 9864, 0xd66c84e6 +0, 140, 140, 2, 8344, 0xba857ad0, F=0x0 +0, 142, 142, 2, 7720, 0x31111984, F=0x0 +1, 209484, 209484, 11016, 22032, 0xcf4f1087 +0, 144, 144, 2, 7608, 0xc6539493, F=0x0 +0, 146, 146, 2, 7640, 0x5b3c8a04, F=0x0 +0, 148, 148, 2, 7624, 0x3eb7731a, F=0x0 +0, 150, 150, 2, 7712, 0x3cf7eb6b, F=0x0 +1, 220500, 220500, 11028, 22056, 0x6c016e48 +0, 152, 152, 2, 7700, 0x98833ab2, F=0x0 +0, 154, 154, 2, 9836, 0x9facaa3d +0, 156, 156, 2, 8280, 0x4c16fc91, F=0x0 +1, 231528, 231528, 11028, 22056, 0x76a2c75c +0, 158, 158, 2, 7708, 0x6464873b, F=0x0 +0, 160, 160, 2, 7608, 0xbe0ff68b, F=0x0 +0, 162, 162, 2, 7500, 0x283a0810, F=0x0 +0, 164, 164, 2, 624, 0xb9b505ed, F=0x0 +1, 242556, 242556, 11028, 22056, 0xa882dcb0 +0, 166, 166, 2, 624, 0xb9b505ed, F=0x0 +0, 168, 168, 2, 624, 0xb9b505ed, F=0x0 +0, 170, 170, 2, 624, 0xb9b505ed, F=0x0 +0, 172, 172, 2, 624, 0xb9b505ed, F=0x0 +1, 253584, 253584, 11016, 22032, 0x3797e11a +0, 174, 174, 2, 624, 0xb9b505ed, F=0x0 +0, 176, 176, 2, 624, 0xb9b505ed, F=0x0 +0, 178, 178, 2, 624, 0xb9b505ed, F=0x0 +0, 180, 180, 2, 624, 0xb9b505ed, F=0x0 +1, 264600, 264600, 11028, 22056, 0xec57619f +0, 182, 182, 2, 624, 0xb9b505ed, F=0x0 +0, 184, 184, 2, 21588, 0xa373a2b0 +0, 186, 186, 2, 624, 0x26350647, F=0x0 +1, 275628, 275628, 11028, 22056, 0x14f9a65c +0, 188, 188, 2, 624, 0x26350647, F=0x0 +0, 190, 190, 2, 624, 0x26350647, F=0x0 +0, 192, 192, 2, 21600, 0x8a2d6cf3 +0, 194, 194, 2, 21600, 0x02580c99 +1, 286656, 286656, 11028, 22056, 0x840a0ff0 +0, 196, 196, 2, 21580, 0x9a904a10 +0, 198, 198, 2, 21564, 0xa392b1b8 +0, 200, 200, 2, 21540, 0x70d29597 +0, 202, 202, 2, 21564, 0x41af0d55 +1, 297684, 297684, 11016, 22032, 0x00000000 +0, 204, 204, 2, 21552, 0x4a79481d +0, 206, 206, 2, 21568, 0xe2d9f71f +0, 208, 208, 2, 21504, 0xa23387f4 +0, 210, 210, 2, 21468, 0x7fa401ba +1, 308700, 308700, 11028, 22056, 0x00000000 +0, 212, 212, 2, 21388, 0xca992a77 +0, 214, 214, 2, 21288, 0xb10f1e06 +0, 216, 216, 2, 21096, 0xc421acd3 +1, 319728, 319728, 2200, 4400, 0x00000000 +0, 218, 218, 1, 18548, 0x640b3376 From d438540d2b2f4aea86a2c475b690b8bc1bff7d0e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 00:39:42 +0200 Subject: [PATCH 369/590] avformat/spdifenc: Reorder struct members to make it smaller Signed-off-by: Andreas Rheinhardt --- libavformat/spdifenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c index 7b8e231cff..2861f828b4 100644 --- a/libavformat/spdifenc.c +++ b/libavformat/spdifenc.c @@ -410,8 +410,8 @@ static const uint8_t mat_end_code[16] = { static const struct { unsigned int pos; - const uint8_t *code; unsigned int len; + const uint8_t *code; } mat_codes[] = { MAT_CODE(0, mat_start_code), MAT_CODE(30708, mat_middle_code), From e601ec3c1991ee09ff45db3be4d894e5774f6f2b Mon Sep 17 00:00:00 2001 From: Will Cassella Date: Fri, 9 Sep 2022 22:50:32 +0000 Subject: [PATCH 370/590] libavformat/riffec: Zero-initialize channels in ff_get_wav_header Clang's static analyzer complains that leaving the variable uninitialized could lead to a code path where the uninitialized value is written to at the end of this function. This patch simply zero-initializes that variable to avoid that. Signed-off-by: Will Cassella Signed-off-by: James Almer --- libavformat/riffdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index c1e4a04550..1c149388ab 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -94,7 +94,7 @@ static void parse_waveformatex(AVFormatContext *s, AVIOContext *pb, AVCodecParam int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian) { - int id, channels; + int id, channels = 0; uint64_t bitrate = 0; if (size < 14) { From cc367a9b8aa1e473bf60c5dc5e03431a7bbcd125 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 21 Sep 2022 07:00:15 +0200 Subject: [PATCH 371/590] lavc/lpc: do not explode when windowing a 1-length array Divided by 0. --- libavcodec/lpc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 3238ad5fc8..4885d5cb06 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -38,6 +38,11 @@ static void lpc_apply_welch_window_c(const int32_t *data, int len, double w; double c; + if (len == 1) { + w_data[0] = 0.0; + return; + } + n2 = (len >> 1); c = 2.0 / (len - 1.0); From 3ade6a8644ab519fcd7caa7ef457dd406162bc14 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 19 Sep 2022 23:48:53 +0200 Subject: [PATCH 372/590] x86/lpc: implement a new Welch windowing function Old one was written with the assumption only even inputs would be given. This very messy replacement supports even and odd inputs, and supports AVX2 for extra speed. The buffers given are usually quite big (4k samples), so the speedup is worth it. The new SSE version is still faster than the old inline asm version by 33%. Also checkasm is provided to make sure this monstrosity works. This fixes some FATE tests. --- libavcodec/x86/Makefile | 3 +- libavcodec/x86/lpc.asm | 241 +++++++++++++++++++++++++++ libavcodec/x86/{lpc.c => lpc_init.c} | 72 ++------ tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 + tests/checkasm/checkasm.h | 1 + tests/checkasm/lpc.c | 80 +++++++++ 7 files changed, 343 insertions(+), 58 deletions(-) create mode 100644 libavcodec/x86/lpc.asm rename libavcodec/x86/{lpc.c => lpc_init.c} (64%) create mode 100644 tests/checkasm/lpc.c diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index 4e448623af..e1120b7e15 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -23,7 +23,7 @@ OBJS-$(CONFIG_LLVIDENCDSP) += x86/lossless_videoencdsp_init.o OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp_init.o OBJS-$(CONFIG_HUFFYUVENCDSP) += x86/huffyuvencdsp_init.o OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp_init.o -OBJS-$(CONFIG_LPC) += x86/lpc.o +OBJS-$(CONFIG_LPC) += x86/lpc_init.o OBJS-$(CONFIG_MDCT15) += x86/mdct15_init.o OBJS-$(CONFIG_ME_CMP) += x86/me_cmp_init.o OBJS-$(CONFIG_MPEGAUDIODSP) += x86/mpegaudiodsp.o @@ -127,6 +127,7 @@ X86ASM-OBJS-$(CONFIG_IDCTDSP) += x86/idctdsp.o X86ASM-OBJS-$(CONFIG_LLAUDDSP) += x86/lossless_audiodsp.o X86ASM-OBJS-$(CONFIG_LLVIDDSP) += x86/lossless_videodsp.o X86ASM-OBJS-$(CONFIG_LLVIDENCDSP) += x86/lossless_videoencdsp.o +X86ASM-OBJS-$(CONFIG_LPC) += x86/lpc.o X86ASM-OBJS-$(CONFIG_MDCT15) += x86/mdct15.o X86ASM-OBJS-$(CONFIG_ME_CMP) += x86/me_cmp.o X86ASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm new file mode 100644 index 0000000000..26101b4e25 --- /dev/null +++ b/libavcodec/x86/lpc.asm @@ -0,0 +1,241 @@ +;****************************************************************************** +;* Copyright (c) Lynne +;* +;* 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 "libavutil/x86/x86util.asm" + +SECTION_RODATA 32 + +one_tab: times 4 dq 1.0 +seq_tab_avx2: dq 3.0, 2.0, 1.0, 0.0 +sub_tab: dq -1.0, -2.0, -3.0, -4.0 +add_tab_avx2: times 4 dq 4.0 +dec_tab_avx2: times 4 dq -4.0 +add_tab_sse2: times 2 dq 2.0 +dec_tab_sse2: times 2 dq -2.0 +dec_tab_scalar: times 2 dq -1.0 +seq_tab_sse2: dq 1.0, 0.0 + +SECTION .text + +%macro APPLY_WELCH_FN 0 +cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 + cmp lenq, 0 + je .end + cmp lenq, 1 + je .one + + movapd m6, [one_tab] + + movd xm1, lend + cvtdq2pd xm1, xm1 ; len +%if cpuflag(avx2) + vbroadcastsd m1, xm1 +%else + shufpd m1, m1, 00b +%endif + + addpd m0, m6, m6 ; 2.0 + subpd m1, m6 ; len - 1 + divpd m0, m1 ; 2.0 / (len - 1) + + mov off1q, lenq + and off1q, 1 + je .even + + movapd m5, m0 + addpd m0, [sub_tab] + + lea off2q, [lenq*4 - mmsize/2] + sub lenq, mmsize/4 ; avoid overwriting + xor off1q, off1q + + cmp lenq, mmsize/4 + jl .scalar_o + +%if cpuflag(avx2) + movapd m7, [dec_tab_avx2] +%else + movapd m7, [dec_tab_sse2] +%endif + +.loop_o: + movapd m1, m6 + mulpd m2, m0, m0 + subpd m1, m2 +%if cpuflag(avx2) + vpermpd m2, m1, q0123 +%else + shufpd m2, m1, m1, 01b +%endif + + cvtdq2pd m3, [dataq + off1q] + cvtdq2pd m4, [dataq + off2q] + + mulpd m1, m3 + mulpd m2, m4 + + movupd [outq + off1q*2], m1 + movupd [outq + off2q*2], m2 + + addpd m0, m7 + add off1q, mmsize/2 + sub off2q, mmsize/2 + sub lenq, mmsize/4 + jg .loop_o + + add lend, (mmsize/4 - 1) + cmp lend, 0 + je .end + sub lenq, (mmsize/4 - 1) + +.scalar_o: + movapd xm7, [dec_tab_scalar] + subpd xm0, xm7 + + ; Set offsets + add off2q, (mmsize/4) + 4*cpuflag(avx2) + add lenq, mmsize/4 - 2 + +.loop_o_scalar: + movapd xm1, xm6 + mulpd xm2, xm0, xm0 + subpd xm1, xm2 + + cvtdq2pd xm3, [dataq + off1q - (mmsize/4) + 4*cpuflag(avx2)] + cvtdq2pd xm4, [dataq + off2q - (mmsize/4) + 4*cpuflag(avx2)] + + mulpd xm3, xm1 + mulpd xm4, xm1 + + movhpd [outq + off1q*2], xm3 + movhpd [outq + off2q*2], xm4 + + addpd xm0, xm7 + + add off1q, 4 + sub off2q, 4 + + sub lenq, 2 + jg .loop_o_scalar + RET + +.even: +%if cpuflag(avx2) + addpd m0, [seq_tab_avx2] +%else + addpd m0, [seq_tab_sse2] +%endif + + mov off1d, lend + shr off1d, 1 + movd xm1, off1d + cvtdq2pd xm1, xm1 ; len/2 +%if cpuflag(avx2) + vbroadcastsd m1, xm1 +%else + shufpd m1, m1, 00b +%endif + subpd m0, m1 + +%if cpuflag(avx2) + movapd m7, [add_tab_avx2] +%else + movapd m7, [add_tab_sse2] +%endif + + lea off2q, [lenq*2] + lea off1q, [lenq*2 - mmsize/2] + sub lenq, mmsize/4 + + cmp lenq, mmsize/4 + jl .scalar_e + +.loop_e: + movapd m1, m6 + mulpd m2, m0, m0 + subpd m1, m2 +%if cpuflag(avx2) + vpermpd m2, m1, q0123 +%else + shufpd m2, m1, m1, 01b +%endif + + cvtdq2pd m3, [dataq + off1q] + cvtdq2pd m4, [dataq + off2q] + + mulpd m1, m3 + mulpd m2, m4 + + movupd [outq + off1q*2], m1 + movupd [outq + off2q*2], m2 + + addpd m0, m7 + add off2q, mmsize/2 + sub off1q, mmsize/2 + sub lenq, mmsize/4 + jge .loop_e + +.scalar_e: + subpd m0, m7 + movapd m7, [dec_tab_scalar] + subpd m0, m7 + subpd m0, m7 + subpd m0, m7 + + add off1q, (mmsize/2) + sub off2q, (mmsize/2) - 4 - 8*cpuflag(avx2) + + addpd xm0, [sub_tab] + +.loop_e_scalar: + movapd xm1, xm6 + mulpd xm2, xm0, xm0 + subpd xm1, xm2 + + cvtdq2pd m3, [dataq + off1q - 4] + cvtdq2pd m4, [dataq + off2q - 4] + + mulpd m3, m1 + mulpd m4, m1 + + movhpd [outq + off1q*2], xm3 + movhpd [outq + off2q*2], xm4 + + subpd xm0, xm7 + + add off2q, 4 + sub off1q, 4 + jge .loop_e_scalar + RET + +.one: + xorpd xm0, xm0 + movhpd [outq], xm0 +.end: + RET +%endmacro + +INIT_XMM sse2 +APPLY_WELCH_FN + +%if HAVE_AVX2_EXTERNAL +INIT_YMM avx2 +APPLY_WELCH_FN +%endif diff --git a/libavcodec/x86/lpc.c b/libavcodec/x86/lpc_init.c similarity index 64% rename from libavcodec/x86/lpc.c rename to libavcodec/x86/lpc_init.c index 40fc29fc0f..df77c966c6 100644 --- a/libavcodec/x86/lpc.c +++ b/libavcodec/x86/lpc_init.c @@ -20,65 +20,19 @@ */ #include "libavutil/attributes.h" -#include "libavutil/cpu.h" -#include "libavutil/mem_internal.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" #include "libavcodec/lpc.h" +void ff_lpc_apply_welch_window_sse2(const int32_t *data, int len, + double *w_data); +void ff_lpc_apply_welch_window_avx2(const int32_t *data, int len, + double *w_data); + DECLARE_ASM_CONST(16, double, pd_1)[2] = { 1.0, 1.0 }; -DECLARE_ASM_CONST(16, double, pd_2)[2] = { 2.0, 2.0 }; #if HAVE_SSE2_INLINE -static void lpc_apply_welch_window_sse2(const int32_t *data, int len, - double *w_data) -{ - double c = 2.0 / (len-1.0); - int n2 = len>>1; - x86_reg i = -n2*sizeof(int32_t); - x86_reg j = n2*sizeof(int32_t); - __asm__ volatile( - "movsd %4, %%xmm7 \n\t" - "movapd "MANGLE(pd_1)", %%xmm6 \n\t" - "movapd "MANGLE(pd_2)", %%xmm5 \n\t" - "movlhps %%xmm7, %%xmm7 \n\t" - "subpd %%xmm5, %%xmm7 \n\t" - "addsd %%xmm6, %%xmm7 \n\t" - "test $1, %5 \n\t" - "jz 2f \n\t" -#define WELCH(MOVPD, offset)\ - "1: \n\t"\ - "movapd %%xmm7, %%xmm1 \n\t"\ - "mulpd %%xmm1, %%xmm1 \n\t"\ - "movapd %%xmm6, %%xmm0 \n\t"\ - "subpd %%xmm1, %%xmm0 \n\t"\ - "pshufd $0x4e, %%xmm0, %%xmm1 \n\t"\ - "cvtpi2pd (%3,%0), %%xmm2 \n\t"\ - "cvtpi2pd "#offset"*4(%3,%1), %%xmm3 \n\t"\ - "mulpd %%xmm0, %%xmm2 \n\t"\ - "mulpd %%xmm1, %%xmm3 \n\t"\ - "movapd %%xmm2, (%2,%0,2) \n\t"\ - MOVPD" %%xmm3, "#offset"*8(%2,%1,2) \n\t"\ - "subpd %%xmm5, %%xmm7 \n\t"\ - "sub $8, %1 \n\t"\ - "add $8, %0 \n\t"\ - "jl 1b \n\t"\ - - WELCH("movupd", -1) - "jmp 3f \n\t" - "2: \n\t" - WELCH("movapd", -2) - "3: \n\t" - :"+&r"(i), "+&r"(j) - :"r"(w_data+n2), "r"(data+n2), "m"(c), "r"(len) - NAMED_CONSTRAINTS_ARRAY_ADD(pd_1,pd_2) - XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3", - "%xmm5", "%xmm6", "%xmm7") - ); -#undef WELCH -} - static void lpc_compute_autocorr_sse2(const double *data, int len, int lag, double *autoc) { @@ -151,12 +105,16 @@ static void lpc_compute_autocorr_sse2(const double *data, int len, int lag, av_cold void ff_lpc_init_x86(LPCContext *c) { -#if HAVE_SSE2_INLINE int cpu_flags = av_get_cpu_flags(); - if (INLINE_SSE2_SLOW(cpu_flags)) { - c->lpc_apply_welch_window = lpc_apply_welch_window_sse2; - c->lpc_compute_autocorr = lpc_compute_autocorr_sse2; - } -#endif /* HAVE_SSE2_INLINE */ +#if HAVE_SSE2_INLINE + if (INLINE_SSE2_SLOW(cpu_flags)) + c->lpc_compute_autocorr = lpc_compute_autocorr_sse2; +#endif + + if (EXTERNAL_SSE2(cpu_flags)) + c->lpc_apply_welch_window = ff_lpc_apply_welch_window_sse2; + + if (EXTERNAL_AVX2(cpu_flags)) + c->lpc_apply_welch_window = ff_lpc_apply_welch_window_avx2; } diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index ac02670e64..f330d3a8ab 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -11,6 +11,7 @@ AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o AVCODECOBJS-$(CONFIG_IDCTDSP) += idctdsp.o AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o AVCODECOBJS-$(CONFIG_LLVIDENCDSP) += llviddspenc.o +AVCODECOBJS-$(CONFIG_LPC) += lpc.o AVCODECOBJS-$(CONFIG_ME_CMP) += motion.o AVCODECOBJS-$(CONFIG_VC1DSP) += vc1dsp.o AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 6b4a0f22b2..8fd9bba0b0 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -135,6 +135,9 @@ static const struct { #if CONFIG_LLVIDENCDSP { "llviddspenc", checkasm_check_llviddspenc }, #endif + #if CONFIG_LPC + { "lpc", checkasm_check_lpc }, + #endif #if CONFIG_ME_CMP { "motion", checkasm_check_motion }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 171dd06b47..97e909170f 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -68,6 +68,7 @@ void checkasm_check_idctdsp(void); void checkasm_check_jpeg2000dsp(void); void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); +void checkasm_check_lpc(void); void checkasm_check_motion(void); void checkasm_check_nlmeans(void); void checkasm_check_opusdsp(void); diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c new file mode 100644 index 0000000000..b68ce05bfa --- /dev/null +++ b/tests/checkasm/lpc.c @@ -0,0 +1,80 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 "libavutil/mem_internal.h" + +#include "libavcodec/lpc.h" + +#include "checkasm.h" + +#define randomize_int32(buf, len) \ + do { \ + for (int i = 0; i < len; i++) { \ + int32_t f = rnd() >> 8; \ + buf[i] = f; \ + } \ + } while (0) + +#define EPS 0.005 + +static void test_window(int len) +{ + LOCAL_ALIGNED(16, int32_t, src, [5000]); + LOCAL_ALIGNED(16, double, dst0, [5000]); + LOCAL_ALIGNED(16, double, dst1, [5000]); + + declare_func(void, int32_t *in, int len, double *out); + + randomize_int32(src, len); + + call_ref(src, len, dst0); + call_new(src, len, dst1); + + if (!double_near_abs_eps_array(dst0, dst1, EPS, len)) + fail(); + + bench_new(src, len, dst1); +} + +void checkasm_check_lpc(void) +{ + LPCContext ctx; + ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { + for (int i = 0; i < 64; i += 2) + test_window(i); + } + report("apply_welch_window_even"); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_odd")) { + for (int i = 1; i < 64; i += 2) + test_window(i); + } + report("apply_welch_window_odd"); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4096")) + test_window(4096); + report("apply_welch_window_4096"); + + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4097")) + test_window(4097); + report("apply_welch_window_4097"); + + ff_lpc_end(&ctx); +} From 0744782de3ee37fc2b8d9db73ec15d774165b4e5 Mon Sep 17 00:00:00 2001 From: Wang Yaqiang Date: Thu, 1 Sep 2022 21:29:03 +0800 Subject: [PATCH 373/590] avformat/mov: get the correct fragment stsd_id when decrypting the sample When determining whether a packet should be decrypted, should use the stsd_id of the fragment where the current packet is located. Reviewed-by: Zhao Zhili Signed-off-by: Wang Yaqiang --- libavformat/isom.h | 1 + libavformat/mov.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index fd236b985f..64fb7065d5 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -139,6 +139,7 @@ typedef struct MOVFragmentStreamInfo { int index_base; int index_entry; MOVEncryptionIndex *encryption_index; + int stsd_id; // current fragment stsd_id } MOVFragmentStreamInfo; typedef struct MOVFragmentIndexItem { diff --git a/libavformat/mov.c b/libavformat/mov.c index 720a72f3ec..1f436e21d6 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4958,9 +4958,10 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_log(c->fc, AV_LOG_TRACE, "frag flags 0x%x\n", frag->flags); frag_stream_info = get_current_frag_stream_info(&c->frag_index); - if (frag_stream_info) + if (frag_stream_info) { frag_stream_info->next_trun_dts = AV_NOPTS_VALUE; - + frag_stream_info->stsd_id = frag->stsd_id; + } return 0; } @@ -7225,7 +7226,7 @@ static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPa encryption_index = NULL; if (frag_stream_info) { // Note this only supports encryption info in the first sample descriptor. - if (mov->fragment.stsd_id == 1) { + if (frag_stream_info->stsd_id == 1) { if (frag_stream_info->encryption_index) { encrypted_index = current_index - frag_stream_info->index_base; encryption_index = frag_stream_info->encryption_index; From acbb2777e28c462d38f774d317e6cd3ad2a0b215 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 20 Sep 2022 17:07:15 +0200 Subject: [PATCH 374/590] avcodec/ac3dec: add downmix support for mono and stereo for eac3 7.1 --- libavcodec/ac3dec.c | 55 ++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 5d0add40fe..f628eae33c 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -183,6 +183,33 @@ static av_cold void ac3_tables_init(void) #endif } +static void ac3_downmix(AVCodecContext *avctx) +{ + AC3DecodeContext *s = avctx->priv_data; + const AVChannelLayout mono = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; + const AVChannelLayout stereo = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; + + /* allow downmixing to stereo or mono */ +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (avctx->request_channel_layout) { + av_channel_layout_uninit(&s->downmix_layout); + av_channel_layout_from_mask(&s->downmix_layout, avctx->request_channel_layout); + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (avctx->ch_layout.nb_channels > 1 && + !av_channel_layout_compare(&s->downmix_layout, &mono)) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; + } else if (avctx->ch_layout.nb_channels > 2 && + !av_channel_layout_compare(&s->downmix_layout, &stereo)) { + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; + } + s->downmixed = 1; +} + /** * AVCodec initialization */ @@ -190,8 +217,6 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; AC3DecodeContext *s = avctx->priv_data; - const AVChannelLayout mono = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; - const AVChannelLayout stereo = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; int i, ret; s->avctx = avctx; @@ -219,25 +244,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) else avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; - /* allow downmixing to stereo or mono */ -#if FF_API_OLD_CHANNEL_LAYOUT -FF_DISABLE_DEPRECATION_WARNINGS - if (avctx->request_channel_layout) { - av_channel_layout_uninit(&s->downmix_layout); - av_channel_layout_from_mask(&s->downmix_layout, avctx->request_channel_layout); - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif - if (avctx->ch_layout.nb_channels > 1 && - !av_channel_layout_compare(&s->downmix_layout, &mono)) { - av_channel_layout_uninit(&avctx->ch_layout); - avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; - } else if (avctx->ch_layout.nb_channels > 2 && - !av_channel_layout_compare(&s->downmix_layout, &stereo)) { - av_channel_layout_uninit(&avctx->ch_layout); - avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; - } - s->downmixed = 1; + ac3_downmix(avctx); for (i = 0; i < AC3_MAX_CHANNELS; i++) { s->xcfptr[i] = s->transform_coeffs[i]; @@ -1751,7 +1758,7 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (index < 0) return AVERROR_INVALIDDATA; if (extend >= channel_map_size) - return AVERROR_INVALIDDATA; + break; extended_channel_map[index] = offset + channel_map[extend++]; } else { @@ -1763,7 +1770,7 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (index < 0) return AVERROR_INVALIDDATA; if (extend >= channel_map_size) - return AVERROR_INVALIDDATA; + break; extended_channel_map[index] = offset + channel_map[extend++]; } @@ -1771,6 +1778,8 @@ static int ac3_decode_frame(AVCodecContext *avctx, AVFrame *frame, } } } + + ac3_downmix(avctx); } /* get output buffer */ From 0ee535b1db392a340a86ce0581dff94624c2da06 Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Tue, 20 Sep 2022 13:01:56 +0200 Subject: [PATCH 375/590] lavc/aarch64: Add neon implementation for pix_median_abs16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation for pix_median_abs16 function. Performance comparison tests are shown below. - median_sad_0_c: 720.5 - median_sad_0_neon: 127.2 Benchmarks and tests run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 4 ++ libavcodec/aarch64/me_cmp_neon.S | 78 ++++++++++++++++++++++++ libavcodec/me_cmp.c | 5 +- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index ade3e9a4c1..fb51a833be 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -53,6 +53,8 @@ int nsse16_neon(int multiplier, const uint8_t *s, const uint8_t *s2, ptrdiff_t stride, int h); int nsse16_neon_wrapper(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); +int pix_median_abs16_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, + ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { @@ -78,6 +80,8 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->vsse[4] = vsse_intra16_neon; c->nsse[0] = nsse16_neon_wrapper; + + c->median_sad[0] = pix_median_abs16_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index f8998749a5..1e08d04869 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -969,3 +969,81 @@ function nsse16_neon, export=1 ret endfunc + +function pix_median_abs16_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v2.16b}, [x1], x3 + ld1 {v3.16b}, [x2], x3 + movi v31.8h, #0 + movi v16.8h, #0 + ext v0.16b, v2.16b, v2.16b, #1 + ext v1.16b, v3.16b, v3.16b, #1 + usubl v28.8h, v2.8b, v3.8b + usubl2 v27.8h, v2.16b, v3.16b + usubl v26.8h, v0.8b, v1.8b + usubl2 v25.8h, v0.16b, v1.16b + sub w4, w4, #1 // we need to make h-1 iterations + saba v31.8h, v26.8h, v28.8h + saba v16.8h, v25.8h, v27.8h + mov h18, v28.h[0] + cmp w4, #1 + sqabs h18, h18 + movi v0.8h, #0 + + b.lt 2f +1: + + ld1 {v6.16b}, [x1], x3 // pix1 vector for V(j-1) + ld1 {v7.16b}, [x2], x3 // pix2 vector for V(j-1) + subs w4, w4, #1 + ext v4.16b, v6.16b, v6.16b, #1 // pix1 vector for V(j) + ext v5.16b, v7.16b, v7.16b, #1 // pix2 vector for V(j) + + // protected registers: v30, v29, v28, v27, v26, v25, v24, v23 + // scratch registers: v22, v21, v20, v19, v17 + + // To find median of three values, calculate sum of them + // and subtract max and min value from it. + usubl v30.8h, v6.8b, v7.8b // V(j-1) + usubl2 v29.8h, v6.16b, v7.16b // V(j-1) + usubl v24.8h, v4.8b, v5.8b // V(j) + usubl2 v23.8h, v4.16b, v5.16b // V(j) + saba v0.8h, v30.8h, v28.8h + add v22.8h, v26.8h, v30.8h + smin v20.8h, v26.8h, v30.8h + add v21.8h, v25.8h, v29.8h + smax v19.8h, v26.8h, v30.8h + sub v22.8h, v22.8h, v28.8h + sub v21.8h, v21.8h, v27.8h + smin v17.8h, v19.8h, v22.8h + smin v22.8h, v25.8h, v29.8h + mov v28.16b, v30.16b + smax v20.8h, v20.8h, v17.8h // median values lower half + smax v19.8h, v25.8h, v29.8h + saba v31.8h, v24.8h, v20.8h + mov v27.16b, v29.16b + smin v19.8h, v19.8h, v21.8h + mov v26.16b, v24.16b + smax v17.8h, v22.8h, v19.8h // median values upper half + mov v25.16b, v23.16b + saba v16.8h, v23.8h, v17.8h + + b.ne 1b + +2: + mov h17, v0.h[0] + ins v16.h[7], wzr + add d18, d18, d17 + add v31.8h, v31.8h, v16.8h + uaddlv s17, v31.8h + add d18, d18, d17 + fmov w0, s18 + + ret + +endfunc diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c index 4242fbc6e4..e2f9f84b05 100644 --- a/libavcodec/me_cmp.c +++ b/libavcodec/me_cmp.c @@ -1048,6 +1048,9 @@ av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx) ff_dsputil_init_dwt(c); #endif + c->median_sad[0] = pix_median_abs16_c; + c->median_sad[1] = pix_median_abs8_c; + #if ARCH_AARCH64 ff_me_cmp_init_aarch64(c, avctx); #elif ARCH_ALPHA @@ -1062,6 +1065,4 @@ av_cold void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx) ff_me_cmp_init_mips(c, avctx); #endif - c->median_sad[0] = pix_median_abs16_c; - c->median_sad[1] = pix_median_abs8_c; } From e9a6170213d9fc48db4f4135b9fd848f461a0bd2 Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Tue, 20 Sep 2022 13:01:57 +0200 Subject: [PATCH 376/590] lavc/aarch64: Add neon implementation for vsad8_intra MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation for vsad8_intra function. Performance comparison tests are shown below. - vsad_5_c: 94.7 - vsad_5_neon: 20.7 Benchmarks and tests run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 3 ++ libavcodec/aarch64/me_cmp_neon.S | 42 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index fb51a833be..d3fa047a86 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -45,6 +45,8 @@ int vsad16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); int vsad_intra16_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, ptrdiff_t stride, int h) ; +int vsad_intra8_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, + ptrdiff_t stride, int h) ; int vsse16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); int vsse_intra16_neon(MpegEncContext *c, const uint8_t *s, const uint8_t *dummy, @@ -75,6 +77,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->vsad[0] = vsad16_neon; c->vsad[4] = vsad_intra16_neon; + c->vsad[5] = vsad_intra8_neon; c->vsse[0] = vsse16_neon; c->vsse[4] = vsse_intra16_neon; diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 1e08d04869..1587f2ea43 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -1047,3 +1047,45 @@ function pix_median_abs16_neon, export=1 ret endfunc + +function vsad_intra8_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *dummy + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v0.8b}, [x1], x3 + sub w4, w4, #1 // we need to make h-1 iterations + cmp w4, #3 + movi v16.8h, #0 + b.lt 2f + +1: + // v = abs( pix1[0] - pix1[0 + stride] ) + // score = sum(v) + ld1 {v1.8b}, [x1], x3 + sub w4, w4, #3 + ld1 {v2.8b}, [x1], x3 + uabal v16.8h, v0.8b, v1.8b + ld1 {v3.8b}, [x1], x3 + uabal v16.8h, v1.8b, v2.8b + cmp w4, #3 + mov v0.8b, v3.8b + uabal v16.8h, v2.8b, v3.8b + b.ge 1b + cbz w4, 3f + +2: + ld1 {v1.8b}, [x1], x3 + subs w4, w4, #1 + uabal v16.8h, v0.8b, v1.8b + mov v0.8b, v1.8b + cbnz w4, 2b + +3: + uaddlv s17, v16.8h + fmov w0, s17 + + ret +endfunc From b2732115ddbe306bc1040227a859b6ce2f7663b3 Mon Sep 17 00:00:00 2001 From: Hubert Mazur Date: Tue, 20 Sep 2022 13:01:58 +0200 Subject: [PATCH 377/590] lavc/aarch64: Add neon implementation for pix_median_abs8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide optimized implementation for pix_median_abs8 function. Performance comparison tests are shown below. - median_sad_1_c: 277.0 - median_sad_1_neon: 82.0 Benchmarks and tests run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_init_aarch64.c | 3 ++ libavcodec/aarch64/me_cmp_neon.S | 62 ++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index d3fa047a86..e143f0816e 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -57,6 +57,8 @@ int nsse16_neon_wrapper(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); int pix_median_abs16_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h); +int pix_median_abs8_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, + ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { @@ -85,6 +87,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->nsse[0] = nsse16_neon_wrapper; c->median_sad[0] = pix_median_abs16_neon; + c->median_sad[1] = pix_median_abs8_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 1587f2ea43..11af4849f9 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -1089,3 +1089,65 @@ function vsad_intra8_neon, export=1 ret endfunc + +function pix_median_abs8_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v2.8b}, [x1], x3 + ld1 {v3.8b}, [x2], x3 + movi v31.8h, #0 + ext v0.8b, v2.8b, v2.8b, #1 + ext v1.8b, v3.8b, v3.8b, #1 + usubl v28.8h, v2.8b, v3.8b + usubl v26.8h, v0.8b, v1.8b + sub w4, w4, #1 // we need to make h-1 iterations + saba v31.8h, v26.8h, v28.8h + mov h18, v28.h[0] + cmp w4, #1 + sqabs h18, h18 + movi v0.8h, #0 + + b.lt 2f +1: + ld1 {v6.8b}, [x1], x3 // pix1 vector for V(j-1) + ld1 {v7.8b}, [x2], x3 // pix2 vector for V(j-1) + subs w4, w4, #1 + ext v4.8b, v6.8b, v6.8b, #1 // pix1 vector for V(j) + ext v5.8b, v7.8b, v7.8b, #1 // pix2 vector for V(j) + + // protected registers: v30, v29, v28, v27, v26, v25, v24, v23 + // scratch registers: v22, v21, v20, v19, v17 + + // To find median of three values, calculate sum of them + // and subtract max and min value from it. + usubl v30.8h, v6.8b, v7.8b // V(j-1) + usubl v24.8h, v4.8b, v5.8b // V(j) + saba v0.8h, v30.8h, v28.8h + add v22.8h, v26.8h, v30.8h + smin v20.8h, v26.8h, v30.8h + smax v19.8h, v26.8h, v30.8h + sub v22.8h, v22.8h, v28.8h + smin v17.8h, v19.8h, v22.8h + mov v28.16b, v30.16b + smax v20.8h, v20.8h, v17.8h // median values lower half + smax v19.8h, v25.8h, v29.8h + saba v31.8h, v24.8h, v20.8h + mov v26.16b, v24.16b + smax v17.8h, v22.8h, v19.8h // median values upper half + + b.ne 1b +2: + mov h17, v0.h[0] + ins v31.h[7], wzr + add d18, d18, d17 + uaddlv s17, v31.8h + add d18, d18, d17 + fmov w0, s18 + + ret + +endfunc From 55c35d84eb2bd6a50c24b1904a3e6c01b83804cc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 03:46:33 +0200 Subject: [PATCH 378/590] avfilter/internal: Remove declaration of inexistent function ff_get_ref_perms_string() has been removed in 7e350379f87e7f74420b4813170fe808e2313911. Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt --- libavfilter/internal.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 0128820be0..36969c442e 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -266,8 +266,6 @@ void ff_command_queue_pop(AVFilterContext *filter); #define FF_TPRINTF_START(ctx, func) ff_tlog(NULL, "%-16s: ", #func) -char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms); - #ifdef TRACE void ff_tlog_link(void *ctx, AVFilterLink *link, int end); #else From 5a7978a694e7cab4684181ca4020caf0ce8cbb06 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 03:51:39 +0200 Subject: [PATCH 379/590] avfilter/avfilter: Make ff_command_queue_pop() static Only used here. Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 6 +++--- libavfilter/internal.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index f34204e650..cc5505e65b 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -78,7 +78,7 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end) #endif } -void ff_command_queue_pop(AVFilterContext *filter) +static void command_queue_pop(AVFilterContext *filter) { AVFilterCommand *c= filter->command_queue; av_freep(&c->arg); @@ -780,7 +780,7 @@ void avfilter_free(AVFilterContext *filter) av_freep(&filter->outputs); av_freep(&filter->priv); while(filter->command_queue){ - ff_command_queue_pop(filter); + command_queue_pop(filter); } av_opt_free(filter); av_expr_free(filter->enable); @@ -1494,7 +1494,7 @@ int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame) "Processing command time:%f command:%s arg:%s\n", cmd->time, cmd->command, cmd->arg); avfilter_process_command(link->dst, cmd->command, cmd->arg, 0, 0, cmd->flags); - ff_command_queue_pop(link->dst); + command_queue_pop(link->dst); cmd= link->dst->command_queue; } return 0; diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 36969c442e..aaf2c6c584 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -256,8 +256,6 @@ void ff_avfilter_link_set_in_status(AVFilterLink *link, int status, int64_t pts) */ void ff_avfilter_link_set_out_status(AVFilterLink *link, int status, int64_t pts); -void ff_command_queue_pop(AVFilterContext *filter); - #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb)) From 2ca2d46f0b1b6ac23dfdb73d67efcadca66384c6 Mon Sep 17 00:00:00 2001 From: Thilo Borgmann Date: Thu, 15 Sep 2022 20:42:58 +0200 Subject: [PATCH 380/590] lavc/videotoolboxenc: Fix crash by uninitialized value If create_cv_pixel_buffer() fails, pixel_buffer_info might get into CFRelease() containing an arbitrary value. --- libavcodec/videotoolboxenc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index bb3065d1d5..dc9e321d3d 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1440,7 +1440,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, static int vtenc_configure_encoder(AVCodecContext *avctx) { CFMutableDictionaryRef enc_info; - CFMutableDictionaryRef pixel_buffer_info; + CFMutableDictionaryRef pixel_buffer_info = NULL; CMVideoCodecType codec_type; VTEncContext *vtctx = avctx->priv_data; CFStringRef profile_level = NULL; @@ -1517,8 +1517,6 @@ static int vtenc_configure_encoder(AVCodecContext *avctx) status = create_cv_pixel_buffer_info(avctx, &pixel_buffer_info); if (status) goto init_cleanup; - } else { - pixel_buffer_info = NULL; } vtctx->dts_delta = vtctx->has_b_frames ? -1 : 0; From 6a150fcdb917787b356b3b7eb87bfbe7d7a0e9d5 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 21 Sep 2022 14:28:23 +0200 Subject: [PATCH 381/590] avcodec/mlpenc: analyze only if there are samples --- libavcodec/mlpenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index b66f3a3067..73fdfc01cc 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -2189,7 +2189,8 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, input_to_sample_buffer(ctx); - analyze_sample_buffer(ctx); + if (number_of_samples > 0) + analyze_sample_buffer(ctx); } if (ctx->frame_index == (ctx->max_restart_interval - 1)) { From b9d71cdb9e920490aec72ec5c17fdf091725c4b4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 21 Sep 2022 14:59:53 +0200 Subject: [PATCH 382/590] avcodec/mjpegbdec: use init_get_bits8() --- libavcodec/mjpegbdec.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index e74addb24b..dfc55d6cf8 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -64,10 +64,8 @@ static int mjpegb_decode_frame(AVCodecContext *avctx, AVFrame *rframe, s->restart_count = 0; s->mjpb_skiptosod = 0; - if (buf_end - buf_ptr >= 1 << 28) - return AVERROR_INVALIDDATA; - - init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8); + if ((ret = init_get_bits8(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr))) < 0) + return ret; skip_bits(&hgb, 32); /* reserved zeros */ From 6a288ada55c0e5a2a74e1ea2b5666412282cb3db Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 18:22:55 +0200 Subject: [PATCH 383/590] fate/lavf-*: Add missing dependency on pipe protocol Forgotten in bf1337f99c66ac574c6e4da65c305ca878f1d65d. Signed-off-by: Andreas Rheinhardt --- tests/fate/lavf-audio.mak | 2 +- tests/fate/lavf-container.mak | 2 +- tests/fate/lavf-image.mak | 2 +- tests/fate/lavf-image2pipe.mak | 3 ++- tests/fate/lavf-video.mak | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/fate/lavf-audio.mak b/tests/fate/lavf-audio.mak index edbd872b11..d54cd107e0 100644 --- a/tests/fate/lavf-audio.mak +++ b/tests/fate/lavf-audio.mak @@ -22,7 +22,7 @@ FATE_LAVF_AUDIO_RESAMPLE-$(call ENCDEC, WAVPACK, WV) += wv FATE_LAVF_AUDIO-$(CONFIG_ARESAMPLE_FILTER) += $(FATE_LAVF_AUDIO_RESAMPLE-yes) FATE_LAVF_AUDIO = $(FATE_LAVF_AUDIO-yes:%=fate-lavf-%) -FATE_LAVF_AUDIO := $(if $(call ENCDEC, PCM_S16LE, CRC PCM_S16LE), $(FATE_LAVF_AUDIO)) +FATE_LAVF_AUDIO := $(if $(call ENCDEC, PCM_S16LE, CRC PCM_S16LE, PIPE_PROTOCOL), $(FATE_LAVF_AUDIO)) $(FATE_LAVF_AUDIO): CMD = lavf_audio $(FATE_LAVF_AUDIO): REF = $(SRC_PATH)/tests/ref/lavf/$(@:fate-lavf-%=%) diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak index 7fb54d7406..4bf7636b56 100644 --- a/tests/fate/lavf-container.mak +++ b/tests/fate/lavf-container.mak @@ -28,7 +28,7 @@ FATE_LAVF_CONTAINER_SCALE := dv dv_pal dv_ntsc flm gxf gxf_pal gxf_ntsc \ FATE_LAVF_CONTAINER-$(!CONFIG_SCALE_FILTER) := $(filter-out $(FATE_LAVF_CONTAINER_SCALE),$(FATE_LAVF_CONTAINER-yes)) FATE_LAVF_CONTAINER = $(FATE_LAVF_CONTAINER-yes:%=fate-lavf-%) -FATE_LAVF_CONTAINER := $(if $(call ENCDEC2, RAWVIDEO PGMYUV, PCM_S16LE, CRC IMAGE2, PCM_S16LE_DEMUXER), $(FATE_LAVF_CONTAINER)) +FATE_LAVF_CONTAINER := $(if $(call ENCDEC2, RAWVIDEO PGMYUV, PCM_S16LE, CRC IMAGE2, PCM_S16LE_DEMUXER PIPE_PROTOCOL), $(FATE_LAVF_CONTAINER)) $(FATE_LAVF_CONTAINER): CMD = lavf_container $(FATE_LAVF_CONTAINER): REF = $(SRC_PATH)/tests/ref/lavf/$(@:fate-lavf-%=%) diff --git a/tests/fate/lavf-image.mak b/tests/fate/lavf-image.mak index 784c85a9f4..4177e091b3 100644 --- a/tests/fate/lavf-image.mak +++ b/tests/fate/lavf-image.mak @@ -1,6 +1,6 @@ LAVF_IMAGES = $(call ALLYES, FILE_PROTOCOL IMAGE2_DEMUXER PGMYUV_DECODER \ SCALE_FILTER $(1)_ENCODER IMAGE2_MUXER \ - $(1)_DECODER RAWVIDEO_ENCODER CRC_MUXER) + $(1)_DECODER RAWVIDEO_ENCODER CRC_MUXER PIPE_PROTOCOL) FATE_LAVF_IMAGES-$(call LAVF_IMAGES, BMP) += bmp FATE_LAVF_IMAGES-$(call LAVF_IMAGES, DPX) += dpx diff --git a/tests/fate/lavf-image2pipe.mak b/tests/fate/lavf-image2pipe.mak index 318655140b..868b6433d6 100644 --- a/tests/fate/lavf-image2pipe.mak +++ b/tests/fate/lavf-image2pipe.mak @@ -1,7 +1,8 @@ LAVF_IMAGE2PIPE = $(call ALLYES, $(1)_DECODER $(1)_ENCODER $(2) \ IMAGE2_DEMUXER PGMYUV_DECODER \ IMAGE2PIPE_MUXER IMAGE2PIPE_DEMUXER \ - RAWVIDEO_ENCODER CRC_MUXER FILE_PROTOCOL) + RAWVIDEO_ENCODER CRC_MUXER \ + FILE_PROTOCOL PIPE_PROTOCOL) FATE_LAVF_IMAGE2PIPE-$(call LAVF_IMAGE2PIPE, PBM, PNM_PARSER SCALE_FILTER) += pbmpipe FATE_LAVF_IMAGE2PIPE-$(call LAVF_IMAGE2PIPE, PGM, PNM_PARSER SCALE_FILTER) += pgmpipe diff --git a/tests/fate/lavf-video.mak b/tests/fate/lavf-video.mak index 7557283dd3..e73f8f203b 100644 --- a/tests/fate/lavf-video.mak +++ b/tests/fate/lavf-video.mak @@ -12,7 +12,7 @@ FATE_LAVF_VIDEO-$(call ENCDEC, WRAPPED_AVFRAME RAWVIDEO, YUV4MPEGPIPE) += y4m FATE_LAVF_VIDEO-$(CONFIG_SCALE_FILTER) += $(FATE_LAVF_VIDEO_SCALE-yes) FATE_LAVF_VIDEO = $(FATE_LAVF_VIDEO-yes:%=fate-lavf-%) FATE_LAVF_VIDEO := $(if $(call ALLYES, IMAGE2_DEMUXER PGMYUV_DECODER \ - RAWVIDEO_ENCODER CRC_MUXER), \ + RAWVIDEO_ENCODER CRC_MUXER, PIPE_PROTOCOL), \ $(FATE_LAVF_VIDEO)) $(FATE_LAVF_VIDEO): CMD = lavf_video From 57f3ca20dcb104665c3c5dce04829574dc8d044f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 02:43:02 +0200 Subject: [PATCH 384/590] avcodec/cavsdsp: Remove unused function parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Rémi Denis-Courmont Signed-off-by: Andreas Rheinhardt --- libavcodec/cavs.c | 2 +- libavcodec/cavsdsp.c | 7 +++---- libavcodec/cavsdsp.h | 6 +++--- libavcodec/x86/cavsdsp.c | 7 +++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index 87bbe26f98..cba0a06e89 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -797,7 +797,7 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); - ff_cavsdsp_init(&h->cdsp, avctx); + ff_cavsdsp_init(&h->cdsp); ff_init_scantable_permutation(h->idsp.idct_permutation, h->cdsp.idct_perm); ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct); diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c index b096de452c..af46eaf8d2 100644 --- a/libavcodec/cavsdsp.c +++ b/libavcodec/cavsdsp.c @@ -22,8 +22,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - #include "idctdsp.h" #include "mathops.h" #include "cavsdsp.h" @@ -548,7 +546,8 @@ CAVS_MC(avg_, 16) #define put_cavs_qpel16_mc00_c ff_put_pixels16x16_c #define avg_cavs_qpel16_mc00_c ff_avg_pixels16x16_c -av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) { +av_cold void ff_cavsdsp_init(CAVSDSPContext* c) +{ #define dspfunc(PFX, IDX, NUM) \ c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ @@ -578,6 +577,6 @@ av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) { c->idct_perm = FF_IDCT_PERM_NONE; #if ARCH_X86 - ff_cavsdsp_init_x86(c, avctx); + ff_cavsdsp_init_x86(c); #endif } diff --git a/libavcodec/cavsdsp.h b/libavcodec/cavsdsp.h index 9ccaa0addd..2cd9298963 100644 --- a/libavcodec/cavsdsp.h +++ b/libavcodec/cavsdsp.h @@ -22,9 +22,9 @@ #ifndef AVCODEC_CAVSDSP_H #define AVCODEC_CAVSDSP_H +#include #include -#include "avcodec.h" #include "qpeldsp.h" typedef struct CAVSDSPContext { @@ -38,7 +38,7 @@ typedef struct CAVSDSPContext { int idct_perm; } CAVSDSPContext; -void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx); -void ff_cavsdsp_init_x86(CAVSDSPContext* c, AVCodecContext *avctx); +void ff_cavsdsp_init(CAVSDSPContext* c); +void ff_cavsdsp_init_x86(CAVSDSPContext* c); #endif /* AVCODEC_CAVSDSP_H */ diff --git a/libavcodec/x86/cavsdsp.c b/libavcodec/x86/cavsdsp.c index 7ceb51a23c..4ad977a034 100644 --- a/libavcodec/x86/cavsdsp.c +++ b/libavcodec/x86/cavsdsp.c @@ -345,8 +345,7 @@ static void avg_cavs_qpel16_mc00_sse2(uint8_t *dst, const uint8_t *src, } #endif -static av_cold void cavsdsp_init_mmx(CAVSDSPContext *c, - AVCodecContext *avctx) +static av_cold void cavsdsp_init_mmx(CAVSDSPContext *c) { #if HAVE_MMX_EXTERNAL c->put_cavs_qpel_pixels_tab[1][0] = put_cavs_qpel8_mc00_mmx; @@ -369,12 +368,12 @@ CAVS_MC(avg_, 8, mmxext) CAVS_MC(avg_, 16, mmxext) #endif /* HAVE_MMXEXT_INLINE */ -av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx) +av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c) { av_unused int cpu_flags = av_get_cpu_flags(); if (X86_MMX(cpu_flags)) - cavsdsp_init_mmx(c, avctx); + cavsdsp_init_mmx(c); #if HAVE_MMXEXT_INLINE if (INLINE_MMXEXT(cpu_flags)) { From fd72d8aea3fbda09e029d2ecd7564f8c98b347e3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 02:52:15 +0200 Subject: [PATCH 385/590] avcodec/blockdsp: Remove unused AVCodecContext parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Possible since be95df12bb06b183c8d2aea3b0831fdf05466cf3. Reviewed-by: Rémi Denis-Courmont Signed-off-by: Andreas Rheinhardt --- libavcodec/4xm.c | 2 +- libavcodec/asvdec.c | 2 +- libavcodec/bink.c | 2 +- libavcodec/blockdsp.c | 5 ++--- libavcodec/blockdsp.h | 6 ++---- libavcodec/cavs.c | 2 +- libavcodec/dnxhddec.c | 2 +- libavcodec/dnxhdenc.c | 2 +- libavcodec/eamad.c | 2 +- libavcodec/eatqi.c | 2 +- libavcodec/g2meet.c | 2 +- libavcodec/intrax8.c | 2 +- libavcodec/jvdec.c | 2 +- libavcodec/mdec.c | 2 +- libavcodec/mimic.c | 2 +- libavcodec/mjpegdec.c | 2 +- libavcodec/mpegvideo.c | 2 +- libavcodec/mv30.c | 2 +- libavcodec/proresdec2.c | 2 +- libavcodec/speedhq.c | 2 +- libavcodec/vc1dec.c | 2 +- libavcodec/wmv2.c | 2 +- libavcodec/x86/blockdsp_init.c | 3 +-- tests/checkasm/blockdsp.c | 3 +-- 24 files changed, 26 insertions(+), 31 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 6015fe5299..5636fdef2d 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -1012,7 +1012,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); f->version = AV_RL32(avctx->extradata) >> 16; - ff_blockdsp_init(&f->bdsp, avctx); + ff_blockdsp_init(&f->bdsp); ff_bswapdsp_init(&f->bbdsp); f->avctx = avctx; diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c index c8c50cc8d4..4ca370d1ec 100644 --- a/libavcodec/asvdec.c +++ b/libavcodec/asvdec.c @@ -292,7 +292,7 @@ static av_cold int decode_init(AVCodecContext *avctx) } ff_asv_common_init(avctx); - ff_blockdsp_init(&a->bdsp, avctx); + ff_blockdsp_init(&a->bdsp); ff_idctdsp_init(&a->idsp, avctx); ff_init_scantable(a->idsp.idct_permutation, &a->scantable, ff_asv_scantab); avctx->pix_fmt = AV_PIX_FMT_YUV420P; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index e43ff1f4fa..e3971e557a 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -1384,7 +1384,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->pix_fmt = c->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P; avctx->color_range = c->version == 'k' ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; - ff_blockdsp_init(&c->bdsp, avctx); + ff_blockdsp_init(&c->bdsp); ff_hpeldsp_init(&hdsp, avctx->flags); c->put_pixels_tab = hdsp.put_pixels_tab[1][0]; ff_binkdsp_init(&c->binkdsp); diff --git a/libavcodec/blockdsp.c b/libavcodec/blockdsp.c index c8f85dd202..98f06c5d16 100644 --- a/libavcodec/blockdsp.c +++ b/libavcodec/blockdsp.c @@ -21,7 +21,6 @@ #include "config.h" #include "libavutil/attributes.h" -#include "avcodec.h" #include "blockdsp.h" static void clear_block_c(int16_t *block) @@ -56,7 +55,7 @@ static void fill_block8_c(uint8_t *block, uint8_t value, ptrdiff_t line_size, } } -av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx) +av_cold void ff_blockdsp_init(BlockDSPContext *c) { c->clear_block = clear_block_c; c->clear_blocks = clear_blocks_c; @@ -71,7 +70,7 @@ av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx) #elif ARCH_PPC ff_blockdsp_init_ppc(c); #elif ARCH_X86 - ff_blockdsp_init_x86(c, avctx); + ff_blockdsp_init_x86(c); #elif ARCH_MIPS ff_blockdsp_init_mips(c); #endif diff --git a/libavcodec/blockdsp.h b/libavcodec/blockdsp.h index 58eecffb07..d853adada2 100644 --- a/libavcodec/blockdsp.h +++ b/libavcodec/blockdsp.h @@ -22,8 +22,6 @@ #include #include -#include "avcodec.h" - /* add and put pixel (decoding) * Block sizes for op_pixels_func are 8x4,8x8 16x8 16x16. * h for op_pixels_func is limited to { width / 2, width }, @@ -38,12 +36,12 @@ typedef struct BlockDSPContext { op_fill_func fill_block_tab[2]; } BlockDSPContext; -void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx); +void ff_blockdsp_init(BlockDSPContext *c); void ff_blockdsp_init_alpha(BlockDSPContext *c); void ff_blockdsp_init_arm(BlockDSPContext *c); void ff_blockdsp_init_ppc(BlockDSPContext *c); -void ff_blockdsp_init_x86(BlockDSPContext *c, AVCodecContext *avctx); +void ff_blockdsp_init_x86(BlockDSPContext *c); void ff_blockdsp_init_mips(BlockDSPContext *c); #endif /* AVCODEC_BLOCKDSP_H */ diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index cba0a06e89..6d54e8eae5 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -793,7 +793,7 @@ av_cold int ff_cavs_init(AVCodecContext *avctx) { AVSContext *h = avctx->priv_data; - ff_blockdsp_init(&h->bdsp, avctx); + ff_blockdsp_init(&h->bdsp); ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 17b7179927..a44f95f044 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -273,7 +273,7 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame, ctx->avctx->bits_per_raw_sample = ctx->bit_depth = bitdepth; if (ctx->bit_depth != old_bit_depth) { - ff_blockdsp_init(&ctx->bdsp, ctx->avctx); + ff_blockdsp_init(&ctx->bdsp); ff_idctdsp_init(&ctx->idsp, ctx->avctx); ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, ff_zigzag_direct); diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index e1008ec776..b7dc54f86a 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -419,7 +419,7 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) avctx->bits_per_raw_sample = ctx->bit_depth; - ff_blockdsp_init(&ctx->bdsp, avctx); + ff_blockdsp_init(&ctx->bdsp); ff_fdctdsp_init(&ctx->m.fdsp, avctx); ff_mpv_idct_init(&ctx->m); ff_mpegvideoencdsp_init(&ctx->m.mpvencdsp, avctx); diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c index 7ce2ce36c8..2a5aac912d 100644 --- a/libavcodec/eamad.c +++ b/libavcodec/eamad.c @@ -69,7 +69,7 @@ static av_cold int decode_init(AVCodecContext *avctx) MadContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_YUV420P; - ff_blockdsp_init(&s->bdsp, avctx); + ff_blockdsp_init(&s->bdsp); ff_bswapdsp_init(&s->bbdsp); ff_idctdsp_init(&s->idsp, avctx); ff_init_scantable_permutation(s->idsp.idct_permutation, FF_IDCT_PERM_NONE); diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 4799f75886..324e6f1ced 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -62,7 +62,7 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx) { TqiContext *t = avctx->priv_data; - ff_blockdsp_init(&t->bdsp, avctx); + ff_blockdsp_init(&t->bdsp); ff_bswapdsp_init(&t->bsdsp); ff_idctdsp_init(&t->idsp, avctx); ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE); diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c index 080544de8b..4367af3dc0 100644 --- a/libavcodec/g2meet.c +++ b/libavcodec/g2meet.c @@ -180,7 +180,7 @@ static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c) if (ret) return ret; - ff_blockdsp_init(&c->bdsp, avctx); + ff_blockdsp_init(&c->bdsp); ff_idctdsp_init(&c->idsp, avctx); ff_init_scantable(c->idsp.idct_permutation, &c->scantable, ff_zigzag_direct); diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index e82cb8680e..f88baf8daf 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -722,7 +722,7 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx, ff_wmv1_scantable[3]); ff_intrax8dsp_init(&w->dsp); - ff_blockdsp_init(&w->bdsp, avctx); + ff_blockdsp_init(&w->bdsp); ff_thread_once(&init_static_once, x8_vlc_init); diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index dd7e4a93ef..e0287a9cb9 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -56,7 +56,7 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); avctx->pix_fmt = AV_PIX_FMT_PAL8; - ff_blockdsp_init(&s->bdsp, avctx); + ff_blockdsp_init(&s->bdsp); return 0; } diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index c8994f68ee..f27cf84122 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -219,7 +219,7 @@ static av_cold int decode_init(AVCodecContext *avctx) a->avctx = avctx; - ff_blockdsp_init(&a->bdsp, avctx); + ff_blockdsp_init(&a->bdsp); ff_bswapdsp_init(&a->bbdsp); ff_idctdsp_init(&a->idsp, avctx); ff_mpeg12_init_vlcs(); diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 1d4f2b85c1..74eaa7d043 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -133,7 +133,7 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) ctx->prev_index = 0; ctx->cur_index = 15; - ff_blockdsp_init(&ctx->bdsp, avctx); + ff_blockdsp_init(&ctx->bdsp); ff_bswapdsp_init(&ctx->bbdsp); ff_hpeldsp_init(&ctx->hdsp, avctx->flags); ff_idctdsp_init(&ctx->idsp, avctx); diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index ca7e752f16..5b7a8b1e7c 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -134,7 +134,7 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) s->pkt = avctx->internal->in_pkt; s->avctx = avctx; - ff_blockdsp_init(&s->bdsp, avctx); + ff_blockdsp_init(&s->bdsp); ff_hpeldsp_init(&s->hdsp, avctx->flags); init_idct(avctx); s->buffer_size = 0; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 86fe5e4022..d8c7bc687d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -281,7 +281,7 @@ static void gray8(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h) /* init common dct for both encoder and decoder */ static av_cold int dct_init(MpegEncContext *s) { - ff_blockdsp_init(&s->bdsp, s->avctx); + ff_blockdsp_init(&s->bdsp); ff_h264chroma_init(&s->h264chroma, 8); //for lowres ff_hpeldsp_init(&s->hdsp, s->avctx->flags); ff_mpegvideodsp_init(&s->mdsp); diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c index 03be4ddd9d..24b04400fd 100644 --- a/libavcodec/mv30.c +++ b/libavcodec/mv30.c @@ -670,7 +670,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->pix_fmt = AV_PIX_FMT_YUV420P; avctx->color_range = AVCOL_RANGE_JPEG; - ff_blockdsp_init(&s->bdsp, avctx); + ff_blockdsp_init(&s->bdsp); s->prev_frame = av_frame_alloc(); if (!s->prev_frame) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 5ec579b994..b0d7f8d5d5 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -177,7 +177,7 @@ static av_cold int decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Auto bitdepth precision. Use 12b decoding based on codec tag.\n"); } - ff_blockdsp_init(&ctx->bdsp, avctx); + ff_blockdsp_init(&ctx->bdsp); ret = ff_proresdsp_init(&ctx->prodsp, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Fail to init proresdsp for bits per raw sample %d\n", avctx->bits_per_raw_sample); diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c index 4f0e417a82..11d3311794 100644 --- a/libavcodec/speedhq.c +++ b/libavcodec/speedhq.c @@ -665,7 +665,7 @@ static av_cold int speedhq_decode_init(AVCodecContext *avctx) if (ret) return AVERROR_UNKNOWN; - ff_blockdsp_init(&s->bdsp, avctx); + ff_blockdsp_init(&s->bdsp); ff_idctdsp_init(&s->idsp, avctx); ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct); diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 9f32e82f9e..fa6b5cfd3c 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -540,7 +540,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) // That this is necessary might indicate a bug. ff_vc1_decode_end(avctx); - ff_blockdsp_init(&s->bdsp, avctx); + ff_blockdsp_init(&s->bdsp); ff_h264chroma_init(&v->h264chroma, 8); ff_qpeldsp_init(&s->qdsp); diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index 5fea009e12..07a5d14f90 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -29,7 +29,7 @@ av_cold void ff_wmv2_common_init(MpegEncContext *s) { WMV2Context *const w = s->private_ctx; - ff_blockdsp_init(&s->bdsp, s->avctx); + ff_blockdsp_init(&s->bdsp); ff_wmv2dsp_init(&w->wdsp); s->idsp.perm_type = w->wdsp.idct_perm; ff_init_scantable_permutation(s->idsp.idct_permutation, diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c index b0ff9376d9..996124114f 100644 --- a/libavcodec/x86/blockdsp_init.c +++ b/libavcodec/x86/blockdsp_init.c @@ -29,8 +29,7 @@ void ff_clear_block_avx(int16_t *block); void ff_clear_blocks_sse(int16_t *blocks); void ff_clear_blocks_avx(int16_t *blocks); -av_cold void ff_blockdsp_init_x86(BlockDSPContext *c, - AVCodecContext *avctx) +av_cold void ff_blockdsp_init_x86(BlockDSPContext *c) { #if HAVE_X86ASM int cpu_flags = av_get_cpu_flags(); diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c index 9e6ce9d7d1..99d79209e4 100644 --- a/tests/checkasm/blockdsp.c +++ b/tests/checkasm/blockdsp.c @@ -57,10 +57,9 @@ void checkasm_check_blockdsp(void) LOCAL_ALIGNED_32(uint16_t, buf0, [6 * 8 * 8]); LOCAL_ALIGNED_32(uint16_t, buf1, [6 * 8 * 8]); - AVCodecContext avctx = { 0 }; BlockDSPContext h; - ff_blockdsp_init(&h, &avctx); + ff_blockdsp_init(&h); check_clear(clear_block, 8 * 8); check_clear(clear_blocks, 8 * 8 * 6); From 9beba053117342dd7619b009c2f87eed77725807 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 03:00:50 +0200 Subject: [PATCH 386/590] avcodec/fmtconvert: Remove unused AVCodecContext parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unused since d74a8cb7e42f703be5796eeb485f06af710ae8ca. Reviewed-by: Rémi Denis-Courmont Signed-off-by: Andreas Rheinhardt --- libavcodec/aarch64/fmtconvert_init.c | 4 +--- libavcodec/ac3dec.c | 2 +- libavcodec/ac3dec.h | 1 + libavcodec/arm/fmtconvert_init_arm.c | 3 +-- libavcodec/fmtconvert.c | 11 +++++------ libavcodec/fmtconvert.h | 12 ++++++------ libavcodec/mips/fmtconvert_mips.c | 1 - libavcodec/ppc/fmtconvert_altivec.c | 3 +-- libavcodec/x86/fmtconvert_init.c | 2 +- tests/checkasm/fmtconvert.c | 2 +- 10 files changed, 18 insertions(+), 23 deletions(-) diff --git a/libavcodec/aarch64/fmtconvert_init.c b/libavcodec/aarch64/fmtconvert_init.c index 210e74b654..e0990afabc 100644 --- a/libavcodec/aarch64/fmtconvert_init.c +++ b/libavcodec/aarch64/fmtconvert_init.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/aarch64/cpu.h" -#include "libavcodec/avcodec.h" #include "libavcodec/fmtconvert.h" void ff_int32_to_float_fmul_array8_neon(FmtConvertContext *c, float *dst, @@ -31,8 +30,7 @@ void ff_int32_to_float_fmul_array8_neon(FmtConvertContext *c, float *dst, void ff_int32_to_float_fmul_scalar_neon(float *dst, const int32_t *src, float mul, int len); -av_cold void ff_fmt_convert_init_aarch64(FmtConvertContext *c, - AVCodecContext *avctx) +av_cold void ff_fmt_convert_init_aarch64(FmtConvertContext *c) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index f628eae33c..aba8e0fb7f 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -230,7 +230,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) #if (USE_FIXED) s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT); #else - ff_fmt_convert_init(&s->fmt_conv, avctx); + ff_fmt_convert_init(&s->fmt_conv); s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); #endif if (!s->fdsp) diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 9444124974..88651ae61f 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -57,6 +57,7 @@ #include "ac3.h" #include "ac3dsp.h" +#include "avcodec.h" #include "bswapdsp.h" #include "get_bits.h" #include "fft.h" diff --git a/libavcodec/arm/fmtconvert_init_arm.c b/libavcodec/arm/fmtconvert_init_arm.c index e88255d619..e12f83c842 100644 --- a/libavcodec/arm/fmtconvert_init_arm.c +++ b/libavcodec/arm/fmtconvert_init_arm.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/arm/cpu.h" -#include "libavcodec/avcodec.h" #include "libavcodec/fmtconvert.h" void ff_int32_to_float_fmul_array8_neon(FmtConvertContext *c, float *dst, @@ -37,7 +36,7 @@ void ff_int32_to_float_fmul_array8_vfp(FmtConvertContext *c, float *dst, const int32_t *src, const float *mul, int len); -av_cold void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx) +av_cold void ff_fmt_convert_init_arm(FmtConvertContext *c) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c index 00f55f8f1e..cedfd61138 100644 --- a/libavcodec/fmtconvert.c +++ b/libavcodec/fmtconvert.c @@ -22,7 +22,6 @@ #include "config.h" #include "libavutil/attributes.h" -#include "avcodec.h" #include "fmtconvert.h" static void int32_to_float_fmul_scalar_c(float *dst, const int32_t *src, @@ -42,19 +41,19 @@ static void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst, c->int32_to_float_fmul_scalar(&dst[i], &src[i], *mul++, 8); } -av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) +av_cold void ff_fmt_convert_init(FmtConvertContext *c) { c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; c->int32_to_float_fmul_array8 = int32_to_float_fmul_array8_c; #if ARCH_AARCH64 - ff_fmt_convert_init_aarch64(c, avctx); + ff_fmt_convert_init_aarch64(c); #elif ARCH_ARM - ff_fmt_convert_init_arm(c, avctx); + ff_fmt_convert_init_arm(c); #elif ARCH_PPC - ff_fmt_convert_init_ppc(c, avctx); + ff_fmt_convert_init_ppc(c); #elif ARCH_X86 - ff_fmt_convert_init_x86(c, avctx); + ff_fmt_convert_init_x86(c); #endif #if HAVE_MIPSFPU ff_fmt_convert_init_mips(c); diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h index b2df7a9629..da244e05a5 100644 --- a/libavcodec/fmtconvert.h +++ b/libavcodec/fmtconvert.h @@ -23,7 +23,7 @@ #ifndef AVCODEC_FMTCONVERT_H #define AVCODEC_FMTCONVERT_H -#include "avcodec.h" +#include typedef struct FmtConvertContext { /** @@ -56,12 +56,12 @@ typedef struct FmtConvertContext { } FmtConvertContext; -void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx); +void ff_fmt_convert_init(FmtConvertContext *c); -void ff_fmt_convert_init_aarch64(FmtConvertContext *c, AVCodecContext *avctx); -void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx); -void ff_fmt_convert_init_ppc(FmtConvertContext *c, AVCodecContext *avctx); -void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx); +void ff_fmt_convert_init_aarch64(FmtConvertContext *c); +void ff_fmt_convert_init_arm(FmtConvertContext *c); +void ff_fmt_convert_init_ppc(FmtConvertContext *c); +void ff_fmt_convert_init_x86(FmtConvertContext *c); void ff_fmt_convert_init_mips(FmtConvertContext *c); #endif /* AVCODEC_FMTCONVERT_H */ diff --git a/libavcodec/mips/fmtconvert_mips.c b/libavcodec/mips/fmtconvert_mips.c index 89c699854e..c39e853575 100644 --- a/libavcodec/mips/fmtconvert_mips.c +++ b/libavcodec/mips/fmtconvert_mips.c @@ -49,7 +49,6 @@ */ #include "config.h" #include "libavutil/attributes.h" -#include "libavcodec/avcodec.h" #include "libavcodec/fmtconvert.h" #include "libavutil/mips/asmdefs.h" diff --git a/libavcodec/ppc/fmtconvert_altivec.c b/libavcodec/ppc/fmtconvert_altivec.c index 7323eff0bd..2e34de7c90 100644 --- a/libavcodec/ppc/fmtconvert_altivec.c +++ b/libavcodec/ppc/fmtconvert_altivec.c @@ -54,8 +54,7 @@ static void int32_to_float_fmul_scalar_altivec(float *dst, const int32_t *src, #endif /* HAVE_ALTIVEC */ -av_cold void ff_fmt_convert_init_ppc(FmtConvertContext *c, - AVCodecContext *avctx) +av_cold void ff_fmt_convert_init_ppc(FmtConvertContext *c) { #if HAVE_ALTIVEC if (!PPC_ALTIVEC(av_get_cpu_flags())) diff --git a/libavcodec/x86/fmtconvert_init.c b/libavcodec/x86/fmtconvert_init.c index 58b396856e..acbc334565 100644 --- a/libavcodec/x86/fmtconvert_init.c +++ b/libavcodec/x86/fmtconvert_init.c @@ -35,7 +35,7 @@ void ff_int32_to_float_fmul_array8_sse2(FmtConvertContext *c, float *dst, const #endif /* HAVE_X86ASM */ -av_cold void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx) +av_cold void ff_fmt_convert_init_x86(FmtConvertContext *c) { #if HAVE_X86ASM int cpu_flags = av_get_cpu_flags(); diff --git a/tests/checkasm/fmtconvert.c b/tests/checkasm/fmtconvert.c index aef74479f6..e103a664d0 100644 --- a/tests/checkasm/fmtconvert.c +++ b/tests/checkasm/fmtconvert.c @@ -56,7 +56,7 @@ void checkasm_check_fmtconvert(void) for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++) scale_arr[i] = (FF_ARRAY_ELEMS(scale_arr) - FF_ARRAY_ELEMS(scale_arr) / 2) / 13; - ff_fmt_convert_init(&c, NULL); + ff_fmt_convert_init(&c); memset(dst0, 0, sizeof(*dst0) * BUF_SIZE); memset(dst1, 0, sizeof(*dst1) * BUF_SIZE); From e2e31815191254ef5581213639f4bed8e4a8be25 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:33:27 +0200 Subject: [PATCH 387/590] avcodec/avcodec: Uninitialize AVChannelLayout before overwriting it Otherwise, there might be leaks. Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 1f8ab37abb..81f30a4a58 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -235,6 +235,7 @@ FF_DISABLE_DEPRECATION_WARNINGS if ((avctx->channels > 0 && avctx->ch_layout.nb_channels != avctx->channels) || (avctx->channel_layout && (avctx->ch_layout.order != AV_CHANNEL_ORDER_NATIVE || avctx->ch_layout.u.mask != avctx->channel_layout))) { + av_channel_layout_uninit(&avctx->ch_layout); if (avctx->channel_layout) { av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout); } else { From 859d9d70f9faf87bfc3fe23f97c38fd661367778 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:27:15 +0200 Subject: [PATCH 388/590] avcodec/encode: Remove dead deprecated check The wrapper for the legacy channel layout API already sets AVCodecContext.channels based upon AVCodecContext.channel_layout if the latter is set while the former is unset. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 049b71c6f4..ffac2c1ff3 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -631,8 +631,6 @@ FF_DISABLE_DEPRECATION_WARNINGS buf, channels, avctx->channels); return AVERROR(EINVAL); } - } else if (avctx->channel_layout) { - avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); } if (avctx->channels < 0) { av_log(avctx, AV_LOG_ERROR, "Specified number of channels %d is not supported\n", From a06a2d89434abd8feb760a943924f3cfacedfda6 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 16 Sep 2022 02:27:25 +0200 Subject: [PATCH 389/590] avcodec/avcodec: Check for more invalid channel layouts In particular, check the provided channel layout for encoders without AVCodec.ch_layouts set. This fixes an infinite loop in the WavPack encoder (and maybe other issues in other encoders as well) in case the channel count is zero. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.c | 14 ++++++++++++++ libavcodec/decode.c | 5 ----- libavcodec/encode.c | 5 ----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 81f30a4a58..737c4bcd04 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -246,6 +246,20 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif + /* AV_CODEC_CAP_CHANNEL_CONF is a decoder-only flag; so the code below + * in particular checks that nb_channels is set for all audio encoders. */ + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && !avctx->ch_layout.nb_channels + && !(codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)) { + av_log(avctx, AV_LOG_ERROR, "%s requires channel layout to be set\n", + av_codec_is_decoder(codec) ? "Decoder" : "Encoder"); + ret = AVERROR(EINVAL); + goto free_and_end; + } + if (avctx->ch_layout.nb_channels && !av_channel_layout_check(&avctx->ch_layout)) { + av_log(avctx, AV_LOG_ERROR, "Invalid channel layout\n"); + ret = AVERROR(EINVAL); + goto free_and_end; + } if (avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->ch_layout.nb_channels); ret = AVERROR(EINVAL); diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 2961705c9d..6be2d3d6ed 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1595,11 +1595,6 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && avctx->ch_layout.nb_channels == 0 && - !(avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)) { - av_log(avctx, AV_LOG_ERROR, "Decoder requires channel count but channels not set\n"); - return AVERROR(EINVAL); - } if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) { av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n", avctx->codec->max_lowres); diff --git a/libavcodec/encode.c b/libavcodec/encode.c index ffac2c1ff3..9f4804cd69 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -602,11 +602,6 @@ static int encode_preinit_audio(AVCodecContext *avctx) return AVERROR(EINVAL); } if (avctx->codec->ch_layouts) { - if (!av_channel_layout_check(&avctx->ch_layout)) { - av_log(avctx, AV_LOG_WARNING, "Channel layout not specified correctly\n"); - return AVERROR(EINVAL); - } - for (i = 0; avctx->codec->ch_layouts[i].nb_channels; i++) { if (!av_channel_layout_compare(&avctx->ch_layout, &avctx->codec->ch_layouts[i])) break; From 90edbd3185e6fac04aed739e2bdef9c69d574b17 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:38:08 +0200 Subject: [PATCH 390/590] avcodec/avcodec: Always use old channel count/layout if set This ensures that if AVCodecContext.channels or AVCodecContext.channel_layout are set, AVCodecContext.ch_layout has the equivalent values after this block. (In case these values are set inconsistently, the consistency check for ch_layout below will error out.) Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 737c4bcd04..a85d3c2309 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -232,7 +232,7 @@ FF_DISABLE_DEPRECATION_WARNINGS if (avctx->channel_layout && !avctx->channels) avctx->channels = av_popcount64(avctx->channel_layout); - if ((avctx->channels > 0 && avctx->ch_layout.nb_channels != avctx->channels) || + if ((avctx->channels && avctx->ch_layout.nb_channels != avctx->channels) || (avctx->channel_layout && (avctx->ch_layout.order != AV_CHANNEL_ORDER_NATIVE || avctx->ch_layout.u.mask != avctx->channel_layout))) { av_channel_layout_uninit(&avctx->ch_layout); @@ -240,8 +240,8 @@ FF_DISABLE_DEPRECATION_WARNINGS av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout); } else { avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; - avctx->ch_layout.nb_channels = avctx->channels; } + avctx->ch_layout.nb_channels = avctx->channels; } FF_ENABLE_DEPRECATION_WARNINGS #endif From 9ffd0c46b1e266625c22151d0c459ddb234848a1 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:49:52 +0200 Subject: [PATCH 391/590] avcodec/encode: Remove deprecated always-false checks Now that it is ensured that the old and new channel count/layout values coincide if the old ones are set, the consistency of the AVChannelLayout (which is checked before we reach this point) implies the consistency of the old values, making these checks here dead code. So remove them. Signed-off-by: Andreas Rheinhardt --- libavcodec/encode.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 9f4804cd69..b275344bd1 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -614,26 +614,6 @@ static int encode_preinit_audio(AVCodecContext *avctx) return AVERROR(EINVAL); } } -#if FF_API_OLD_CHANNEL_LAYOUT -FF_DISABLE_DEPRECATION_WARNINGS - if (avctx->channel_layout && avctx->channels) { - int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); - if (channels != avctx->channels) { - char buf[512]; - av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout); - av_log(avctx, AV_LOG_ERROR, - "Channel layout '%s' with %d channels does not match number of specified channels %d\n", - buf, channels, avctx->channels); - return AVERROR(EINVAL); - } - } - if (avctx->channels < 0) { - av_log(avctx, AV_LOG_ERROR, "Specified number of channels %d is not supported\n", - avctx->channels); - return AVERROR(EINVAL); - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif if (!avctx->bits_per_raw_sample) avctx->bits_per_raw_sample = 8 * av_get_bytes_per_sample(avctx->sample_fmt); From cd335de53f853087b45b53fa96b09ddf4ab01108 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 16 Sep 2022 02:32:07 +0200 Subject: [PATCH 392/590] avcodec/dfpwmdec: Remove always-false check This decoder does not have the AV_CODEC_CAP_CHANNEL_CONF set, so that number of channels has to be set by the user before avcodec_open2(). Signed-off-by: Andreas Rheinhardt --- libavcodec/dfpwmdec.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavcodec/dfpwmdec.c b/libavcodec/dfpwmdec.c index 532a955b4c..4ddb806561 100644 --- a/libavcodec/dfpwmdec.c +++ b/libavcodec/dfpwmdec.c @@ -85,11 +85,6 @@ static av_cold int dfpwm_dec_init(struct AVCodecContext *ctx) { DFPWMState *state = ctx->priv_data; - if (ctx->ch_layout.nb_channels <= 0) { - av_log(ctx, AV_LOG_ERROR, "Invalid number of channels\n"); - return AVERROR(EINVAL); - } - state->fq = 0; state->q = 0; state->s = 0; From ce6af2df617f70d6947c7936f9fb462bf5546886 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 20:45:46 +0200 Subject: [PATCH 393/590] avcodec/pcm-blurayenc: Don't presume every channel layout to be native The pcm_bluray encoder has AVCodec.ch_layouts set, so that ff_encode_preinit() checks that the channel layout in use is equivalent to one of the layouts from AVCodec.ch_layouts. Yet equivalent is not the same as identical; in particular, custom layouts equivalent to native layouts are possible (and necessary if one wants to use the name/opaque fields with an ordinary channel layout), so one must not simply use AVChannelLayout.u.mask. Use av_channel_layout_subset() instead. Signed-off-by: Andreas Rheinhardt --- libavcodec/pcm-blurayenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c index 1f1a3a27d8..03ed88b8ae 100644 --- a/libavcodec/pcm-blurayenc.c +++ b/libavcodec/pcm-blurayenc.c @@ -63,7 +63,7 @@ static av_cold int pcm_bluray_encode_init(AVCodecContext *avctx) return AVERROR_BUG; } - switch (avctx->ch_layout.u.mask) { + switch (av_channel_layout_subset(&avctx->ch_layout, ~(uint64_t)0)) { case AV_CH_LAYOUT_MONO: ch_layout = 1; break; From 5c18934c6d8bb56e412efc5636fbc22b6c57b16d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 20:55:23 +0200 Subject: [PATCH 394/590] avcodec/pcm: Remove always-false check None of the decoders here have the AV_CODEC_CAP_CHANNEL_CONF set, so that it is already checked generically that the number of channels is positive. Signed-off-by: Andreas Rheinhardt --- libavcodec/pcm.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index fcb8ae1c2c..ee36a364c8 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -254,11 +254,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) AVFloatDSPContext *fdsp; int i; - if (avctx->ch_layout.nb_channels <= 0) { - av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); - return AVERROR(EINVAL); - } - switch (avctx->codec_id) { case AV_CODEC_ID_PCM_ALAW: for (i = 0; i < 256; i++) From e6073665c43ec199b43689b5f305e7fed8f84379 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 20:59:36 +0200 Subject: [PATCH 395/590] avcodec/libcodec2: Remove dead channel count check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This encoder has AVCodec.ch_layouts set, so that this is checked generically. Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- libavcodec/libcodec2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index be9677ddeb..581ef04ce2 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -105,7 +105,6 @@ static av_cold int libcodec2_init_encoder(AVCodecContext *avctx) //will need to be smarter once we get wideband support if (avctx->sample_rate != 8000 || - avctx->ch_layout.nb_channels != 1 || avctx->sample_fmt != AV_SAMPLE_FMT_S16) { av_log(avctx, AV_LOG_ERROR, "only 8 kHz 16-bit mono allowed\n"); return AVERROR(EINVAL); From 56f7b39456e65c31262c12ad0e03126ec29ce92d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:00:51 +0200 Subject: [PATCH 396/590] avcodec/libshine: Remove dead channel count check This encoder has AVCodec.ch_layouts set, so that this is checked generically. Signed-off-by: Andreas Rheinhardt --- libavcodec/libshine.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c index 621c57816a..e266229f03 100644 --- a/libavcodec/libshine.c +++ b/libavcodec/libshine.c @@ -44,11 +44,6 @@ static av_cold int libshine_encode_init(AVCodecContext *avctx) { SHINEContext *s = avctx->priv_data; - if (avctx->ch_layout.nb_channels <= 0 || avctx->ch_layout.nb_channels > 2){ - av_log(avctx, AV_LOG_ERROR, "only mono or stereo is supported\n"); - return AVERROR(EINVAL); - } - shine_set_config_mpeg_defaults(&s->config.mpeg); if (avctx->bit_rate) s->config.mpeg.bitr = avctx->bit_rate / 1000; From 4668ff792a509ec1eb61f3ebc133d40db3b5a420 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:02:01 +0200 Subject: [PATCH 397/590] avcodec/libspeexenc: Remove dead channel count check This encoder has AVCodec.ch_layouts set, so that this is checked generically. Signed-off-by: Andreas Rheinhardt --- libavcodec/libspeexenc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 8d2c6347fa..2191e7dac7 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -152,13 +152,6 @@ static av_cold int encode_init(AVCodecContext *avctx) int header_size; int32_t complexity; - /* channels */ - if (channels < 1 || channels > 2) { - av_log(avctx, AV_LOG_ERROR, "Invalid channels (%d). Only stereo and " - "mono are supported\n", channels); - return AVERROR(EINVAL); - } - /* sample rate and encoding mode */ switch (avctx->sample_rate) { case 8000: mode = speex_lib_get_mode(SPEEX_MODEID_NB); break; From 17366d6128c7c3e3781442cfd1e84e4ec5b6f20e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 21:03:22 +0200 Subject: [PATCH 398/590] avcodec/mpegaudioenc_template: Remove dead channel count check The encoders using this have AVCodec.ch_layouts set, so that this is checked generically. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegaudioenc_template.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavcodec/mpegaudioenc_template.c b/libavcodec/mpegaudioenc_template.c index 67b8069102..396e8a4899 100644 --- a/libavcodec/mpegaudioenc_template.c +++ b/libavcodec/mpegaudioenc_template.c @@ -82,10 +82,6 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) int i, v, table; float a; - if (channels <= 0 || channels > 2){ - av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels); - return AVERROR(EINVAL); - } bitrate = bitrate / 1000; s->nb_channels = channels; avctx->frame_size = MPA_FRAME_SIZE; From 03fb801cd97ab203a6beb5bdfc495f16801cc13e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 22:51:59 +0200 Subject: [PATCH 399/590] avcodec/mlpenc: Fix channel layouts The encoder actually creates files with side channels, not back channels. See thd_layout in mlp_parse.h. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/mlpenc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 73fdfc01cc..ac1f446313 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -628,14 +628,14 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) ctx->channel_arrangement = 1; ctx->thd_substream_info = 0x14; } else if (!av_channel_layout_compare(&avctx->ch_layout, - &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK)) { + &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0)) { ctx->ch_modifier_thd0 = 1; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 1; ctx->channel_arrangement = 11; ctx->thd_substream_info = 0x104; } else if (!av_channel_layout_compare(&avctx->ch_layout, - &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK)) { + &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1)) { ctx->ch_modifier_thd0 = 2; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 2; @@ -2278,13 +2278,13 @@ const FFCodec ff_truehd_encoder = { .p.sample_fmts = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .p.supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, #if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) {AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, 0}, + .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1, 0 }, #endif .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, - AV_CHANNEL_LAYOUT_5POINT0_BACK, - AV_CHANNEL_LAYOUT_5POINT1_BACK, + AV_CHANNEL_LAYOUT_5POINT0, + AV_CHANNEL_LAYOUT_5POINT1, { 0 } }, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, From a12338afe5192f23349c0fde8592891be230bfc3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 23:13:05 +0200 Subject: [PATCH 400/590] avcodec/mlpenc: Simplify channel layout comparisons These encoders have AVCodec.ch_layouts set, so ff_encode_preinit() has already checked that the used channel layout is equivalent to one of these native layouts. Therefore one can simply compare the channel masks (with the added complication that one has to use av_channel_layout_subset() to get it, because the channel layout is not guaranteed to have AV_CHANNEL_ORDER_NATIVE). Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/mlpenc.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index ac1f446313..18e8ce4579 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -480,6 +480,7 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) static AVOnce init_static_once = AV_ONCE_INIT; MLPEncodeContext *ctx = avctx->priv_data; RestartHeader *const rh = &ctx->restart_header; + uint64_t channels_present; unsigned int sum = 0; size_t size; int ret; @@ -589,19 +590,20 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) ctx->num_substreams = 1; // TODO: change this after adding multi-channel support for TrueHD + channels_present = av_channel_layout_subset(&avctx->ch_layout, ~(uint64_t)0); if (ctx->avctx->codec_id == AV_CODEC_ID_MLP) { - static const AVChannelLayout layout_arrangement[] = { - AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, - AV_CHANNEL_LAYOUT_2_1, AV_CHANNEL_LAYOUT_QUAD, - AV_CHANNEL_LAYOUT_2POINT1, { 0 }, { 0 }, - AV_CHANNEL_LAYOUT_SURROUND, AV_CHANNEL_LAYOUT_4POINT0, - AV_CHANNEL_LAYOUT_5POINT0_BACK, AV_CHANNEL_LAYOUT_3POINT1, - AV_CHANNEL_LAYOUT_4POINT1, AV_CHANNEL_LAYOUT_5POINT1_BACK, + static const uint64_t layout_arrangement[] = { + AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_2_1, AV_CH_LAYOUT_QUAD, + AV_CH_LAYOUT_2POINT1, 0, 0, + AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_4POINT0, + AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_3POINT1, + AV_CH_LAYOUT_4POINT1, AV_CH_LAYOUT_5POINT1_BACK, }; int i; for (i = 0; i < FF_ARRAY_ELEMS(layout_arrangement); i++) - if (!av_channel_layout_compare(&avctx->ch_layout, &layout_arrangement[i])) + if (channels_present == layout_arrangement[i]) break; if (i == FF_ARRAY_ELEMS(layout_arrangement)) { av_log(avctx, AV_LOG_ERROR, "Unsupported channel arrangement\n"); @@ -613,29 +615,25 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) ctx->summary_info = ff_mlp_ch_info[ctx->channel_arrangement].summary_info ; } else { /* TrueHD */ - if (!av_channel_layout_compare(&avctx->ch_layout, - &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) { + if (channels_present == AV_CH_LAYOUT_MONO) { ctx->ch_modifier_thd0 = 3; ctx->ch_modifier_thd1 = 3; ctx->ch_modifier_thd2 = 3; ctx->channel_arrangement = 2; ctx->thd_substream_info = 0x14; - } else if (!av_channel_layout_compare(&avctx->ch_layout, - &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) { + } else if (channels_present == AV_CH_LAYOUT_STEREO) { ctx->ch_modifier_thd0 = 1; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 1; ctx->channel_arrangement = 1; ctx->thd_substream_info = 0x14; - } else if (!av_channel_layout_compare(&avctx->ch_layout, - &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0)) { + } else if (channels_present == AV_CH_LAYOUT_5POINT0) { ctx->ch_modifier_thd0 = 1; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 1; ctx->channel_arrangement = 11; ctx->thd_substream_info = 0x104; - } else if (!av_channel_layout_compare(&avctx->ch_layout, - &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1)) { + } else if (channels_present == AV_CH_LAYOUT_5POINT1) { ctx->ch_modifier_thd0 = 2; ctx->ch_modifier_thd1 = 1; ctx->ch_modifier_thd2 = 2; From 65dbc83eec2656786b901ed15569d7044c6c6dee Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 23:49:57 +0200 Subject: [PATCH 401/590] avcodec/mlpenc: Remove dead channel layout checks ff_encode_preinit() has already checked that the channel layout is equivalent to one of the layouts in AVCodec.ch_layouts. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavcodec/mlpenc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 18e8ce4579..a8b0486cf3 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -27,6 +27,7 @@ #include "encode.h" #include "put_bits.h" #include "audio_frame_queue.h" +#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/crc.h" #include "libavutil/avstring.h" @@ -602,12 +603,11 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) }; int i; - for (i = 0; i < FF_ARRAY_ELEMS(layout_arrangement); i++) + for (i = 0;; i++) { + av_assert1(i < FF_ARRAY_ELEMS(layout_arrangement) || + !"Impossible channel layout"); if (channels_present == layout_arrangement[i]) break; - if (i == FF_ARRAY_ELEMS(layout_arrangement)) { - av_log(avctx, AV_LOG_ERROR, "Unsupported channel arrangement\n"); - return AVERROR(EINVAL); } ctx->channel_arrangement = i; ctx->flags = FLAGS_DVDA; @@ -640,8 +640,7 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) ctx->channel_arrangement = 15; ctx->thd_substream_info = 0x104; } else { - av_log(avctx, AV_LOG_ERROR, "Unsupported channel arrangement\n"); - return AVERROR(EINVAL); + av_assert1(!"AVCodec.ch_layouts needs to be updated"); } ctx->flags = 0; ctx->channel_occupancy = 0; From 66e297fc848a6ec90143b4ace005b4503665e909 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 Sep 2022 23:54:21 +0200 Subject: [PATCH 402/590] avcodec/dcaenc: Remove dead checks for unspec channel layouts This encoder has AVCodec.ch_layouts set, so ff_encode_preinit() ensures that the used channel layout is equivalent to one of these. Signed-off-by: Andreas Rheinhardt --- libavcodec/dcaenc.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index d0de6d3eee..0996296d8c 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -222,13 +222,6 @@ static int encode_init(AVCodecContext *avctx) if (ff_dcaadpcm_init(&c->adpcm_ctx)) return AVERROR(ENOMEM); - if (layout.order == AV_CHANNEL_ORDER_UNSPEC) { - av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " - "encoder will guess the layout, but it " - "might be incorrect.\n"); - av_channel_layout_default(&layout, layout.nb_channels); - } - if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) c->channel_config = 0; else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) @@ -239,10 +232,6 @@ static int encode_init(AVCodecContext *avctx) c->channel_config = 9; else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1)) c->channel_config = 9; - else { - av_log(avctx, AV_LOG_ERROR, "Unsupported channel layout!\n"); - return AVERROR_PATCHWELCOME; - } if (c->lfe_channel) { c->fullband_channels--; From ce16d18307559213b20b24c4c824c7014a564590 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 18 Sep 2022 00:14:51 +0200 Subject: [PATCH 403/590] avcodec/dcaenc: Simplify channel layout check ff_encode_preinit() ensures that the channel layout is equivalent to one of the channel layouts in AVCodec.ch_layout; given that all of these channel layouts have distinct numbers of channels, one can therefore uniquely determine the channel layout by the number of channels. Signed-off-by: Andreas Rheinhardt --- libavcodec/dcaenc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 0996296d8c..46618c13f9 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -222,16 +222,25 @@ static int encode_init(AVCodecContext *avctx) if (ff_dcaadpcm_init(&c->adpcm_ctx)) return AVERROR(ENOMEM); - if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO)) + switch (layout.nb_channels) { + case 1: /* mono */ c->channel_config = 0; - else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) + break; + case 2: /* stereo */ c->channel_config = 2; - else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_2)) + break; + case 4: /* 2.2 */ c->channel_config = 8; - else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0)) + break; + case 5: /* 5.0 */ c->channel_config = 9; - else if (!av_channel_layout_compare(&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1)) + break; + case 6: /* 5.1 */ c->channel_config = 9; + break; + default: + av_assert1(!"impossible channel layout"); + } if (c->lfe_channel) { c->fullband_channels--; From dea944b838626b5576598b7f13cc34e6263ebbfe Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 22 Sep 2022 03:06:00 +0200 Subject: [PATCH 404/590] x86/lpc: fix odd scalar loop overreads/writes --- libavcodec/x86/lpc.asm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index 26101b4e25..f5133a2950 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -107,7 +107,6 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 .scalar_o: movapd xm7, [dec_tab_scalar] - subpd xm0, xm7 ; Set offsets add off2q, (mmsize/4) + 4*cpuflag(avx2) @@ -118,14 +117,14 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 mulpd xm2, xm0, xm0 subpd xm1, xm2 - cvtdq2pd xm3, [dataq + off1q - (mmsize/4) + 4*cpuflag(avx2)] - cvtdq2pd xm4, [dataq + off2q - (mmsize/4) + 4*cpuflag(avx2)] + cvtdq2pd xm3, [dataq + off1q] + cvtdq2pd xm4, [dataq + off2q] mulpd xm3, xm1 mulpd xm4, xm1 - movhpd [outq + off1q*2], xm3 - movhpd [outq + off2q*2], xm4 + movlpd [outq + off1q*2], xm3 + movlpd [outq + off2q*2], xm4 addpd xm0, xm7 From b67776e12f90a11c0c976d0add8d213a2684064f Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 22 Sep 2022 03:41:02 +0200 Subject: [PATCH 405/590] x86/lpc: fix even scalar loop overreads/writes Passes checkasm with valgrind, tested to sizes of more than 4000 samples. --- libavcodec/x86/lpc.asm | 32 +++++++++++++++++++------------- tests/checkasm/lpc.c | 4 ++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index f5133a2950..ad74f1d8ac 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -38,6 +38,8 @@ SECTION .text cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 cmp lenq, 0 je .end + cmp lenq, 2 + je .two cmp lenq, 1 je .one @@ -192,14 +194,13 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 jge .loop_e .scalar_e: - subpd m0, m7 - movapd m7, [dec_tab_scalar] - subpd m0, m7 - subpd m0, m7 - subpd m0, m7 + subpd xm0, xm7 + movapd xm7, [dec_tab_scalar] + subpd xm0, xm7 add off1q, (mmsize/2) - sub off2q, (mmsize/2) - 4 - 8*cpuflag(avx2) + sub off2q, (mmsize/2) - 8*cpuflag(avx2) + add lenq, 6 + 4*cpuflag(avx2) addpd xm0, [sub_tab] @@ -208,22 +209,27 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 mulpd xm2, xm0, xm0 subpd xm1, xm2 - cvtdq2pd m3, [dataq + off1q - 4] - cvtdq2pd m4, [dataq + off2q - 4] + cvtdq2pd xm3, [dataq + off1q] + cvtdq2pd xm4, [dataq + off2q] - mulpd m3, m1 - mulpd m4, m1 + mulpd xm3, xm1 + shufpd xm1, xm1, 00b + mulpd xm4, xm1 - movhpd [outq + off1q*2], xm3 - movhpd [outq + off2q*2], xm4 + movlpd [outq + off1q*2], xm3 + movhpd [outq + off2q*2 + 8], xm4 subpd xm0, xm7 add off2q, 4 sub off1q, 4 - jge .loop_e_scalar + sub lenq, 2 + jg .loop_e_scalar RET +.two: + xorpd xm0, xm0 + movhpd [outq + 8], xm0 .one: xorpd xm0, xm0 movhpd [outq], xm0 diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index b68ce05bfa..e072599908 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -68,6 +68,10 @@ void checkasm_check_lpc(void) } report("apply_welch_window_odd"); + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_2560")) + test_window(2560); + report("apply_welch_window_2560"); + if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4096")) test_window(4096); report("apply_welch_window_4096"); From f2d75d7fb05ce1fb901432dacf6a630ef841b43c Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 22 Sep 2022 03:43:12 +0200 Subject: [PATCH 406/590] fate/checkasm: add LPC test to list --- tests/fate/checkasm.mak | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index fbba0b5b8f..aa9b288e12 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -23,6 +23,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ fate-checkasm-jpeg2000dsp \ fate-checkasm-llviddsp \ fate-checkasm-llviddspenc \ + fate-checkasm-lpc \ fate-checkasm-motion \ fate-checkasm-opusdsp \ fate-checkasm-pixblockdsp \ From c9aa6164d4b7bd73f0fcc1800e4f1cc49ead9bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 22 Sep 2022 11:13:13 +0300 Subject: [PATCH 407/590] x86/lpc: Fix parameter sign extension, unbreaking checkasm-lpc on x86_64 windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/x86/lpc.asm | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index ad74f1d8ac..731aa7e2d8 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -36,6 +36,7 @@ SECTION .text %macro APPLY_WELCH_FN 0 cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 + movsxdifnidn lenq, lend cmp lenq, 0 je .end cmp lenq, 2 From f55f81795552d8f0a5d287973203bfce9cffe51e Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 22 Sep 2022 10:28:36 +0200 Subject: [PATCH 408/590] avcodec/exr: fix skipping too long metadata values --- libavcodec/exr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index e381e77e3f..f10754d6ae 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1962,7 +1962,7 @@ static int decode_header(EXRContext *s, AVFrame *frame) { uint8_t name[256] = { 0 }; uint8_t type[256] = { 0 }; - uint8_t value[256] = { 0 }; + uint8_t value[8192] = { 0 }; int i = 0, size; while (bytestream2_get_bytes_left(gb) > 0 && @@ -1980,6 +1980,8 @@ static int decode_header(EXRContext *s, AVFrame *frame) size = bytestream2_get_le32(gb); bytestream2_get_buffer(gb, value, FFMIN(sizeof(value) - 1, size)); + if (size > sizeof(value) - 1) + bytestream2_skip(gb, size - (sizeof(value) - 1)); if (!strcmp(type, "string")) av_dict_set(&metadata, name, value, 0); } From af919cf780b59cdf60835f412f78db1138fc1138 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Thu, 1 Sep 2022 10:57:42 +0800 Subject: [PATCH 409/590] fftools/ffmpeg: fix av_display_rotation_set() type cast Signed-off-by: Zhao Zhili --- fftools/ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0e1477299d..69716de6b6 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3256,7 +3256,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return AVERROR(ENOMEM); memcpy(dst, sd->data, sd->size); if (ist->autorotate && sd->type == AV_PKT_DATA_DISPLAYMATRIX) - av_display_rotation_set((uint32_t *)dst, 0); + av_display_rotation_set((int32_t *)dst, 0); } } } From 05cff214b9234c0e24ffe73b0bb929787267c7e2 Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 21 Sep 2022 18:30:47 -0300 Subject: [PATCH 410/590] avutil/channel_layout: mention how the API user should treat channel orders it does not understand In case new orders are added in the future, existing library users can still use the layout simply by ignoring everything but the channel count in it, so make this explicit. Reviewed-by: Anton Khirnov Signed-off-by: James Almer --- libavutil/channel_layout.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 4dd6614de9..9e685fab72 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -290,6 +290,9 @@ typedef struct AVChannelCustom { typedef struct AVChannelLayout { /** * Channel order used in this layout. + * Any value not defined in the AVChannelOrder enum in a layout that + * av_channel_layout_check() doesn't reject must be treated as if it was + * AV_CHANNEL_ORDER_UNSPEC. * This is a mandatory field. */ enum AVChannelOrder order; From 14b3830b33075e92f8e2766c0c53e8b6bc570c6c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 22:08:47 +0200 Subject: [PATCH 411/590] avformat/dashdec: Fix crash on invalid input/ENOMEM, fix leak In case a SupplementalProperty node exists in an adaptationset, it is searched for a "schemeIdUri" property via xmlGetProp(). Whatever xmlGetProp() returns is then compared via av_strcasecmp() to a string literal. xmlGetProp() can return NULL, namely in case no "schemeIdUri" exists and (given that this string is allocated) presumably also on allocation failure. No check for NULL is done, so this may crash. Furthermore, the string returned by xmlGetProp() needs to be freed with xmlFree(), but this is not done either. This commit fixes both of these issues; they existed since this code has been added in 10d008f0fd9e713e290f626300d66382ad786c49. This has been found while investigating ticket #9697. The continuous leaks might very well be the reason behind the observed slowdown. Reviewed-by: Steven Liu Signed-off-by: Andreas Rheinhardt --- libavformat/dashdec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 63bf7e96a5..2ca91bea8b 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -956,7 +956,11 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url, xmlFree(val); } if (adaptionset_supplementalproperty_node) { - if (!av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,"schemeIdUri"), "http://dashif.org/guidelines/last-segment-number")) { + char *scheme_id_uri = xmlGetProp(adaptionset_supplementalproperty_node, "schemeIdUri"); + if (scheme_id_uri) { + int is_last_segment_number = !av_strcasecmp(scheme_id_uri, "http://dashif.org/guidelines/last-segment-number"); + xmlFree(scheme_id_uri); + if (is_last_segment_number) { val = xmlGetProp(adaptionset_supplementalproperty_node,"value"); if (!val) { av_log(s, AV_LOG_ERROR, "Missing value attribute in adaptionset_supplementalproperty_node\n"); @@ -965,6 +969,7 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url, xmlFree(val); } } + } } fragment_timeline_node = find_child_node_by_name(representation_segmenttemplate_node, "SegmentTimeline"); From 8306074dc64e7b288d462c9252d6ac2e92710eaf Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 22:22:27 +0200 Subject: [PATCH 412/590] avformat/dashdec: Reindent after the previous commit Reviewed-by: Steven Liu Signed-off-by: Andreas Rheinhardt --- libavformat/dashdec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 2ca91bea8b..29d4680c68 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -961,15 +961,15 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url, int is_last_segment_number = !av_strcasecmp(scheme_id_uri, "http://dashif.org/guidelines/last-segment-number"); xmlFree(scheme_id_uri); if (is_last_segment_number) { - val = xmlGetProp(adaptionset_supplementalproperty_node,"value"); - if (!val) { - av_log(s, AV_LOG_ERROR, "Missing value attribute in adaptionset_supplementalproperty_node\n"); - } else { - rep->last_seq_no =(int64_t) strtoll(val, NULL, 10) - 1; - xmlFree(val); + val = xmlGetProp(adaptionset_supplementalproperty_node, "value"); + if (!val) { + av_log(s, AV_LOG_ERROR, "Missing value attribute in adaptionset_supplementalproperty_node\n"); + } else { + rep->last_seq_no = (int64_t)strtoll(val, NULL, 10) - 1; + xmlFree(val); + } } } - } } fragment_timeline_node = find_child_node_by_name(representation_segmenttemplate_node, "SegmentTimeline"); From dd81cc22b3dd5bd6badf012b4fe4c19e062650f4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 23:42:02 +0200 Subject: [PATCH 413/590] avcodec/mjpegdec: Check for unsupported bayer case Fixes: out of array access Fixes: 51462/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-662559341582745 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mjpegdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 5b7a8b1e7c..c594950500 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -1212,6 +1212,8 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1]; } } else if (s->bayer) { + if (s->bits <= 8) + return AVERROR_PATCHWELCOME; if (nb_components == 1) { /* Leave decoding to the TIFF/DNG decoder (see comment in ff_mjpeg_decode_sof) */ for (mb_x = 0; mb_x < width; mb_x++) From 7786097825d9e3f02b4574c1924c28818eb83340 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 14:28:03 +0200 Subject: [PATCH 414/590] avformat/mxfdec: Check run_in is within 65536 Fixes: signed integer overflow: 9223372036854775807 - -2146905566 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6570996594769920 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 19cddf08d3..a33bfb0409 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -65,6 +65,7 @@ #include "mxf.h" #define MXF_MAX_CHUNK_SIZE (32 << 20) +#define RUN_IN_MAX (65535+1) // S377m-2004 section 5.5 and S377-1-2009 section 6.5, the +1 is to be slightly more tolerant typedef enum { Header, @@ -3706,6 +3707,7 @@ static int mxf_read_header(AVFormatContext *s) KLVPacket klv; int64_t essence_offset = 0; int ret; + int64_t run_in; mxf->last_forward_tell = INT64_MAX; @@ -3715,7 +3717,10 @@ static int mxf_read_header(AVFormatContext *s) } avio_seek(s->pb, -14, SEEK_CUR); mxf->fc = s; - mxf->run_in = avio_tell(s->pb); + run_in = avio_tell(s->pb); + if (run_in < 0 || run_in > RUN_IN_MAX) + return AVERROR_INVALIDDATA; + mxf->run_in = run_in; mxf_read_random_index_pack(s); From 1182bbb2c3226260ed672920251e3410bde8c6c9 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 21 Sep 2022 18:23:30 +0200 Subject: [PATCH 415/590] avformat/mxfdec: only probe max run in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested-by: Tomas Härdin Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index a33bfb0409..1493a2a958 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -4126,7 +4126,7 @@ static int mxf_read_close(AVFormatContext *s) static int mxf_probe(const AVProbeData *p) { const uint8_t *bufp = p->buf; - const uint8_t *end = p->buf + p->buf_size; + const uint8_t *end = p->buf + FFMIN(p->buf_size, RUN_IN_MAX + 1 + sizeof(mxf_header_partition_pack_key)); if (p->buf_size < sizeof(mxf_header_partition_pack_key)) return 0; From c5bd689655332232d370d6087e9d8bfc509e623b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 11 Sep 2022 16:27:17 +0200 Subject: [PATCH 416/590] avformat/mxfdec: Avoid some redundant writing to tables in mxf_compute_ptses_fake_index() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit offsets suggested by Tomas Härdin Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 1493a2a958..badd2be224 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1940,10 +1940,10 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, MXFIndexTable *index_ta if (index_table->nb_ptses <= 0) return 0; - if (!(index_table->ptses = av_calloc(index_table->nb_ptses, sizeof(int64_t))) || + if (!(index_table->ptses = av_malloc_array(index_table->nb_ptses, sizeof(int64_t))) || !(index_table->fake_index = av_calloc(index_table->nb_ptses, sizeof(AVIndexEntry))) || - !(index_table->offsets = av_calloc(index_table->nb_ptses, sizeof(int8_t))) || - !(flags = av_calloc(index_table->nb_ptses, sizeof(uint8_t)))) { + !(index_table->offsets = av_malloc_array(index_table->nb_ptses, sizeof(int8_t))) || + !(flags = av_malloc_array(index_table->nb_ptses, sizeof(uint8_t)))) { av_freep(&index_table->ptses); av_freep(&index_table->fake_index); av_freep(&index_table->offsets); From 1c2b6265c87417033f990fa4a14da9d4008320a4 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 16:32:08 +0200 Subject: [PATCH 417/590] avformat/aiffdec: Check block_duration Fixes: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6668935979728896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer --- libavformat/aiffdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 0487d3f029..318e3ad742 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -372,6 +372,8 @@ static int aiff_read_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n"); return AVERROR_INVALIDDATA; } + if (aiff->block_duration < 0) + return AVERROR_INVALIDDATA; /* Now positioned, get the sound data start and end */ avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); From 9303ba272e988d87084880c57056b750cc5ffd08 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 16:32:09 +0200 Subject: [PATCH 418/590] avformat/aiffdec: Use 64bit for block_duration use Fixes: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6668935979728896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer --- libavformat/aiffdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 318e3ad742..80733e5801 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -428,7 +428,7 @@ static int aiff_read_packet(AVFormatContext *s, pkt->flags &= ~AV_PKT_FLAG_CORRUPT; /* Only one stream in an AIFF file */ pkt->stream_index = 0; - pkt->duration = (res / st->codecpar->block_align) * aiff->block_duration; + pkt->duration = (res / st->codecpar->block_align) * (int64_t) aiff->block_duration; return 0; } From db73ae0dc114aa6fae08e69f977944f056a24995 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 23:15:56 +0200 Subject: [PATCH 419/590] avformat/icodec: Check nb_pal Fixes: signed integer overflow: 538976288 * 4 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-6690068904935424 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Peter Ross Signed-off-by: Michael Niedermayer --- libavformat/icodec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/icodec.c b/libavformat/icodec.c index 290f658d0c..85dab3bca0 100644 --- a/libavformat/icodec.c +++ b/libavformat/icodec.c @@ -196,6 +196,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) AV_WL32(buf + 32, image->nb_pal); } + if (image->nb_pal > INT_MAX / 4 - 14 - 40) + return AVERROR_INVALIDDATA; + AV_WL32(buf - 4, 14 + 40 + image->nb_pal * 4); AV_WL32(buf + 8, AV_RL32(buf + 8) / 2); } From 08edacc248bce3f8946d75e97188d189c74a6de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 20 Sep 2022 20:42:13 +0300 Subject: [PATCH 420/590] lavc/aacpsdsp: precompute constant factors The input complex factors are constant for each iterations. This substitudes 4 loads, 2 additions and 2 subtractions per iteration of the inner-loop with another 4 loads. Thus effectively 4 arithmetic operations per iteration of the inner loop are avoided, i.e. 24 operations per iteration of the outer loop, or 24 * (n - 1) operations in total. If the inner loop is not unrolled by the compiler, this also might also save some pointer arithmetic as most instruction sets do not have addressing modes with negated register offsets (12 - j). Unless the compiler is optimising for code size, this is unlikely though. --- libavcodec/aacpsdsp_template.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libavcodec/aacpsdsp_template.c b/libavcodec/aacpsdsp_template.c index e644037587..e3cbf3feec 100644 --- a/libavcodec/aacpsdsp_template.c +++ b/libavcodec/aacpsdsp_template.c @@ -47,21 +47,24 @@ static void ps_hybrid_analysis_c(INTFLOAT (*out)[2], INTFLOAT (*in)[2], const INTFLOAT (*filter)[8][2], ptrdiff_t stride, int n) { - int i, j; + INT64FLOAT inre0[6], inre1[6], inim0[6], inim1[6]; - for (i = 0; i < n; i++) { + for (int j = 0; j < 6; j++) { + inre0[j] = in[j][0] + in[12 - j][0]; + inre1[j] = in[j][1] - in[12 - j][1]; + inim0[j] = in[j][1] + in[12 - j][1]; + inim1[j] = in[j][0] - in[12 - j][0]; + } + + for (int i = 0; i < n; i++) { INT64FLOAT sum_re = (INT64FLOAT)filter[i][6][0] * in[6][0]; INT64FLOAT sum_im = (INT64FLOAT)filter[i][6][0] * in[6][1]; - for (j = 0; j < 6; j++) { - INT64FLOAT in0_re = in[j][0]; - INT64FLOAT in0_im = in[j][1]; - INT64FLOAT in1_re = in[12-j][0]; - INT64FLOAT in1_im = in[12-j][1]; - sum_re += (INT64FLOAT)filter[i][j][0] * (in0_re + in1_re) - - (INT64FLOAT)filter[i][j][1] * (in0_im - in1_im); - sum_im += (INT64FLOAT)filter[i][j][0] * (in0_im + in1_im) + - (INT64FLOAT)filter[i][j][1] * (in0_re - in1_re); + for (int j = 0; j < 6; j++) { + sum_re += (INT64FLOAT)filter[i][j][0] * inre0[j] - + (INT64FLOAT)filter[i][j][1] * inre1[j]; + sum_im += (INT64FLOAT)filter[i][j][0] * inim0[j] + + (INT64FLOAT)filter[i][j][1] * inim1[j]; } #if USE_FIXED out[i * stride][0] = (int)((sum_re + 0x40000000) >> 31); From 2bcf86d53df64276fbe1b95d8eaf335be0a766ab Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 20 Sep 2022 15:09:40 -0300 Subject: [PATCH 421/590] x86/aacpsdsp: precompute constant factors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inspired by the optimization done to the C version by Rémi Denis-Courmont. Signed-off-by: James Almer --- libavcodec/x86/aacpsdsp.asm | 42 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/libavcodec/x86/aacpsdsp.asm b/libavcodec/x86/aacpsdsp.asm index 4acd087c85..543d33e68d 100644 --- a/libavcodec/x86/aacpsdsp.asm +++ b/libavcodec/x86/aacpsdsp.asm @@ -400,29 +400,32 @@ HYBRID_SYNTHESIS_DEINT ; const float (*filter)[8][2], ; ptrdiff_t stride, int n); ;******************************************************************* -%macro PS_HYBRID_ANALYSIS_LOOP 3 - movu %1, [inq+mmsize*%3] - movu m1, [inq+mmsize*(5-%3)+8] -%if cpuflag(sse3) - pshufd %2, %1, q2301 - pshufd m4, m1, q0123 - pshufd m1, m1, q1032 - pshufd m2, [filterq+nq+mmsize*%3], q2301 - addsubps %2, m4 - addsubps %1, m1 -%else - mova m2, [filterq+nq+mmsize*%3] - mova %2, %1 +%macro PS_HYBRID_ANALYSIS_IN 1 + movu m0, [inq+mmsize*%1] + movu m1, [inq+mmsize*(5-%1)+8] + mova m3, m0 mova m4, m1 - shufps %2, %2, q2301 + shufps m3, m3, q2301 shufps m4, m4, q0123 shufps m1, m1, q1032 - shufps m2, m2, q2301 +%if cpuflag(sse3) + addsubps m3, m4 + addsubps m0, m1 +%else xorps m4, m7 xorps m1, m7 - subps %2, m4 - subps %1, m1 + subps m3, m4 + subps m0, m1 %endif + mova [rsp+mmsize*%1*2], m3 + mova [rsp+mmsize+mmsize*%1*2], m0 +%endmacro + +%macro PS_HYBRID_ANALYSIS_LOOP 3 + mova m2, [filterq+nq+mmsize*%3] + shufps m2, m2, q2301 + mova %2, [rsp+mmsize*%3*2] + mova %1, [rsp+mmsize+mmsize*%3*2] mulps %2, m2 mulps %1, m2 %if %3 @@ -432,7 +435,7 @@ HYBRID_SYNTHESIS_DEINT %endmacro %macro PS_HYBRID_ANALYSIS 0 -cglobal ps_hybrid_analysis, 5, 5, 8, out, in, filter, stride, n +cglobal ps_hybrid_analysis, 5, 5, 8, 24 * 4, out, in, filter, stride, n %if cpuflag(sse3) %define MOVH movsd %else @@ -443,6 +446,9 @@ cglobal ps_hybrid_analysis, 5, 5, 8, out, in, filter, stride, n add filterq, nq neg nq mova m7, [ps_p1m1p1m1] + PS_HYBRID_ANALYSIS_IN 0 + PS_HYBRID_ANALYSIS_IN 1 + PS_HYBRID_ANALYSIS_IN 2 align 16 .loop: From 48615f0a7861fd1c24195f74856f68e06c7ca73c Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 20 Sep 2022 16:02:49 -0300 Subject: [PATCH 422/590] x86/aacpsdsp: add ps_hybrid_analysis_fma3 This replace the sse3 version, which was not really faster than the sse one. Signed-off-by: James Almer --- libavcodec/x86/aacpsdsp.asm | 42 +++++++++++++++++----------------- libavcodec/x86/aacpsdsp_init.c | 6 +++-- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/libavcodec/x86/aacpsdsp.asm b/libavcodec/x86/aacpsdsp.asm index 543d33e68d..105e1af5c5 100644 --- a/libavcodec/x86/aacpsdsp.asm +++ b/libavcodec/x86/aacpsdsp.asm @@ -403,10 +403,8 @@ HYBRID_SYNTHESIS_DEINT %macro PS_HYBRID_ANALYSIS_IN 1 movu m0, [inq+mmsize*%1] movu m1, [inq+mmsize*(5-%1)+8] - mova m3, m0 - mova m4, m1 - shufps m3, m3, q2301 - shufps m4, m4, q0123 + shufps m3, m0, m0, q2301 + shufps m4, m1, m1, q0123 shufps m1, m1, q1032 %if cpuflag(sse3) addsubps m3, m4 @@ -424,6 +422,15 @@ HYBRID_SYNTHESIS_DEINT %macro PS_HYBRID_ANALYSIS_LOOP 3 mova m2, [filterq+nq+mmsize*%3] shufps m2, m2, q2301 +%if cpuflag(fma3) +%if %3 + fmaddps m3, m2, [rsp+mmsize*%3*2], m3 + fmaddps m0, m2, [rsp+mmsize+mmsize*%3*2], m0 +%else + mulps m3, m2, [rsp] + mulps m0, m2, [rsp+mmsize] +%endif +%else ; cpuflag(sse) mova %2, [rsp+mmsize*%3*2] mova %1, [rsp+mmsize+mmsize*%3*2] mulps %2, m2 @@ -432,20 +439,21 @@ HYBRID_SYNTHESIS_DEINT addps m3, %2 addps m0, %1 %endif +%endif %endmacro %macro PS_HYBRID_ANALYSIS 0 -cglobal ps_hybrid_analysis, 5, 5, 8, 24 * 4, out, in, filter, stride, n +cglobal ps_hybrid_analysis, 5, 5, 5 + notcpuflag(fma3) * 3, 24 * 4, out, in, filter, stride, n %if cpuflag(sse3) %define MOVH movsd %else %define MOVH movlps + mova m7, [ps_p1m1p1m1] %endif shl strideq, 3 shl nd, 6 add filterq, nq neg nq - mova m7, [ps_p1m1p1m1] PS_HYBRID_ANALYSIS_IN 0 PS_HYBRID_ANALYSIS_IN 1 PS_HYBRID_ANALYSIS_IN 2 @@ -456,30 +464,22 @@ align 16 PS_HYBRID_ANALYSIS_LOOP m5, m6, 1 PS_HYBRID_ANALYSIS_LOOP m5, m6, 2 -%if cpuflag(sse3) - pshufd m3, m3, q2301 - xorps m0, m7 - hsubps m3, m0 - pshufd m1, m3, q0020 - pshufd m3, m3, q0031 - addps m1, m3 - movsd m2, [inq+6*8] -%else - mova m1, m3 - mova m2, m0 - shufps m1, m1, q2301 - shufps m2, m2, q2301 + shufps m1, m3, m3, q2301 + shufps m2, m0, m0, q2301 subps m1, m3 addps m2, m0 unpcklps m3, m1, m2 unpckhps m1, m2 addps m1, m3 movu m2, [inq+6*8] ; faster than movlps and no risk of overread -%endif movss m3, [filterq+nq+8*6] SPLATD m3 +%if cpuflag(fma3) + fmaddps m1, m2, m3, m1 +%else mulps m2, m3 addps m1, m2 +%endif MOVH [outq], m1 add outq, strideq add nq, 64 @@ -489,5 +489,5 @@ align 16 INIT_XMM sse PS_HYBRID_ANALYSIS -INIT_XMM sse3 +INIT_XMM fma3 PS_HYBRID_ANALYSIS diff --git a/libavcodec/x86/aacpsdsp_init.c b/libavcodec/x86/aacpsdsp_init.c index 21f00efa24..0b0ee07db4 100644 --- a/libavcodec/x86/aacpsdsp_init.c +++ b/libavcodec/x86/aacpsdsp_init.c @@ -33,7 +33,7 @@ void ff_ps_mul_pair_single_sse (float (*dst)[2], float (*src0)[2], void ff_ps_hybrid_analysis_sse (float (*out)[2], float (*in)[2], const float (*filter)[8][2], ptrdiff_t stride, int n); -void ff_ps_hybrid_analysis_sse3(float (*out)[2], float (*in)[2], +void ff_ps_hybrid_analysis_fma3(float (*out)[2], float (*in)[2], const float (*filter)[8][2], ptrdiff_t stride, int n); void ff_ps_stereo_interpolate_sse3(float (*l)[2], float (*r)[2], @@ -64,9 +64,11 @@ av_cold void ff_psdsp_init_x86(PSDSPContext *s) s->add_squares = ff_ps_add_squares_sse3; s->stereo_interpolate[0] = ff_ps_stereo_interpolate_sse3; s->stereo_interpolate[1] = ff_ps_stereo_interpolate_ipdopd_sse3; - s->hybrid_analysis = ff_ps_hybrid_analysis_sse3; } if (EXTERNAL_SSE4(cpu_flags)) { s->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_sse4; } + if (EXTERNAL_FMA3(cpu_flags)) { + s->hybrid_analysis = ff_ps_hybrid_analysis_fma3; + } } From bd7d69fe354cf5b3d6247f049af44bfa56f0531a Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 13 Sep 2022 17:23:53 -0700 Subject: [PATCH 423/590] avcodec/libvpxenc: add -min-gf-interval this maps to the vpxenc argument with the same name and the VP9E_SET_MIN_GF_INTERVAL codec control Signed-off-by: James Zern Reviewed-by: Vignesh Venkatasubramanian --- doc/encoders.texi | 2 ++ libavcodec/libvpxenc.c | 11 +++++++++++ libavcodec/version.h | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index ac71f50ad2..5a5579d5e5 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2176,6 +2176,8 @@ Set altref noise reduction filter type: backward, forward, centered. Set altref noise reduction filter strength. @item rc-lookahead, lag-in-frames (@emph{lag-in-frames}) Set number of frames to look ahead for frametype and ratecontrol. +@item min-gf-interval +Set minimum golden/alternate reference frame interval (VP9 only). @end table @item error-resilient diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 09b56aae2a..667cffc200 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -131,6 +131,7 @@ typedef struct VPxEncoderContext { int tune_content; int corpus_complexity; int tpl_model; + int min_gf_interval; AVFifo *hdr10_plus_fifo; /** * If the driver does not support ROI then warn the first time we @@ -186,6 +187,9 @@ static const char *const ctlidstr[] = { #ifdef VPX_CTRL_VP9E_SET_TPL [VP9E_SET_TPL] = "VP9E_SET_TPL", #endif +#ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL + [VP9E_SET_MIN_GF_INTERVAL] = "VP9E_SET_MIN_GF_INTERVAL", +#endif #endif }; @@ -1173,6 +1177,10 @@ static av_cold int vpx_init(AVCodecContext *avctx, #ifdef VPX_CTRL_VP9E_SET_TPL if (ctx->tpl_model >= 0) codecctl_int(avctx, VP9E_SET_TPL, ctx->tpl_model); +#endif +#ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL + if (ctx->min_gf_interval >= 0) + codecctl_int(avctx, VP9E_SET_MIN_GF_INTERVAL, ctx->min_gf_interval); #endif } #endif @@ -1911,6 +1919,9 @@ static const AVOption vp9_options[] = { #endif #ifdef VPX_CTRL_VP9E_SET_TPL { "enable-tpl", "Enable temporal dependency model", OFFSET(tpl_model), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE }, +#endif +#ifdef VPX_CTRL_VP9E_SET_MIN_GF_INTERVAL + { "min-gf-interval", "Minimum golden/alternate reference frame interval", OFFSET(min_gf_interval), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE }, #endif LEGACY_OPTIONS { NULL } diff --git a/libavcodec/version.h b/libavcodec/version.h index 2cad78e640..c2404cf9ee 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 44 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From a2d95928c3584e7224a06b73845755f45c13c7f7 Mon Sep 17 00:00:00 2001 From: Vignesh Venkatasubramanian Date: Tue, 20 Sep 2022 14:17:11 -0700 Subject: [PATCH 424/590] avformat/movenc: Write auxi box for animated AVIF with alpha According to the HEIF specification (ISO/IEC 23008-12) Section 7.5.3.1, tracks with handler_type 'auxv' must contain a 'auxi' box in its SampleEntry to notify the nature of the auxiliary track to the decoder. The content is the same as the 'auxC' box. So parameterize and re-use the existing function. Signed-off-by: Vignesh Venkatasubramanian Signed-off-by: James Zern --- libavformat/movenc.c | 27 +++++++++++++++------------ libavformat/version.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c8b2e141cb..754f95912a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2179,6 +2179,16 @@ static int mov_write_ccst_tag(AVIOContext *pb) return update_size(pb, pos); } +static int mov_write_aux_tag(AVIOContext *pb, const char *aux_type) +{ + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, aux_type); + avio_wb32(pb, 0); /* Version & flags */ + avio_write(pb, "urn:mpeg:mpegB:cicp:systems:auxiliary:alpha\0", 44); + return update_size(pb, pos); +} + static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int ret = AVERROR_BUG; @@ -2363,8 +2373,11 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex if (avid) avio_wb32(pb, 0); - if (track->mode == MODE_AVIF) + if (track->mode == MODE_AVIF) { mov_write_ccst_tag(pb); + if (s->nb_streams > 0 && track == &mov->tracks[1]) + mov_write_aux_tag(pb, "auxi"); + } return update_size(pb, pos); } @@ -3044,16 +3057,6 @@ static int mov_write_pixi_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatConte return update_size(pb, pos); } -static int mov_write_auxC_tag(AVIOContext *pb) -{ - int64_t pos = avio_tell(pb); - avio_wb32(pb, 0); /* size */ - ffio_wfourcc(pb, "auxC"); - avio_wb32(pb, 0); /* Version & flags */ - avio_write(pb, "urn:mpeg:mpegB:cicp:systems:auxiliary:alpha\0", 44); - return update_size(pb, pos); -} - static int mov_write_ipco_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) { int64_t pos = avio_tell(pb); @@ -3066,7 +3069,7 @@ static int mov_write_ipco_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatConte if (!i) mov_write_colr_tag(pb, &mov->tracks[0], 0); else - mov_write_auxC_tag(pb); + mov_write_aux_tag(pb, "auxC"); } return update_size(pb, pos); } diff --git a/libavformat/version.h b/libavformat/version.h index ede3f46428..f7eb36a04a 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ #include "version_major.h" #define LIBAVFORMAT_VERSION_MINOR 32 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From c8c4a162fc18c0fd99bada66d9ea3b48c64b2450 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 22 Sep 2022 13:41:29 -0300 Subject: [PATCH 425/590] avcodec/lpc: use ptrdiff_t for length parameters Signed-off-by: James Almer --- libavcodec/lpc.c | 4 ++-- libavcodec/lpc.h | 5 +++-- libavcodec/x86/lpc.asm | 1 - libavcodec/x86/lpc_init.c | 6 +++--- tests/checkasm/lpc.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 4885d5cb06..8603bb9709 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -31,7 +31,7 @@ /** * Apply Welch window function to audio block */ -static void lpc_apply_welch_window_c(const int32_t *data, int len, +static void lpc_apply_welch_window_c(const int32_t *data, ptrdiff_t len, double *w_data) { int i, n2; @@ -70,7 +70,7 @@ static void lpc_apply_welch_window_c(const int32_t *data, int len, * Calculate autocorrelation data from audio samples * A Welch window function is applied before calculation. */ -static void lpc_compute_autocorr_c(const double *data, int len, int lag, +static void lpc_compute_autocorr_c(const double *data, ptrdiff_t len, int lag, double *autoc) { int i, j; diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h index e1b41bfd9b..467d0b2830 100644 --- a/libavcodec/lpc.h +++ b/libavcodec/lpc.h @@ -23,6 +23,7 @@ #define AVCODEC_LPC_H #include +#include #include "libavutil/avassert.h" #include "libavutil/lls.h" #include "aac_defines.h" @@ -64,7 +65,7 @@ typedef struct LPCContext { * @param len number of input samples * @param w_data output samples */ - void (*lpc_apply_welch_window)(const int32_t *data, int len, + void (*lpc_apply_welch_window)(const int32_t *data, ptrdiff_t len, double *w_data); /** * Perform autocorrelation on input samples with delay of 0 to lag. @@ -79,7 +80,7 @@ typedef struct LPCContext { * @param autoc output autocorrelation coefficients. * constraints: array size must be at least lag+1. */ - void (*lpc_compute_autocorr)(const double *data, int len, int lag, + void (*lpc_compute_autocorr)(const double *data, ptrdiff_t len, int lag, double *autoc); // TODO: these should be allocated to reduce ABI compatibility issues diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index 731aa7e2d8..ad74f1d8ac 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -36,7 +36,6 @@ SECTION .text %macro APPLY_WELCH_FN 0 cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 - movsxdifnidn lenq, lend cmp lenq, 0 je .end cmp lenq, 2 diff --git a/libavcodec/x86/lpc_init.c b/libavcodec/x86/lpc_init.c index df77c966c6..f2fca53799 100644 --- a/libavcodec/x86/lpc_init.c +++ b/libavcodec/x86/lpc_init.c @@ -24,16 +24,16 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/lpc.h" -void ff_lpc_apply_welch_window_sse2(const int32_t *data, int len, +void ff_lpc_apply_welch_window_sse2(const int32_t *data, ptrdiff_t len, double *w_data); -void ff_lpc_apply_welch_window_avx2(const int32_t *data, int len, +void ff_lpc_apply_welch_window_avx2(const int32_t *data, ptrdiff_t len, double *w_data); DECLARE_ASM_CONST(16, double, pd_1)[2] = { 1.0, 1.0 }; #if HAVE_SSE2_INLINE -static void lpc_compute_autocorr_sse2(const double *data, int len, int lag, +static void lpc_compute_autocorr_sse2(const double *data, ptrdiff_t len, int lag, double *autoc) { int j; diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index e072599908..da5364def0 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -38,7 +38,7 @@ static void test_window(int len) LOCAL_ALIGNED(16, double, dst0, [5000]); LOCAL_ALIGNED(16, double, dst1, [5000]); - declare_func(void, int32_t *in, int len, double *out); + declare_func(void, const int32_t *in, ptrdiff_t len, double *out); randomize_int32(src, len); From 0627e6d74ce6f28287ea787c099a0f9fe4baaacb Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 22 Sep 2022 15:54:22 -0300 Subject: [PATCH 426/590] avcodec/lpc: zero the middle odd sample in the output Signed-off-by: James Almer --- libavcodec/lpc.c | 1 + libavcodec/x86/lpc.asm | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 8603bb9709..dc6a3060ce 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -53,6 +53,7 @@ static void lpc_apply_welch_window_c(const int32_t *data, ptrdiff_t len, w_data[i] = data[i] * w; w_data[len-1-i] = data[len-1-i] * w; } + w_data[n2] = 0.0; return; } diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index ad74f1d8ac..61a5796e5d 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -37,7 +37,7 @@ SECTION .text %macro APPLY_WELCH_FN 0 cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 cmp lenq, 0 - je .end + je .end_e cmp lenq, 2 je .two cmp lenq, 1 @@ -104,7 +104,7 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 add lend, (mmsize/4 - 1) cmp lend, 0 - je .end + je .end_o sub lenq, (mmsize/4 - 1) .scalar_o: @@ -135,6 +135,10 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 sub lenq, 2 jg .loop_o_scalar + +.end_o: + xorpd xm3, xm3 + movlpd [outq + off1q*2], xm3 RET .even: @@ -233,7 +237,7 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 .one: xorpd xm0, xm0 movhpd [outq], xm0 -.end: +.end_e: RET %endmacro From a1c6f4b653b6fca51eea40f12a22ab1cb045751d Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 22 Sep 2022 13:54:05 -0300 Subject: [PATCH 427/590] tests/checkasm/lpc: randomize buffer length Simplifies the test, while trying more values and preventing pointlessly running benchmarks in a loop. Signed-off-by: James Almer --- tests/checkasm/lpc.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index da5364def0..8528fd6e20 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -54,31 +54,18 @@ static void test_window(int len) void checkasm_check_lpc(void) { LPCContext ctx; + int len = rnd() % 5000; ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { - for (int i = 0; i < 64; i += 2) - test_window(i); + test_window(len & ~1); } report("apply_welch_window_even"); if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_odd")) { - for (int i = 1; i < 64; i += 2) - test_window(i); + test_window(len | 1); } report("apply_welch_window_odd"); - if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_2560")) - test_window(2560); - report("apply_welch_window_2560"); - - if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4096")) - test_window(4096); - report("apply_welch_window_4096"); - - if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_4097")) - test_window(4097); - report("apply_welch_window_4097"); - ff_lpc_end(&ctx); } From 0922c6b01bd50f0ce6e659f765c244f6a8f29eb3 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 22 Sep 2022 17:10:37 -0300 Subject: [PATCH 428/590] x86/lpc: use fused negative multiply-add instructions where useful Signed-off-by: James Almer --- libavcodec/x86/lpc.asm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index 61a5796e5d..a585c17ef5 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -79,11 +79,12 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 .loop_o: movapd m1, m6 - mulpd m2, m0, m0 - subpd m1, m2 %if cpuflag(avx2) + fnmaddpd m1, m0, m0, m1 vpermpd m2, m1, q0123 %else + mulpd m2, m0, m0 + subpd m1, m2 shufpd m2, m1, m1, 01b %endif @@ -116,8 +117,12 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 .loop_o_scalar: movapd xm1, xm6 +%if cpuflag(avx2) + fnmaddpd xm1, xm0, xm0, xm1 +%else mulpd xm2, xm0, xm0 subpd xm1, xm2 +%endif cvtdq2pd xm3, [dataq + off1q] cvtdq2pd xm4, [dataq + off2q] @@ -174,8 +179,12 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 .loop_e: movapd m1, m6 +%if cpuflag(avx2) + fnmaddpd m1, m0, m0, m1 +%else mulpd m2, m0, m0 subpd m1, m2 +%endif %if cpuflag(avx2) vpermpd m2, m1, q0123 %else @@ -210,8 +219,12 @@ cglobal lpc_apply_welch_window, 3, 5, 8, data, len, out, off1, off2 .loop_e_scalar: movapd xm1, xm6 +%if cpuflag(avx2) + fnmaddpd xm1, xm0, xm0, xm1 +%else mulpd xm2, xm0, xm0 subpd xm1, xm2 +%endif cvtdq2pd xm3, [dataq + off1q] cvtdq2pd xm4, [dataq + off2q] From 9cbfffa0d4c5dabd05e5bbf9923cfaefa16ceb11 Mon Sep 17 00:00:00 2001 From: James Almer Date: Thu, 22 Sep 2022 18:15:12 -0300 Subject: [PATCH 429/590] tests/checkasm/lpc: print mismatching values Will help debugging. Signed-off-by: James Almer --- tests/checkasm/lpc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 8528fd6e20..49e608f8c1 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -45,8 +45,14 @@ static void test_window(int len) call_ref(src, len, dst0); call_new(src, len, dst1); - if (!double_near_abs_eps_array(dst0, dst1, EPS, len)) - fail(); + for (int i = 0; i < len; i++) { + if (!double_near_abs_eps(dst0[i], dst1[i], EPS)) { + fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", + i, dst0[i], dst1[i], dst0[i] - dst1[i]); + fail(); + break; + } + } bench_new(src, len, dst1); } From 6ad39f01dfb3ed7d7bbebac3924797966ad99dbf Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 23 Sep 2022 01:41:02 +0200 Subject: [PATCH 430/590] tests/checkasm/lpc: reduce range and use signed values This is more similar to its regular use, and prevents inaccuracies of huge float*float multiplications from failing the tests. --- tests/checkasm/lpc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 49e608f8c1..2823953878 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -22,12 +22,12 @@ #include "checkasm.h" -#define randomize_int32(buf, len) \ - do { \ - for (int i = 0; i < len; i++) { \ - int32_t f = rnd() >> 8; \ - buf[i] = f; \ - } \ +#define randomize_int32(buf, len) \ + do { \ + for (int i = 0; i < len; i++) { \ + int32_t f = (UINT32_MAX >> 8) - (rnd() >> 16); \ + buf[i] = f; \ + } \ } while (0) #define EPS 0.005 From 668f43af2004af92e2df4f8633e7fc3602975073 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 23 Sep 2022 01:48:00 +0200 Subject: [PATCH 431/590] tests/checkasm/lpc: correct arithmetic when randomizing buffers Results weren't signed. --- tests/checkasm/lpc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 2823953878..592e34c03d 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -22,12 +22,12 @@ #include "checkasm.h" -#define randomize_int32(buf, len) \ - do { \ - for (int i = 0; i < len; i++) { \ - int32_t f = (UINT32_MAX >> 8) - (rnd() >> 16); \ - buf[i] = f; \ - } \ +#define randomize_int32(buf, len) \ + do { \ + for (int i = 0; i < len; i++) { \ + int32_t f = ((int)(UINT32_MAX >> 17)) - ((int)(rnd() >> 16)); \ + buf[i] = f; \ + } \ } while (0) #define EPS 0.005 From 686096739b129c7e3ea26be29c875e0887e58c49 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Sat, 17 Sep 2022 12:30:01 +0800 Subject: [PATCH 432/590] fftools/ffmpeg_filter: configure min_hard_comp unconditionally There are two issues here. Firstly, the floating-point comparison is always true. Seconly, the code depends on the default value of min_hard_comp implicitly, which can be dangerous. Partially fixes ticket 9859. Reviewed-by: Anton Khirnov Signed-off-by: Zhao Zhili --- fftools/ffmpeg_filter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 7a5308425d..17928cea2c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -896,8 +896,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, char args[256] = {0}; av_strlcatf(args, sizeof(args), "async=%d", audio_sync_method); - if (audio_drift_threshold != 0.1) - av_strlcatf(args, sizeof(args), ":min_hard_comp=%f", audio_drift_threshold); + av_strlcatf(args, sizeof(args), ":min_hard_comp=%f", audio_drift_threshold); if (!fg->reconfiguration) av_strlcatf(args, sizeof(args), ":first_pts=0"); AUTO_INSERT_FILTER_INPUT("-async", "aresample", args); From 7e7baf8ab86c4ae715f12d2c0babf831a5b18c39 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 22 Sep 2022 08:25:52 +0200 Subject: [PATCH 433/590] lavu/tx: do not steal lookup tables of subcontexts in the iMDCT As it happens, some still need their contexts. --- libavutil/tx_template.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c index 5e7159bd87..2c9682ffb7 100644 --- a/libavutil/tx_template.c +++ b/libavutil/tx_template.c @@ -965,15 +965,14 @@ static av_cold int TX_NAME(ff_tx_mdct_init)(AVTXContext *s, return ret; } - /* If we need to preshuffle just steal the map from the subcontext */ + s->map = av_malloc((len >> 1)*sizeof(*s->map)); + if (!s->map) + return AVERROR(ENOMEM); + + /* If we need to preshuffle copy the map from the subcontext */ if (s->sub[0].flags & FF_TX_PRESHUFFLE) { - s->map = s->sub[0].map; - s->sub[0].map = NULL; + memcpy(s->map, s->sub->map, (len >> 1)*sizeof(*s->map)); } else { - s->map = av_malloc((len >> 1)*sizeof(*s->map)); - if (!s->map) - return AVERROR(ENOMEM); - for (int i = 0; i < len >> 1; i++) s->map[i] = i; } From 3241e9225c7adfb2d8d24cfd05a7a8db8ddbd023 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 23 Sep 2022 10:34:08 +0200 Subject: [PATCH 434/590] x86/tx_float: adjust internal ASM call ABI again There are many ways to go about it, and this one seems optimal for both MDCTs and PFA FFTs without requiring excessive instructions or stack usage. --- libavutil/x86/tx_float.asm | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index b3a85a7cb9..5e0c438b9c 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -22,11 +22,10 @@ ; based upon and compare. ; Intra-asm call convention: -; 272 bytes of stack available -; First 10 GPRs available +; 320 bytes of stack available +; 14 GPRs available (last 4 must not be clobbered) +; Additionally, don't clobber ctx, in, out, len, lut ; All vector regs available -; Don't clobber ctx, len, lut -; in and out must point to the end ; TODO: ; carry over registers from smaller transforms to save on ~8 loads/stores @@ -686,8 +685,6 @@ cglobal fft2_asm_float, 0, 0, 0, ctx, out, in, stride movaps m0, [inq] FFT2 m0, m1 movaps [outq], m0 - add inq, mmsize*1 - add outq, mmsize*1 ret cglobal fft2_float, 4, 4, 2, ctx, out, in, stride @@ -721,8 +718,6 @@ cglobal fft4_ %+ %1 %+ _float, 4, 4, 3, ctx, out, in, stride movaps [outq + 1*mmsize], m0 %if %3 - add inq, mmsize*2 - add outq, mmsize*2 ret %else RET @@ -764,8 +759,6 @@ cglobal fft8_float, 4, 4, 6, ctx, out, in, tmp movups [outq + 3*mmsize], m1 %if %1 - add inq, mmsize*4 - add outq, mmsize*4 ret %else RET @@ -806,8 +799,6 @@ cglobal fft8_float, 4, 4, 4, ctx, out, in, tmp vextractf128 [outq + 16*3], m0, 1 %if %1 - add inq, mmsize*2 - add outq, mmsize*2 ret %else RET @@ -857,8 +848,6 @@ cglobal fft16_float, 4, 4, 8, ctx, out, in, tmp vextractf128 [outq + 16*7], m1, 1 %if %2 - add inq, mmsize*4 - add outq, mmsize*4 ret %else RET @@ -943,8 +932,6 @@ cglobal fft32_float, 4, 4, 16, ctx, out, in, tmp vextractf128 [outq + 16*15], m5, 1 %if %2 - add inq, mmsize*8 - add outq, mmsize*8 ret %else RET @@ -1282,12 +1269,13 @@ FFT_SPLIT_RADIX_DEF 131072 add outq, 8*mmsize add rtabq, 4*mmsize sub itabq, 4*mmsize - sub lenq, 4*mmsize + sub tgtq, 4*mmsize jg .synth_deinterleave %if %2 - mov lenq, tgtq - add outq, offq + sub outq, tmpq + neg tmpq + lea inq, [inq + tmpq*4] ret %else RET @@ -1369,7 +1357,7 @@ FFT_SPLIT_RADIX_DEF 131072 vextractf128 [outq + 15*mmsize + 16], tx2_e1, 1 %if %2 - add outq, 16*mmsize + sub inq, 16*mmsize ret %else RET From ace42cf581f8c06872bfb58cf575d9e8bd398c0a Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 19 Sep 2022 05:53:01 +0200 Subject: [PATCH 435/590] x86/tx_float: add 15xN PFA FFT AVX SIMD ~4x faster than the C version. The shuffles in the 15pt dim1 are seriously expensive. Not happy with it, but I'm contempt. Can be easily converted to pure AVX by removing all vpermpd/vpermps instructions. --- doc/transforms.md | 323 ++++++++++++++++++++++++++++++++++ libavutil/tx_template.c | 59 ++++--- libavutil/x86/tx_float.asm | 280 +++++++++++++++++++++++++++++ libavutil/x86/tx_float_init.c | 68 +++++++ tests/checkasm/av_tx.c | 4 +- 5 files changed, 706 insertions(+), 28 deletions(-) diff --git a/doc/transforms.md b/doc/transforms.md index 78f3f68d65..04a7c408f1 100644 --- a/doc/transforms.md +++ b/doc/transforms.md @@ -704,3 +704,326 @@ Also note that this function requires a special iteration way, due to coefficien beginning to overlap, particularly `[o1]` with `[0]` after the second iteration. To iterate further, set `z = &z[16]` via `z += 8` for the second iteration. After the 4th iteration, the layout resets, so repeat the same. + + +# 15-point AVX FFT transform +The 15-point transform is based on the following unrolling. The input +must be permuted via the following loop: + +``` C + for (int k = 0; k < s->sub[0].len; k++) { + int cnt = 0; + int tmp[15]; + memcpy(tmp, &s->map[k*15], 15*sizeof(*tmp)); + for (int i = 1; i < 15; i += 3) { + s->map[k*15 + cnt] = tmp[i]; + cnt++; + } + for (int i = 2; i < 15; i += 3) { + s->map[k*15 + cnt] = tmp[i]; + cnt++; + } + for (int i = 0; i < 15; i += 3) { + s->map[k*15 + cnt] = tmp[i]; + cnt++; + } + memmove(&s->map[k*15 + 7], &s->map[k*15 + 6], 4*sizeof(int)); + memmove(&s->map[k*15 + 3], &s->map[k*15 + 1], 4*sizeof(int)); + s->map[k*15 + 1] = tmp[2]; + s->map[k*15 + 2] = tmp[0]; + } + +``` + +This separates the ACs from the DCs and flips the SIMD direction to +performing 5x3pt transforms at once, followed by 3x5pt transforms. + +``` C +static av_always_inline void fft15(TXComplex *out, TXComplex *in, + ptrdiff_t stride) +{ + const TXSample *tab = TX_TAB(ff_tx_tab_53); + TXComplex q[20]; + TXComplex dc[3], pc[32]; + TXComplex y[32], k[32]; + TXComplex t[32]; + TXComplex r[32]; + TXComplex z0[32]; + + /* DC */ + pc[0].re = in[ 1].im - in[ 0].im; + pc[0].im = in[ 1].re - in[ 0].re; + pc[1].re = in[ 1].re + in[ 0].re; + pc[1].im = in[ 1].im + in[ 0].im; + + dc[0].re = in[2].re + pc[1].re; + dc[0].im = in[2].im + pc[1].im; + + pc[0].re = tab[ 8] * pc[0].re; + pc[0].im = tab[ 9] * pc[0].im; + pc[1].re = tab[10] * pc[1].re; + pc[1].im = tab[11] * pc[1].im; + + dc[1].re = pc[0].re + pc[1].re; + dc[1].im = pc[0].im + pc[1].im; + dc[2].re = pc[1].re - pc[0].re; + dc[2].im = pc[1].im - pc[0].im; + + dc[1].re = in[2].re - dc[1].re; + dc[1].im = in[2].im + dc[1].im; + dc[2].re = in[2].re - dc[2].re; + dc[2].im = in[2].im + dc[2].im; + + /* ACs */ + q[0].im = in[ 3].re - in[ 7].re; // NOTE THE ORDER + q[0].re = in[ 3].im - in[ 7].im; + q[1].im = in[ 4].re - in[ 8].re; + q[1].re = in[ 4].im - in[ 8].im; + q[2].im = in[ 5].re - in[ 9].re; + q[2].re = in[ 5].im - in[ 9].im; + q[3].re = in[ 6].im - in[10].im; + q[3].im = in[ 6].re - in[10].re; + + q[4].re = in[ 3].re + in[ 7].re; + q[4].im = in[ 3].im + in[ 7].im; + q[5].re = in[ 4].re + in[ 8].re; + q[5].im = in[ 4].im + in[ 8].im; + q[6].re = in[ 5].re + in[ 9].re; + q[6].im = in[ 5].im + in[ 9].im; + q[7].re = in[ 6].re + in[10].re; + q[7].im = in[ 6].im + in[10].im; + + y[0].re = in[11].re + q[4].re; + y[0].im = in[11].im + q[4].im; + y[1].re = in[12].re + q[5].re; + y[1].im = in[12].im + q[5].im; + y[2].re = in[13].re + q[6].re; + y[2].im = in[13].im + q[6].im; + y[3].re = in[14].re + q[7].re; + y[3].im = in[14].im + q[7].im; + + q[0].re = tab[ 8] * q[0].re; + q[0].im = tab[ 9] * q[0].im; + q[1].re = tab[ 8] * q[1].re; + q[1].im = tab[ 9] * q[1].im; + q[2].re = tab[ 8] * q[2].re; + q[2].im = tab[ 9] * q[2].im; + q[3].re = tab[ 8] * q[3].re; + q[3].im = tab[ 9] * q[3].im; + + q[4].re = tab[10] * q[4].re; + q[4].im = tab[11] * q[4].im; + q[5].re = tab[10] * q[5].re; + q[5].im = tab[11] * q[5].im; + q[6].re = tab[10] * q[6].re; + q[6].im = tab[11] * q[6].im; + q[7].re = tab[10] * q[7].re; + q[7].im = tab[11] * q[7].im; + + k[0].re = q[4].re - q[0].re; + k[0].im = q[4].im - q[0].im; + k[1].re = q[5].re - q[1].re; + k[1].im = q[5].im - q[1].im; + k[2].re = q[6].re - q[2].re; + k[2].im = q[6].im - q[2].im; + k[3].re = q[7].re - q[3].re; + k[3].im = q[7].im - q[3].im; + + k[4].re = q[4].re + q[0].re; + k[4].im = q[4].im + q[0].im; + k[5].re = q[5].re + q[1].re; + k[5].im = q[5].im + q[1].im; + k[6].re = q[6].re + q[2].re; + k[6].im = q[6].im + q[2].im; + k[7].re = q[7].re + q[3].re; + k[7].im = q[7].im + q[3].im; + + k[0].re = in[11].re - k[0].re; + k[0].im = in[11].im + k[0].im; + k[1].re = in[12].re - k[1].re; + k[1].im = in[12].im + k[1].im; + k[2].re = in[13].re - k[2].re; + k[2].im = in[13].im + k[2].im; + k[3].re = in[14].re - k[3].re; + k[3].im = in[14].im + k[3].im; + + k[4].re = in[11].re - k[4].re; + k[4].im = in[11].im + k[4].im; + k[5].re = in[12].re - k[5].re; + k[5].im = in[12].im + k[5].im; + k[6].re = in[13].re - k[6].re; + k[6].im = in[13].im + k[6].im; + k[7].re = in[14].re - k[7].re; + k[7].im = in[14].im + k[7].im; + + /* 15pt start here */ + t[0].re = y[3].re + y[0].re; + t[0].im = y[3].im + y[0].im; + t[1].re = y[2].re + y[1].re; + t[1].im = y[2].im + y[1].im; + t[2].re = y[1].re - y[2].re; + t[2].im = y[1].im - y[2].im; + t[3].re = y[0].re - y[3].re; + t[3].im = y[0].im - y[3].im; + + t[4].re = k[3].re + k[0].re; + t[4].im = k[3].im + k[0].im; + t[5].re = k[2].re + k[1].re; + t[5].im = k[2].im + k[1].im; + t[6].re = k[1].re - k[2].re; + t[6].im = k[1].im - k[2].im; + t[7].re = k[0].re - k[3].re; + t[7].im = k[0].im - k[3].im; + + t[ 8].re = k[7].re + k[4].re; + t[ 8].im = k[7].im + k[4].im; + t[ 9].re = k[6].re + k[5].re; + t[ 9].im = k[6].im + k[5].im; + t[10].re = k[5].re - k[6].re; + t[10].im = k[5].im - k[6].im; + t[11].re = k[4].re - k[7].re; + t[11].im = k[4].im - k[7].im; + + out[ 0*stride].re = dc[0].re + t[0].re + t[ 1].re; + out[ 0*stride].im = dc[0].im + t[0].im + t[ 1].im; + out[10*stride].re = dc[1].re + t[4].re + t[ 5].re; + out[10*stride].im = dc[1].im + t[4].im + t[ 5].im; + out[ 5*stride].re = dc[2].re + t[8].re + t[ 9].re; + out[ 5*stride].im = dc[2].im + t[8].im + t[ 9].im; + + r[0].re = t[0].re * tab[0]; + r[0].im = t[0].im * tab[1]; + r[1].re = t[1].re * tab[0]; + r[1].im = t[1].im * tab[1]; + r[2].re = t[2].re * tab[4]; + r[2].im = t[2].im * tab[5]; + r[3].re = t[3].re * tab[4]; + r[3].im = t[3].im * tab[5]; + + r[4].re = t[4].re * tab[0]; + r[4].im = t[4].im * tab[1]; + r[5].re = t[5].re * tab[0]; + r[5].im = t[5].im * tab[1]; + r[6].re = t[6].re * tab[4]; + r[6].im = t[6].im * tab[5]; + r[7].re = t[7].re * tab[4]; + r[7].im = t[7].im * tab[5]; + + r[ 8].re = t[ 8].re * tab[0]; + r[ 8].im = t[ 8].im * tab[1]; + r[ 9].re = t[ 9].re * tab[0]; + r[ 9].im = t[ 9].im * tab[1]; + r[10].re = t[10].re * tab[4]; + r[10].im = t[10].im * tab[5]; + r[11].re = t[11].re * tab[4]; + r[11].im = t[11].im * tab[5]; + + t[0].re = t[0].re * tab[2]; + t[0].im = t[0].im * tab[3]; + t[1].re = t[1].re * tab[2]; + t[1].im = t[1].im * tab[3]; + t[2].re = t[2].re * tab[6]; + t[2].im = t[2].im * tab[7]; + t[3].re = t[3].re * tab[6]; + t[3].im = t[3].im * tab[7]; + + t[4].re = t[4].re * tab[2]; + t[4].im = t[4].im * tab[3]; + t[5].re = t[5].re * tab[2]; + t[5].im = t[5].im * tab[3]; + t[6].re = t[6].re * tab[6]; + t[6].im = t[6].im * tab[7]; + t[7].re = t[7].re * tab[6]; + t[7].im = t[7].im * tab[7]; + + t[ 8].re = t[ 8].re * tab[2]; + t[ 8].im = t[ 8].im * tab[3]; + t[ 9].re = t[ 9].re * tab[2]; + t[ 9].im = t[ 9].im * tab[3]; + t[10].re = t[10].re * tab[6]; + t[10].im = t[10].im * tab[7]; + t[11].re = t[11].re * tab[6]; + t[11].im = t[11].im * tab[7]; + + r[0].re = r[0].re - t[1].re; + r[0].im = r[0].im - t[1].im; + r[1].re = r[1].re - t[0].re; + r[1].im = r[1].im - t[0].im; + r[2].re = r[2].re - t[3].re; + r[2].im = r[2].im - t[3].im; + r[3].re = r[3].re + t[2].re; + r[3].im = r[3].im + t[2].im; + + r[4].re = r[4].re - t[5].re; + r[4].im = r[4].im - t[5].im; + r[5].re = r[5].re - t[4].re; + r[5].im = r[5].im - t[4].im; + r[6].re = r[6].re - t[7].re; + r[6].im = r[6].im - t[7].im; + r[7].re = r[7].re + t[6].re; + r[7].im = r[7].im + t[6].im; + + r[ 8].re = r[ 8].re - t[ 9].re; + r[ 8].im = r[ 8].im - t[ 9].im; + r[ 9].re = r[ 9].re - t[ 8].re; + r[ 9].im = r[ 9].im - t[ 8].im; + r[10].re = r[10].re - t[11].re; + r[10].im = r[10].im - t[11].im; + r[11].re = r[11].re + t[10].re; + r[11].im = r[11].im + t[10].im; + + z0[ 0].re = r[ 3].im + r[ 0].re; + z0[ 0].im = r[ 3].re + r[ 0].im; + z0[ 1].re = r[ 2].im + r[ 1].re; + z0[ 1].im = r[ 2].re + r[ 1].im; + z0[ 2].re = r[ 1].im - r[ 2].re; + z0[ 2].im = r[ 1].re - r[ 2].im; + z0[ 3].re = r[ 0].im - r[ 3].re; + z0[ 3].im = r[ 0].re - r[ 3].im; + + z0[ 4].re = r[ 7].im + r[ 4].re; + z0[ 4].im = r[ 7].re + r[ 4].im; + z0[ 5].re = r[ 6].im + r[ 5].re; + z0[ 5].im = r[ 6].re + r[ 5].im; + z0[ 6].re = r[ 5].im - r[ 6].re; + z0[ 6].im = r[ 5].re - r[ 6].im; + z0[ 7].re = r[ 4].im - r[ 7].re; + z0[ 7].im = r[ 4].re - r[ 7].im; + + z0[ 8].re = r[11].im + r[ 8].re; + z0[ 8].im = r[11].re + r[ 8].im; + z0[ 9].re = r[10].im + r[ 9].re; + z0[ 9].im = r[10].re + r[ 9].im; + z0[10].re = r[ 9].im - r[10].re; + z0[10].im = r[ 9].re - r[10].im; + z0[11].re = r[ 8].im - r[11].re; + z0[11].im = r[ 8].re - r[11].im; + + out[ 6*stride].re = dc[0].re + z0[0].re; + out[ 6*stride].im = dc[0].im + z0[3].re; + out[12*stride].re = dc[0].re + z0[2].im; + out[12*stride].im = dc[0].im + z0[1].im; + out[ 3*stride].re = dc[0].re + z0[1].re; + out[ 3*stride].im = dc[0].im + z0[2].re; + out[ 9*stride].re = dc[0].re + z0[3].im; + out[ 9*stride].im = dc[0].im + z0[0].im; + + out[ 1*stride].re = dc[1].re + z0[4].re; + out[ 1*stride].im = dc[1].im + z0[7].re; + out[ 7*stride].re = dc[1].re + z0[6].im; + out[ 7*stride].im = dc[1].im + z0[5].im; + out[13*stride].re = dc[1].re + z0[5].re; + out[13*stride].im = dc[1].im + z0[6].re; + out[ 4*stride].re = dc[1].re + z0[7].im; + out[ 4*stride].im = dc[1].im + z0[4].im; + + out[11*stride].re = dc[2].re + z0[8].re; + out[11*stride].im = dc[2].im + z0[11].re; + out[ 2*stride].re = dc[2].re + z0[10].im; + out[ 2*stride].im = dc[2].im + z0[9].im; + out[ 8*stride].re = dc[2].re + z0[9].re; + out[ 8*stride].im = dc[2].im + z0[10].re; + out[14*stride].re = dc[2].re + z0[11].im; + out[14*stride].im = dc[2].im + z0[8].im; +} +``` diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c index 2c9682ffb7..6b63cc575f 100644 --- a/libavutil/tx_template.c +++ b/libavutil/tx_template.c @@ -48,9 +48,9 @@ SR_TABLE(65536); SR_TABLE(131072); /* Other factors' tables */ -TABLE_DEF(53, 8); -TABLE_DEF( 7, 6); -TABLE_DEF( 9, 8); +TABLE_DEF(53, 12); +TABLE_DEF( 7, 6); +TABLE_DEF( 9, 8); typedef struct FFSRTabsInitOnce { void (*func)(void); @@ -104,19 +104,26 @@ static FFSRTabsInitOnce sr_tabs_init_once[] = { { TX_TAB(ff_tx_init_tab_131072), AV_ONCE_INIT }, }; -static void TX_TAB(ff_tx_init_tab_53)(void) +static av_cold void TX_TAB(ff_tx_init_tab_53)(void) { - TX_TAB(ff_tx_tab_53)[0] = RESCALE(cos(2 * M_PI / 12)); - TX_TAB(ff_tx_tab_53)[1] = RESCALE(cos(2 * M_PI / 12)); - TX_TAB(ff_tx_tab_53)[2] = RESCALE(cos(2 * M_PI / 6)); - TX_TAB(ff_tx_tab_53)[3] = RESCALE(cos(8 * M_PI / 6)); - TX_TAB(ff_tx_tab_53)[4] = RESCALE(cos(2 * M_PI / 5)); - TX_TAB(ff_tx_tab_53)[5] = RESCALE(sin(8 * M_PI / 5)); - TX_TAB(ff_tx_tab_53)[6] = RESCALE(cos(2 * M_PI / 10)); - TX_TAB(ff_tx_tab_53)[7] = RESCALE(sin(6 * M_PI / 5)); + /* 5pt, doubled to eliminate AVX lane shuffles */ + TX_TAB(ff_tx_tab_53)[0] = RESCALE(cos(2 * M_PI / 5)); + TX_TAB(ff_tx_tab_53)[1] = RESCALE(cos(2 * M_PI / 5)); + TX_TAB(ff_tx_tab_53)[2] = RESCALE(cos(2 * M_PI / 10)); + TX_TAB(ff_tx_tab_53)[3] = RESCALE(cos(2 * M_PI / 10)); + TX_TAB(ff_tx_tab_53)[4] = RESCALE(sin(2 * M_PI / 5)); + TX_TAB(ff_tx_tab_53)[5] = RESCALE(sin(2 * M_PI / 5)); + TX_TAB(ff_tx_tab_53)[6] = RESCALE(sin(2 * M_PI / 10)); + TX_TAB(ff_tx_tab_53)[7] = RESCALE(sin(2 * M_PI / 10)); + + /* 3pt */ + TX_TAB(ff_tx_tab_53)[ 8] = RESCALE(cos(2 * M_PI / 12)); + TX_TAB(ff_tx_tab_53)[ 9] = RESCALE(cos(2 * M_PI / 12)); + TX_TAB(ff_tx_tab_53)[10] = RESCALE(cos(2 * M_PI / 6)); + TX_TAB(ff_tx_tab_53)[11] = RESCALE(cos(8 * M_PI / 6)); } -static void TX_TAB(ff_tx_init_tab_7)(void) +static av_cold void TX_TAB(ff_tx_init_tab_7)(void) { TX_TAB(ff_tx_tab_7)[0] = RESCALE(cos(2 * M_PI / 7)); TX_TAB(ff_tx_tab_7)[1] = RESCALE(sin(2 * M_PI / 7)); @@ -126,7 +133,7 @@ static void TX_TAB(ff_tx_init_tab_7)(void) TX_TAB(ff_tx_tab_7)[5] = RESCALE(sin(2 * M_PI / 14)); } -static void TX_TAB(ff_tx_init_tab_9)(void) +static av_cold void TX_TAB(ff_tx_init_tab_9)(void) { TX_TAB(ff_tx_tab_9)[0] = RESCALE(cos(2 * M_PI / 3)); TX_TAB(ff_tx_tab_9)[1] = RESCALE(sin(2 * M_PI / 3)); @@ -189,19 +196,19 @@ static av_always_inline void fft3(TXComplex *out, TXComplex *in, out[0*stride].im = in[0].im + tmp[1].im; #ifdef TX_INT32 - mtmp[0] = (int64_t)tab[0] * tmp[0].re; - mtmp[1] = (int64_t)tab[1] * tmp[0].im; - mtmp[2] = (int64_t)tab[2] * tmp[1].re; - mtmp[3] = (int64_t)tab[2] * tmp[1].im; + mtmp[0] = (int64_t)tab[ 8] * tmp[0].re; + mtmp[1] = (int64_t)tab[ 9] * tmp[0].im; + mtmp[2] = (int64_t)tab[10] * tmp[1].re; + mtmp[3] = (int64_t)tab[10] * tmp[1].im; out[1*stride].re = in[0].re - (mtmp[2] + mtmp[0] + 0x40000000 >> 31); out[1*stride].im = in[0].im - (mtmp[3] - mtmp[1] + 0x40000000 >> 31); out[2*stride].re = in[0].re - (mtmp[2] - mtmp[0] + 0x40000000 >> 31); out[2*stride].im = in[0].im - (mtmp[3] + mtmp[1] + 0x40000000 >> 31); #else - tmp[0].re = tab[0] * tmp[0].re; - tmp[0].im = tab[1] * tmp[0].im; - tmp[1].re = tab[2] * tmp[1].re; - tmp[1].im = tab[2] * tmp[1].im; + tmp[0].re = tab[ 8] * tmp[0].re; + tmp[0].im = tab[ 9] * tmp[0].im; + tmp[1].re = tab[10] * tmp[1].re; + tmp[1].im = tab[10] * tmp[1].im; out[1*stride].re = in[0].re - tmp[1].re + tmp[0].re; out[1*stride].im = in[0].im - tmp[1].im - tmp[0].im; out[2*stride].re = in[0].re - tmp[1].re - tmp[0].re; @@ -224,10 +231,10 @@ static av_always_inline void NAME(TXComplex *out, TXComplex *in, \ out[D0*stride].re = in[0].re + t[0].re + t[2].re; \ out[D0*stride].im = in[0].im + t[0].im + t[2].im; \ \ - SMUL(t[4].re, t[0].re, tab[4], tab[6], t[2].re, t[0].re); \ - SMUL(t[4].im, t[0].im, tab[4], tab[6], t[2].im, t[0].im); \ - CMUL(t[5].re, t[1].re, -tab[5], -tab[7], t[3].re, t[1].re); \ - CMUL(t[5].im, t[1].im, -tab[5], -tab[7], t[3].im, t[1].im); \ + SMUL(t[4].re, t[0].re, tab[0], tab[2], t[2].re, t[0].re); \ + SMUL(t[4].im, t[0].im, tab[0], tab[2], t[2].im, t[0].im); \ + CMUL(t[5].re, t[1].re, tab[4], tab[6], t[3].re, t[1].re); \ + CMUL(t[5].im, t[1].im, tab[4], tab[6], t[3].im, t[1].im); \ \ BF(z0[0].re, z0[3].re, t[0].re, t[1].re); \ BF(z0[0].im, z0[3].im, t[0].im, t[1].im); \ diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 5e0c438b9c..67f363fc01 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -51,6 +51,8 @@ cextern tab_ %+ i %+ _float ; ff_tab_i_float... %assign i (i << 1) %endrep +cextern tab_53_float + struc AVTXContext .len: resd 1 ; Length .inv resd 1 ; Inverse flag @@ -87,6 +89,9 @@ s16_mult_odd1: dd COS16_1, COS16_1, COS16_3, COS16_3, COS16_1, -COS16_1, CO s16_mult_odd2: dd COS16_3, -COS16_3, COS16_1, -COS16_1, -COS16_3, -COS16_3, -COS16_1, -COS16_1 s16_perm: dd 0, 1, 2, 3, 1, 0, 3, 2 +s15_perm: dd 0, 6, 5, 3, 2, 4, 7, 1 + +mask_mmmmmmpp: dd NEG, NEG, NEG, NEG, NEG, NEG, POS, POS mask_mmmmpppm: dd NEG, NEG, NEG, NEG, POS, POS, POS, NEG mask_ppmpmmpm: dd POS, POS, NEG, POS, NEG, NEG, POS, NEG mask_mppmmpmp: dd NEG, POS, POS, NEG, NEG, POS, NEG, POS @@ -1565,3 +1570,278 @@ cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, %if ARCH_X86_64 && HAVE_AVX2_EXTERNAL IMDCT_FN avx2 %endif + +%macro PFA_15_FN 2 +INIT_YMM %1 +%if %2 +cglobal fft_pfa_15xM_asm_float, 0, 0, 0, ctx, out, in, stride, len, lut, buf, map, tgt, tmp, \ + tgt5, stride3, stride5, btmp +%else +cglobal fft_pfa_15xM_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, buf, map, tgt, tmp, \ + tgt5, stride3, stride5, btmp +%endif + +%if %2 + PUSH inq + PUSH tgt5q + PUSH stride3q + PUSH stride5q + PUSH btmpq +%endif + + mov btmpq, outq + + mov outq, [ctxq + AVTXContext.tmp] +%if !%2 + movsxd lenq, dword [ctxq + AVTXContext.len] + mov lutq, [ctxq + AVTXContext.map] +%endif + + ; Load stride (second transform's length) and second transform's LUT + mov tmpq, [ctxq + AVTXContext.sub] + movsxd strideq, dword [tmpq + AVTXContext.len] + mov mapq, [tmpq + AVTXContext.map] + + shl strideq, 3 + imul stride3q, strideq, 3 + imul stride5q, strideq, 5 + + movaps m13, [mask_mmmmmmpp] ; mmmmmmpp + vpermpd m12, m13, q0033 ; ppppmmmm + vextractf128 xm11, m13, 1 ; mmpp + movaps m10, [ff_tx_tab_53_float] ; tab5 + movaps xm9, [ff_tx_tab_53_float + 32] ; tab3 + movaps m8, [s15_perm] + +.dim1: + mov tmpd, [mapq] + lea tgtq, [outq + tmpq*8] + +%if %2 + movups xm0, [inq] +%else + LOAD64_LUT xm0, inq, lutq, 0, tmpq, m14, xm15 ; in[0,1].reim +%endif + + shufps xm1, xm0, xm0, q3223 ; in[1].imrereim + shufps xm0, xm0, xm0, q1001 ; in[0].imrereim + + xorps xm1, xm11 + addps xm1, xm0 ; pc[0,1].imre + +%if %2 + movddup xm14, [inq + 16] ; in[2].reimreim +%else + mov tmpd, [lutq + 8] + movddup xm14, [inq + tmpq*8] ; in[2].reimreim +%endif + shufps xm0, xm1, xm1, q3232 ; pc[1].reimreim + addps xm0, xm14 ; dc[0].reimreim + + mulps xm1, xm9 ; tab[0123]*pc[01] + + shufpd xm5, xm1, xm1, 01b ; pc[1,0].reim + xorps xm1, xm11 + addps xm1, xm1, xm5 + addsubps xm1, xm14, xm1 ; dc[1,2].reim + +%if %2 + movups m2, [inq + mmsize*0 + 24] + movups m3, [inq + mmsize*1 + 24] +%else + LOAD64_LUT m2, inq, lutq, (mmsize/2)*0 + 12, tmpq, m14, m15 + LOAD64_LUT m3, inq, lutq, (mmsize/2)*1 + 12, tmpq, m14, m15 +%endif + + subps m7, m2, m3 ; q[0-3].imre + addps m6, m2, m3 ; q[4-7] + shufps m7, m7, m7, q2301 ; q[0-3].reim + +%if %2 + movups m4, [inq + mmsize*2 + 24] +%else + LOAD64_LUT m4, inq, lutq, (mmsize/2)*2 + 12, tmpq, m14, m15 +%endif + + addps m5, m4, m6 ; y[0-3] + + vpermpd m14, m9, q1111 ; tab[23232323] + vbroadcastsd m15, xm9 ; tab[01010101] + + mulps m6, m14 + mulps m7, m15 + + subps m2, m6, m7 ; k[0-3] + addps m3, m6, m7 ; k[4-7] + + addsubps m6, m4, m2 ; k[0-3] + addsubps m7, m4, m3 ; k[4-7] + + ; 15pt from here on + vpermpd m2, m5, q0123 ; y[3-0] + vpermpd m3, m6, q0123 ; k[3-0] + vpermpd m4, m7, q0123 ; k[7-4] + + xorps m5, m12 + xorps m6, m12 + xorps m7, m12 + + addps m2, m5 ; t[0-3] + addps m3, m6 ; t[4-7] + addps m4, m7 ; t[8-11] + + movlhps xm14, xm2 ; out[0] + unpcklpd xm7, xm3, xm4 ; out[10,5] + unpckhpd xm5, xm3, xm4 ; out[10,5] + + addps xm14, xm2 ; out[0] + addps xm7, xm5 ; out[10,5] + addps xm14, xm0 ; out[0] + addps xm7, xm1 ; out[10,5] + + movhps [tgtq], xm14 ; out[0] + movhps [tgtq + stride5q*1], xm7 ; out[5] + movlps [tgtq + stride5q*2], xm7 ; out[10] + + shufps m14, m10, m10, q3232 ; tab5 4 5 4 5 8 9 8 9 + shufps m15, m10, m10, q1010 ; tab5 6 7 6 7 10 11 10 11 + + mulps m5, m2, m14 ; t[0-3] + mulps m6, m3, m14 ; t[4-7] + mulps m7, m4, m14 ; t[8-11] + + mulps m2, m15 ; r[0-3] + mulps m3, m15 ; r[4-7] + mulps m4, m15 ; r[8-11] + + shufps m5, m5, m5, q1032 ; t[1,0,3,2].reim + shufps m6, m6, m6, q1032 ; t[5,4,7,6].reim + shufps m7, m7, m7, q1032 ; t[9,8,11,10].reim + + lea tgt5q, [tgtq + stride5q] + lea tmpq, [tgtq + stride5q*2] + + xorps m5, m13 + xorps m6, m13 + xorps m7, m13 + + addps m2, m5 ; r[0,1,2,3] + addps m3, m6 ; r[4,5,6,7] + addps m4, m7 ; r[8,9,10,11] + + shufps m5, m2, m2, q2301 + shufps m6, m3, m3, q2301 + shufps m7, m4, m4, q2301 + + xorps m2, m12 + xorps m3, m12 + xorps m4, m12 + + vpermpd m5, m5, q0123 + vpermpd m6, m6, q0123 + vpermpd m7, m7, q0123 + + addps m5, m2 + addps m6, m3 + addps m7, m4 + + vpermps m5, m8, m5 + vpermps m6, m8, m6 + vpermps m7, m8, m7 + + vbroadcastsd m0, xm0 ; dc[0] + vpermpd m2, m1, q1111 ; dc[2] + vbroadcastsd m1, xm1 ; dc[1] + + addps m0, m5 + addps m1, m6 + addps m2, m7 + + vextractf128 xm3, m0, 1 + vextractf128 xm4, m1, 1 + vextractf128 xm5, m2, 1 + + movlps [tgtq + strideq*1], xm1 + movhps [tgtq + strideq*2], xm2 + movlps [tgtq + stride3q*1], xm3 + movhps [tgtq + strideq*4], xm4 + movlps [tgtq + stride3q*2], xm0 + movlps [tgtq + strideq*8], xm5 + movhps [tgtq + stride3q*4], xm0 + movhps [tgt5q + strideq*2], xm1 + movhps [tgt5q + strideq*4], xm3 + movlps [tmpq + strideq*1], xm2 + movlps [tmpq + stride3q*1], xm4 + movhps [tmpq + strideq*4], xm5 + +%if %2 + add inq, mmsize*3 + 24 +%else + add lutq, (mmsize/2)*3 + 12 +%endif + add mapq, 4 + sub lenq, 15 + jg .dim1 + + ; Second transform setup + mov stride5q, ctxq ; backup original context + movsxd stride3q, dword [ctxq + AVTXContext.len] ; full length + mov tgt5q, [ctxq + AVTXContext.fn] ; subtransform's jump point + + mov inq, outq ; in-place transform + mov ctxq, [ctxq + AVTXContext.sub] ; load subtransform's context + mov lutq, [ctxq + AVTXContext.map] ; load subtransform's map + movsxd lenq, dword [ctxq + AVTXContext.len] ; load subtransform's length + +.dim2: + call tgt5q ; call the FFT + lea inq, [inq + lenq*8] + lea outq, [outq + lenq*8] + sub stride3q, lenq + jg .dim2 + + mov ctxq, stride5q ; restore original context + mov lutq, [ctxq + AVTXContext.map] + mov inq, [ctxq + AVTXContext.tmp] + movsxd lenq, dword [ctxq + AVTXContext.len] ; full length + + lea stride3q, [lutq + lenq*4] ; second part of the LUT + mov stride5q, lenq + mov tgt5q, btmpq + +.post: + LOAD64_LUT m0, inq, stride3q, 0, tmpq, m8, m9 + movups [tgt5q], m0 + + add tgt5q, mmsize + add stride3q, mmsize/2 + sub stride5q, mmsize/8 + jg .post + +%if %2 + mov outq, btmpq + POP btmpq + POP stride5q + POP stride3q + POP tgt5q + POP inq + ret +%else + RET +%endif + +%if %2 +cglobal fft_pfa_15xM_ns_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, buf, map, tgt, tmp, \ + tgt5, stride3, stride5, btmp + movsxd lenq, dword [ctxq + AVTXContext.len] + mov lutq, [ctxq + AVTXContext.map] + + call mangle(fft_pfa_15xM_asm_float) + RET +%endif +%endmacro + +%if ARCH_X86_64 +PFA_15_FN avx2, 0 +PFA_15_FN avx2, 1 +%endif diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c index 06df749fa9..c6695d9afb 100644 --- a/libavutil/x86/tx_float_init.c +++ b/libavutil/x86/tx_float_init.c @@ -43,6 +43,9 @@ TX_DECL_FN(fft_sr_ns, fma3) TX_DECL_FN(fft_sr, avx2) TX_DECL_FN(fft_sr_ns, avx2) +TX_DECL_FN(fft_pfa_15xM, avx2) +TX_DECL_FN(fft_pfa_15xM_ns, avx2) + TX_DECL_FN(mdct_sr_inv, avx2) TX_DECL_FN(fft2_asm, sse3) @@ -57,6 +60,8 @@ TX_DECL_FN(fft32_asm, fma3) TX_DECL_FN(fft_sr_asm, fma3) TX_DECL_FN(fft_sr_asm, avx2) +TX_DECL_FN(fft_pfa_15xM_asm, avx2) + #define DECL_INIT_FN(basis, interleave) \ static av_cold int b ##basis## _i ##interleave(AVTXContext *s, \ const FFTXCodelet *cd, \ @@ -102,6 +107,61 @@ static av_cold int m_inv_init(AVTXContext *s, const FFTXCodelet *cd, return 0; } +static av_cold int fft_pfa_init(AVTXContext *s, + const FFTXCodelet *cd, + uint64_t flags, + FFTXCodeletOptions *opts, + int len, int inv, + const void *scale) +{ + int ret; + int sub_len = len / cd->factors[0]; + FFTXCodeletOptions sub_opts = { .invert_lookup = 0 }; + + flags &= ~FF_TX_OUT_OF_PLACE; /* We want the subtransform to be */ + flags |= AV_TX_INPLACE; /* in-place */ + flags |= FF_TX_PRESHUFFLE; /* This function handles the permute step */ + flags |= FF_TX_ASM_CALL; /* We want an assembly function, not C */ + + if ((ret = ff_tx_init_subtx(s, TX_TYPE(FFT), flags, &sub_opts, + sub_len, inv, scale))) + return ret; + + if ((ret = ff_tx_gen_compound_mapping(s, cd->factors[0], sub_len))) + return ret; + + if (cd->factors[0] == 15) { + for (int k = 0; k < s->sub[0].len; k++) { + int cnt = 0; + int tmp[15]; + memcpy(tmp, &s->map[k*15], 15*sizeof(*tmp)); + for (int i = 1; i < 15; i += 3) { + s->map[k*15 + cnt] = tmp[i]; + cnt++; + } + for (int i = 2; i < 15; i += 3) { + s->map[k*15 + cnt] = tmp[i]; + cnt++; + } + for (int i = 0; i < 15; i += 3) { + s->map[k*15 + cnt] = tmp[i]; + cnt++; + } + memmove(&s->map[k*15 + 7], &s->map[k*15 + 6], 4*sizeof(int)); + memmove(&s->map[k*15 + 3], &s->map[k*15 + 1], 4*sizeof(int)); + s->map[k*15 + 1] = tmp[2]; + s->map[k*15 + 2] = tmp[0]; + } + } + + if (!(s->tmp = av_malloc(len*sizeof(*s->tmp)))) + return AVERROR(ENOMEM); + + TX_TAB(ff_tx_init_tabs)(len / sub_len); + + return 0; +} + const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { TX_DEF(fft2, FFT, 2, 2, 2, 0, 128, NULL, sse3, SSE3, AV_TX_INPLACE, 0), TX_DEF(fft2_asm, FFT, 2, 2, 2, 0, 192, b8_i0, sse3, SSE3, @@ -150,6 +210,7 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), + #if HAVE_AVX2_EXTERNAL TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 320, b8_i2, avx2, AVX2, 0, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), @@ -158,6 +219,13 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 384, b8_i2, avx2, AVX2, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), + TX_DEF(fft_pfa_15xM, FFT, 60, TX_LEN_UNLIMITED, 15, TX_FACTOR_ANY, 320, fft_pfa_init, avx2, AVX2, + AV_TX_INPLACE, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), + TX_DEF(fft_pfa_15xM_asm, FFT, 60, TX_LEN_UNLIMITED, 15, TX_FACTOR_ANY, 384, fft_pfa_init, avx2, AVX2, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), + TX_DEF(fft_pfa_15xM_ns, FFT, 60, TX_LEN_UNLIMITED, 15, TX_FACTOR_ANY, 384, fft_pfa_init, avx2, AVX2, + AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), + TX_DEF(mdct_sr_inv, MDCT, 16, TX_LEN_UNLIMITED, 2, TX_FACTOR_ANY, 384, m_inv_init, avx2, AVX2, FF_TX_INVERSE_ONLY, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), #endif diff --git a/tests/checkasm/av_tx.c b/tests/checkasm/av_tx.c index 1fa6da45ac..aa8fc6b4e9 100644 --- a/tests/checkasm/av_tx.c +++ b/tests/checkasm/av_tx.c @@ -24,7 +24,7 @@ #include -#define EPS 0.00005 +#define EPS 0.0005 #define SCALE_NOOP(x) (x) #define SCALE_INT20(x) (av_clip64(lrintf((x) * 2147483648.0), INT32_MIN, INT32_MAX) >> 12) @@ -40,7 +40,7 @@ } while (0) static const int check_lens[] = { - 2, 4, 8, 16, 32, 64, 1024, 16384, + 2, 4, 8, 16, 32, 64, 120, 960, 1024, 1920, 16384, }; static AVTXContext *tx_refs[AV_TX_NB][2 /* Direction */][FF_ARRAY_ELEMS(check_lens)] = { 0 }; From 74e8541bab8e885a0e819b8298ae6bfb72042be9 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 23 Sep 2022 10:38:29 +0200 Subject: [PATCH 436/590] x86/tx_float: generalize iMDCT To support non-aligned buffers during the post-transform step, just iterate backwards over the array. This allows using the 15xN-point FFT, with which the speed is 2.1 times faster than our old libavcodec implementation. --- libavutil/x86/tx_float.asm | 52 ++++++++++++++++++----------------- libavutil/x86/tx_float_init.c | 17 +++++++++--- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 67f363fc01..c3b1375bc4 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1389,17 +1389,16 @@ FFT_SPLIT_RADIX_FN avx2, 1 %macro IMDCT_FN 1 INIT_YMM %1 -cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, t1, t2, t3, t4, t5, bctx +cglobal mdct_inv_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, exp, t1, t2, t3, \ + t4, t5, btmp movsxd lenq, dword [ctxq + AVTXContext.len] mov expq, [ctxq + AVTXContext.exp] lea t1d, [lend - 1] imul t1d, strided - mov bctxq, ctxq ; backup original context - mov t5q, [ctxq + AVTXContext.fn] ; subtransform's jump point - mov ctxq, [ctxq + AVTXContext.sub] ; load subtransform's context - mov lutq, [ctxq + AVTXContext.map] ; load subtransform's map + mov btmpq, ctxq ; backup original context + mov lutq, [ctxq + AVTXContext.map] ; load map cmp strideq, 4 je .stride4 @@ -1444,8 +1443,8 @@ cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, fmaddsubps m10, m12, m2, m10 fmaddsubps m11, m13, m3, m11 - mova [t2q + 0*mmsize], m10 - mova [t2q + 1*mmsize], m11 + movups [t2q + 0*mmsize], m10 + movups [t2q + 1*mmsize], m11 add expq, mmsize*2 add lutq, mmsize @@ -1462,16 +1461,16 @@ cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, lea t2q, [lenq*2 - mmsize/2] .stride4_pre: - movaps m4, [inq] - movaps m3, [t1q] + movups m4, [inq] + movups m3, [t1q] movsldup m1, m4 ; im im, im im movshdup m0, m3 ; re re, re re movshdup m4, m4 ; re re, re re (2) movsldup m3, m3 ; im im, im im (2) - movaps m2, [expq] ; tab - movaps m5, [expq + 2*t2q] ; tab (2) + movups m2, [expq] ; tab + movups m5, [expq + 2*t2q] ; tab (2) vpermpd m0, m0, q0123 ; flip shufps m7, m2, m2, q2301 @@ -1513,29 +1512,31 @@ cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, add inq, mmsize sub t1q, mmsize sub t2q, mmsize - jg .stride4_pre + jge .stride4_pre .transform: + mov t4q, ctxq ; backup original context + mov t5q, [ctxq + AVTXContext.fn] ; subtransform's jump point + mov ctxq, [ctxq + AVTXContext.sub] + mov lutq, [ctxq + AVTXContext.map] movsxd lenq, dword [ctxq + AVTXContext.len] + mov inq, outq ; in-place transform call t5q ; call the FFT - mov ctxq, bctxq ; restore original context + mov ctxq, t4q ; restore original context movsxd lenq, dword [ctxq + AVTXContext.len] mov expq, [ctxq + AVTXContext.exp] lea expq, [expq + lenq*4] - lea t1q, [lenq*2] ; high - lea t2q, [lenq*2 - mmsize] ; low - - neg lenq - lea outq, [outq + lenq*4] + xor t1q, t1q ; low + lea t2q, [lenq*4 - mmsize] ; high .post: - movaps m2, [expq + t1q] ; tab h - movaps m3, [expq + t2q] ; tab l - movaps m0, [outq + t1q] ; in h - movaps m1, [outq + t2q] ; in l + movaps m2, [expq + t2q] ; tab h + movaps m3, [expq + t1q] ; tab l + movups m0, [outq + t2q] ; in h + movups m1, [outq + t1q] ; in l movshdup m4, m2 ; tab h imim movshdup m5, m3 ; tab l imim @@ -1557,12 +1558,13 @@ cglobal mdct_sr_inv_float, 4, 13, 16, 272, ctx, out, in, stride, len, lut, exp, blendps m1, m2, m5, 01010101b blendps m0, m3, m4, 01010101b - movaps [outq + t2q], m1 - movaps [outq + t1q], m0 + movups [outq + t2q], m0 + movups [outq + t1q], m1 add t1q, mmsize sub t2q, mmsize - jge .post + sub lenq, mmsize/2 + jg .post RET %endmacro diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c index c6695d9afb..20c1ad6869 100644 --- a/libavutil/x86/tx_float_init.c +++ b/libavutil/x86/tx_float_init.c @@ -46,7 +46,7 @@ TX_DECL_FN(fft_sr_ns, avx2) TX_DECL_FN(fft_pfa_15xM, avx2) TX_DECL_FN(fft_pfa_15xM_ns, avx2) -TX_DECL_FN(mdct_sr_inv, avx2) +TX_DECL_FN(mdct_inv, avx2) TX_DECL_FN(fft2_asm, sse3) TX_DECL_FN(fft4_fwd_asm, sse2) @@ -87,7 +87,7 @@ static av_cold int m_inv_init(AVTXContext *s, const FFTXCodelet *cd, int len, int inv, const void *scale) { int ret; - FFTXCodeletOptions sub_opts = { .invert_lookup = -1 }; + FFTXCodeletOptions sub_opts = { .invert_lookup = 1 }; s->scale_d = *((SCALE_TYPE *)scale); s->scale_f = s->scale_d; @@ -101,7 +101,16 @@ static av_cold int m_inv_init(AVTXContext *s, const FFTXCodelet *cd, inv, scale))) return ret; - if ((ret = ff_tx_mdct_gen_exp_float(s, s->sub->map))) + s->map = av_malloc(len*sizeof(*s->map)); + if (!s->map) + return AVERROR(ENOMEM); + + memcpy(s->map, s->sub->map, (len >> 1)*sizeof(*s->map)); + /* Invert lookup table for unstrided path */ + for (int i = 0; i < (len >> 1); i++) + s->map[(len >> 1) + s->map[i]] = i; + + if ((ret = ff_tx_mdct_gen_exp_float(s, s->map))) return ret; return 0; @@ -226,7 +235,7 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { TX_DEF(fft_pfa_15xM_ns, FFT, 60, TX_LEN_UNLIMITED, 15, TX_FACTOR_ANY, 384, fft_pfa_init, avx2, AVX2, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), - TX_DEF(mdct_sr_inv, MDCT, 16, TX_LEN_UNLIMITED, 2, TX_FACTOR_ANY, 384, m_inv_init, avx2, AVX2, + TX_DEF(mdct_inv, MDCT, 16, TX_LEN_UNLIMITED, 2, TX_FACTOR_ANY, 384, m_inv_init, avx2, AVX2, FF_TX_INVERSE_ONLY, AV_CPU_FLAG_AVXSLOW | AV_CPU_FLAG_SLOW_GATHER), #endif #endif From e7a987d7c91e4fb2fc5dd93128d5dee8e2c514f6 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 23 Sep 2022 10:32:39 +0200 Subject: [PATCH 437/590] lavu/tx: remove special -1 inverted lookup mode It was somewhat hacky and unnecessary. --- libavutil/tx.c | 5 +---- libavutil/tx_priv.h | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index aeb0d9dada..0c16ecffc3 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -213,7 +213,7 @@ int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, if (len < basis) return AVERROR(EINVAL); - if (!(s->map = av_mallocz((inv_lookup == -1 ? 2 : 1)*len*sizeof(*s->map)))) + if (!(s->map = av_mallocz(len*sizeof(*s->map)))) return AVERROR(ENOMEM); av_assert0(!dual_stride || !(dual_stride & (dual_stride - 1))); @@ -221,9 +221,6 @@ int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, parity_revtab_generator(s->map, len, inv, 0, 0, 0, len, basis, dual_stride, inv_lookup != 0); - if (inv_lookup == -1) - parity_revtab_generator(s->map + len, len, inv, 0, 0, 0, len, - basis, dual_stride, 0); return 0; } diff --git a/libavutil/tx_priv.h b/libavutil/tx_priv.h index 28ac31a597..3195cb51b2 100644 --- a/libavutil/tx_priv.h +++ b/libavutil/tx_priv.h @@ -290,8 +290,7 @@ int ff_tx_gen_ptwo_inplace_revtab_idx(AVTXContext *s); * If length is smaller than basis/2 this function will not do anything. * * If inv_lookup is set to 1, it will flip the lookup from out[map[i]] = src[i] - * to out[i] = src[map[i]]. If set to -1, will generate 2 maps, the first one - * flipped, the second one regular. + * to out[i] = src[map[i]]. */ int ff_tx_gen_split_radix_parity_revtab(AVTXContext *s, int len, int inv, int inv_lookup, int basis, int dual_stride); From 10137d9d63f1a9796f5612e81befadd4037911f8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 20 Sep 2022 10:40:14 +0200 Subject: [PATCH 438/590] MAINTAINERS: add myself as a ffmpeg.c maintainer Michael has not been doing much work on it in the last few years and I have by far the most commits. --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index ed2ec0b90c..4f94d662db 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21,7 +21,7 @@ Applications ============ ffmpeg: - ffmpeg.c Michael Niedermayer + ffmpeg.c Michael Niedermayer, Anton Khirnov ffplay: ffplay.c Marton Balint From 07d930014d839dc1c10f3a539e78cc7f8b9d7a4a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 20 Sep 2022 10:42:38 +0200 Subject: [PATCH 439/590] MAINTAINERS: remove the project leader section The position does not exist anymore. --- MAINTAINERS | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 4f94d662db..eebfa5cfb7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11,12 +11,6 @@ A (CC
) after the name means that the maintainer prefers to be CC-ed on patches and related discussions. -Project Leader -============== - - final design decisions - - Applications ============ From e301143f96639b97a8e9a0045f93b56e0f399289 Mon Sep 17 00:00:00 2001 From: Tristan Matthews Date: Fri, 23 Sep 2022 07:43:35 -0400 Subject: [PATCH 440/590] opus_silk: reset midonly flag after skipping LBRR Fix suggested by Mark Harris. Fixes ticket #9890 Simplified after feedback from Anton Khirnov. Signed-off-by: Anton Khirnov --- libavcodec/opus_silk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/opus_silk.c b/libavcodec/opus_silk.c index 8523b55ada..f9d67f4fb3 100644 --- a/libavcodec/opus_silk.c +++ b/libavcodec/opus_silk.c @@ -833,6 +833,8 @@ int ff_silk_decode_superframe(SilkContext *s, OpusRangeCoder *rc, int active1 = (j == 0 && !(redundancy[1] & (1 << i))) ? 0 : 1; silk_decode_frame(s, rc, i, j, coded_channels, 1, active1, 1); } + + s->midonly = 0; } for (i = 0; i < nb_frames; i++) { From c504fb869264fbd8fba6e81c186b2f2848b62e26 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 19 Sep 2022 14:50:30 +0200 Subject: [PATCH 441/590] lavc/pthread_frame: always transfer stashed hwaccel state Fixes assertion failures after avcodec_flush_buffers(), where stashed hwaccel state is present, but prev_thread is NULL. Found-by: Wang Bin --- libavcodec/pthread_frame.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 066269621d..f8fddc5e4d 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -459,14 +459,14 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx, pthread_mutex_unlock(&p->mutex); return err; } - - /* transfer hwaccel state stashed from previous thread, if any */ - av_assert0(!p->avctx->hwaccel); - FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel); - FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context); - FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv); } + /* transfer the stashed hwaccel state, if any */ + av_assert0(!p->avctx->hwaccel); + FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel); + FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context); + FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv); + av_packet_unref(p->avpkt); ret = av_packet_ref(p->avpkt, avpkt); if (ret < 0) { From 750f378becf15c0552c45a66a66aca7cc506d490 Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 23 Sep 2022 15:15:20 -0300 Subject: [PATCH 442/590] x86/tx_float: add missing preprocessor wrapper for AVX2 functions Fixes compilation with old assemblers. Signed-off-by: James Almer --- libavutil/x86/tx_float.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index c3b1375bc4..fd934e9eac 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1843,7 +1843,7 @@ cglobal fft_pfa_15xM_ns_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, b %endif %endmacro -%if ARCH_X86_64 +%if ARCH_X86_64 && HAVE_AVX2_EXTERNAL PFA_15_FN avx2, 0 PFA_15_FN avx2, 1 %endif From 84f467454bc22804662d179abc1b667674e34929 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 19 Sep 2022 22:14:05 +0200 Subject: [PATCH 443/590] avcodec: add APAC decoder --- Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/apac.c | 269 ++++++++++++++++++++++++++++++++++++++++ libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/version.h | 4 +- 7 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 libavcodec/apac.c diff --git a/Changelog b/Changelog index 720a092659..c7a54f0847 100644 --- a/Changelog +++ b/Changelog @@ -14,6 +14,7 @@ version : - bonk decoder and demuxer - Micronas SC-4 audio decoder - LAF demuxer +- APAC decoder version 5.1: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c836252664..b9aa6efaac 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -214,6 +214,7 @@ OBJS-$(CONFIG_AMRWB_DECODER) += amrwbdec.o celp_filters.o \ OBJS-$(CONFIG_AMV_ENCODER) += mjpegenc.o mjpegenc_common.o OBJS-$(CONFIG_ANM_DECODER) += anm.o OBJS-$(CONFIG_ANSI_DECODER) += ansi.o cga_data.o +OBJS-$(CONFIG_APAC_DECODER) += apac.o OBJS-$(CONFIG_APE_DECODER) += apedec.o OBJS-$(CONFIG_APTX_DECODER) += aptxdec.o aptx.o OBJS-$(CONFIG_APTX_ENCODER) += aptxenc.o aptx.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 447225e26b..fc88e25fda 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -432,6 +432,7 @@ extern const FFCodec ff_alac_decoder; extern const FFCodec ff_als_decoder; extern const FFCodec ff_amrnb_decoder; extern const FFCodec ff_amrwb_decoder; +extern const FFCodec ff_apac_decoder; extern const FFCodec ff_ape_decoder; extern const FFCodec ff_aptx_encoder; extern const FFCodec ff_aptx_decoder; diff --git a/libavcodec/apac.c b/libavcodec/apac.c new file mode 100644 index 0000000000..6a1f61b842 --- /dev/null +++ b/libavcodec/apac.c @@ -0,0 +1,269 @@ +/* + * APAC audio decoder + * + * 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 "libavutil/audio_fifo.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "avcodec.h" +#include "codec_internal.h" +#include "decode.h" +#include "get_bits.h" + +typedef struct ChContext { + int have_code; + int last_sample; + int last_delta; + int bit_length; + int block_length; + uint8_t block[32 * 2]; + AVAudioFifo *samples; +} ChContext; + +typedef struct APACContext { + GetBitContext gb; + int skip; + + int cur_ch; + ChContext ch[2]; + + uint8_t *bitstream; + int64_t max_framesize; + int bitstream_size; + int bitstream_index; +} APACContext; + +static av_cold int apac_close(AVCodecContext *avctx) +{ + APACContext *s = avctx->priv_data; + + av_freep(&s->bitstream); + s->bitstream_size = 0; + + for (int ch = 0; ch < 2; ch++) { + ChContext *c = &s->ch[ch]; + + av_audio_fifo_free(c->samples); + } + + return 0; +} + +static av_cold int apac_init(AVCodecContext *avctx) +{ + APACContext *s = avctx->priv_data; + + if (avctx->bits_per_coded_sample > 8) + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; + else + avctx->sample_fmt = AV_SAMPLE_FMT_U8P; + + if (avctx->ch_layout.nb_channels < 1 || + avctx->ch_layout.nb_channels > 2) + return AVERROR_INVALIDDATA; + + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { + ChContext *c = &s->ch[ch]; + + c->bit_length = avctx->bits_per_coded_sample; + c->block_length = 8; + c->have_code = 0; + c->samples = av_audio_fifo_alloc(avctx->sample_fmt, 1, 1024); + if (!c->samples) + return AVERROR(ENOMEM); + } + + s->max_framesize = 1024; + s->bitstream = av_realloc_f(s->bitstream, s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream)); + if (!s->bitstream) + return AVERROR(ENOMEM); + + return 0; +} + +static int get_code(ChContext *c, GetBitContext *gb) +{ + if (get_bits1(gb)) { + int code = get_bits(gb, 2); + + switch (code) { + case 0: + c->bit_length--; + break; + case 1: + c->bit_length++; + break; + case 2: + c->bit_length = get_bits(gb, 5); + break; + case 3: + c->block_length = get_bits(gb, 4); + return 1; + } + } + + return 0; +} + +static int apac_decode(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *pkt) +{ + APACContext *s = avctx->priv_data; + GetBitContext *gb = &s->gb; + int ret, n, buf_size, input_buf_size; + const uint8_t *buf; + int nb_samples; + + if (!pkt->size && s->bitstream_size <= 0) { + *got_frame_ptr = 0; + return 0; + } + + buf_size = pkt->size; + input_buf_size = buf_size; + + if (s->bitstream_index > 0 && s->bitstream_size > 0) { + memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); + s->bitstream_index = 0; + } + + if (s->bitstream_index + s->bitstream_size + buf_size > s->max_framesize) { + s->bitstream = av_realloc_f(s->bitstream, s->bitstream_index + + s->bitstream_size + + buf_size + AV_INPUT_BUFFER_PADDING_SIZE, + sizeof(*s->bitstream)); + if (!s->bitstream) + return AVERROR(ENOMEM); + s->max_framesize = s->bitstream_index + s->bitstream_size + buf_size; + } + if (pkt->data) + memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], pkt->data, buf_size); + buf = &s->bitstream[s->bitstream_index]; + buf_size += s->bitstream_size; + s->bitstream_size = buf_size; + + frame->nb_samples = s->bitstream_size * 16 * 8; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + + if ((ret = init_get_bits8(gb, buf, buf_size)) < 0) + return ret; + + skip_bits(gb, s->skip); + s->skip = 0; + + while (get_bits_left(gb) > 0) { + for (int ch = s->cur_ch; ch < avctx->ch_layout.nb_channels; ch++) { + ChContext *c = &s->ch[ch]; + int16_t *dst16 = (int16_t *)c->block; + uint8_t *dst8 = (uint8_t *)c->block; + void *samples[4]; + + samples[0] = &c->block[0]; + if (get_bits_left(gb) < 16 && pkt->size) { + s->cur_ch = ch; + goto end; + } + + if (!c->have_code && get_code(c, gb)) + get_code(c, gb); + c->have_code = 0; + + if (c->block_length <= 0) + continue; + + if (c->bit_length < 0 || + c->bit_length > 17) { + c->bit_length = avctx->bits_per_coded_sample; + return AVERROR_INVALIDDATA; + } + + if (get_bits_left(gb) < c->block_length * c->bit_length && pkt->size) { + c->have_code = 1; + s->cur_ch = ch; + goto end; + } + + for (int i = 0; i < c->block_length; i++) { + int val = get_bits_long(gb, c->bit_length); + int delta = (val & 1) ? ~(val >> 1) : (val >> 1); + int sample; + + delta += c->last_delta; + sample = c->last_sample + delta; + c->last_delta = delta; + c->last_sample = sample; + + switch (avctx->sample_fmt) { + case AV_SAMPLE_FMT_S16P: + dst16[i] = sample; + break; + case AV_SAMPLE_FMT_U8P: + dst8[i] = sample; + break; + } + } + + av_audio_fifo_write(c->samples, samples, c->block_length); + } + + s->cur_ch = 0; + } +end: + nb_samples = frame->nb_samples; + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) + nb_samples = FFMIN(av_audio_fifo_size(s->ch[ch].samples), nb_samples); + + frame->nb_samples = nb_samples; + for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) { + void *samples[1] = { frame->extended_data[ch] }; + av_audio_fifo_read(s->ch[ch].samples, samples, nb_samples); + } + + s->skip = get_bits_count(gb) - 8 * (get_bits_count(gb) / 8); + n = get_bits_count(gb) / 8; + + if (nb_samples > 0 || pkt->size) + *got_frame_ptr = 1; + + if (s->bitstream_size > 0) { + s->bitstream_index += n; + s->bitstream_size -= n; + return input_buf_size; + } + return n; +} + +const FFCodec ff_apac_decoder = { + .p.name = "apac", + CODEC_LONG_NAME("Marian's A-pac audio"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_APAC, + .priv_data_size = sizeof(APACContext), + .init = apac_init, + FF_CODEC_DECODE_CB(apac_decode), + .close = apac_close, + .p.capabilities = AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_DR1 | + AV_CODEC_CAP_SUBFRAMES, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, + AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_NONE }, +}; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 648c518b3c..e8e1529401 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3304,6 +3304,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Micronas SC-4 Audio"), .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_INTRA_ONLY, }, + { + .id = AV_CODEC_ID_APAC, + .type = AVMEDIA_TYPE_AUDIO, + .name = "apac", + .long_name = NULL_IF_CONFIG_SMALL("Marian's A-pac audio"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, /* subtitle codecs */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index bc8226ff07..9c01ea9750 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -529,6 +529,7 @@ enum AVCodecID { AV_CODEC_ID_DFPWM, AV_CODEC_ID_BONK, AV_CODEC_ID_MISC4, + AV_CODEC_ID_APAC, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/version.h b/libavcodec/version.h index c2404cf9ee..a3441795e0 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 44 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 45 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From 6c233910640e0616db2f2ed0b39a6c20f6208add Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 19 Sep 2022 22:05:20 +0200 Subject: [PATCH 444/590] avformat: add APAC demuxer --- Changelog | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/apac.c | 86 ++++++++++++++++++++++++++++++++++++++++ libavformat/version.h | 4 +- 5 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 libavformat/apac.c diff --git a/Changelog b/Changelog index c7a54f0847..8360492abe 100644 --- a/Changelog +++ b/Changelog @@ -14,7 +14,7 @@ version : - bonk decoder and demuxer - Micronas SC-4 audio decoder - LAF demuxer -- APAC decoder +- APAC decoder and demuxer version 5.1: diff --git a/libavformat/Makefile b/libavformat/Makefile index 19a4ba2a8f..d7f198bf39 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -101,6 +101,7 @@ OBJS-$(CONFIG_AMRNB_DEMUXER) += amr.o rawdec.o OBJS-$(CONFIG_AMRWB_DEMUXER) += amr.o rawdec.o OBJS-$(CONFIG_AMV_MUXER) += amvenc.o OBJS-$(CONFIG_ANM_DEMUXER) += anm.o +OBJS-$(CONFIG_APAC_DEMUXER) += apac.o rawdec.o OBJS-$(CONFIG_APC_DEMUXER) += apc.o OBJS-$(CONFIG_APE_DEMUXER) += ape.o apetag.o img2.o OBJS-$(CONFIG_APM_DEMUXER) += apm.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index a545b5ff45..47c419a009 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -52,6 +52,7 @@ extern const AVInputFormat ff_amrnb_demuxer; extern const AVInputFormat ff_amrwb_demuxer; extern const AVOutputFormat ff_amv_muxer; extern const AVInputFormat ff_anm_demuxer; +extern const AVInputFormat ff_apac_demuxer; extern const AVInputFormat ff_apc_demuxer; extern const AVInputFormat ff_ape_demuxer; extern const AVInputFormat ff_apm_demuxer; diff --git a/libavformat/apac.c b/libavformat/apac.c new file mode 100644 index 0000000000..18970e19dd --- /dev/null +++ b/libavformat/apac.c @@ -0,0 +1,86 @@ +/* + * APAC demuxer + * Copyright (c) 2022 Paul B Mahol + * + * 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 "libavutil/intreadwrite.h" +#include "avformat.h" +#include "demux.h" +#include "internal.h" +#include "rawdec.h" + +static int apac_probe(const AVProbeData *p) +{ + if (AV_RB32(p->buf) == MKBETAG('A','P','A','C') && + AV_RB32(p->buf + 8) == MKBETAG('P','R','O','F') && + AV_RB32(p->buf + 12) == MKBETAG('N','A','D',' ')) + return AVPROBE_SCORE_MAX; + + return 0; +} + +static int apac_read_header(AVFormatContext *s) +{ + AVIOContext *pb = s->pb; + uint32_t chunk_size; + AVStream *st; + int64_t pos; + + avio_skip(pb, 16); + chunk_size = avio_rl32(pb); + avio_skip(pb, chunk_size); + if (avio_rb32(pb) != MKBETAG('P','F','M','T')) + return AVERROR_INVALIDDATA; + chunk_size = avio_rl32(pb); + pos = avio_tell(pb); + avio_skip(pb, 2); + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->codec_id = AV_CODEC_ID_APAC; + st->codecpar->ch_layout.nb_channels = avio_rl16(pb); + st->codecpar->sample_rate = avio_rl32(pb); + if (st->codecpar->ch_layout.nb_channels <= 0 || + st->codecpar->ch_layout.nb_channels > 2 || + st->codecpar->sample_rate <= 0) + return AVERROR_INVALIDDATA; + avio_skip(pb, 2); + st->codecpar->bits_per_coded_sample = avio_rl16(pb); + avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + avio_skip(pb, (chunk_size + pos) - avio_tell(pb) + (chunk_size & 1)); + if (avio_rb32(pb) != MKBETAG('P','A','D',' ')) + return AVERROR_INVALIDDATA; + avio_skip(pb, 4); + + return 0; +} + +const AVInputFormat ff_apac_demuxer = { + .name = "apac", + .long_name = NULL_IF_CONFIG_SMALL("raw APAC"), + .read_probe = apac_probe, + .read_header = apac_read_header, + .read_packet = ff_raw_read_partial_packet, + .extensions = "apc", + .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS, + .raw_codec_id = AV_CODEC_ID_APAC, + .priv_data_size = sizeof(FFRawDemuxerContext), + .priv_class = &ff_raw_demuxer_class, +}; diff --git a/libavformat/version.h b/libavformat/version.h index f7eb36a04a..6c740dd187 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 32 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 33 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From ec8be8a913d64af210afee27cbedfafcbcbd05c9 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 23 Sep 2022 17:30:55 +0200 Subject: [PATCH 445/590] avcodec/tiff: improve lut handling for DNG --- libavcodec/tiff.c | 8 ++++---- libavcodec/tiff.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 226050744f..4da77a3a31 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -283,16 +283,15 @@ static uint16_t av_always_inline dng_process_color16(uint16_t value, float value_norm; // Lookup table lookup - if (lut) - value = lut[value]; + value = lut[value]; // Black level subtraction value = av_clip_uint16_c((unsigned)value - black_level); // Color scaling - value_norm = (float)value * scale_factor; + value_norm = (float)value * scale_factor * 65535.f; - value = av_clip_uint16_c(value_norm * 65535); + value = av_clip_uint16_c(lrintf(value_norm)); return value; } @@ -1414,6 +1413,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) else if (count > 1) s->sub_ifd = ff_tget(&s->gb, TIFF_LONG, s->le); /** Only get the first SubIFD */ break; + case TIFF_GRAY_RESPONSE_CURVE: case DNG_LINEARIZATION_TABLE: if (count > FF_ARRAY_ELEMS(s->dng_lut)) return AVERROR_INVALIDDATA; diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h index c07a5d4fa9..9d2ab90f52 100644 --- a/libavcodec/tiff.h +++ b/libavcodec/tiff.h @@ -66,6 +66,7 @@ enum TiffTags { TIFF_PAGE_NAME = 0x11D, TIFF_XPOS = 0x11E, TIFF_YPOS = 0x11F, + TIFF_GRAY_RESPONSE_CURVE= 0x123, TIFF_T4OPTIONS = 0x124, TIFF_T6OPTIONS, TIFF_RES_UNIT = 0x128, From 0d8f43c74d0b1039ba70aacb4c9c7768e8bebf9f Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 23 Sep 2022 16:04:10 -0300 Subject: [PATCH 446/590] x86/tx_float: change a condition in a preprocessor check Fixes compilation with yasm. Signed-off-by: James Almer --- libavutil/x86/tx_float.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index fd934e9eac..4f4fd720f8 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1594,7 +1594,7 @@ cglobal fft_pfa_15xM_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, buf, mov btmpq, outq mov outq, [ctxq + AVTXContext.tmp] -%if !%2 +%if %2 == 0 movsxd lenq, dword [ctxq + AVTXContext.len] mov lutq, [ctxq + AVTXContext.map] %endif From d5a0dc037df48f53cb4dbe37cfae1724f11c8a58 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 23 Sep 2022 17:27:34 +0200 Subject: [PATCH 447/590] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That way the SAR will be automatically set on the AVFrame. Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeg2000dec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 7d9661f29f..c3f2a7aa03 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2519,6 +2519,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (ret = jpeg2000_read_main_headers(s)) goto end; + if (s->sar.num && s->sar.den) + avctx->sample_aspect_ratio = s->sar; + s->sar.num = s->sar.den = 0; + /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) goto end; @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(picture->data[1], s->palette, 256 * sizeof(uint32_t)); - if (s->sar.num && s->sar.den) - avctx->sample_aspect_ratio = s->sar; - s->sar.num = s->sar.den = 0; return bytestream2_tell(&s->g); From 793282adc2afe962a1bd97828468e499f247be3a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 23 Sep 2022 17:37:41 +0200 Subject: [PATCH 448/590] avcodec/jpeg2000dec: Implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This could be improved further by not allocating the buffers that won't be needed lateron in the first place. Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeg2000dec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index c3f2a7aa03..c2b81ec103 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2523,6 +2523,11 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, avctx->sample_aspect_ratio = s->sar; s->sar.num = s->sar.den = 0; + if (avctx->skip_frame >= AVDISCARD_ALL) { + jpeg2000_dec_cleanup(s); + return avpkt->size; + } + /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) goto end; @@ -2587,4 +2592,5 @@ const FFCodec ff_jpeg2000_decoder = { .p.priv_class = &jpeg2000_class, .p.max_lowres = 5, .p.profiles = NULL_IF_CONFIG_SMALL(ff_jpeg2000_profiles), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, }; From 7adf7502b8c5f7d47bef7474de25f6328fd9bb9a Mon Sep 17 00:00:00 2001 From: Chema Gonzalez Date: Mon, 12 Sep 2022 16:49:56 -0700 Subject: [PATCH 449/590] doc/examples/extract_mvs: add motion information Note that the motion information includes subpel motion information This was likely forgotten in 56bdf61baa04c4fd8d165f34499115ce0aa97c43. Tested: ``` $ make examples -j ... $ doc/examples/extract_mvs in.264 | head -40 | \ csvcut -C framenum,source,flags |csvlook | blockw | blockh | srcx | srcy | dstx | dsty | motion_x | motion_y | motion_scale | | ------ | ------ | ----- | ---- | ----- | ---- | -------- | -------- | ------------ | | 16 | 16 | 20 | 26 | 8 | 8 | 49 | 72 | 4 | | 16 | 16 | 152 | 15 | 136 | 8 | 65 | 28 | 4 | | 16 | 8 | 360 | 3 | 360 | 4 | 1 | -6 | 4 | | 16 | 8 | 360 | 13 | 360 | 12 | -1 | 4 | 4 | | 16 | 16 | 440 | 10 | 440 | 8 | 3 | 10 | 4 | | 8 | 16 | 829 | 7 | 836 | 8 | -31 | -6 | 4 | | 8 | 16 | 844 | 7 | 844 | 8 | -1 | -4 | 4 | | 16 | 16 | 1,004 | 14 | 1,048 | 8 | -177 | 24 | 4 | | 16 | 16 | 1,096 | 8 | 1,096 | 8 | -1 | 0 | 4 | | 16 | 8 | 1,417 | 24 | 1,416 | 4 | 7 | 82 | 4 | | 16 | 8 | 1,416 | 13 | 1,416 | 12 | 0 | 6 | 4 | | 16 | 8 | 87 | 20 | 88 | 20 | -7 | 0 | 4 | | 16 | 8 | 99 | 44 | 88 | 28 | 45 | 66 | 4 | ... ``` Also: ``` $ make fate -j ... ``` Signed-off-by: Michael Niedermayer --- doc/examples/extract_mvs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/examples/extract_mvs.c b/doc/examples/extract_mvs.c index cc1311da91..b80ba26bb7 100644 --- a/doc/examples/extract_mvs.c +++ b/doc/examples/extract_mvs.c @@ -61,10 +61,11 @@ static int decode_packet(const AVPacket *pkt) const AVMotionVector *mvs = (const AVMotionVector *)sd->data; for (i = 0; i < sd->size / sizeof(*mvs); i++) { const AVMotionVector *mv = &mvs[i]; - printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64"\n", + printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%"PRIx64",%4d,%4d,%4d\n", video_frame_count, mv->source, mv->w, mv->h, mv->src_x, mv->src_y, - mv->dst_x, mv->dst_y, mv->flags); + mv->dst_x, mv->dst_y, mv->flags, + mv->motion_x, mv->motion_y, mv->motion_scale); } } av_frame_unref(frame); @@ -166,7 +167,7 @@ int main(int argc, char **argv) goto end; } - printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags\n"); + printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags,motion_x,motion_y,motion_scale\n"); /* read frames from the file */ while (av_read_frame(fmt_ctx, pkt) >= 0) { From d2f482965f55736e7abcfab891446481a8371ce2 Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 23 Sep 2022 18:51:32 -0300 Subject: [PATCH 450/590] x86/tx_float: fix some symbol names Should fix compilation on MacOS Signed-off-by: James Almer --- libavutil/x86/tx_float.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 4f4fd720f8..0fbab99e45 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1611,8 +1611,8 @@ cglobal fft_pfa_15xM_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, buf, movaps m13, [mask_mmmmmmpp] ; mmmmmmpp vpermpd m12, m13, q0033 ; ppppmmmm vextractf128 xm11, m13, 1 ; mmpp - movaps m10, [ff_tx_tab_53_float] ; tab5 - movaps xm9, [ff_tx_tab_53_float + 32] ; tab3 + movaps m10, [tab_53_float] ; tab5 + movaps xm9, [tab_53_float + 32] ; tab3 movaps m8, [s15_perm] .dim1: @@ -1838,7 +1838,7 @@ cglobal fft_pfa_15xM_ns_float, 4, 14, 16, 320, ctx, out, in, stride, len, lut, b movsxd lenq, dword [ctxq + AVTXContext.len] mov lutq, [ctxq + AVTXContext.map] - call mangle(fft_pfa_15xM_asm_float) + call mangle(ff_tx_fft_pfa_15xM_asm_float) RET %endif %endmacro From f21899db7dae114e4519c0d14dd047efe022e16b Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 24 Sep 2022 03:51:48 +0200 Subject: [PATCH 451/590] x86/tx_float: enable AVX-only split-radix FFT codelets Sandy Bridge, Ivy Bridge and Bulldozer cores don't support FMA3. --- libavutil/x86/tx_float.asm | 2 ++ libavutil/x86/tx_float_init.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm index 0fbab99e45..5ed0007530 100644 --- a/libavutil/x86/tx_float.asm +++ b/libavutil/x86/tx_float.asm @@ -1379,6 +1379,8 @@ cglobal fft_sr_ns_float, 4, 10, 16, 272, ctx, out, in, tmp, len, lut, itab, rtab %endmacro %if ARCH_X86_64 +FFT_SPLIT_RADIX_FN avx, 0 +FFT_SPLIT_RADIX_FN avx, 1 FFT_SPLIT_RADIX_FN fma3, 0 FFT_SPLIT_RADIX_FN fma3, 1 %if HAVE_AVX2_EXTERNAL diff --git a/libavutil/x86/tx_float_init.c b/libavutil/x86/tx_float_init.c index 20c1ad6869..8e2babb539 100644 --- a/libavutil/x86/tx_float_init.c +++ b/libavutil/x86/tx_float_init.c @@ -38,6 +38,8 @@ TX_DECL_FN(fft32, avx) TX_DECL_FN(fft32_ns, avx) TX_DECL_FN(fft32, fma3) TX_DECL_FN(fft32_ns, fma3) +TX_DECL_FN(fft_sr, avx) +TX_DECL_FN(fft_sr_ns, avx) TX_DECL_FN(fft_sr, fma3) TX_DECL_FN(fft_sr_ns, fma3) TX_DECL_FN(fft_sr, avx2) @@ -57,6 +59,7 @@ TX_DECL_FN(fft16_asm, avx) TX_DECL_FN(fft16_asm, fma3) TX_DECL_FN(fft32_asm, avx) TX_DECL_FN(fft32_asm, fma3) +TX_DECL_FN(fft_sr_asm, avx) TX_DECL_FN(fft_sr_asm, fma3) TX_DECL_FN(fft_sr_asm, avx2) @@ -214,6 +217,11 @@ const FFTXCodelet * const ff_tx_codelet_list_float_x86[] = { AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft32_ns, FFT, 32, 32, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE | FF_TX_PRESHUFFLE, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 256, b8_i2, avx, AVX, 0, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 320, b8_i2, avx, AVX, + AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), + TX_DEF(fft_sr_ns, FFT, 64, 131072, 2, 0, 320, b8_i2, avx, AVX, AV_TX_INPLACE | FF_TX_PRESHUFFLE, + AV_CPU_FLAG_AVXSLOW), TX_DEF(fft_sr, FFT, 64, 131072, 2, 0, 288, b8_i2, fma3, FMA3, 0, AV_CPU_FLAG_AVXSLOW), TX_DEF(fft_sr_asm, FFT, 64, 131072, 2, 0, 352, b8_i2, fma3, FMA3, AV_TX_INPLACE | FF_TX_PRESHUFFLE | FF_TX_ASM_CALL, AV_CPU_FLAG_AVXSLOW), From 3c16f9eb0d2eea9c64d011bca6c52f520d66ec09 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:17:08 +0200 Subject: [PATCH 452/590] avcodec/qoidec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/qoidec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/qoidec.c b/libavcodec/qoidec.c index d218d649de..9414d2fbe9 100644 --- a/libavcodec/qoidec.c +++ b/libavcodec/qoidec.c @@ -28,19 +28,18 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int ret, buf_size = avpkt->size; int width, height, channels, space, run = 0; uint8_t index[64][4] = { 0 }; uint8_t px[4] = { 0, 0, 0, 255 }; GetByteContext gb; uint8_t *dst; uint64_t len; + int ret; - if (buf_size < 20) + if (avpkt->size < 20) return AVERROR_INVALIDDATA; - bytestream2_init(&gb, buf, buf_size); + bytestream2_init(&gb, avpkt->data, avpkt->size); bytestream2_skip(&gb, 4); width = bytestream2_get_be32(&gb); height = bytestream2_get_be32(&gb); @@ -61,6 +60,9 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, default: return AVERROR_INVALIDDATA; } + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0) return ret; @@ -109,7 +111,7 @@ static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p, *got_frame = 1; - return buf_size; + return avpkt->size; } const FFCodec ff_qoi_decoder = { @@ -118,5 +120,6 @@ const FFCodec ff_qoi_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_QOI, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(qoi_decode_frame), }; From cea1e1f261b8d185df7effceedc135cbb6be4681 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:27:28 +0200 Subject: [PATCH 453/590] avcodec/exr: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/exr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index f10754d6ae..6a0af96ce4 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -2121,6 +2121,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, ff_set_sar(s->avctx, av_d2q(av_int2float(s->sar), 255)); + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + s->desc = av_pix_fmt_desc_get(avctx->pix_fmt); if (!s->desc) return AVERROR_INVALIDDATA; @@ -2351,5 +2354,6 @@ const FFCodec ff_exr_decoder = { FF_CODEC_DECODE_CB(decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .p.priv_class = &exr_class, }; From 1e079525d5ae692bc0470bc5f6bcc04b11fc8b1d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:33:45 +0200 Subject: [PATCH 454/590] avcodec/xwddec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/xwddec.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavcodec/xwddec.c b/libavcodec/xwddec.c index cee230a363..6c5bc44a02 100644 --- a/libavcodec/xwddec.c +++ b/libavcodec/xwddec.c @@ -32,8 +32,6 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int i, ret, buf_size = avpkt->size; uint32_t version, header_size, vclass, ncolors; uint32_t xoffset, be, bpp, lsize, rsize; uint32_t pixformat, pixdepth, bunit, bitorder, bpad; @@ -41,11 +39,12 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, uint8_t *ptr; int width, height; GetByteContext gb; + int ret; - if (buf_size < XWD_HEADER_SIZE) + if (avpkt->size < XWD_HEADER_SIZE) return AVERROR_INVALIDDATA; - bytestream2_init(&gb, buf, buf_size); + bytestream2_init(&gb, avpkt->data, avpkt->size); header_size = bytestream2_get_be32u(&gb); version = bytestream2_get_be32u(&gb); @@ -54,7 +53,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, return AVERROR_INVALIDDATA; } - if (buf_size < header_size || header_size < XWD_HEADER_SIZE) { + if (avpkt->size < header_size || header_size < XWD_HEADER_SIZE) { av_log(avctx, AV_LOG_ERROR, "invalid header size\n"); return AVERROR_INVALIDDATA; } @@ -211,6 +210,9 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, return AVERROR_PATCHWELCOME; } + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; @@ -221,8 +223,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, uint32_t *dst = (uint32_t *)p->data[1]; uint8_t red, green, blue; - for (i = 0; i < ncolors; i++) { - + for (int i = 0; i < ncolors; i++) { bytestream2_skipu(&gb, 4); // skip colormap entry number red = bytestream2_get_byteu(&gb); bytestream2_skipu(&gb, 1); @@ -236,7 +237,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, } ptr = p->data[0]; - for (i = 0; i < avctx->height; i++) { + for (int i = 0; i < avctx->height; i++) { bytestream2_get_bufferu(&gb, ptr, rsize); bytestream2_skipu(&gb, lsize - rsize); ptr += p->linesize[0]; @@ -244,7 +245,7 @@ static int xwd_decode_frame(AVCodecContext *avctx, AVFrame *p, *got_frame = 1; - return buf_size; + return avpkt->size; } const FFCodec ff_xwd_decoder = { @@ -253,5 +254,6 @@ const FFCodec ff_xwd_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XWD, .p.capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(xwd_decode_frame), }; From eb9045455d7f4d5696320c92ae378c8221d26f79 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:40:07 +0200 Subject: [PATCH 455/590] avcodec/hdrdec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/hdrdec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c index 7727826e2a..21d3e7f693 100644 --- a/libavcodec/hdrdec.c +++ b/libavcodec/hdrdec.c @@ -88,14 +88,13 @@ static int decompress(uint8_t *scanline, int w, GetByteContext *gb, const uint8_ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int ret, buf_size = avpkt->size; int width = 0, height = 0; GetByteContext gb; uint8_t line[512]; float sar; + int ret; - bytestream2_init(&gb, buf, buf_size); + bytestream2_init(&gb, avpkt->data, avpkt->size); hdr_get_line(&gb, line, sizeof(line)); if (memcmp("#?RADIANCE\n", line, 11)) return AVERROR_INVALIDDATA; @@ -129,6 +128,10 @@ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame *p, return ret; avctx->pix_fmt = AV_PIX_FMT_GBRPF32; + + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0) return ret; @@ -206,7 +209,7 @@ static int hdr_decode_frame(AVCodecContext *avctx, AVFrame *p, *got_frame = 1; - return buf_size; + return avpkt->size; } const FFCodec ff_hdr_decoder = { @@ -215,5 +218,6 @@ const FFCodec ff_hdr_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_RADIANCE_HDR, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(hdr_decode_frame), }; From 08f6b1e5b3bc0c3d133cefb4e856ba83d7a93678 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:42:40 +0200 Subject: [PATCH 456/590] avcodec/xbmdec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/xbmdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index 6a31215329..a0cc1cb8c6 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -82,6 +82,9 @@ static int xbm_decode_frame(AVCodecContext *avctx, AVFrame *p, if ((ret = ff_set_dimensions(avctx, width, height)) < 0) return ret; + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; @@ -141,5 +144,6 @@ const FFCodec ff_xbm_decoder = { .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_XBM, .p.capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(xbm_decode_frame), }; From 3e49c1e07a945b88545381c373dfaf1c1b7c64c3 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 11:54:43 +0200 Subject: [PATCH 457/590] avcodec/xpmdec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/xpmdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c index d0e5d696e7..ff1f51dd32 100644 --- a/libavcodec/xpmdec.c +++ b/libavcodec/xpmdec.c @@ -360,6 +360,9 @@ static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p, if (end - ptr < 1) return AVERROR_INVALIDDATA; + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; @@ -443,5 +446,6 @@ const FFCodec ff_xpm_decoder = { .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(XPMDecContext), .close = xpm_decode_close, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(xpm_decode_frame), }; From a44a540ed16e8cac4612df27c470325740bf5a1d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 12:06:31 +0200 Subject: [PATCH 458/590] avcodec/cri: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/cri.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/cri.c b/libavcodec/cri.c index ec5c88f897..5761152c2d 100644 --- a/libavcodec/cri.c +++ b/libavcodec/cri.c @@ -317,6 +317,9 @@ static int cri_decode_frame(AVCodecContext *avctx, AVFrame *p, if (!s->data || !s->data_size) return AVERROR_INVALIDDATA; + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0) return ret; @@ -432,6 +435,7 @@ const FFCodec ff_cri_decoder = { FF_CODEC_DECODE_CB(cri_decode_frame), .close = cri_decode_close, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, CODEC_LONG_NAME("Cintel RAW"), }; From a54da0831ca347e99f5e8f2050b4f102e3b177d8 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 12:11:45 +0200 Subject: [PATCH 459/590] avcodec/photocd: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/photocd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c index f0e1ef7796..3030a80e0d 100644 --- a/libavcodec/photocd.c +++ b/libavcodec/photocd.c @@ -325,6 +325,9 @@ static int photocd_decode_frame(AVCodecContext *avctx, AVFrame *p, if (ret < 0) return ret; + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0) return ret; @@ -466,5 +469,6 @@ const FFCodec ff_photocd_decoder = { .close = photocd_decode_close, FF_CODEC_DECODE_CB(photocd_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, CODEC_LONG_NAME("Kodak Photo CD"), }; From 2f9fa7e3e9e85c736e6ba87192ec8f32bdf069a7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Thu, 14 Apr 2022 17:57:39 +0200 Subject: [PATCH 460/590] avcodec/mjpegbdec: Don't create unnecessary AVFrame reference MJPEG-B is an intra-codec, so it makes no sense to keep the reference. It is unused lateron anyway. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegbdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c index dfc55d6cf8..98c64b44ca 100644 --- a/libavcodec/mjpegbdec.c +++ b/libavcodec/mjpegbdec.c @@ -142,8 +142,8 @@ static int mjpegb_decode_frame(AVCodecContext *avctx, AVFrame *rframe, return buf_size; } - if ((ret = av_frame_ref(rframe, s->picture_ptr)) < 0) - return ret; + av_frame_move_ref(rframe, s->picture_ptr); + s->got_picture = 0; *got_frame = 1; if (!s->lossless && avctx->debug & FF_DEBUG_QP) { From a166b8a19bb34afc2c6727f20f551fce9a53d6fe Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 30 Aug 2022 17:14:46 +0200 Subject: [PATCH 461/590] avcodec: add FTR audio decoder and parser --- libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/ftr.c | 208 ++++++++++++++++++++++++++++++++++++++++ libavcodec/ftr_parser.c | 107 +++++++++++++++++++++ libavcodec/parsers.c | 1 + libavcodec/utils.c | 1 + libavcodec/version.h | 2 +- libavformat/avidec.c | 1 + libavformat/riff.c | 3 + 11 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 libavcodec/ftr.c create mode 100644 libavcodec/ftr_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b9aa6efaac..14434dc06c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -361,6 +361,7 @@ OBJS-$(CONFIG_FMVC_DECODER) += fmvc.o OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o OBJS-$(CONFIG_FRWU_DECODER) += frwu.o +OBJS-$(CONFIG_FTR_DECODER) += ftr.o OBJS-$(CONFIG_G2M_DECODER) += g2meet.o elsdec.o mjpegdec_common.o OBJS-$(CONFIG_G723_1_DECODER) += g723_1dec.o g723_1.o \ acelp_vectors.o celp_filters.o celp_math.o @@ -1133,6 +1134,7 @@ OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o +OBJS-$(CONFIG_FTR_PARSER) += ftr_parser.o OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o OBJS-$(CONFIG_G729_PARSER) += g729_parser.o OBJS-$(CONFIG_GIF_PARSER) += gif_parser.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index fc88e25fda..3454823a05 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -468,6 +468,7 @@ extern const FFCodec ff_fastaudio_decoder; extern const FFCodec ff_ffwavesynth_decoder; extern const FFCodec ff_flac_encoder; extern const FFCodec ff_flac_decoder; +extern const FFCodec ff_ftr_decoder; extern const FFCodec ff_g723_1_encoder; extern const FFCodec ff_g723_1_decoder; extern const FFCodec ff_g729_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index e8e1529401..ee47489b75 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -3311,6 +3311,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Marian's A-pac audio"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, + { + .id = AV_CODEC_ID_FTR, + .type = AVMEDIA_TYPE_AUDIO, + .name = "ftr", + .long_name = NULL_IF_CONFIG_SMALL("FTR Voice"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, /* subtitle codecs */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 9c01ea9750..a0a720f9ff 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -530,6 +530,7 @@ enum AVCodecID { AV_CODEC_ID_BONK, AV_CODEC_ID_MISC4, AV_CODEC_ID_APAC, + AV_CODEC_ID_FTR, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/ftr.c b/libavcodec/ftr.c new file mode 100644 index 0000000000..277b9be5b8 --- /dev/null +++ b/libavcodec/ftr.c @@ -0,0 +1,208 @@ +/* + * 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 "adts_header.h" +#include "avcodec.h" +#include "codec_internal.h" +#include "get_bits.h" +#include "decode.h" + +typedef struct FTRContext { + AVCodecContext *aac_avctx[64]; // wrapper context for AAC + int nb_context; + AVPacket *packet; + AVFrame *frame; +} FTRContext; + +static av_cold int ftr_init(AVCodecContext *avctx) +{ + FTRContext *s = avctx->priv_data; + const AVCodec *codec; + int ret; + + if (avctx->ch_layout.nb_channels > 64 || + avctx->ch_layout.nb_channels <= 0) + return AVERROR(ENOTSUP); + + s->packet = av_packet_alloc(); + if (!s->packet) + return AVERROR(ENOMEM); + + s->frame = av_frame_alloc(); + if (!s->frame) + return AVERROR(ENOMEM); + + s->nb_context = avctx->ch_layout.nb_channels; + + codec = avcodec_find_decoder(AV_CODEC_ID_AAC); + if (!codec) + return AVERROR_BUG; + + for (int i = 0; i < s->nb_context; i++) { + s->aac_avctx[i] = avcodec_alloc_context3(codec); + if (!s->aac_avctx[i]) + return AVERROR(ENOMEM); + ret = avcodec_open2(s->aac_avctx[i], codec, NULL); + if (ret < 0) + return ret; + } + + avctx->sample_fmt = s->aac_avctx[0]->sample_fmt; + if (!av_sample_fmt_is_planar(avctx->sample_fmt)) + return AVERROR(EINVAL); + + return 0; +} + +static int ftr_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt) +{ + FTRContext *s = avctx->priv_data; + GetBitContext gb; + int ret, ch_offset = 0; + + ret = init_get_bits8(&gb, avpkt->data, avpkt->size); + if (ret < 0) + return ret; + + frame->nb_samples = 0; + + for (int i = 0; i < s->nb_context; i++) { + AVCodecContext *codec_avctx = s->aac_avctx[i]; + GetBitContext gb2 = gb; + AACADTSHeaderInfo hdr_info; + int size; + + if (get_bits_left(&gb) < 64) + return AVERROR_INVALIDDATA; + + memset(&hdr_info, 0, sizeof(hdr_info)); + + size = ff_adts_header_parse(&gb2, &hdr_info); + if (size <= 0 || size * 8 > get_bits_left(&gb)) + return AVERROR_INVALIDDATA; + + if (size > s->packet->size) { + ret = av_grow_packet(s->packet, size - s->packet->size); + if (ret < 0) + return ret; + } + + ret = av_packet_make_writable(s->packet); + if (ret < 0) + return ret; + + memcpy(s->packet->data, avpkt->data + (get_bits_count(&gb) >> 3), size); + s->packet->size = size; + + if (size > 12) { + uint8_t *buf = s->packet->data; + + if (buf[3] & 0x20) { + int tmp = buf[8]; + buf[ 9] = ~buf[9]; + buf[11] = ~buf[11]; + buf[12] = ~buf[12]; + buf[ 8] = ~buf[10]; + buf[10] = ~tmp; + } + } + + ret = avcodec_send_packet(codec_avctx, s->packet); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n"); + return ret; + } + + ret = avcodec_receive_frame(codec_avctx, s->frame); + if (ret < 0) + return ret; + + if (!avctx->sample_rate) { + avctx->sample_rate = codec_avctx->sample_rate; + } else { + if (avctx->sample_rate != codec_avctx->sample_rate) + return AVERROR_INVALIDDATA; + } + + if (!frame->nb_samples) { + frame->nb_samples = s->frame->nb_samples; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) + return ret; + } else { + if (frame->nb_samples != s->frame->nb_samples) + return AVERROR_INVALIDDATA; + } + + skip_bits_long(&gb, size * 8); + + if (ch_offset + s->frame->ch_layout.nb_channels > avctx->ch_layout.nb_channels) + return AVERROR_INVALIDDATA; + + if (avctx->sample_fmt != codec_avctx->sample_fmt) + return AVERROR_INVALIDDATA; + + for (int ch = 0; ch < s->frame->ch_layout.nb_channels; ch++) + memcpy(frame->extended_data[ch_offset + ch], + s->frame->extended_data[ch], + av_get_bytes_per_sample(codec_avctx->sample_fmt) * s->frame->nb_samples); + + ch_offset += s->frame->ch_layout.nb_channels; + + if (ch_offset >= avctx->ch_layout.nb_channels) + break; + } + + *got_frame = 1; + + return get_bits_count(&gb) >> 3; +} + +static void ftr_flush(AVCodecContext *avctx) +{ + FTRContext *s = avctx->priv_data; + + for (int i = 0; i < s->nb_context; i++) + avcodec_flush_buffers(s->aac_avctx[i]); +} + +static av_cold int ftr_close(AVCodecContext *avctx) +{ + FTRContext *s = avctx->priv_data; + + for (int i = 0; i < s->nb_context; i++) + avcodec_free_context(&s->aac_avctx[i]); + av_packet_free(&s->packet); + av_frame_free(&s->frame); + + return 0; +} + +const FFCodec ff_ftr_decoder = { + .p.name = "ftr", + .p.long_name = NULL_IF_CONFIG_SMALL("FTR Voice"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_FTR, + .init = ftr_init, + FF_CODEC_DECODE_CB(ftr_decode_frame), + .close = ftr_close, + .flush = ftr_flush, + .priv_data_size = sizeof(FTRContext), + .p.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +}; diff --git a/libavcodec/ftr_parser.c b/libavcodec/ftr_parser.c new file mode 100644 index 0000000000..05e6cfed98 --- /dev/null +++ b/libavcodec/ftr_parser.c @@ -0,0 +1,107 @@ +/* + * FTR parser + * Copyright (c) 2022 Paul B Mahol + * + * 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 + */ + +/** + * @file + * FTR parser + */ + +#include "parser.h" +#include "get_bits.h" +#include "adts_header.h" +#include "adts_parser.h" +#include "mpeg4audio.h" + +typedef struct FTRParseContext { + ParseContext pc; + int skip; + int split; + int frame_index; +} FTRParseContext; + +static int ftr_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ + uint8_t tmp[8 + AV_INPUT_BUFFER_PADDING_SIZE]; + FTRParseContext *ftr = s->priv_data; + uint64_t state = ftr->pc.state64; + int next = END_NOT_FOUND; + GetBitContext bits; + AACADTSHeaderInfo hdr; + int size; + + *poutbuf_size = 0; + *poutbuf = NULL; + + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { + for (int i = 0; i < buf_size; i++) { + if (ftr->skip > 0) { + ftr->skip--; + if (ftr->skip == 0 && ftr->split) { + ftr->split = 0; + next = i; + s->duration = 1024; + s->key_frame = 1; + break; + } else if (ftr->skip > 0) { + continue; + } + } + + state = (state << 8) | buf[i]; + AV_WB64(tmp, state); + init_get_bits(&bits, tmp + 8 - AV_AAC_ADTS_HEADER_SIZE, + AV_AAC_ADTS_HEADER_SIZE * 8); + + if ((size = ff_adts_header_parse(&bits, &hdr)) > 0) { + ftr->skip = size - 6; + ftr->frame_index += ff_mpeg4audio_channels[hdr.chan_config]; + if (ftr->frame_index >= avctx->ch_layout.nb_channels) { + ftr->frame_index = 0; + ftr->split = 1; + } + } + } + + ftr->pc.state64 = state; + + if (ff_combine_frame(&ftr->pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } + } + + *poutbuf = buf; + *poutbuf_size = buf_size; + + return next; +} + +const AVCodecParser ff_ftr_parser = { + .codec_ids = { AV_CODEC_ID_FTR }, + .priv_data_size = sizeof(FTRParseContext), + .parser_parse = ftr_parse, + .parser_close = ff_parse_close, +}; diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index bcba94ca69..d355808018 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -42,6 +42,7 @@ extern const AVCodecParser ff_dvbsub_parser; extern const AVCodecParser ff_dvdsub_parser; extern const AVCodecParser ff_dvd_nav_parser; extern const AVCodecParser ff_flac_parser; +extern const AVCodecParser ff_ftr_parser; extern const AVCodecParser ff_g723_1_parser; extern const AVCodecParser ff_g729_parser; extern const AVCodecParser ff_gif_parser; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index ba64aaf32d..18c7a1be14 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -639,6 +639,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, case AV_CODEC_ID_MP2: case AV_CODEC_ID_MUSEPACK7: return 1152; case AV_CODEC_ID_AC3: return 1536; + case AV_CODEC_ID_FTR: return 1024; } if (sr > 0) { diff --git a/libavcodec/version.h b/libavcodec/version.h index a3441795e0..e973bb1c4d 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 45 +#define LIBAVCODEC_VERSION_MINOR 46 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 910a4e8792..7a3fad6392 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -923,6 +923,7 @@ static int avi_read_header(AVFormatContext *s) ast->dshow_block_align = 0; } if ((st->codecpar->codec_id == AV_CODEC_ID_AAC || + st->codecpar->codec_id == AV_CODEC_ID_FTR || st->codecpar->codec_id == AV_CODEC_ID_FLAC || st->codecpar->codec_id == AV_CODEC_ID_MP2 ) && ast->dshow_block_align <= 4 && ast->dshow_block_align) { av_log(s, AV_LOG_DEBUG, "overriding invalid dshow_block_align of %d\n", ast->dshow_block_align); diff --git a/libavformat/riff.c b/libavformat/riff.c index 5114114364..0d3f322545 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -558,6 +558,7 @@ const AVCodecTag ff_codec_wav_tags[] = { { AV_CODEC_ID_WMALOSSLESS, 0x0163 }, { AV_CODEC_ID_XMA1, 0x0165 }, { AV_CODEC_ID_XMA2, 0x0166 }, + { AV_CODEC_ID_FTR, 0x0180 }, { AV_CODEC_ID_ADPCM_CT, 0x0200 }, { AV_CODEC_ID_DVAUDIO, 0x0215 }, { AV_CODEC_ID_DVAUDIO, 0x0216 }, @@ -584,8 +585,10 @@ const AVCodecTag ff_codec_wav_tags[] = { { AV_CODEC_ID_PCM_MULAW, 0x6c75 }, { AV_CODEC_ID_AAC, 0x706d }, { AV_CODEC_ID_AAC, 0x4143 }, + { AV_CODEC_ID_FTR, 0x4180 }, { AV_CODEC_ID_XAN_DPCM, 0x594a }, { AV_CODEC_ID_G729, 0x729A }, + { AV_CODEC_ID_FTR, 0x8180 }, { AV_CODEC_ID_G723_1, 0xA100 }, /* Comverse Infosys Ltd. G723 1 */ { AV_CODEC_ID_AAC, 0xA106 }, { AV_CODEC_ID_SPEEX, 0xA109 }, From 257eea3db44bb4862b0fa56e12f5627cb3f8fed4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 24 Sep 2022 14:00:09 +0200 Subject: [PATCH 462/590] doc: mention new audio formats --- doc/general_contents.texi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/general_contents.texi b/doc/general_contents.texi index a632b23f6f..b005cb6c3e 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -584,8 +584,10 @@ library: @item raw AC-3 @tab X @tab X @item raw AMR-NB @tab @tab X @item raw AMR-WB @tab @tab X +@item raw APAC @tab @tab X @item raw aptX @tab X @tab X @item raw aptX HD @tab X @tab X +@item raw Bonk @tab @tab X @item raw Chinese AVS video @tab X @tab X @item raw DFPWM @tab X @tab X @item raw Dirac @tab X @tab X @@ -1207,6 +1209,7 @@ following image formats are supported: @item ATRAC9 @tab @tab X @item Bink Audio @tab @tab X @tab Used in Bink and Smacker files in many games. +@item Bonk audio @tab @tab X @item CELT @tab @tab E @tab decoding supported through external library libcelt @item codec2 @tab E @tab E @@ -1245,6 +1248,7 @@ following image formats are supported: @item Enhanced AC-3 @tab X @tab X @item EVRC (Enhanced Variable Rate Codec) @tab @tab X @item FLAC (Free Lossless Audio Codec) @tab X @tab IX +@item FTR Voice @tab @tab X @item G.723.1 @tab X @tab X @item G.729 @tab @tab X @item GSM @tab E @tab X @@ -1258,6 +1262,7 @@ following image formats are supported: @item Interplay ACM @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X +@item Marian's A-pac audio @tab @tab X @item MI-SC4 (Micronas SC-4 Audio) @tab @tab X @item MLP (Meridian Lossless Packing) @tab X @tab X @tab Used in DVD-Audio discs. From aa79d13f51aa820c7e5f07784a2512434e68bc46 Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 21 Sep 2022 00:01:40 -0300 Subject: [PATCH 463/590] avformat/cafenc: derive Opus frame size from the relevant stream parameters Use the stream duration as last resort, as an off-by-one result of the "st->duration / (caf->packets - 1)" calculation can break playback on some devices. Also, don't write the sample_rate value propagated by encoders like libopus. The sample rate of the audio fed to it is irrelevant after being encoded. Fixes ticket #9930. Signed-off-by: James Almer --- libavformat/cafenc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c index fedb430b17..b90811d46f 100644 --- a/libavformat/cafenc.c +++ b/libavformat/cafenc.c @@ -53,7 +53,11 @@ static uint32_t codec_flags(enum AVCodecID codec_id) { } } -static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int block_align) { +static uint32_t samples_per_packet(const AVCodecParameters *par) { + enum AVCodecID codec_id = par->codec_id; + int channels = par->ch_layout.nb_channels, block_align = par->block_align; + int frame_size = par->frame_size, sample_rate = par->sample_rate; + switch (codec_id) { case AV_CODEC_ID_PCM_S8: case AV_CODEC_ID_PCM_S16LE: @@ -83,6 +87,8 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int bl return 320; case AV_CODEC_ID_MP1: return 384; + case AV_CODEC_ID_OPUS: + return frame_size * 48000 / sample_rate; case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP3: return 1152; @@ -110,7 +116,7 @@ static int caf_write_header(AVFormatContext *s) AVDictionaryEntry *t = NULL; unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, par->codec_id); int64_t chunk_size = 0; - int frame_size = par->frame_size; + int frame_size = par->frame_size, sample_rate = par->sample_rate; if (s->nb_streams != 1) { av_log(s, AV_LOG_ERROR, "CAF files have exactly one stream\n"); @@ -139,7 +145,10 @@ static int caf_write_header(AVFormatContext *s) } if (par->codec_id != AV_CODEC_ID_MP3 || frame_size != 576) - frame_size = samples_per_packet(par->codec_id, par->ch_layout.nb_channels, par->block_align); + frame_size = samples_per_packet(par); + + if (par->codec_id == AV_CODEC_ID_OPUS) + sample_rate = 48000; ffio_wfourcc(pb, "caff"); //< mFileType avio_wb16(pb, 1); //< mFileVersion @@ -147,7 +156,7 @@ static int caf_write_header(AVFormatContext *s) ffio_wfourcc(pb, "desc"); //< Audio Description chunk avio_wb64(pb, 32); //< mChunkSize - avio_wb64(pb, av_double2int(par->sample_rate)); //< mSampleRate + avio_wb64(pb, av_double2int(sample_rate)); //< mSampleRate avio_wl32(pb, codec_tag); //< mFormatID avio_wb32(pb, codec_flags(par->codec_id)); //< mFormatFlags avio_wb32(pb, par->block_align); //< mBytesPerPacket @@ -248,7 +257,7 @@ static int caf_write_trailer(AVFormatContext *s) avio_seek(pb, caf->data, SEEK_SET); avio_wb64(pb, file_size - caf->data - 8); if (!par->block_align) { - int packet_size = samples_per_packet(par->codec_id, par->ch_layout.nb_channels, par->block_align); + int packet_size = samples_per_packet(par); if (!packet_size) { packet_size = st->duration / (caf->packets - 1); avio_seek(pb, FRAME_SIZE_OFFSET, SEEK_SET); From 1b47190c94317d0d1bb5c60a43005ed78b4808a2 Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 23 Sep 2022 16:43:00 -0300 Subject: [PATCH 464/590] avcodec/opusdec: stop setting deprecated swr options Signed-off-by: James Almer --- libavcodec/opusdec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/opusdec.c b/libavcodec/opusdec.c index c04aa598b8..d255486d06 100644 --- a/libavcodec/opusdec.c +++ b/libavcodec/opusdec.c @@ -640,7 +640,7 @@ static av_cold int opus_decode_init(AVCodecContext *avctx) for (i = 0; i < c->nb_streams; i++) { OpusStreamContext *s = &c->streams[i]; - uint64_t layout; + AVChannelLayout layout; s->output_channels = (i < c->nb_stereo_streams) ? 2 : 1; @@ -658,11 +658,12 @@ static av_cold int opus_decode_init(AVCodecContext *avctx) if (!s->swr) return AVERROR(ENOMEM); - layout = (s->output_channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; + layout = (s->output_channels == 1) ? (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO : + (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; av_opt_set_int(s->swr, "in_sample_fmt", avctx->sample_fmt, 0); av_opt_set_int(s->swr, "out_sample_fmt", avctx->sample_fmt, 0); - av_opt_set_int(s->swr, "in_channel_layout", layout, 0); - av_opt_set_int(s->swr, "out_channel_layout", layout, 0); + av_opt_set_chlayout(s->swr, "in_chlayout", &layout, 0); + av_opt_set_chlayout(s->swr, "out_chlayout", &layout, 0); av_opt_set_int(s->swr, "out_sample_rate", avctx->sample_rate, 0); av_opt_set_int(s->swr, "filter_size", 16, 0); From d0349c9929e2891c90011a83152624d5cf18e628 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 21:19:53 +0200 Subject: [PATCH 465/590] avformat/ape: Check frames size Fixes: signed integer overflow: 9223372036854775806 + 3 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APE_fuzzer-6389264140599296 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/ape.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/ape.c b/libavformat/ape.c index f904fde178..92e9ac7cb1 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -298,6 +298,8 @@ static int ape_read_header(AVFormatContext * s) ape->frames[i].pos -= ape->frames[i].skip; ape->frames[i].size += ape->frames[i].skip; } + if (ape->frames[i].size > INT_MAX - 3) + return AVERROR_INVALIDDATA; ape->frames[i].size = (ape->frames[i].size + 3) & ~3; } if (ape->fileversion < 3810) { From 5b23cab5c769d6611a3fe111546d65809046a4d8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 21:24:49 +0200 Subject: [PATCH 466/590] avformat/apm: Use 64bit for bit_rate computation Fixes: signed integer overflow: -1155522528 * 4 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_APM_fuzzer-6580670570299392 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/apm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/apm.c b/libavformat/apm.c index baf7d2f941..a3ddc08e83 100644 --- a/libavformat/apm.c +++ b/libavformat/apm.c @@ -148,7 +148,7 @@ static int apm_read_header(AVFormatContext *s) par->codec_id = AV_CODEC_ID_ADPCM_IMA_APM; par->format = AV_SAMPLE_FMT_S16; par->bit_rate = par->ch_layout.nb_channels * - par->sample_rate * + (int64_t)par->sample_rate * par->bits_per_coded_sample; if ((ret = avio_read(s->pb, buf, APM_FILE_EXTRADATA_SIZE)) < 0) From 736e9e69d5dbbe1d81885dfef59917eb915d2f96 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 21:30:55 +0200 Subject: [PATCH 467/590] avformat/asfdec_o: Limit packet offset avoids overflows with it Fixes: signed integer overflow: 9223372036846866010 + 4294967047 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-6538296768987136 Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-657169555665715 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/asfdec_o.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index 48b7d17322..e837ca62e7 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -1242,6 +1242,8 @@ static int asf_read_packet_header(AVFormatContext *s) unsigned char error_flags, len_flags, pay_flags; asf->packet_offset = avio_tell(pb); + if (asf->packet_offset > INT64_MAX/2) + asf->packet_offset = 0; error_flags = avio_r8(pb); // read Error Correction Flags if (error_flags & ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT) { if (!(error_flags & ASF_ERROR_CORRECTION_LENGTH_TYPE)) { From d4bb4e375975dc0d31d5309106cf6ee0ed75140f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 21:48:43 +0200 Subject: [PATCH 468/590] avformat/cafdec: Check that nb_frasmes fits within 64bit Fixes: signed integer overflow: 1099511693312 * 538976288 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6565048815845376 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/cafdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index d5b8c38c25..e0a9031cb8 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -387,7 +387,7 @@ static int read_header(AVFormatContext *s) found_data: if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) { - if (caf->data_size > 0) + if (caf->data_size > 0 && caf->data_size / caf->bytes_per_packet < INT64_MAX / caf->frames_per_packet) st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet; } else if (ffstream(st)->nb_index_entries && st->duration > 0) { if (st->codecpar->sample_rate && caf->data_size / st->duration > INT64_MAX / st->codecpar->sample_rate / 8) { From 10453f5192869b63b071aee3962ae2c712f9bfd3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 21:54:31 +0200 Subject: [PATCH 469/590] avformat/dhav: Use 64bit seek_back Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-6604736532447232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/dhav.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dhav.c b/libavformat/dhav.c index 9d26efe8fc..4e720f2a26 100644 --- a/libavformat/dhav.c +++ b/libavformat/dhav.c @@ -242,7 +242,7 @@ static int64_t get_duration(AVFormatContext *s) avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET); while (avio_tell(s->pb) > 12 && max_interations--) { if (avio_rl32(s->pb) == MKTAG('d','h','a','v')) { - int seek_back = avio_rl32(s->pb); + int64_t seek_back = avio_rl32(s->pb); avio_seek(s->pb, -seek_back, SEEK_CUR); read_chunk(s); From 93db0f0740cacd64ae07b5e8606b70021e48d364 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 22:40:47 +0200 Subject: [PATCH 470/590] avformat/dxa: avoid bpc overflows Fixes: signed integer overflow: 2147483647 + 32 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-6639823726706688 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/dxa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/dxa.c b/libavformat/dxa.c index 16fbb08156..474b85270a 100644 --- a/libavformat/dxa.c +++ b/libavformat/dxa.c @@ -118,9 +118,12 @@ static int dxa_read_header(AVFormatContext *s) if(tag == MKTAG('d', 'a', 't', 'a')) break; avio_skip(pb, fsize); } - c->bpc = (fsize + c->frames - 1) / c->frames; - if(ast->codecpar->block_align) + c->bpc = (fsize + (int64_t)c->frames - 1) / c->frames; + if(ast->codecpar->block_align) { + if (c->bpc > INT_MAX - ast->codecpar->block_align + 1) + return AVERROR_INVALIDDATA; c->bpc = ((c->bpc + ast->codecpar->block_align - 1) / ast->codecpar->block_align) * ast->codecpar->block_align; + } c->bytes_left = fsize; c->wavpos = avio_tell(pb); avio_seek(pb, c->vidpos, SEEK_SET); From 0345a885455dea52fcc570b97f5dc5c75372a39c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 22:46:35 +0200 Subject: [PATCH 471/590] avformat/genh: Check nb_channels for IMA ADPCM The check could be made more strict Fixes: signed integer overflow: 36 * 538976288 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-6539389873815552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/genh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/genh.c b/libavformat/genh.c index a25d4d625a..1f707b5555 100644 --- a/libavformat/genh.c +++ b/libavformat/genh.c @@ -78,6 +78,8 @@ static int genh_read_header(AVFormatContext *s) case 0: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break; case 1: case 11: st->codecpar->bits_per_coded_sample = 4; + if (st->codecpar->ch_layout.nb_channels > INT_MAX / 36) + return AVERROR_INVALIDDATA; st->codecpar->block_align = 36 * st->codecpar->ch_layout.nb_channels; st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV; break; case 2: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK; break; From b1a68127bbcd3d638363fa0249982c494e87c9e2 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 17 Sep 2022 22:55:24 +0200 Subject: [PATCH 472/590] avformat/jacosubdec: Fix overflow in get_shift() Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-6722544461283328 Fixes: signed integer overflow: 48214448 * 60 cannot be represented in type 'int' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/jacosubdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 0ee4820f62..61b1316dc9 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -144,7 +144,7 @@ static int get_shift(int timeres, const char *buf) ret = 0; switch (n) { case 4: - ret = sign * (((int64_t)a*3600 + b*60 + c) * timeres + d); + ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d); break; case 3: ret = sign * (( (int64_t)a*60 + b) * timeres + c); From 7124f10c1d521096042ba3c9c519828147f78c46 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 13:38:21 +0200 Subject: [PATCH 473/590] avformat/flvdec: Use 64bit for sum_flv_tag_size Fixes: signed integer overflow: 2138820085 + 16130322 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6704728165187584 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/flvdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 7f9d795044..d83edff727 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -66,7 +66,7 @@ typedef struct FLVContext { uint8_t resync_buffer[2*RESYNC_BUFFER_SIZE]; int broken_sizes; - int sum_flv_tag_size; + int64_t sum_flv_tag_size; int last_keyframe_stream_index; int keyframe_count; @@ -1032,7 +1032,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) type = (avio_r8(s->pb) & 0x1F); orig_size = size = avio_rb24(s->pb); - flv->sum_flv_tag_size += size + 11; + flv->sum_flv_tag_size += size + 11LL; dts = avio_rb24(s->pb); dts |= (unsigned)avio_r8(s->pb) << 24; av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb)); @@ -1332,7 +1332,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) !avio_feof(s->pb) && (last != orig_size || !last) && last != flv->sum_flv_tag_size && !flv->broken_sizes) { - av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %d\n", last, orig_size + 11, flv->sum_flv_tag_size); + av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size); avio_seek(s->pb, pos + 1, SEEK_SET); ret = resync(s); av_packet_unref(pkt); From 2c146406eac06f3d3cd3d981c29e7affd834cb4d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 14:47:25 +0200 Subject: [PATCH 474/590] avformat/nutdec: Check fields Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6566001610719232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/nutdec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 8cc56615ad..24dedc4758 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -245,6 +245,11 @@ static int decode_main_header(NUTContext *nut) for (i = 0; i < 256;) { int tmp_flags = ffio_read_varlen(bc); int tmp_fields = ffio_read_varlen(bc); + if (tmp_fields < 0) { + av_log(s, AV_LOG_ERROR, "fields %d is invalid\n", tmp_fields); + ret = AVERROR_INVALIDDATA; + goto fail; + } if (tmp_fields > 0) tmp_pts = get_s(bc); From 2cb7ee8a36bddd3425897135db514ca62fec6e44 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 15:06:25 +0200 Subject: [PATCH 475/590] avformat/rmdec: check tag_size Fixes: signed integer overflow: -2147483648 - 8 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-6598073725353984 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/rmdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 881d7002ad..0f1534b582 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -563,6 +563,8 @@ static int rm_read_header(AVFormatContext *s) } tag_size = avio_rb32(pb); + if (tag_size < 0) + return AVERROR_INVALIDDATA; avio_skip(pb, tag_size - 8); for(;;) { From 981f5e46afa3673dfa43eb2bf5017680d5df25dd Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 16:29:37 +0200 Subject: [PATCH 476/590] avformat/sbgdec: clamp end_ts Fixes: signed integer overflow: 9223372036851135042 + 15666854 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6573717339111424 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/sbgdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index 8a6d679056..4cd12347e7 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -1478,7 +1478,7 @@ static int sbg_read_packet(AVFormatContext *avf, AVPacket *packet) int ret; ts = ffstream(avf->streams[0])->cur_dts; - end_ts = ts + avf->streams[0]->codecpar->frame_size; + end_ts = av_sat_add64(ts, avf->streams[0]->codecpar->frame_size); if (avf->streams[0]->duration != AV_NOPTS_VALUE) end_ts = FFMIN(avf->streams[0]->start_time + avf->streams[0]->duration, end_ts); From 5f529e9147a5c5c8ecf8d5ef0dd569194ce30eed Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 16:35:41 +0200 Subject: [PATCH 477/590] avformat/sbgdec: Check ts_int in genrate_intervals There is probably a better place to check for this, but better here than nowhere Fixes: signed integer overflow: -9223372036824775808 - 86400000000 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6601162580688896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/sbgdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index 4cd12347e7..5edb9664cc 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -1317,6 +1317,8 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate, /* Pseudo event before the first one */ ev0 = s->events[s->nb_events - 1]; + if (av_sat_sub64(ev0.ts_int, period) != (uint64_t)ev0.ts_int - period) + return AVERROR_INVALIDDATA; ev0.ts_int -= period; ev0.ts_trans -= period; ev0.ts_next -= period; From aa8eb1bed075931b0ce0a8bc9a8ff5882830044c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 16:42:21 +0200 Subject: [PATCH 478/590] avformat/sdsdec: Use av_rescale() to avoid intermediate overflow in duration calculation Fixes: signed integer overflow: 72128794995445727 * 240 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_SDS_fuzzer-6628185583779840 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/sdsdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/sdsdec.c b/libavformat/sdsdec.c index f98096dca9..d296500bec 100644 --- a/libavformat/sdsdec.c +++ b/libavformat/sdsdec.c @@ -112,7 +112,7 @@ static int sds_read_header(AVFormatContext *ctx) st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->ch_layout.nb_channels = 1; st->codecpar->sample_rate = sample_period ? 1000000000 / sample_period : 16000; - st->duration = (avio_size(pb) - 21) / (127) * s->size / 4; + st->duration = av_rescale((avio_size(pb) - 21) / 127, s->size, 4); avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); From 2c789f753c3657be9041307f9c03749f5ba5a6bb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 16:45:30 +0200 Subject: [PATCH 479/590] avformat/xwma: Use av_rescale() for duration computation Fixes: signed integer overflow: 34242363648 * 538976288 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6577923913547776 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/xwma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/xwma.c b/libavformat/xwma.c index c16ff1be63..12689f37fd 100644 --- a/libavformat/xwma.c +++ b/libavformat/xwma.c @@ -278,7 +278,7 @@ static int xwma_read_header(AVFormatContext *s) * the total duration using the average bits per sample and the * total data length. */ - st->duration = (size<<3) * st->codecpar->sample_rate / st->codecpar->bit_rate; + st->duration = av_rescale((size<<3), st->codecpar->sample_rate, st->codecpar->bit_rate); } fail: From 529f64b2eb98e0c3ae4944abd5d01fa7c1def047 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 16:49:26 +0200 Subject: [PATCH 480/590] avformat/rpl: Use 64bit for duration computation Fixes: signed integer overflow: 24709512 * 88 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6737973728641024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/rpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/rpl.c b/libavformat/rpl.c index d025589bfc..3ef6fda386 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -279,7 +279,7 @@ static int rpl_read_header(AVFormatContext *s) error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite if (vst) { error |= read_line(pb, line, sizeof(line)); // offset to key frame list - vst->duration = number_of_chunks * rpl->frames_per_chunk; + vst->duration = number_of_chunks * (int64_t)rpl->frames_per_chunk; } // Read the index From 4075f0cec1830a7ac081b1a23bd3f5c4e266fe26 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 18:12:11 +0200 Subject: [PATCH 481/590] avformat/spdifdec: Use 64bit to compute bit rate Fixes: signed integer overflow: 32 * 553590816 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-6564974517944320 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/spdifdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c index 2af75ca9db..672133581a 100644 --- a/libavformat/spdifdec.c +++ b/libavformat/spdifdec.c @@ -226,7 +226,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) if (!s->bit_rate && s->streams[0]->codecpar->sample_rate) /* stream bitrate matches 16-bit stereo PCM bitrate for currently supported codecs */ - s->bit_rate = 2 * 16 * s->streams[0]->codecpar->sample_rate; + s->bit_rate = 2 * 16LL * s->streams[0]->codecpar->sample_rate; return 0; } From aa441ac105328965bb3b7a7a19571fc6446e544b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Sep 2022 18:35:19 +0200 Subject: [PATCH 482/590] avformat/matroskadec: Error out if a timestamp is beyond duration Maybe timestamp / duration validity should be checked earlier Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6586894739177472 Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/matroskadec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 16a3e93611..8b079e1110 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -4009,7 +4009,8 @@ typedef struct { /* This function searches all the Cues and returns the CueDesc corresponding to * the timestamp ts. Returned CueDesc will be such that start_time_ns <= ts < - * end_time_ns. All 4 fields will be set to -1 if ts >= file's duration. + * end_time_ns. All 4 fields will be set to -1 if ts >= file's duration or + * if an error occurred. */ static CueDesc get_cue_desc(AVFormatContext *s, int64_t ts, int64_t cues_start) { MatroskaDemuxContext *matroska = s->priv_data; @@ -4028,6 +4029,8 @@ static CueDesc get_cue_desc(AVFormatContext *s, int64_t ts, int64_t cues_start) } } --i; + if (index_entries[i].timestamp > matroska->duration) + return (CueDesc) {-1, -1, -1, -1}; cue_desc.start_time_ns = index_entries[i].timestamp * matroska->time_scale; cue_desc.start_offset = index_entries[i].pos - matroska->segment_start; if (i != nb_index_entries - 1) { From 8008940da5aa43895fd4574114309c3324249eab Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 10 Sep 2022 23:49:28 +0200 Subject: [PATCH 483/590] avcodec/dstdec: Check for overflow in build_filter() Fixes: signed integer overflow: 1917019860 + 265558963 cannot be represented in type 'int' Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-4833165046317056 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/dstdec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/dstdec.c b/libavcodec/dstdec.c index 6bdd6c885c..4b1762db33 100644 --- a/libavcodec/dstdec.c +++ b/libavcodec/dstdec.c @@ -215,7 +215,7 @@ static uint8_t prob_dst_x_bit(int c) return (ff_reverse[c & 127] >> 1) + 1; } -static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets) +static int build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table *fsets) { int i, j, k, l; @@ -226,14 +226,17 @@ static void build_filter(int16_t table[DST_MAX_ELEMENTS][16][256], const Table * int total = av_clip(length - j * 8, 0, 8); for (k = 0; k < 256; k++) { - int v = 0; + int64_t v = 0; for (l = 0; l < total; l++) v += (((k >> l) & 1) * 2 - 1) * fsets->coeff[i][j * 8 + l]; + if ((int16_t)v != v) + return AVERROR_INVALIDDATA; table[i][j][k] = v; } } } + return 0; } static int decode_frame(AVCodecContext *avctx, AVFrame *frame, @@ -328,7 +331,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR_INVALIDDATA; ac_init(ac, gb); - build_filter(s->filter, &s->fsets); + ret = build_filter(s->filter, &s->fsets); + if (ret < 0) + return ret; memset(s->status, 0xAA, sizeof(s->status)); memset(dsd, 0, frame->nb_samples * 4 * channels); From 7cd252ee41ddc693fa140c5b5eb472b6d6f27f9e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 23 Sep 2022 21:57:29 +0200 Subject: [PATCH 484/590] avcodec/parser: Remove declaration of inexistent function Forgotten in e5af9203098a889f36b759652615046254d45102. Signed-off-by: Andreas Rheinhardt --- libavcodec/parser.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/parser.h b/libavcodec/parser.h index ef35547e9b..2cee5ae4ff 100644 --- a/libavcodec/parser.h +++ b/libavcodec/parser.h @@ -45,8 +45,6 @@ typedef struct ParseContext{ * AVERROR(ENOMEM) if there was a memory allocation error */ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size); -int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf, - int buf_size); void ff_parse_close(AVCodecParserContext *s); /** From 7ae1c0dd3ef8038f541716eb283380fd196041ad Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 14:20:07 +0200 Subject: [PATCH 485/590] avcodec/h264_redundant_pps_bsf: Don't remove PPS There is no check for whether these supposedly redundant PPS are actually redundant. One could check via memcmp which would work in practice* (because all content buffers are initially zero-allocated), but this is not portable as compilers may trash padding inside structures as they wish. In case the PPS is not really redundant the output is garbage. This happens with several files from the FATE-suite. E.g. h264-conformance/CVCANLMA2_Sony_C.jsv doesn't decode correctly any more, whereas h264-conformance/CABA3_TOSHIBA_E.264 even fails in ff_cbs_write_packet(), because the inferred value of num_ref_idx_l0_active_minus1 mismatches with the value set in the slice (this happens when num_ref_idx_l0_default_active_minus1 changes in the PPS; the value in the slice header is inferred from the original PPS's num_ref_idx_l0_default_active_minus1). *: Unless slice_group_id is used, i.e. unless slice_group_map_type is six. Signed-off-by: Andreas Rheinhardt --- doc/bitstream_filters.texi | 3 --- libavcodec/h264_redundant_pps_bsf.c | 11 ----------- 2 files changed, 14 deletions(-) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 50c95f035d..c63c20370f 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -382,9 +382,6 @@ This applies a specific fixup to some Blu-ray streams which contain redundant PPSs modifying irrelevant parameters of the stream which confuse other transformations which require correct extradata. -A new single global PPS is created, and all of the redundant PPSs -within the stream are removed. - @section hevc_metadata Modify metadata embedded in an HEVC stream. diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index f8bab1f109..df9a88a705 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -80,26 +80,15 @@ static int h264_redundant_pps_update_fragment(AVBSFContext *bsf, CodedBitstreamFragment *au) { H264RedundantPPSContext *ctx = bsf->priv_data; - int au_has_sps; int err, i; - au_has_sps = 0; for (i = 0; i < au->nb_units; i++) { CodedBitstreamUnit *nal = &au->units[i]; - if (nal->type == H264_NAL_SPS) - au_has_sps = 1; if (nal->type == H264_NAL_PPS) { err = h264_redundant_pps_fixup_pps(ctx, nal); if (err < 0) return err; - if (!au_has_sps) { - av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS " - "at %"PRId64".\n", pkt->pts); - ff_cbs_delete_unit(au, i); - i--; - continue; - } } if (nal->type == H264_NAL_SLICE || nal->type == H264_NAL_IDR_SLICE) { From a7e54196cc94a71c44dd0bd4b91641740a7caf20 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 14:37:38 +0200 Subject: [PATCH 486/590] avcodec/cbs: Only write extradata if there is something to write It is e.g. legal for an ISOBMFF avcc to contain zero parameter sets. In this case the annex B that we produce would be empty and therefore useless. This happens e.g. with mov/frag_overlap.mp4 from the FATE-suite. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 07ae658a4c..8d6e3c3442 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -438,6 +438,10 @@ int ff_cbs_write_extradata(CodedBitstreamContext *ctx, return err; av_freep(&par->extradata); + par->extradata_size = 0; + + if (!frag->data_size) + return 0; par->extradata = av_malloc(frag->data_size + AV_INPUT_BUFFER_PADDING_SIZE); From 843fe314ea30a3b7ccaa165031663292d14a9e02 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 17:23:55 +0200 Subject: [PATCH 487/590] avformat/nutdec: Don't shrink packet size manually It is unnecessary because an av_shrink_packet() a few lines below will set the size; furthermore, it is actually harmful, because av_shrink_packet() does nothing in case the size already matches, so that the packet's padding is not correctly zeroed. Signed-off-by: Andreas Rheinhardt --- libavformat/nutdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 24dedc4758..afa27b827c 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -1132,7 +1132,6 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code) } sm_size = avio_tell(bc) - pkt->pos; size -= sm_size; - pkt->size -= sm_size; } ret = avio_read(bc, pkt->data + nut->header_len[header_idx], size); From 54b29e1656979a6879221c0d2d0b50cc91e43bdc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 20 Sep 2022 17:51:01 +0200 Subject: [PATCH 488/590] fate/cbs: Add tests for h264_redundant_pps BSF This also tests writing slice data in the unaligned mode (some of these files use CAVLC) as well as updating side data as well as parsing ISOBMFF avcc extradata. Signed-off-by: Andreas Rheinhardt --- tests/fate/cbs.mak | 43 ++- tests/ref/fate/h264_redundant_pps-annexb | 307 +++++++++++++++++++ tests/ref/fate/h264_redundant_pps-mov | 115 +++++++ tests/ref/fate/h264_redundant_pps-side_data | 21 ++ tests/ref/fate/h264_redundant_pps-side_data2 | 11 + 5 files changed, 494 insertions(+), 3 deletions(-) create mode 100644 tests/ref/fate/h264_redundant_pps-annexb create mode 100644 tests/ref/fate/h264_redundant_pps-mov create mode 100644 tests/ref/fate/h264_redundant_pps-side_data create mode 100644 tests/ref/fate/h264_redundant_pps-side_data2 diff --git a/tests/fate/cbs.mak b/tests/fate/cbs.mak index 18efa96a61..a93e58ea9f 100644 --- a/tests/fate/cbs.mak +++ b/tests/fate/cbs.mak @@ -1,4 +1,4 @@ -# Read/write tests: this uses the codec metadata filter - with no +# Read/write tests: By default, this uses the codec metadata filters - with no # arguments, it decomposes the stream fully and then recomposes it # without making any changes. @@ -66,8 +66,45 @@ $(foreach N,$(FATE_CBS_H264_CONFORMANCE_SAMPLES),$(eval $(call FATE_CBS_TEST,h26 $(foreach N,$(FATE_CBS_H264_SAMPLES),$(eval $(call FATE_CBS_TEST,h264,$(basename $(N)),h264,h264/$(N),h264))) FATE_CBS_H264-$(call FATE_CBS_DEPS, H264, H264, H264, H264, H264) = $(FATE_CBS_h264) -FATE_SAMPLES_AVCONV += $(FATE_CBS_H264-yes) -fate-cbs-h264: $(FATE_CBS_H264-yes) + + +FATE_H264_REDUNDANT_PPS-$(call REMUX, H264, MOV_DEMUXER H264_REDUNDANT_PPS_BSF \ + H264_DECODER H264_PARSER RAWVIDEO_ENCODER) \ + += fate-h264_redundant_pps-mov +fate-h264_redundant_pps-mov: CMD = transcode \ + mov $(TARGET_SAMPLES)/mov/frag_overlap.mp4 h264 \ + "-map 0:v -c copy -bsf h264_redundant_pps" + +# This file has changing pic_init_qp_minus26. +FATE_H264_REDUNDANT_PPS-$(call REMUX, H264, H264_PARSER H264_REDUNDANT_PPS_BSF \ + H264_DECODER RAWVIDEO_ENCODER) \ + += fate-h264_redundant_pps-annexb +fate-h264_redundant_pps-annexb: CMD = transcode \ + h264 $(TARGET_SAMPLES)/h264-conformance/CABA3_TOSHIBA_E.264 \ + h264 "-map 0:v -c copy -bsf h264_redundant_pps" + +# These two tests test that new extradata in packet side data is properly +# modified by h264_redundant_pps. nut is used as destination container +# because it can store extradata updates (in its experimental mode); +# setting -syncpoints none is a hack to use nut version 4. +FATE_H264_REDUNDANT_PPS-$(call REMUX, NUT, MOV_DEMUXER H264_REDUNDANT_PPS_BSF H264_DECODER) \ + += fate-h264_redundant_pps-side_data +fate-h264_redundant_pps-side_data: CMD = transcode \ + mov $(TARGET_SAMPLES)/h264/thezerotheorem-cut.mp4 nut \ + "-map 0:v -c copy -bsf h264_redundant_pps -syncpoints none -strict experimental" "-c copy" + +FATE_H264_REDUNDANT_PPS-$(call REMUX, NUT, MOV_DEMUXER H264_REDUNDANT_PPS_BSF \ + H264_DECODER SCALE_FILTER RAWVIDEO_ENCODER) \ + += fate-h264_redundant_pps-side_data2 +fate-h264_redundant_pps-side_data2: CMD = transcode \ + mov $(TARGET_SAMPLES)/h264/extradata-reload-multi-stsd.mov nut \ + "-map 0:v -c copy -bsf h264_redundant_pps -syncpoints none -strict experimental" + +fate-h264_redundant_pps: $(FATE_H264_REDUNDANT_PPS-yes) + + +FATE_SAMPLES_FFMPEG += $(FATE_CBS_H264-yes) $(FATE_H264_REDUNDANT_PPS-yes) +fate-cbs-h264: $(FATE_CBS_H264-yes) $(FATE_H264_REDUNDANT_PPS-yes) # H.265 read/write diff --git a/tests/ref/fate/h264_redundant_pps-annexb b/tests/ref/fate/h264_redundant_pps-annexb new file mode 100644 index 0000000000..11d79f8b1f --- /dev/null +++ b/tests/ref/fate/h264_redundant_pps-annexb @@ -0,0 +1,307 @@ +ce0890bd80342f8a3f6703f83b1c4959 *tests/data/fate/h264_redundant_pps-annexb.h264 +163967 tests/data/fate/h264_redundant_pps-annexb.h264 +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 176x144 +#sar 0: 0/1 +0, 0, 0, 1, 38016, 0x72723ce4 +0, 1, 1, 1, 38016, 0x347219d7 +0, 2, 2, 1, 38016, 0x813ff182 +0, 3, 3, 1, 38016, 0x4e69d41a +0, 4, 4, 1, 38016, 0x5e56acb6 +0, 5, 5, 1, 38016, 0xe72197e5 +0, 6, 6, 1, 38016, 0xd035807a +0, 7, 7, 1, 38016, 0x9ee57559 +0, 8, 8, 1, 38016, 0xd0f56f28 +0, 9, 9, 1, 38016, 0xa5097788 +0, 10, 10, 1, 38016, 0xf108978d +0, 11, 11, 1, 38016, 0xf76cb475 +0, 12, 12, 1, 38016, 0x0184cc3a +0, 13, 13, 1, 38016, 0xa4b5dc15 +0, 14, 14, 1, 38016, 0x209cdc42 +0, 15, 15, 1, 38016, 0xd9e69a8c +0, 16, 16, 1, 38016, 0xa2c3a9ba +0, 17, 17, 1, 38016, 0xdf84a52e +0, 18, 18, 1, 38016, 0xfe48a7f0 +0, 19, 19, 1, 38016, 0xb0279a19 +0, 20, 20, 1, 38016, 0xf3b48652 +0, 21, 21, 1, 38016, 0xc12b61b5 +0, 22, 22, 1, 38016, 0x13065a22 +0, 23, 23, 1, 38016, 0x804853d4 +0, 24, 24, 1, 38016, 0x40935736 +0, 25, 25, 1, 38016, 0x1a135ecb +0, 26, 26, 1, 38016, 0x125f6116 +0, 27, 27, 1, 38016, 0x53286da3 +0, 28, 28, 1, 38016, 0xd49287ac +0, 29, 29, 1, 38016, 0xc70a9c2c +0, 30, 30, 1, 38016, 0x0c0c6998 +0, 31, 31, 1, 38016, 0xf37d9141 +0, 32, 32, 1, 38016, 0xd36eafa2 +0, 33, 33, 1, 38016, 0x0d1fc298 +0, 34, 34, 1, 38016, 0xf84ad5d9 +0, 35, 35, 1, 38016, 0xc1e8d93d +0, 36, 36, 1, 38016, 0xe190dabd +0, 37, 37, 1, 38016, 0x9542db28 +0, 38, 38, 1, 38016, 0xa67edc7f +0, 39, 39, 1, 38016, 0x65efdfa7 +0, 40, 40, 1, 38016, 0x7039e6c6 +0, 41, 41, 1, 38016, 0x8307ee87 +0, 42, 42, 1, 38016, 0x1f83ec00 +0, 43, 43, 1, 38016, 0x9e33ea6e +0, 44, 44, 1, 38016, 0xb53ef238 +0, 45, 45, 1, 38016, 0x6d04930c +0, 46, 46, 1, 38016, 0xed90a50e +0, 47, 47, 1, 38016, 0xd98cb4a6 +0, 48, 48, 1, 38016, 0xa7f5bd5e +0, 49, 49, 1, 38016, 0x4df9ca95 +0, 50, 50, 1, 38016, 0xc8e7cb40 +0, 51, 51, 1, 38016, 0x93d9d23c +0, 52, 52, 1, 38016, 0xc07fd34f +0, 53, 53, 1, 38016, 0xf7c5d645 +0, 54, 54, 1, 38016, 0x3c1ddf53 +0, 55, 55, 1, 38016, 0x0bafe394 +0, 56, 56, 1, 38016, 0x9179ec6f +0, 57, 57, 1, 38016, 0x3483efc3 +0, 58, 58, 1, 38016, 0xf7ccf70d +0, 59, 59, 1, 38016, 0x289ef13b +0, 60, 60, 1, 38016, 0xb00c99dc +0, 61, 61, 1, 38016, 0x59409b34 +0, 62, 62, 1, 38016, 0x3fc079a2 +0, 63, 63, 1, 38016, 0x90ad49d9 +0, 64, 64, 1, 38016, 0x8e7751e2 +0, 65, 65, 1, 38016, 0xed20743d +0, 66, 66, 1, 38016, 0x66a1a470 +0, 67, 67, 1, 38016, 0x7a77e252 +0, 68, 68, 1, 38016, 0x6bb427fe +0, 69, 69, 1, 38016, 0x87126360 +0, 70, 70, 1, 38016, 0x330789d0 +0, 71, 71, 1, 38016, 0xc298b987 +0, 72, 72, 1, 38016, 0x4959f143 +0, 73, 73, 1, 38016, 0xa66e3082 +0, 74, 74, 1, 38016, 0xb9f67824 +0, 75, 75, 1, 38016, 0x27fe46a2 +0, 76, 76, 1, 38016, 0xc50c87ed +0, 77, 77, 1, 38016, 0x9523a9f6 +0, 78, 78, 1, 38016, 0xbe28d1d7 +0, 79, 79, 1, 38016, 0x3c0ee964 +0, 80, 80, 1, 38016, 0x65c7f36c +0, 81, 81, 1, 38016, 0xe5030946 +0, 82, 82, 1, 38016, 0x4bbb11fa +0, 83, 83, 1, 38016, 0xeaf209ed +0, 84, 84, 1, 38016, 0x96c80987 +0, 85, 85, 1, 38016, 0x69820c58 +0, 86, 86, 1, 38016, 0x5f951aa7 +0, 87, 87, 1, 38016, 0xfe6122d9 +0, 88, 88, 1, 38016, 0xa202301a +0, 89, 89, 1, 38016, 0xdd2628fb +0, 90, 90, 1, 38016, 0xe081a5ff +0, 91, 91, 1, 38016, 0x5b858e9e +0, 92, 92, 1, 38016, 0x7a368229 +0, 93, 93, 1, 38016, 0x3791829a +0, 94, 94, 1, 38016, 0x9c68723d +0, 95, 95, 1, 38016, 0xef26778e +0, 96, 96, 1, 38016, 0x39a491cf +0, 97, 97, 1, 38016, 0x776ea867 +0, 98, 98, 1, 38016, 0xda9ac03b +0, 99, 99, 1, 38016, 0x653bc9a3 +0, 100, 100, 1, 38016, 0x79e1da19 +0, 101, 101, 1, 38016, 0x3b98c6eb +0, 102, 102, 1, 38016, 0x42cdb846 +0, 103, 103, 1, 38016, 0x7872ada1 +0, 104, 104, 1, 38016, 0xb2f6d2ef +0, 105, 105, 1, 38016, 0x9468b16a +0, 106, 106, 1, 38016, 0xe793c91a +0, 107, 107, 1, 38016, 0x80bde366 +0, 108, 108, 1, 38016, 0xa7250446 +0, 109, 109, 1, 38016, 0x7039280b +0, 110, 110, 1, 38016, 0x1665350c +0, 111, 111, 1, 38016, 0xb5c93f1f +0, 112, 112, 1, 38016, 0xf77a4c44 +0, 113, 113, 1, 38016, 0x3a093143 +0, 114, 114, 1, 38016, 0x1d6b1005 +0, 115, 115, 1, 38016, 0xe1a10c01 +0, 116, 116, 1, 38016, 0x2d4d1d54 +0, 117, 117, 1, 38016, 0x902f2b14 +0, 118, 118, 1, 38016, 0xb26e3e73 +0, 119, 119, 1, 38016, 0xed7a469e +0, 120, 120, 1, 38016, 0xbc663d2a +0, 121, 121, 1, 38016, 0x60a5488e +0, 122, 122, 1, 38016, 0x451b31ca +0, 123, 123, 1, 38016, 0x54311166 +0, 124, 124, 1, 38016, 0x57d9f31e +0, 125, 125, 1, 38016, 0x567dd693 +0, 126, 126, 1, 38016, 0x0e58d88c +0, 127, 127, 1, 38016, 0xa555e124 +0, 128, 128, 1, 38016, 0x94e2f835 +0, 129, 129, 1, 38016, 0xe49e0ec0 +0, 130, 130, 1, 38016, 0x585d188e +0, 131, 131, 1, 38016, 0x696e1a0d +0, 132, 132, 1, 38016, 0xac9014b1 +0, 133, 133, 1, 38016, 0x915413c6 +0, 134, 134, 1, 38016, 0x5fa30be7 +0, 135, 135, 1, 38016, 0x8fbfb69c +0, 136, 136, 1, 38016, 0xcaeabfab +0, 137, 137, 1, 38016, 0xe494bf5c +0, 138, 138, 1, 38016, 0xae03be55 +0, 139, 139, 1, 38016, 0xb734b4d3 +0, 140, 140, 1, 38016, 0xdc6fb56f +0, 141, 141, 1, 38016, 0xfea0a853 +0, 142, 142, 1, 38016, 0xb4919381 +0, 143, 143, 1, 38016, 0x13a792fe +0, 144, 144, 1, 38016, 0xc8829fd8 +0, 145, 145, 1, 38016, 0x2113a62b +0, 146, 146, 1, 38016, 0x171f98d2 +0, 147, 147, 1, 38016, 0x1a6d6d17 +0, 148, 148, 1, 38016, 0xd4ab41c3 +0, 149, 149, 1, 38016, 0xd2df1c80 +0, 150, 150, 1, 38016, 0x14cdbb35 +0, 151, 151, 1, 38016, 0x2b74b829 +0, 152, 152, 1, 38016, 0x6433bd55 +0, 153, 153, 1, 38016, 0xd11dbc28 +0, 154, 154, 1, 38016, 0x4981ad33 +0, 155, 155, 1, 38016, 0xc38bbbad +0, 156, 156, 1, 38016, 0x048de367 +0, 157, 157, 1, 38016, 0x6c9a0c5a +0, 158, 158, 1, 38016, 0x384c4255 +0, 159, 159, 1, 38016, 0x3e9873ba +0, 160, 160, 1, 38016, 0xe4988671 +0, 161, 161, 1, 38016, 0x05b4843c +0, 162, 162, 1, 38016, 0xed0a7e13 +0, 163, 163, 1, 38016, 0x750c6f90 +0, 164, 164, 1, 38016, 0x9d296035 +0, 165, 165, 1, 38016, 0xbaa006bd +0, 166, 166, 1, 38016, 0x8289f8ae +0, 167, 167, 1, 38016, 0x3f3de147 +0, 168, 168, 1, 38016, 0xc5debc49 +0, 169, 169, 1, 38016, 0x1fe9bbfc +0, 170, 170, 1, 38016, 0x006cd4a9 +0, 171, 171, 1, 38016, 0xe551f2b3 +0, 172, 172, 1, 38016, 0xb370140e +0, 173, 173, 1, 38016, 0xc9441c24 +0, 174, 174, 1, 38016, 0x7f5c01c5 +0, 175, 175, 1, 38016, 0x352ad9f6 +0, 176, 176, 1, 38016, 0xe0909a17 +0, 177, 177, 1, 38016, 0x49bf5ea8 +0, 178, 178, 1, 38016, 0x7f1d387b +0, 179, 179, 1, 38016, 0x30812233 +0, 180, 180, 1, 38016, 0xb0bdf16f +0, 181, 181, 1, 38016, 0x5372d0e9 +0, 182, 182, 1, 38016, 0xbf1bc91c +0, 183, 183, 1, 38016, 0xaef5d647 +0, 184, 184, 1, 38016, 0xf007e86c +0, 185, 185, 1, 38016, 0x683bf72b +0, 186, 186, 1, 38016, 0xbb722114 +0, 187, 187, 1, 38016, 0xc5864b63 +0, 188, 188, 1, 38016, 0xfefd5cf4 +0, 189, 189, 1, 38016, 0xa0f263d5 +0, 190, 190, 1, 38016, 0x18401a02 +0, 191, 191, 1, 38016, 0x55cdd97b +0, 192, 192, 1, 38016, 0x5a4ee22d +0, 193, 193, 1, 38016, 0xa60706b3 +0, 194, 194, 1, 38016, 0x644422bb +0, 195, 195, 1, 38016, 0xc22421c9 +0, 196, 196, 1, 38016, 0x1d6b54e4 +0, 197, 197, 1, 38016, 0xc7627820 +0, 198, 198, 1, 38016, 0x0a6ea609 +0, 199, 199, 1, 38016, 0x4315c087 +0, 200, 200, 1, 38016, 0x3164d978 +0, 201, 201, 1, 38016, 0x08e3e7eb +0, 202, 202, 1, 38016, 0x4f04eaed +0, 203, 203, 1, 38016, 0x9f83eb5a +0, 204, 204, 1, 38016, 0xfbbcf0b2 +0, 205, 205, 1, 38016, 0xee1efb8a +0, 206, 206, 1, 38016, 0x87710ba0 +0, 207, 207, 1, 38016, 0xb96b05c1 +0, 208, 208, 1, 38016, 0xd5a4fc50 +0, 209, 209, 1, 38016, 0xad85ea19 +0, 210, 210, 1, 38016, 0x5f606058 +0, 211, 211, 1, 38016, 0xdaf55ad0 +0, 212, 212, 1, 38016, 0xee8564d6 +0, 213, 213, 1, 38016, 0xa1846cad +0, 214, 214, 1, 38016, 0xcd316a62 +0, 215, 215, 1, 38016, 0xdcf5638f +0, 216, 216, 1, 38016, 0xc5e36d1d +0, 217, 217, 1, 38016, 0x958369a6 +0, 218, 218, 1, 38016, 0x05826bf0 +0, 219, 219, 1, 38016, 0x22146914 +0, 220, 220, 1, 38016, 0xf5086111 +0, 221, 221, 1, 38016, 0x88f35468 +0, 222, 222, 1, 38016, 0x3ae94126 +0, 223, 223, 1, 38016, 0xf4473aa8 +0, 224, 224, 1, 38016, 0x430c3da2 +0, 225, 225, 1, 38016, 0xaf95113e +0, 226, 226, 1, 38016, 0xa8a216d6 +0, 227, 227, 1, 38016, 0xad2f328c +0, 228, 228, 1, 38016, 0xea724415 +0, 229, 229, 1, 38016, 0x34016af4 +0, 230, 230, 1, 38016, 0x4829a4cb +0, 231, 231, 1, 38016, 0x4b24bc67 +0, 232, 232, 1, 38016, 0xb523f023 +0, 233, 233, 1, 38016, 0x5c6d2305 +0, 234, 234, 1, 38016, 0x39e63adc +0, 235, 235, 1, 38016, 0xf7c64a7c +0, 236, 236, 1, 38016, 0xd601680a +0, 237, 237, 1, 38016, 0xbbad6a12 +0, 238, 238, 1, 38016, 0xddc1500f +0, 239, 239, 1, 38016, 0x1f1726e6 +0, 240, 240, 1, 38016, 0x48aee68f +0, 241, 241, 1, 38016, 0xc1fbd4f0 +0, 242, 242, 1, 38016, 0x4a89dc83 +0, 243, 243, 1, 38016, 0xa7cd2b02 +0, 244, 244, 1, 38016, 0xf52aa0b8 +0, 245, 245, 1, 38016, 0x1f260626 +0, 246, 246, 1, 38016, 0x80561eac +0, 247, 247, 1, 38016, 0x6687f8ef +0, 248, 248, 1, 38016, 0x986ab08f +0, 249, 249, 1, 38016, 0xb4923773 +0, 250, 250, 1, 38016, 0x5cc2d603 +0, 251, 251, 1, 38016, 0x9e8d93db +0, 252, 252, 1, 38016, 0x33fd8981 +0, 253, 253, 1, 38016, 0xaf45e630 +0, 254, 254, 1, 38016, 0x1227448e +0, 255, 255, 1, 38016, 0x424cccf0 +0, 256, 256, 1, 38016, 0x03b0cb3e +0, 257, 257, 1, 38016, 0x7aad547d +0, 258, 258, 1, 38016, 0xbf8544b2 +0, 259, 259, 1, 38016, 0x54a843ca +0, 260, 260, 1, 38016, 0x759d4dd0 +0, 261, 261, 1, 38016, 0x000162da +0, 262, 262, 1, 38016, 0x87ec74b0 +0, 263, 263, 1, 38016, 0xefee8259 +0, 264, 264, 1, 38016, 0x7b547eea +0, 265, 265, 1, 38016, 0xcae96b73 +0, 266, 266, 1, 38016, 0x730f59c3 +0, 267, 267, 1, 38016, 0x7d9b3e82 +0, 268, 268, 1, 38016, 0x3bb11ef0 +0, 269, 269, 1, 38016, 0x7581fa6b +0, 270, 270, 1, 38016, 0xe594a982 +0, 271, 271, 1, 38016, 0xde3888d6 +0, 272, 272, 1, 38016, 0x0e096d6b +0, 273, 273, 1, 38016, 0x297c20dc +0, 274, 274, 1, 38016, 0x51f7ce7f +0, 275, 275, 1, 38016, 0x23d2c247 +0, 276, 276, 1, 38016, 0x0bdcd0d0 +0, 277, 277, 1, 38016, 0x63cfd4f3 +0, 278, 278, 1, 38016, 0x6d4b01f8 +0, 279, 279, 1, 38016, 0xa50d72f0 +0, 280, 280, 1, 38016, 0xccad0d72 +0, 281, 281, 1, 38016, 0x10c9e33e +0, 282, 282, 1, 38016, 0xba6daf97 +0, 283, 283, 1, 38016, 0xd65074e0 +0, 284, 284, 1, 38016, 0xd36954aa +0, 285, 285, 1, 38016, 0xd9a2a642 +0, 286, 286, 1, 38016, 0xce755f9f +0, 287, 287, 1, 38016, 0x81d29c44 +0, 288, 288, 1, 38016, 0x23b0aef5 +0, 289, 289, 1, 38016, 0xb0ef9efa +0, 290, 290, 1, 38016, 0xf20d4a7a +0, 291, 291, 1, 38016, 0xa0c86899 +0, 292, 292, 1, 38016, 0x1ae4f865 +0, 293, 293, 1, 38016, 0x3a5731c8 +0, 294, 294, 1, 38016, 0x75f17ec5 +0, 295, 295, 1, 38016, 0x8f447aa9 +0, 296, 296, 1, 38016, 0x71615441 +0, 297, 297, 1, 38016, 0x90c13e26 +0, 298, 298, 1, 38016, 0x08d04aaf +0, 299, 299, 1, 38016, 0x14fd7b04 diff --git a/tests/ref/fate/h264_redundant_pps-mov b/tests/ref/fate/h264_redundant_pps-mov new file mode 100644 index 0000000000..7cab0e0b29 --- /dev/null +++ b/tests/ref/fate/h264_redundant_pps-mov @@ -0,0 +1,115 @@ +ac2e8f528dae4e4d610fa3517d2c94fb *tests/data/fate/h264_redundant_pps-mov.h264 +187284 tests/data/fate/h264_redundant_pps-mov.h264 +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 640x360 +#sar 0: 1/1 +0, 0, 0, 1, 345600, 0xc40ffa02 +0, 1, 1, 1, 345600, 0x346acaba +0, 2, 2, 1, 345600, 0x26f3de5d +0, 3, 3, 1, 345600, 0xacf384e1 +0, 4, 4, 1, 345600, 0xd7dc8e0b +0, 5, 5, 1, 345600, 0xd7dc8e0b +0, 6, 6, 1, 345600, 0x47f99430 +0, 7, 7, 1, 345600, 0x00259c5a +0, 8, 8, 1, 345600, 0xec659aa2 +0, 9, 9, 1, 345600, 0xec659aa2 +0, 10, 10, 1, 345600, 0x84fef765 +0, 11, 11, 1, 345600, 0xcbeecbe4 +0, 12, 12, 1, 345600, 0x9386982e +0, 13, 13, 1, 345600, 0x682ccf66 +0, 14, 14, 1, 345600, 0x89d10278 +0, 15, 15, 1, 345600, 0x407272a3 +0, 16, 16, 1, 345600, 0x32e0b287 +0, 17, 17, 1, 345600, 0x709ccfe5 +0, 18, 18, 1, 345600, 0x00dcbebc +0, 19, 19, 1, 345600, 0x61b7aa83 +0, 20, 20, 1, 345600, 0x03c7c404 +0, 21, 21, 1, 345600, 0x9b794d4c +0, 22, 22, 1, 345600, 0xb090b3f0 +0, 23, 23, 1, 345600, 0xdb596340 +0, 24, 24, 1, 345600, 0x031f4ba8 +0, 25, 25, 1, 345600, 0xef484d42 +0, 26, 26, 1, 345600, 0xa2814cec +0, 27, 27, 1, 345600, 0x5432765c +0, 28, 28, 1, 345600, 0xef5fd507 +0, 29, 29, 1, 345600, 0x13b2138d +0, 30, 30, 1, 345600, 0x29f24795 +0, 31, 31, 1, 345600, 0x6dce96e1 +0, 32, 32, 1, 345600, 0xb0cdf793 +0, 33, 33, 1, 345600, 0x1b921fb6 +0, 34, 34, 1, 345600, 0xcc446384 +0, 35, 35, 1, 345600, 0x784689e7 +0, 36, 36, 1, 345600, 0xfaf5ac7e +0, 37, 37, 1, 345600, 0x6ce2c6b5 +0, 38, 38, 1, 345600, 0xcb9408ad +0, 39, 39, 1, 345600, 0x4f40082d +0, 40, 40, 1, 345600, 0x9c039eb7 +0, 41, 41, 1, 345600, 0xb271ec7d +0, 42, 42, 1, 345600, 0x31d2af2c +0, 43, 43, 1, 345600, 0xe187adc4 +0, 44, 44, 1, 345600, 0xec28b3cc +0, 45, 45, 1, 345600, 0x5596b34c +0, 46, 46, 1, 345600, 0xb75f475c +0, 47, 47, 1, 345600, 0x888f311c +0, 48, 48, 1, 345600, 0xedab720f +0, 49, 49, 1, 345600, 0xbf75fa40 +0, 50, 50, 1, 345600, 0x13bb37d7 +0, 51, 51, 1, 345600, 0xbc6aeded +0, 52, 52, 1, 345600, 0xf6a6478a +0, 53, 53, 1, 345600, 0x46d4e723 +0, 54, 54, 1, 345600, 0x1263e5e3 +0, 55, 55, 1, 345600, 0x6d3fc449 +0, 56, 56, 1, 345600, 0xc218c2c9 +0, 57, 57, 1, 345600, 0x12ef8744 +0, 58, 58, 1, 345600, 0xc073486e +0, 59, 59, 1, 345600, 0xa3403147 +0, 60, 60, 1, 345600, 0x720a8c5b +0, 61, 61, 1, 345600, 0x7a268f12 +0, 62, 62, 1, 345600, 0xf311d147 +0, 63, 63, 1, 345600, 0x5cc12e78 +0, 64, 64, 1, 345600, 0xf09ecd59 +0, 65, 65, 1, 345600, 0x0e3b46c3 +0, 66, 66, 1, 345600, 0x80786a01 +0, 67, 67, 1, 345600, 0x3edd6931 +0, 68, 68, 1, 345600, 0x14e27291 +0, 69, 69, 1, 345600, 0x12776fd1 +0, 70, 70, 1, 345600, 0xa68cf46d +0, 71, 71, 1, 345600, 0x04f99d27 +0, 72, 72, 1, 345600, 0x76618a97 +0, 73, 73, 1, 345600, 0x7559dcae +0, 74, 74, 1, 345600, 0xc9f4d77f +0, 75, 75, 1, 345600, 0xe76fbad7 +0, 76, 76, 1, 345600, 0x6efca571 +0, 77, 77, 1, 345600, 0x0619a437 +0, 78, 78, 1, 345600, 0x0b48a563 +0, 79, 79, 1, 345600, 0x6ec1bae9 +0, 80, 80, 1, 345600, 0xcce588aa +0, 81, 81, 1, 345600, 0xa003e269 +0, 82, 82, 1, 345600, 0x6507ec83 +0, 83, 83, 1, 345600, 0xa697ec03 +0, 84, 84, 1, 345600, 0xb18a0ddd +0, 85, 85, 1, 345600, 0x96b74d36 +0, 86, 86, 1, 345600, 0x6b6d5ebb +0, 87, 87, 1, 345600, 0x86a082c4 +0, 88, 88, 1, 345600, 0x463ac3e6 +0, 89, 89, 1, 345600, 0xac54e07e +0, 90, 90, 1, 345600, 0xdd32e5ce +0, 91, 91, 1, 345600, 0xc27b9140 +0, 92, 92, 1, 345600, 0x70855f0b +0, 93, 93, 1, 345600, 0xad849d48 +0, 94, 94, 1, 345600, 0x26f6bbba +0, 95, 95, 1, 345600, 0x4c01cc6c +0, 96, 96, 1, 345600, 0x2f6fdac5 +0, 97, 97, 1, 345600, 0xb4d8f6d6 +0, 98, 98, 1, 345600, 0x53aafc9f +0, 99, 99, 1, 345600, 0x53aafc9f +0, 100, 100, 1, 345600, 0xa016f90b +0, 101, 101, 1, 345600, 0x7a68ea8b +0, 102, 102, 1, 345600, 0x74cee980 +0, 103, 103, 1, 345600, 0x16621888 +0, 104, 104, 1, 345600, 0x16621888 +0, 105, 105, 1, 345600, 0x4f6c5227 +0, 106, 106, 1, 345600, 0x5d8343c2 +0, 107, 107, 1, 345600, 0x4ea83d1a diff --git a/tests/ref/fate/h264_redundant_pps-side_data b/tests/ref/fate/h264_redundant_pps-side_data new file mode 100644 index 0000000000..c1c00eebae --- /dev/null +++ b/tests/ref/fate/h264_redundant_pps-side_data @@ -0,0 +1,21 @@ +a35cca13c3f91d1a279bf576b8264d05 *tests/data/fate/h264_redundant_pps-side_data.nut +596153 tests/data/fate/h264_redundant_pps-side_data.nut +#extradata 0: 34, 0x851f08e4 +#tb 0: 1/48000 +#media_type 0: video +#codec_id 0: h264 +#dimensions 0: 1920x1080 +#sar 0: 0/1 +0, -2002, 0, 2002, 247959, 0xdb721881, S=1, 34 +0, 0, 4004, 2002, 43356, 0xa366eb79, F=0x0 +0, 2002, 2002, 2002, 11423, 0x9c0a86fa, F=0x0 +0, 4004, 8008, 2002, 50801, 0xfbfe860d, F=0x0 +0, 6006, 6006, 2002, 12567, 0x650a5321, F=0x0 +0, 8008, 12012, 2002, 52447, 0x19e106c1, F=0x0 +0, 10010, 10010, 2002, 12575, 0x83c94868, F=0x0 +0, 12012, 16016, 2002, 54028, 0xa8460c03, F=0x0 +0, 14014, 14014, 2002, 13539, 0x0bc96c74, F=0x0 +0, 16016, 20020, 2002, 54489, 0x319c9032, F=0x0 +0, 18018, 18018, 2002, 13705, 0x38a02805, F=0x0 +0, 20020, 22022, 2002, 22313, 0xec81a420, F=0x0 +0, 22022, 24024, 2002, 6335, 0xa524214d diff --git a/tests/ref/fate/h264_redundant_pps-side_data2 b/tests/ref/fate/h264_redundant_pps-side_data2 new file mode 100644 index 0000000000..7484fbeb07 --- /dev/null +++ b/tests/ref/fate/h264_redundant_pps-side_data2 @@ -0,0 +1,11 @@ +dd953f8d95d2927703ce9593a07fe2e7 *tests/data/fate/h264_redundant_pps-side_data2.nut +5162 tests/data/fate/h264_redundant_pps-side_data2.nut +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 256x128 +#sar 0: 1/1 +0, 0, 0, 1, 49152, 0x08745db9 +0, 1, 1, 1, 49152, 0x96bf5e58 +0, 2, 2, 1, 49152, 0x8fe31b6d +0, 3, 3, 1, 49152, 0x0b621cc3 From 63bb6d6a9b64f78e0cfbbc008947c9e0bf2fc409 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 14 Sep 2022 14:09:02 +0200 Subject: [PATCH 489/590] avutil: add RGB single-precision float formats --- libavutil/pixdesc.c | 25 +++++++++++++++++++++++++ libavutil/pixfmt.h | 3 +++ tests/ref/fate/imgutils | 2 ++ tests/ref/fate/sws-pixdesc-query | 9 +++++++++ 4 files changed, 39 insertions(+) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index b472a94f60..248d5f29cd 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2636,6 +2636,31 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_RGBF32BE] = { + .name = "rgbf32be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 12, 0, 0, 32 }, /* R */ + { 0, 12, 4, 0, 32 }, /* G */ + { 0, 12, 8, 0, 32 }, /* B */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | + AV_PIX_FMT_FLAG_FLOAT, + }, + [AV_PIX_FMT_RGBF32LE] = { + .name = "rgbf32le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 12, 0, 0, 32 }, /* R */ + { 0, 12, 4, 0, 32 }, /* G */ + { 0, 12, 8, 0, 32 }, /* B */ + }, + .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT, + }, }; static const char * const color_range_names[] = { diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index a1c4c9fb75..3c34d73e2c 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -386,6 +386,9 @@ enum AVPixelFormat { AV_PIX_FMT_XV36BE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian, variant of Y412 where alpha channel is left undefined AV_PIX_FMT_XV36LE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian, variant of Y412 where alpha channel is left undefined + AV_PIX_FMT_RGBF32BE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian + AV_PIX_FMT_RGBF32LE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index de73513e7c..8ad5615ed8 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -258,3 +258,5 @@ xv30be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 xv30le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 xv36be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 xv36le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 +rgbf32be planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 +rgbf32le planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index 20fc596ce9..e850d52d12 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -169,6 +169,7 @@ isBE: rgb565be rgba64be rgbaf16be + rgbf32be x2bgr10be x2rgb10be xv30be @@ -509,6 +510,8 @@ isRGB: rgba64le rgbaf16be rgbaf16le + rgbf32be + rgbf32le x2bgr10be x2bgr10le x2rgb10be @@ -661,6 +664,8 @@ AnyRGB: rgba64le rgbaf16be rgbaf16le + rgbf32be + rgbf32le x2bgr10be x2bgr10le x2rgb10be @@ -775,6 +780,8 @@ Packed: rgba64le rgbaf16be rgbaf16le + rgbf32be + rgbf32le uyvy422 uyyvyy411 vuya @@ -965,6 +972,8 @@ PackedRGB: rgba64le rgbaf16be rgbaf16le + rgbf32be + rgbf32le x2bgr10be x2bgr10le x2rgb10be From 7bb0afc245d093b065b849461a5e0361050df512 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 14 Sep 2022 14:13:06 +0200 Subject: [PATCH 490/590] avutil: add RGBA single-float precision packed formats --- libavutil/pixdesc.c | 28 ++++++++++++++++++++++++++++ libavutil/pixfmt.h | 3 +++ tests/ref/fate/imgutils | 2 ++ tests/ref/fate/sws-pixdesc-query | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 248d5f29cd..bfba414167 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2661,6 +2661,34 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT, }, + [AV_PIX_FMT_RGBAF32BE] = { + .name = "rgbaf32be", + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 16, 0, 0, 32 }, /* R */ + { 0, 16, 4, 0, 32 }, /* G */ + { 0, 16, 8, 0, 32 }, /* B */ + { 0, 16, 12, 0, 32 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | + AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA, + }, + [AV_PIX_FMT_RGBAF32LE] = { + .name = "rgbaf32le", + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 16, 0, 0, 32 }, /* R */ + { 0, 16, 4, 0, 32 }, /* G */ + { 0, 16, 8, 0, 32 }, /* B */ + { 0, 16, 12, 0, 32 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT | + AV_PIX_FMT_FLAG_ALPHA, + }, }; static const char * const color_range_names[] = { diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 3c34d73e2c..f8b3c0514f 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -389,6 +389,9 @@ enum AVPixelFormat { AV_PIX_FMT_RGBF32BE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian AV_PIX_FMT_RGBF32LE, ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian + AV_PIX_FMT_RGBAF32BE, ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., big-endian + AV_PIX_FMT_RGBAF32LE, ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., little-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 8ad5615ed8..e79ec7e4b3 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -260,3 +260,5 @@ xv36be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 xv36le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 rgbf32be planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 rgbf32le planes: 1, linesizes: 768 0 0 0, plane_sizes: 36864 0 0 0, plane_offsets: 0 0 0, total_size: 36864 +rgbaf32be planes: 1, linesizes: 1024 0 0 0, plane_sizes: 49152 0 0 0, plane_offsets: 0 0 0, total_size: 49152 +rgbaf32le planes: 1, linesizes: 1024 0 0 0, plane_sizes: 49152 0 0 0, plane_offsets: 0 0 0, total_size: 49152 diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index e850d52d12..14156a383c 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -169,6 +169,7 @@ isBE: rgb565be rgba64be rgbaf16be + rgbaf32be rgbf32be x2bgr10be x2rgb10be @@ -510,6 +511,8 @@ isRGB: rgba64le rgbaf16be rgbaf16le + rgbaf32be + rgbaf32le rgbf32be rgbf32le x2bgr10be @@ -664,6 +667,8 @@ AnyRGB: rgba64le rgbaf16be rgbaf16le + rgbaf32be + rgbaf32le rgbf32be rgbf32le x2bgr10be @@ -694,6 +699,8 @@ ALPHA: rgba64le rgbaf16be rgbaf16le + rgbaf32be + rgbaf32le vuya ya16be ya16le @@ -780,6 +787,8 @@ Packed: rgba64le rgbaf16be rgbaf16le + rgbaf32be + rgbaf32le rgbf32be rgbf32le uyvy422 @@ -972,6 +981,8 @@ PackedRGB: rgba64le rgbaf16be rgbaf16le + rgbaf32be + rgbaf32le rgbf32be rgbf32le x2bgr10be From baf9099cf380fad2be4ae17379f6cb5762bb2c92 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 14 Sep 2022 13:58:21 +0200 Subject: [PATCH 491/590] avcodec/tiff: add packed/planar 32bit float support --- libavcodec/tiff.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 4da77a3a31..750c42ca51 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1026,14 +1026,14 @@ static int init_image(TiffContext *s, AVFrame *frame) int create_gray_palette = 0; // make sure there is no aliasing in the following switch - if (s->bpp >= 100 || s->bppcount >= 10) { + if (s->bpp > 128 || s->bppcount >= 10) { av_log(s->avctx, AV_LOG_ERROR, "Unsupported image parameters: bpp=%d, bppcount=%d\n", s->bpp, s->bppcount); return AVERROR_INVALIDDATA; } - switch (s->planar * 1000 + s->bpp * 10 + s->bppcount + s->is_bayer * 10000) { + switch (s->planar * 10000 + s->bpp * 10 + s->bppcount + s->is_bayer * 100000) { case 11: if (!s->palette_is_set) { s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK; @@ -1052,7 +1052,7 @@ static int init_image(TiffContext *s, AVFrame *frame) case 121: s->avctx->pix_fmt = AV_PIX_FMT_GRAY12; break; - case 10081: + case 100081: switch (AV_RL32(s->pattern)) { case 0x02010100: s->avctx->pix_fmt = AV_PIX_FMT_BAYER_RGGB8; @@ -1072,10 +1072,10 @@ static int init_image(TiffContext *s, AVFrame *frame) return AVERROR_PATCHWELCOME; } break; - case 10101: - case 10121: - case 10141: - case 10161: + case 100101: + case 100121: + case 100141: + case 100161: switch (AV_RL32(s->pattern)) { case 0x02010100: s->avctx->pix_fmt = AV_PIX_FMT_BAYER_RGGB16; @@ -1143,18 +1143,30 @@ static int init_image(TiffContext *s, AVFrame *frame) case 644: s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBA64LE : AV_PIX_FMT_RGBA64BE; break; - case 1243: + case 10243: s->avctx->pix_fmt = AV_PIX_FMT_GBRP; break; - case 1324: + case 10324: s->avctx->pix_fmt = AV_PIX_FMT_GBRAP; break; - case 1483: + case 10483: s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRP16LE : AV_PIX_FMT_GBRP16BE; break; - case 1644: + case 10644: s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRAP16LE : AV_PIX_FMT_GBRAP16BE; break; + case 963: + s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBF32LE : AV_PIX_FMT_RGBF32BE; + break; + case 1284: + s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBAF32LE : AV_PIX_FMT_RGBAF32BE; + break; + case 10963: + s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRPF32LE : AV_PIX_FMT_GBRPF32BE; + break; + case 11284: + s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRAPF32LE : AV_PIX_FMT_GBRAPF32BE; + break; default: av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, bppcount=%d)\n", @@ -1732,7 +1744,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) } } end: - if (s->bpp > 64U) { + if (s->bpp > 128U) { av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); From 9995a76f7c5b507c0304de6a926b32c70d5ea2aa Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 14 Sep 2022 16:41:48 +0200 Subject: [PATCH 492/590] avfilter/vf_extractplanes: add support for packed rgb float formats --- libavfilter/vf_extractplanes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c index 60b55578cf..3c794eaa28 100644 --- a/libavfilter/vf_extractplanes.c +++ b/libavfilter/vf_extractplanes.c @@ -124,6 +124,7 @@ AVFILTER_DEFINE_CLASS(extractplanes); #define FLOAT_FORMATS(suf) \ AV_PIX_FMT_GRAYF32##suf, \ + AV_PIX_FMT_RGBF32##suf, AV_PIX_FMT_RGBAF32##suf, \ AV_PIX_FMT_GBRPF32##suf, AV_PIX_FMT_GBRAPF32##suf \ static int query_formats(AVFilterContext *ctx) @@ -283,6 +284,13 @@ static void extract_from_packed(uint8_t *dst, int dst_linesize, dst[x * 2 ] = src[x * step + comp * 2 ]; dst[x * 2 + 1] = src[x * step + comp * 2 + 1]; } + case 4: + for (x = 0; x < width; x++) { + dst[x * 4 ] = src[x * step + comp * 4 ]; + dst[x * 4 + 1] = src[x * step + comp * 4 + 1]; + dst[x * 4 + 2] = src[x * step + comp * 4 + 2]; + dst[x * 4 + 3] = src[x * step + comp * 4 + 3]; + } break; } dst += dst_linesize; From 91897110b012dbad18c54de169569ab6eb47af4b Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 25 Sep 2022 14:59:32 +0200 Subject: [PATCH 493/590] avcodec/tiff: improve color handling in DNG --- libavcodec/tiff.c | 204 +++++++++++++++++++++++++++++++++++++++++++--- libavcodec/tiff.h | 7 ++ 2 files changed, 199 insertions(+), 12 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 750c42ca51..302444cb0f 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -33,6 +33,8 @@ #include #endif +#include + #include "libavutil/attributes.h" #include "libavutil/error.h" #include "libavutil/intreadwrite.h" @@ -82,7 +84,16 @@ typedef struct TiffContext { unsigned last_tag; int is_bayer; + int use_color_matrix; uint8_t pattern[4]; + + float analog_balance[4]; + float as_shot_neutral[4]; + float as_shot_white[4]; + float color_matrix[3][4]; + float camera_calibration[4][4]; + float premultiply[4]; + unsigned black_level; unsigned white_level; uint16_t dng_lut[65536]; @@ -112,6 +123,8 @@ typedef struct TiffContext { TiffGeoTag *geotags; } TiffContext; +static const float d65_white[3] = { 0.950456f, 1.f, 1.088754f }; + static void tiff_set_type(TiffContext *s, enum TiffType tiff_type) { if (s->tiff_type < tiff_type) // Prioritize higher-valued entries s->tiff_type = tiff_type; @@ -286,12 +299,12 @@ static uint16_t av_always_inline dng_process_color16(uint16_t value, value = lut[value]; // Black level subtraction - value = av_clip_uint16_c((unsigned)value - black_level); + value = av_clip_uint16((unsigned)value - black_level); // Color scaling - value_norm = (float)value * scale_factor * 65535.f; + value_norm = (float)value * scale_factor; - value = av_clip_uint16_c(lrintf(value_norm)); + value = av_clip_uint16(lrintf(value_norm)); return value; } @@ -306,12 +319,18 @@ static uint16_t av_always_inline dng_process_color8(uint16_t value, static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, - int is_single_comp, int is_u16) + int is_single_comp, int is_u16, int odd_line) { + float scale_factor[4]; int line, col; - float scale_factor; - scale_factor = 1.0f / (s->white_level - s->black_level); + if (s->is_bayer) { + for (int i = 0; i < 4; i++) + scale_factor[i] = s->premultiply[s->pattern[i]] * 65535.f / (s->white_level - s->black_level); + } else { + for (int i = 0; i < 4; i++) + scale_factor[i] = 65535.f * s->premultiply[i] / (s->white_level - s->black_level); + } if (is_single_comp) { if (!is_u16) @@ -325,7 +344,7 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri /* Blit first half of input row row to initial row of output */ for (col = 0; col < width; col++) - *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor); + *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor[col&1]); /* Advance the destination pointer by a row (source pointer remains in the same place) */ dst += dst_stride * sizeof(uint16_t); @@ -333,7 +352,7 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri /* Blit second half of input row row to next row of output */ for (col = 0; col < width; col++) - *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor); + *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor[(col&1) + 2]); dst += dst_stride * sizeof(uint16_t); src += src_stride * sizeof(uint16_t); @@ -347,7 +366,7 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri uint16_t *src_u16 = (uint16_t *)src; for (col = 0; col < width; col++) - *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor); + *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor[(col&1) + 2 * ((line&1) + odd_line)]); dst += dst_stride * sizeof(uint16_t); src += src_stride * sizeof(uint16_t); @@ -358,7 +377,7 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri const uint8_t *src_u8 = src; for (col = 0; col < width; col++) - *dst_u8++ = dng_process_color8(*src_u8++, s->dng_lut, s->black_level, scale_factor); + *dst_u8++ = dng_process_color8(*src_u8++, s->dng_lut, s->black_level, scale_factor[(col&1) + 2 * ((line&1) + odd_line)]); dst += dst_stride; src += src_stride; @@ -712,7 +731,7 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame, w, h, is_single_comp, - is_u16); + is_u16, 0); av_frame_unref(s->jpgframe); @@ -892,7 +911,8 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid elements, 1, 0, // single-component variation is only preset in JPEG-encoded DNGs - is_u16); + is_u16, + (line + strip_start)&1); } src += width; @@ -1431,6 +1451,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) return AVERROR_INVALIDDATA; for (int i = 0; i < count; i++) s->dng_lut[i] = ff_tget(&s->gb, type, s->le); + s->white_level = s->dng_lut[count-1]; break; case DNG_BLACK_LEVEL: if (count > 1) { /* Use the first value in the pattern (assume they're all the same) */ @@ -1728,6 +1749,84 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) tiff_set_type(s, TIFF_TYPE_DNG); } break; + case DNG_ANALOG_BALANCE: + if (type != TIFF_RATIONAL) + break; + + for (int i = 0; i < 3; i++) { + value = ff_tget(&s->gb, TIFF_LONG, s->le); + value2 = ff_tget(&s->gb, TIFF_LONG, s->le); + if (!value2) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); + value2 = 1; + } + + s->analog_balance[i] = value / (float)value2; + } + break; + case DNG_AS_SHOT_NEUTRAL: + if (type != TIFF_RATIONAL) + break; + + for (int i = 0; i < 3; i++) { + value = ff_tget(&s->gb, TIFF_LONG, s->le); + value2 = ff_tget(&s->gb, TIFF_LONG, s->le); + if (!value2) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); + value2 = 1; + } + + s->as_shot_neutral[i] = value / (float)value2; + } + break; + case DNG_AS_SHOT_WHITE_XY: + if (type != TIFF_RATIONAL) + break; + + for (int i = 0; i < 2; i++) { + value = ff_tget(&s->gb, TIFF_LONG, s->le); + value2 = ff_tget(&s->gb, TIFF_LONG, s->le); + if (!value2) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); + value2 = 1; + } + + s->as_shot_white[i] = value / (float)value2; + } + s->as_shot_white[2] = 1.f - s->as_shot_white[0] - s->as_shot_white[1]; + for (int i = 0; i < 3; i++) { + s->as_shot_white[i] /= d65_white[i]; + } + break; + case DNG_COLOR_MATRIX1: + case DNG_COLOR_MATRIX2: + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + int value = ff_tget(&s->gb, TIFF_LONG, s->le); + int value2 = ff_tget(&s->gb, TIFF_LONG, s->le); + if (!value2) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); + value2 = 1; + } + s->color_matrix[i][j] = value / (float)value2; + } + s->use_color_matrix = 1; + } + break; + case DNG_CAMERA_CALIBRATION1: + case DNG_CAMERA_CALIBRATION2: + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + int value = ff_tget(&s->gb, TIFF_LONG, s->le); + int value2 = ff_tget(&s->gb, TIFF_LONG, s->le); + if (!value2) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); + value2 = 1; + } + s->camera_calibration[i][j] = value / (float)value2; + } + } + break; case CINEMADNG_TIME_CODES: case CINEMADNG_FRAME_RATE: case CINEMADNG_T_STOP: @@ -1755,6 +1854,41 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) return 0; } +static const float xyz2rgb[3][3] = { + { 0.412453f, 0.357580f, 0.180423f }, + { 0.212671f, 0.715160f, 0.072169f }, + { 0.019334f, 0.119193f, 0.950227f }, +}; + +static void camera_xyz_coeff(TiffContext *s, + float rgb2cam[3][4], + double cam2xyz[4][3]) +{ + double cam2rgb[4][3], inverse[4][3], num; + int i, j, k; + + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) { + cam2rgb[i][j] = 0.; + for (k = 0; k < 3; k++) + cam2rgb[i][j] += cam2xyz[i][k] * xyz2rgb[k][j]; + } + } + + for (i = 0; i < 3; i++) { + for (num = j = 0; j < 3; j++) + num += cam2rgb[i][j]; + for (j = 0; j < 3; j++) + cam2rgb[i][j] /= num; + s->premultiply[i] = 1.f / num; + } + +// pseudoinverse(cam2rgb, inverse, colors); +// for (i = 0; i < 3; i++) +// for (j = 0; j < 3; j++) +// rgb2cam[i][j] = inverse[j][i]; +} + static int decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt) { @@ -1784,6 +1918,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, // TIFF_BPP is not a required tag and defaults to 1 s->tiff_type = TIFF_TYPE_TIFF; + s->use_color_matrix = 0; again: s->is_thumbnail = 0; s->bppcount = s->bpp = 1; @@ -1800,6 +1935,22 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, for (i = 0; i < 65536; i++) s->dng_lut[i] = i; + for (i = 0; i < FF_ARRAY_ELEMS(s->as_shot_neutral); i++) + s->as_shot_neutral[i] = 0.f; + + for (i = 0; i < FF_ARRAY_ELEMS(s->as_shot_white); i++) + s->as_shot_white[i] = 1.f; + + for (i = 0; i < FF_ARRAY_ELEMS(s->analog_balance); i++) + s->analog_balance[i] = 1.f; + + for (i = 0; i < FF_ARRAY_ELEMS(s->premultiply); i++) + s->premultiply[i] = 1.f; + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + s->camera_calibration[i][j] = i == j; + free_geotags(s); // Reset these offsets so we can tell if they were set this frame @@ -1872,8 +2023,37 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, } if (is_dng) { + double cam2xyz[4][3]; + float cmatrix[3][4]; + float pmin = FLT_MAX; int bps; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) + s->camera_calibration[i][j] *= s->analog_balance[i]; + } + + if (!s->use_color_matrix) { + for (i = 0; i < 3; i++) + s->premultiply[i] /= s->camera_calibration[i][i]; + } else { + for (int c = 0; c < 3; c++) { + for (i = 0; i < 3; i++) { + cam2xyz[c][i] = 0.; + for (j = 0; j < 3; j++) + cam2xyz[c][i] += s->camera_calibration[c][j] * s->color_matrix[j][i] * s->as_shot_white[i]; + } + } + + camera_xyz_coeff(s, cmatrix, cam2xyz); + } + + for (int c = 0; c < 3; c++) + pmin = fminf(pmin, s->premultiply[c]); + + for (int c = 0; c < 3; c++) + s->premultiply[c] /= pmin; + if (s->bpp % s->bppcount) return AVERROR_INVALIDDATA; bps = s->bpp / s->bppcount; diff --git a/libavcodec/tiff.h b/libavcodec/tiff.h index 9d2ab90f52..e67c59abad 100644 --- a/libavcodec/tiff.h +++ b/libavcodec/tiff.h @@ -106,6 +106,13 @@ enum DngTags { DNG_LINEARIZATION_TABLE = 0xC618, DNG_BLACK_LEVEL = 0xC61A, DNG_WHITE_LEVEL = 0xC61D, + DNG_COLOR_MATRIX1 = 0xC621, + DNG_COLOR_MATRIX2 = 0xC622, + DNG_CAMERA_CALIBRATION1 = 0xC623, + DNG_CAMERA_CALIBRATION2 = 0xC624, + DNG_ANALOG_BALANCE = 0xC627, + DNG_AS_SHOT_NEUTRAL = 0xC628, + DNG_AS_SHOT_WHITE_XY = 0xC629, }; /** list of CinemaDNG tags */ From c0771055ec648e0e02dff44a8848e5a60d4c2a73 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 25 Sep 2022 15:48:13 +0200 Subject: [PATCH 494/590] avcodec/pnmdec: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/pnmdec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index 6ba54ddccd..e95b4072eb 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -59,6 +59,9 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, if ((ret = ff_pnm_decode_header(avctx, s)) < 0) return ret; + if (avctx->skip_frame >= AVDISCARD_ALL) + return avpkt->size; + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; p->pict_type = AV_PICTURE_TYPE_I; @@ -408,6 +411,7 @@ const FFCodec ff_pgm_decoder = { .p.id = AV_CODEC_ID_PGM, .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif @@ -420,6 +424,7 @@ const FFCodec ff_pgmyuv_decoder = { .p.id = AV_CODEC_ID_PGMYUV, .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif @@ -432,6 +437,7 @@ const FFCodec ff_ppm_decoder = { .p.id = AV_CODEC_ID_PPM, .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif @@ -444,6 +450,7 @@ const FFCodec ff_pbm_decoder = { .p.id = AV_CODEC_ID_PBM, .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif @@ -456,6 +463,7 @@ const FFCodec ff_pam_decoder = { .p.id = AV_CODEC_ID_PAM, .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif @@ -468,6 +476,7 @@ const FFCodec ff_pfm_decoder = { .p.id = AV_CODEC_ID_PFM, .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif @@ -490,6 +499,7 @@ const FFCodec ff_phm_decoder = { .p.capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(PNMContext), .init = phm_dec_init, + .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, FF_CODEC_DECODE_CB(pnm_decode_frame), }; #endif From 1452445116f3a265762ffeb7fdc5b8f2fbaa2cfc Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 25 Sep 2022 15:59:13 +0200 Subject: [PATCH 495/590] avcodec/tiff: implement FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM --- libavcodec/tiff.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 302444cb0f..9c29cd5a73 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1209,6 +1209,10 @@ static int init_image(TiffContext *s, AVFrame *frame) if (ret < 0) return ret; } + + if (s->avctx->skip_frame >= AVDISCARD_ALL) + return 0; + if ((ret = ff_thread_get_buffer(s->avctx, frame, 0)) < 0) return ret; if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) { @@ -1222,7 +1226,7 @@ static int init_image(TiffContext *s, AVFrame *frame) pal[i] = 0xFFU << 24 | i * 255 / ((1<bpp) - 1) * 0x010101; } } - return 0; + return 1; } static void set_sar(TiffContext *s, unsigned tag, unsigned num, unsigned den) @@ -2089,7 +2093,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, } /* now we have the data and may start decoding */ - if ((ret = init_image(s, p)) < 0) + if ((ret = init_image(s, p)) <= 0) return ret; if (!s->is_tiled || has_strip_bits) { @@ -2382,6 +2386,7 @@ const FFCodec ff_tiff_decoder = { .close = tiff_end, FF_CODEC_DECODE_CB(decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES | + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, .p.priv_class = &tiff_decoder_class, }; From 0ca738673a07977ea65d0fdfcedb6f5d5deeec30 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 25 Sep 2022 17:02:35 +0200 Subject: [PATCH 496/590] avcodec/tiff: support multiple black levels --- libavcodec/tiff.c | 63 ++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 9c29cd5a73..3a610ada85 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -93,8 +93,8 @@ typedef struct TiffContext { float color_matrix[3][4]; float camera_calibration[4][4]; float premultiply[4]; + float black_level[4]; - unsigned black_level; unsigned white_level; uint16_t dng_lut[65536]; @@ -290,7 +290,7 @@ static int add_metadata(int count, int type, */ static uint16_t av_always_inline dng_process_color16(uint16_t value, const uint16_t *lut, - uint16_t black_level, + float black_level, float scale_factor) { float value_norm; @@ -299,10 +299,8 @@ static uint16_t av_always_inline dng_process_color16(uint16_t value, value = lut[value]; // Black level subtraction - value = av_clip_uint16((unsigned)value - black_level); - // Color scaling - value_norm = (float)value * scale_factor; + value_norm = ((float)value - black_level) * scale_factor; value = av_clip_uint16(lrintf(value_norm)); @@ -311,7 +309,7 @@ static uint16_t av_always_inline dng_process_color16(uint16_t value, static uint16_t av_always_inline dng_process_color8(uint16_t value, const uint16_t *lut, - uint16_t black_level, + float black_level, float scale_factor) { return dng_process_color16(value, lut, black_level, scale_factor) >> 8; @@ -326,10 +324,10 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri if (s->is_bayer) { for (int i = 0; i < 4; i++) - scale_factor[i] = s->premultiply[s->pattern[i]] * 65535.f / (s->white_level - s->black_level); + scale_factor[i] = s->premultiply[s->pattern[i]] * 65535.f / (s->white_level - s->black_level[i]); } else { for (int i = 0; i < 4; i++) - scale_factor[i] = 65535.f * s->premultiply[i] / (s->white_level - s->black_level); + scale_factor[i] = 65535.f * s->premultiply[i] / (s->white_level - s->black_level[i]); } if (is_single_comp) { @@ -344,7 +342,7 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri /* Blit first half of input row row to initial row of output */ for (col = 0; col < width; col++) - *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor[col&1]); + *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level[col&1], scale_factor[col&1]); /* Advance the destination pointer by a row (source pointer remains in the same place) */ dst += dst_stride * sizeof(uint16_t); @@ -352,7 +350,7 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri /* Blit second half of input row row to next row of output */ for (col = 0; col < width; col++) - *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor[(col&1) + 2]); + *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level[(col&1) + 2], scale_factor[(col&1) + 2]); dst += dst_stride * sizeof(uint16_t); src += src_stride * sizeof(uint16_t); @@ -366,7 +364,9 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri uint16_t *src_u16 = (uint16_t *)src; for (col = 0; col < width; col++) - *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, s->black_level, scale_factor[(col&1) + 2 * ((line&1) + odd_line)]); + *dst_u16++ = dng_process_color16(*src_u16++, s->dng_lut, + s->black_level[(col&1) + 2 * ((line&1) + odd_line)], + scale_factor[(col&1) + 2 * ((line&1) + odd_line)]); dst += dst_stride * sizeof(uint16_t); src += src_stride * sizeof(uint16_t); @@ -377,7 +377,9 @@ static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int dst_stri const uint8_t *src_u8 = src; for (col = 0; col < width; col++) - *dst_u8++ = dng_process_color8(*src_u8++, s->dng_lut, s->black_level, scale_factor[(col&1) + 2 * ((line&1) + odd_line)]); + *dst_u8++ = dng_process_color8(*src_u8++, s->dng_lut, + s->black_level[(col&1) + 2 * ((line&1) + odd_line)], + scale_factor[(col&1) + 2 * ((line&1) + odd_line)]); dst += dst_stride; src += src_stride; @@ -1458,22 +1460,34 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) s->white_level = s->dng_lut[count-1]; break; case DNG_BLACK_LEVEL: - if (count > 1) { /* Use the first value in the pattern (assume they're all the same) */ + if (count > FF_ARRAY_ELEMS(s->black_level)) + return AVERROR_INVALIDDATA; + s->black_level[0] = value / (float)value2; + for (int i = 0; i < count && count > 1; i++) { if (type == TIFF_RATIONAL) { value = ff_tget(&s->gb, TIFF_LONG, s->le); value2 = ff_tget(&s->gb, TIFF_LONG, s->le); if (!value2) { - av_log(s->avctx, AV_LOG_WARNING, "Invalid black level denominator\n"); + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); value2 = 1; } - s->black_level = value / value2; - } else - s->black_level = ff_tget(&s->gb, type, s->le); - av_log(s->avctx, AV_LOG_WARNING, "Assuming black level pattern values are identical\n"); - } else { - s->black_level = value / value2; + s->black_level[i] = value / (float)value2; + } else if (type == TIFF_SRATIONAL) { + int value = ff_tget(&s->gb, TIFF_LONG, s->le); + int value2 = ff_tget(&s->gb, TIFF_LONG, s->le); + if (!value2) { + av_log(s->avctx, AV_LOG_WARNING, "Invalid denominator\n"); + value2 = 1; + } + + s->black_level[i] = value / (float)value2; + } else { + s->black_level[i] = ff_tget(&s->gb, type, s->le); + } } + for (int i = count; i < 4 && count > 0; i++) + s->black_level[i] = s->black_level[count - 1]; break; case DNG_WHITE_LEVEL: s->white_level = value; @@ -1939,6 +1953,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, for (i = 0; i < 65536; i++) s->dng_lut[i] = i; + for (i = 0; i < FF_ARRAY_ELEMS(s->black_level); i++) + s->black_level[i] = 0.f; + for (i = 0; i < FF_ARRAY_ELEMS(s->as_shot_neutral); i++) s->as_shot_neutral[i] = 0.f; @@ -2067,9 +2084,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, if (s->white_level == 0) s->white_level = (1LL << bps) - 1; /* Default value as per the spec */ - if (s->white_level <= s->black_level) { - av_log(avctx, AV_LOG_ERROR, "BlackLevel (%"PRId32") must be less than WhiteLevel (%"PRId32")\n", - s->black_level, s->white_level); + if (s->white_level <= s->black_level[0]) { + av_log(avctx, AV_LOG_ERROR, "BlackLevel (%g) must be less than WhiteLevel (%"PRId32")\n", + s->black_level[0], s->white_level); return AVERROR_INVALIDDATA; } From cf856d8957f82a3b15071b8f1f551b06a65b9b3f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 01:03:52 +0200 Subject: [PATCH 497/590] avcodec/avcodec: Move AV_ER_* and FF_COMPLIANCE_* to defs.h They are also frequently used in libavformat. This change does not cause any breakage as avcodec.h includes defs.h. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 25 +++---------------------- libavcodec/defs.h | 22 ++++++++++++++++++++++ libavcodec/version.h | 2 +- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 729f56be7b..a0988d1354 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-26 - xxxxxxxxxx - lavc 59.47.100 - avcodec.h defs.h + Move the AV_EF_* and FF_COMPLIANCE_* defines from avcodec.h to defs.h. + 2022-09-03 - xxxxxxxxxx - lavu 57.36.100 - pixfmt.h Add AV_PIX_FMT_P012, AV_PIX_FMT_Y212, AV_PIX_FMT_XV30, AV_PIX_FMT_XV36 diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7db5d1b1c5..0769577338 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1305,13 +1305,9 @@ typedef struct AVCodecContext { * unofficial and experimental (that is, they always try to decode things * when they can) unless they are explicitly asked to behave stupidly * (=strictly conform to the specs) + * This may only be set to one of the FF_COMPLIANCE_* values in defs.h. */ int strict_std_compliance; -#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. -#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. -#define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions -#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. /** * error concealment flags @@ -1347,28 +1343,13 @@ typedef struct AVCodecContext { /** * Error recognition; may misdetect some more or less valid parts as errors. + * This is a bitfield of the AV_EF_* values defined in defs.h. + * * - encoding: Set by user. * - decoding: Set by user. */ int err_recognition; -/** - * Verify checksums embedded in the bitstream (could be of either encoded or - * decoded data, depending on the codec) and print an error message on mismatch. - * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the - * decoder returning an error. - */ -#define AV_EF_CRCCHECK (1<<0) -#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations -#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length -#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection - -#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue -#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors -#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors -#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error - - /** * opaque 64-bit number (generally a PTS) that will be reordered and * output in AVFrame.reordered_opaque diff --git a/libavcodec/defs.h b/libavcodec/defs.h index 420a042b8f..fbe3254db2 100644 --- a/libavcodec/defs.h +++ b/libavcodec/defs.h @@ -39,6 +39,28 @@ */ #define AV_INPUT_BUFFER_PADDING_SIZE 64 +/** + * Verify checksums embedded in the bitstream (could be of either encoded or + * decoded data, depending on the format) and print an error message on mismatch. + * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the + * decoder/demuxer returning an error. + */ +#define AV_EF_CRCCHECK (1<<0) +#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations +#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length +#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection + +#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue +#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors +#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors +#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder/muxer should not do as an error + +#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. +#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. +#define FF_COMPLIANCE_NORMAL 0 +#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions +#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. + /** * @ingroup lavc_decoding */ diff --git a/libavcodec/version.h b/libavcodec/version.h index e973bb1c4d..1802a7ba1d 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 46 +#define LIBAVCODEC_VERSION_MINOR 47 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From 8be6552aa4bff1ce1016739a77733a2dcbdfaa8b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 02:30:39 +0200 Subject: [PATCH 498/590] avutil/pixdesc: Add av_chroma_location_(enum_to_pos|pos_to_enum) They are intended as replacements for avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum(). Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 3 +++ libavutil/pixdesc.c | 23 +++++++++++++++++++++++ libavutil/pixdesc.h | 22 ++++++++++++++++++++++ libavutil/version.h | 4 ++-- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a0988d1354..535e4e56bd 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-26 - xxxxxxxxxx - lavu 57.37.100 - pixdesc.h + Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum(). + 2022-09-26 - xxxxxxxxxx - lavc 59.47.100 - avcodec.h defs.h Move the AV_EF_* and FF_COMPLIANCE_* defines from avcodec.h to defs.h. diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index bfba414167..3ac44614a7 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -3315,3 +3315,26 @@ int av_chroma_location_from_name(const char *name) return AVERROR(EINVAL); } + +int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos) +{ + if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB) + return AVERROR(EINVAL); + pos--; + + *xpos = (pos&1) * 128; + *ypos = ((pos>>1)^(pos<4)) * 128; + + return 0; +} + +enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos) +{ + int pos, xout, yout; + + for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) { + if (av_chroma_location_enum_to_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos) + return pos; + } + return AVCHROMA_LOC_UNSPECIFIED; +} diff --git a/libavutil/pixdesc.h b/libavutil/pixdesc.h index 48d9300bfe..0df73e6efe 100644 --- a/libavutil/pixdesc.h +++ b/libavutil/pixdesc.h @@ -264,6 +264,28 @@ const char *av_chroma_location_name(enum AVChromaLocation location); */ int av_chroma_location_from_name(const char *name); +/** + * Converts AVChromaLocation to swscale x/y chroma position. + * + * The positions represent the chroma (0,0) position in a coordinates system + * with luma (0,0) representing the origin and luma(1,1) representing 256,256 + * + * @param xpos horizontal chroma sample position + * @param ypos vertical chroma sample position + */ +int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation pos); + +/** + * Converts swscale x/y chroma position to AVChromaLocation. + * + * The positions represent the chroma (0,0) position in a coordinates system + * with luma (0,0) representing the origin and luma(1,1) representing 256,256 + * + * @param xpos horizontal chroma sample position + * @param ypos vertical chroma sample position + */ +enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos); + /** * Return the pixel format corresponding to name. * diff --git a/libavutil/version.h b/libavutil/version.h index 0585fa7b80..9c44cef6aa 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 102 +#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ From 832e6563df9bb6ca79b8a9b39c6a7e8dc28808e2 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 02:36:04 +0200 Subject: [PATCH 499/590] avformat/matroska*: Use av_chroma_location_(pos_to_enum|enum_to_pos) Signed-off-by: Andreas Rheinhardt --- libavformat/matroskadec.c | 5 +++-- libavformat/matroskaenc.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8b079e1110..d582f566a2 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -46,6 +46,7 @@ #include "libavutil/mastering_display_metadata.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavutil/pixdesc.h" #include "libavutil/time_internal.h" #include "libavutil/spherical.h" @@ -2184,8 +2185,8 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) { color->chroma_siting_horz < MATROSKA_COLOUR_CHROMASITINGHORZ_NB && color->chroma_siting_vert < MATROSKA_COLOUR_CHROMASITINGVERT_NB) { st->codecpar->chroma_location = - avcodec_chroma_pos_to_enum((color->chroma_siting_horz - 1) << 7, - (color->chroma_siting_vert - 1) << 7); + av_chroma_location_pos_to_enum((color->chroma_siting_horz - 1) << 7, + (color->chroma_siting_vert - 1) << 7); } if (color->max_cll && color->max_fall) { size_t size = 0; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index ed1ad5039d..147f29988e 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -51,6 +51,7 @@ #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" +#include "libavutil/pixdesc.h" #include "libavutil/random_seed.h" #include "libavutil/rational.h" #include "libavutil/samplefmt.h" @@ -1322,7 +1323,7 @@ static void mkv_write_video_color(EbmlWriter *writer, const AVStream *st, par->chroma_location <= AVCHROMA_LOC_TOP) { int xpos, ypos; - avcodec_enum_to_chroma_pos(&xpos, &ypos, par->chroma_location); + av_chroma_location_enum_to_pos(&xpos, &ypos, par->chroma_location); ebml_writer_add_uint(writer, MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ, (xpos >> 7) + 1); ebml_writer_add_uint(writer, MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT, From a02a0e8db492ae91672449ac3be8ff084a903402 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 02:42:48 +0200 Subject: [PATCH 500/590] avcodec/avcodec: Deprecate lavc chroma pos API functions avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum() deal with enum AVChromaLocation which is defined in lavu. These functions are therefore replaced by av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum(). This commit provides the necessary deprecations. Also already make these functions wrappers around the corresponding lavu functions as not doing so would force one to disable deprecation warnings. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 5 +++++ libavcodec/avcodec.h | 6 ++++++ libavcodec/utils.c | 20 ++++---------------- libavcodec/version.h | 2 +- libavcodec/version_major.h | 1 + 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 535e4e56bd..b0a41c9e37 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,11 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-09-26 - xxxxxxxxxx - lavc 59.48.100 - avcodec.h + Deprecate avcodec_enum_to_chroma_pos() and avcodec_chroma_pos_to_enum(). + Use av_chroma_location_enum_to_pos() or av_chroma_location_pos_to_enum() + instead. + 2022-09-26 - xxxxxxxxxx - lavu 57.37.100 - pixdesc.h Add av_chroma_location_enum_to_pos() and av_chroma_location_pos_to_enum(). diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0769577338..7365eb5cc0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2496,6 +2496,7 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]); +#ifdef FF_API_AVCODEC_CHROMA_POS /** * Converts AVChromaLocation to swscale x/y chroma position. * @@ -2504,7 +2505,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, * * @param xpos horizontal chroma sample position * @param ypos vertical chroma sample position + * @deprecated Use av_chroma_location_enum_to_pos() instead. */ + attribute_deprecated int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); /** @@ -2515,8 +2518,11 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); * * @param xpos horizontal chroma sample position * @param ypos vertical chroma sample position + * @deprecated Use av_chroma_location_pos_to_enum() instead. */ + attribute_deprecated enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); +#endif /** * Decode a subtitle message. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 18c7a1be14..2b63a498b9 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -353,29 +353,17 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height) align = FFMAX3(align, linesize_align[1], linesize_align[2]); *width = FFALIGN(*width, align); } - +#if FF_API_AVCODEC_CHROMA_POS int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos) { - if (pos <= AVCHROMA_LOC_UNSPECIFIED || pos >= AVCHROMA_LOC_NB) - return AVERROR(EINVAL); - pos--; - - *xpos = (pos&1) * 128; - *ypos = ((pos>>1)^(pos<4)) * 128; - - return 0; + return av_chroma_location_enum_to_pos(xpos, ypos, pos); } enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos) { - int pos, xout, yout; - - for (pos = AVCHROMA_LOC_UNSPECIFIED + 1; pos < AVCHROMA_LOC_NB; pos++) { - if (avcodec_enum_to_chroma_pos(&xout, &yout, pos) == 0 && xout == xpos && yout == ypos) - return pos; - } - return AVCHROMA_LOC_UNSPECIFIED; + return av_chroma_location_pos_to_enum(xpos, ypos); } +#endif int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, diff --git a/libavcodec/version.h b/libavcodec/version.h index 1802a7ba1d..be26e9c364 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 47 +#define LIBAVCODEC_VERSION_MINOR 48 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h index d9386792de..12f863deb7 100644 --- a/libavcodec/version_major.h +++ b/libavcodec/version_major.h @@ -52,5 +52,6 @@ #define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 60) #endif /* AVCODEC_VERSION_MAJOR_H */ From 2b41463b8706638b9aaf967655f95ddc195c32eb Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 21 Sep 2022 03:03:07 +0200 Subject: [PATCH 501/590] avformat/internal: Don't include avcodec.h The general demuxing API uses parsers and decoders. Therefore FFStream contains pointers to AVCodecContexts and AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h. Yet actually only a few files files really use these; and it is best when this number stays small. Therefore this commit uses opaque structs in lavf/internal.h for these contexts and stops including avcodec.h. This also avoids including lavc/codec_desc.h implicitly. All other headers are implicitly included as now (mostly through codec.h). Signed-off-by: Andreas Rheinhardt --- libavdevice/jack.c | 1 - libavdevice/v4l2.c | 1 + libavformat/asfenc.c | 1 + libavformat/av1dec.c | 2 +- libavformat/concatdec.c | 1 + libavformat/dashenc.c | 2 ++ libavformat/demux.c | 1 + libavformat/dump.c | 3 ++- libavformat/flacdec.c | 1 + libavformat/flvenc.c | 1 + libavformat/hlsenc.c | 2 ++ libavformat/internal.h | 3 +-- libavformat/matroskaenc.c | 1 + libavformat/mpegts.c | 1 + libavformat/mpegtsenc.c | 1 + libavformat/mxfenc.c | 1 + libavformat/oggparseflac.c | 1 + libavformat/rawdec.c | 6 ++---- libavformat/riffenc.c | 1 - libavformat/rtsp.c | 1 + libavformat/seek.c | 2 ++ 21 files changed, 24 insertions(+), 10 deletions(-) diff --git a/libavdevice/jack.c b/libavdevice/jack.c index e34eb8961c..db056d824f 100644 --- a/libavdevice/jack.c +++ b/libavdevice/jack.c @@ -29,7 +29,6 @@ #include "libavutil/fifo.h" #include "libavutil/opt.h" #include "libavutil/time.h" -#include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libavformat/internal.h" #include "timefilter.h" diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index be422d7c8c..5e85d1a2b3 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -38,6 +38,7 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/time.h" +#include "libavcodec/avcodec.h" #include "libavcodec/codec_desc.h" #include "libavformat/demux.h" #include "libavformat/internal.h" diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c index e1563b1da6..70800a6df5 100644 --- a/libavformat/asfenc.c +++ b/libavformat/asfenc.c @@ -25,6 +25,7 @@ #include "libavutil/dict.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavcodec/codec_desc.h" #include "avformat.h" #include "avlanguage.h" #include "avio_internal.h" diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c index 350f5360d5..d4b430af7e 100644 --- a/libavformat/av1dec.c +++ b/libavformat/av1dec.c @@ -19,11 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" #include "config_components.h" #include "libavutil/common.h" #include "libavutil/opt.h" +#include "libavcodec/avcodec.h" #include "libavcodec/av1_parse.h" #include "libavcodec/bsf.h" #include "avformat.h" diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index e57da59e04..7748c20b6d 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -25,6 +25,7 @@ #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/timestamp.h" +#include "libavcodec/codec_desc.h" #include "libavcodec/bsf.h" #include "avformat.h" #include "avio_internal.h" diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 295b01e225..a0919f6f2d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -38,6 +38,8 @@ #include "libavutil/time.h" #include "libavutil/time_internal.h" +#include "libavcodec/avcodec.h" + #include "av1.h" #include "avc.h" #include "avformat.h" diff --git a/libavformat/demux.c b/libavformat/demux.c index 1620716716..2dfd82a63c 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -34,6 +34,7 @@ #include "libavutil/time.h" #include "libavutil/timestamp.h" +#include "libavcodec/avcodec.h" #include "libavcodec/bsf.h" #include "libavcodec/internal.h" #include "libavcodec/packet_internal.h" diff --git a/libavformat/dump.c b/libavformat/dump.c index cafcef36c6..225f80ac22 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -30,12 +30,13 @@ #include "libavutil/dovi_meta.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" -#include "libavutil/avstring.h" #include "libavutil/replaygain.h" #include "libavutil/spherical.h" #include "libavutil/stereo3d.h" #include "libavutil/timecode.h" +#include "libavcodec/avcodec.h" + #include "avformat.h" #include "internal.h" diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index eadd41fc36..b58ec03963 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -20,6 +20,7 @@ */ #include "libavutil/channel_layout.h" +#include "libavcodec/avcodec.h" #include "libavcodec/bytestream.h" #include "libavcodec/flac.h" #include "avformat.h" diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 5d574fa790..59be11eba8 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -24,6 +24,7 @@ #include "libavutil/intfloat.h" #include "libavutil/avassert.h" #include "libavutil/mathematics.h" +#include "libavcodec/codec_desc.h" #include "libavcodec/mpeg4audio.h" #include "avio.h" #include "avc.h" diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 6f49ae1aa2..a86fc8907f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -43,6 +43,8 @@ #include "libavutil/time.h" #include "libavutil/time_internal.h" +#include "libavcodec/avcodec.h" + #include "avformat.h" #include "avio_internal.h" #include "avc.h" diff --git a/libavformat/internal.h b/libavformat/internal.h index 23757dc4fc..ce837fefc7 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -23,7 +23,6 @@ #include -#include "libavcodec/avcodec.h" #include "libavcodec/packet_internal.h" #include "avformat.h" @@ -221,7 +220,7 @@ typedef struct FFStream { /** * The codec context used by avformat_find_stream_info, the parser, etc. */ - AVCodecContext *avctx; + struct AVCodecContext *avctx; /** * 1 if avctx has been initialized with the values from the codec parameters */ diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 147f29988e..2be4f87284 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -58,6 +58,7 @@ #include "libavutil/stereo3d.h" #include "libavcodec/av1.h" +#include "libavcodec/codec_desc.h" #include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 8a3436f2be..d97702fcd7 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -32,6 +32,7 @@ #include "libavutil/opt.h" #include "libavutil/avassert.h" #include "libavutil/dovi_meta.h" +#include "libavcodec/avcodec.h" #include "libavcodec/bytestream.h" #include "libavcodec/get_bits.h" #include "libavcodec/opus.h" diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index c964d58c8e..5148a6aecd 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -28,6 +28,7 @@ #include "libavutil/opt.h" #include "libavcodec/ac3_parser_internal.h" +#include "libavcodec/avcodec.h" #include "libavcodec/startcode.h" #include "avformat.h" diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index 9a9acbfa08..58c551c83c 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -47,6 +47,7 @@ #include "libavutil/mastering_display_metadata.h" #include "libavutil/pixdesc.h" #include "libavutil/time_internal.h" +#include "libavcodec/avcodec.h" #include "libavcodec/golomb.h" #include "libavcodec/h264.h" #include "libavcodec/packet_internal.h" diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index fa7459c162..eef6e09927 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -19,6 +19,7 @@ */ #include +#include "libavcodec/avcodec.h" #include "libavcodec/get_bits.h" #include "libavcodec/flac.h" #include "avformat.h" diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 17649bc077..de804366ed 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -24,12 +24,10 @@ #include "avformat.h" #include "internal.h" -#include "avio_internal.h" #include "rawdec.h" #include "libavutil/opt.h" -#include "libavutil/parseutils.h" -#include "libavutil/pixdesc.h" -#include "libavutil/intreadwrite.h" + +#include "libavcodec/avcodec.h" #define RAW_PACKET_SIZE 1024 diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index 7825c4e746..179b0f12cb 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -23,7 +23,6 @@ #include "libavutil/dict.h" #include "libavutil/log.h" #include "libavutil/mathematics.h" -#include "libavcodec/avcodec.h" #include "libavcodec/bytestream.h" #include "avformat.h" #include "avio_internal.h" diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index f948f1d395..cfafb4be80 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -32,6 +32,7 @@ #include "libavutil/dict.h" #include "libavutil/opt.h" #include "libavutil/time.h" +#include "libavcodec/codec_desc.h" #include "avformat.h" #include "avio_internal.h" diff --git a/libavformat/seek.c b/libavformat/seek.c index 3b1c75f1b1..a236e285c0 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -25,6 +25,8 @@ #include "libavutil/mathematics.h" #include "libavutil/timestamp.h" +#include "libavcodec/avcodec.h" + #include "avformat.h" #include "avio_internal.h" #include "demux.h" From dd2ea014ef273157fe9a0e928e77841fbbee9b2f Mon Sep 17 00:00:00 2001 From: Dmitry Rogozhkin Date: Fri, 23 Sep 2022 14:19:20 -0700 Subject: [PATCH 502/590] libavcodec/qsvenc: fixy typo for min/max qp reset Fixes: 005c7a4 ("libavcodec/qsvenc: Add max/min qp reset support in qsvenc") Reviewed-by: Wenbin Chen Signed-off-by: Dmitry Rogozhkin --- libavcodec/qsvenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 84c6e292aa..8bd9272dc6 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1760,8 +1760,8 @@ static int update_min_max_qp(AVCodecContext *avctx, QSVEncContext *q) if (avctx->codec_id != AV_CODEC_ID_H264) return 0; - UPDATE_PARAM(q->old_qmax, avctx->qmin); - UPDATE_PARAM(q->old_qmax, avctx->qmin); + UPDATE_PARAM(q->old_qmin, avctx->qmin); + UPDATE_PARAM(q->old_qmax, avctx->qmax); UPDATE_PARAM(q->old_min_qp_i, q->min_qp_i); UPDATE_PARAM(q->old_max_qp_i, q->max_qp_i); UPDATE_PARAM(q->old_min_qp_p, q->min_qp_p); From 543a46b4b2ff0f02fa85e45d7b7bcda19d3be9b4 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 24 Sep 2022 00:46:44 +0200 Subject: [PATCH 503/590] opus: convert encoder and decoder to lavu/tx This commit changes both the encoder and decoder to use the new lavu/tx code, which has faster C transforms and more assembly optimizations. --- libavcodec/opus_celt.c | 20 ++++++++++++-------- libavcodec/opus_celt.h | 5 +++-- libavcodec/opusenc.c | 15 +++++++++------ libavcodec/opusenc_psy.c | 13 ++++++++----- libavcodec/opusenc_psy.h | 4 +++- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index 9dbeff1927..f1fb88a56d 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -323,7 +323,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, { int i, j, downmix = 0; int consumed; // bits of entropy consumed thus far for this frame - MDCT15Context *imdct; + AVTXContext *imdct; + av_tx_fn imdct_fn; if (channels != 1 && channels != 2) { av_log(f->avctx, AV_LOG_ERROR, "Invalid number of coded channels: %d\n", @@ -385,7 +386,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, f->blocks = f->transient ? 1 << f->size : 1; f->blocksize = frame_size / f->blocks; - imdct = f->imdct[f->transient ? 0 : f->size]; + imdct = f->tx[f->transient ? 0 : f->size]; + imdct_fn = f->tx_fn[f->transient ? 0 : f->size]; if (channels == 1) { for (i = 0; i < CELT_MAX_BANDS; i++) @@ -440,8 +442,8 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, for (j = 0; j < f->blocks; j++) { float *dst = block->buf + 1024 + j * f->blocksize; - imdct->imdct_half(imdct, dst + CELT_OVERLAP / 2, f->block[i].coeffs + j, - f->blocks); + imdct_fn(imdct, dst + CELT_OVERLAP / 2, f->block[i].coeffs + j, + sizeof(float)*f->blocks); f->dsp->vector_fmul_window(dst, dst, dst + CELT_OVERLAP / 2, ff_celt_window, CELT_OVERLAP / 2); } @@ -526,8 +528,8 @@ void ff_celt_free(CeltFrame **f) if (!frm) return; - for (i = 0; i < FF_ARRAY_ELEMS(frm->imdct); i++) - ff_mdct15_uninit(&frm->imdct[i]); + for (i = 0; i < FF_ARRAY_ELEMS(frm->tx); i++) + av_tx_uninit(&frm->tx[i]); ff_celt_pvq_uninit(&frm->pvq); @@ -555,9 +557,11 @@ int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels, frm->output_channels = output_channels; frm->apply_phase_inv = apply_phase_inv; - for (i = 0; i < FF_ARRAY_ELEMS(frm->imdct); i++) - if ((ret = ff_mdct15_init(&frm->imdct[i], 1, i + 3, -1.0f/32768)) < 0) + for (i = 0; i < FF_ARRAY_ELEMS(frm->tx); i++) { + const float scale = -1.0f/32768; + if ((ret = av_tx_init(&frm->tx[i], &frm->tx_fn[i], AV_TX_FLOAT_MDCT, 1, 15 << (i + 3), &scale, 0)) < 0) goto fail; + } if ((ret = ff_celt_pvq_init(&frm->pvq, 0)) < 0) goto fail; diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h index 661ca251de..291a544298 100644 --- a/libavcodec/opus_celt.h +++ b/libavcodec/opus_celt.h @@ -30,10 +30,10 @@ #include "opus_pvq.h" #include "opusdsp.h" -#include "mdct15.h" #include "libavutil/float_dsp.h" #include "libavutil/libm.h" #include "libavutil/mem_internal.h" +#include "libavutil/tx.h" #define CELT_VECTORS 11 #define CELT_ALLOC_STEPS 6 @@ -93,7 +93,8 @@ typedef struct CeltBlock { struct CeltFrame { // constant values that do not change during context lifetime AVCodecContext *avctx; - MDCT15Context *imdct[4]; + AVTXContext *tx[4]; + av_tx_fn tx_fn[4]; AVFloatDSPContext *dsp; CeltBlock block[2]; CeltPVQ *pvq; diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index a7a9d3a5f5..8cdd27d930 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -40,7 +40,8 @@ typedef struct OpusEncContext { AVCodecContext *avctx; AudioFrameQueue afq; AVFloatDSPContext *dsp; - MDCT15Context *mdct[CELT_BLOCK_NB]; + AVTXContext *tx[CELT_BLOCK_NB]; + av_tx_fn tx_fn[CELT_BLOCK_NB]; CeltPVQ *pvq; struct FFBufQueue bufqueue; @@ -204,7 +205,7 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f) s->dsp->vector_fmul_reverse(&win[CELT_OVERLAP], src2, ff_celt_window - 8, 128); src1 = src2; - s->mdct[0]->mdct(s->mdct[0], b->coeffs + t, win, f->blocks); + s->tx_fn[0](s->tx[0], b->coeffs + t, win, sizeof(float)*f->blocks); } } } else { @@ -226,7 +227,7 @@ static void celt_frame_mdct(OpusEncContext *s, CeltFrame *f) ff_celt_window - 8, 128); memcpy(win + lap_dst + blk_len, temp, CELT_OVERLAP*sizeof(float)); - s->mdct[f->size]->mdct(s->mdct[f->size], b->coeffs, win, 1); + s->tx_fn[f->size](s->tx[f->size], b->coeffs, win, sizeof(float)); } } @@ -612,7 +613,7 @@ static av_cold int opus_encode_end(AVCodecContext *avctx) OpusEncContext *s = avctx->priv_data; for (int i = 0; i < CELT_BLOCK_NB; i++) - ff_mdct15_uninit(&s->mdct[i]); + av_tx_uninit(&s->tx[i]); ff_celt_pvq_uninit(&s->pvq); av_freep(&s->dsp); @@ -668,9 +669,11 @@ static av_cold int opus_encode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); /* I have no idea why a base scaling factor of 68 works, could be the twiddles */ - for (int i = 0; i < CELT_BLOCK_NB; i++) - if ((ret = ff_mdct15_init(&s->mdct[i], 0, i + 3, 68 << (CELT_BLOCK_NB - 1 - i)))) + for (int i = 0; i < CELT_BLOCK_NB; i++) { + const float scale = 68 << (CELT_BLOCK_NB - 1 - i); + if ((ret = av_tx_init(&s->tx[i], &s->tx_fn[i], AV_TX_FLOAT_MDCT, 0, 15 << (i + 3), &scale, 0))) return AVERROR(ENOMEM); + } /* Zero out previous energy (matters for inter first frame) */ for (int ch = 0; ch < s->channels; ch++) diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c index 1c8f69269c..3bff57d347 100644 --- a/libavcodec/opusenc_psy.c +++ b/libavcodec/opusenc_psy.c @@ -22,7 +22,6 @@ #include "opusenc_psy.h" #include "opus_pvq.h" #include "opustab.h" -#include "mdct15.h" #include "libavutil/qsort.h" static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int band, @@ -99,7 +98,8 @@ static void step_collect_psy_metrics(OpusPsyContext *s, int index) s->dsp->vector_fmul(s->scratch, s->scratch, s->window[s->bsize_analysis], (OPUS_BLOCK_SIZE(s->bsize_analysis) << 1)); - s->mdct[s->bsize_analysis]->mdct(s->mdct[s->bsize_analysis], st->coeffs[ch], s->scratch, 1); + s->mdct_fn[s->bsize_analysis](s->mdct[s->bsize_analysis], st->coeffs[ch], + s->scratch, sizeof(float)); for (i = 0; i < CELT_MAX_BANDS; i++) st->bands[ch][i] = &st->coeffs[ch][ff_celt_freq_bands[i] << s->bsize_analysis]; @@ -558,13 +558,16 @@ av_cold int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx, for (i = 0; i < CELT_BLOCK_NB; i++) { float tmp; const int len = OPUS_BLOCK_SIZE(i); + const float scale = 68 << (CELT_BLOCK_NB - 1 - i); s->window[i] = av_malloc(2*len*sizeof(float)); if (!s->window[i]) { ret = AVERROR(ENOMEM); goto fail; } generate_window_func(s->window[i], 2*len, WFUNC_SINE, &tmp); - if ((ret = ff_mdct15_init(&s->mdct[i], 0, i + 3, 68 << (CELT_BLOCK_NB - 1 - i)))) + ret = av_tx_init(&s->mdct[i], &s->mdct_fn[i], AV_TX_FLOAT_MDCT, + 0, 15 << (i + 3), &scale, 0); + if (ret < 0) goto fail; } @@ -575,7 +578,7 @@ av_cold int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx, av_freep(&s->dsp); for (i = 0; i < CELT_BLOCK_NB; i++) { - ff_mdct15_uninit(&s->mdct[i]); + av_tx_uninit(&s->mdct[i]); av_freep(&s->window[i]); } @@ -598,7 +601,7 @@ av_cold int ff_opus_psy_end(OpusPsyContext *s) av_freep(&s->dsp); for (i = 0; i < CELT_BLOCK_NB; i++) { - ff_mdct15_uninit(&s->mdct[i]); + av_tx_uninit(&s->mdct[i]); av_freep(&s->window[i]); } diff --git a/libavcodec/opusenc_psy.h b/libavcodec/opusenc_psy.h index d4fb096a3d..0a7cdb6f2c 100644 --- a/libavcodec/opusenc_psy.h +++ b/libavcodec/opusenc_psy.h @@ -22,6 +22,7 @@ #ifndef AVCODEC_OPUSENC_PSY_H #define AVCODEC_OPUSENC_PSY_H +#include "libavutil/tx.h" #include "libavutil/mem_internal.h" #include "opusenc.h" @@ -70,7 +71,8 @@ typedef struct OpusPsyContext { int max_steps; float *window[CELT_BLOCK_NB]; - MDCT15Context *mdct[CELT_BLOCK_NB]; + AVTXContext *mdct[CELT_BLOCK_NB]; + av_tx_fn mdct_fn[CELT_BLOCK_NB]; int bsize_analysis; DECLARE_ALIGNED(32, float, scratch)[2048]; From 179830108dbeb1c6b73105ae2234cf04874728b4 Mon Sep 17 00:00:00 2001 From: Tristan Schmelcher Date: Mon, 26 Sep 2022 17:14:09 +0000 Subject: [PATCH 504/590] avfilter/scale_eval: Reduce rounding error. When force_original_aspect_ratio and force_divisible_by are both used, dimensions are now rounded to the nearest allowed multiple of force_divisible_by rather than first rounding to the nearest integer and then rounding in a static direction. This results in less distortion of the aspect ratio. Reviewed-by: Thierry Foucu Signed-off-by: Tristan Schmelcher Signed-off-by: Michael Niedermayer --- libavfilter/scale_eval.c | 11 +++++++---- libavfilter/scale_eval.h | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c index dfec081e15..75ed503f15 100644 --- a/libavfilter/scale_eval.c +++ b/libavfilter/scale_eval.c @@ -148,14 +148,17 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, * dimensions so that it is not divisible by the set factors anymore * unless force_divisible_by is defined as well */ if (force_original_aspect_ratio) { - int tmp_w = av_rescale(h, inlink->w, inlink->h); - int tmp_h = av_rescale(w, inlink->h, inlink->w); + // Including force_divisible_by here rounds to the nearest multiple of it. + int tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by) + * force_divisible_by; + int tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by) + * force_divisible_by; if (force_original_aspect_ratio == 1) { w = FFMIN(tmp_w, w); h = FFMIN(tmp_h, h); if (force_divisible_by > 1) { - // round down + // round down in case provided w or h is not divisible. w = w / force_divisible_by * force_divisible_by; h = h / force_divisible_by * force_divisible_by; } @@ -163,7 +166,7 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, w = FFMAX(tmp_w, w); h = FFMAX(tmp_h, h); if (force_divisible_by > 1) { - // round up + // round up in case provided w or h is not divisible. w = (w + force_divisible_by - 1) / force_divisible_by * force_divisible_by; h = (h + force_divisible_by - 1) / force_divisible_by * force_divisible_by; } diff --git a/libavfilter/scale_eval.h b/libavfilter/scale_eval.h index fceb023fec..2eb6970aad 100644 --- a/libavfilter/scale_eval.h +++ b/libavfilter/scale_eval.h @@ -38,7 +38,8 @@ int ff_scale_eval_dimensions(void *ctx, * Transform evaluated width and height obtained from ff_scale_eval_dimensions * into actual target width and height for scaling. Adjustment can occur if one * or both of the evaluated values are of the form '-n' or if - * force_original_aspect_ratio is set. + * force_original_aspect_ratio is set. force_divisible_by is used only when + * force_original_aspect_ratio is set and must be at least 1. * * Returns 0. */ From b95e2fbd85e93b58d019ad0e3da64a72ee7cc3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:21 +0300 Subject: [PATCH 505/590] lavu/cpu: detect RISC-V base extensions This introduces compile-time and run-time CPU detection on RISC-V. In practice, I doubt that FFmpeg will ever see a RISC-V CPU without all of I, F and D extensions, and if it does, it probably won't have run-time detection. So the flags are essentially always set. But as things stand, checkasm wants them that way. Compare the ARMV8 flag on AArch64. We are nowhere near running short on CPU flag bits. --- libavutil/cpu.c | 6 +++++ libavutil/cpu.h | 5 ++++ libavutil/cpu_internal.h | 1 + libavutil/riscv/Makefile | 1 + libavutil/riscv/cpu.c | 56 +++++++++++++++++++++++++++++++++++++++ tests/checkasm/checkasm.c | 4 +++ 6 files changed, 73 insertions(+) create mode 100644 libavutil/riscv/Makefile create mode 100644 libavutil/riscv/cpu.c diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 0035e927a5..8b6eef9873 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -62,6 +62,8 @@ static int get_cpu_flags(void) return ff_get_cpu_flags_arm(); #elif ARCH_PPC return ff_get_cpu_flags_ppc(); +#elif ARCH_RISCV + return ff_get_cpu_flags_riscv(); #elif ARCH_X86 return ff_get_cpu_flags_x86(); #elif ARCH_LOONGARCH @@ -178,6 +180,10 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) #elif ARCH_LOONGARCH { "lsx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_LSX }, .unit = "flags" }, { "lasx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_LASX }, .unit = "flags" }, +#elif ARCH_RISCV + { "rvi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVI }, .unit = "flags" }, + { "rvf", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVF }, .unit = "flags" }, + { "rvd", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVD }, .unit = "flags" }, #endif { NULL }, }; diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 9711e574c5..9aae2ccc7a 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -78,6 +78,11 @@ #define AV_CPU_FLAG_LSX (1 << 0) #define AV_CPU_FLAG_LASX (1 << 1) +// RISC-V extensions +#define AV_CPU_FLAG_RVI (1 << 0) ///< I (full GPR bank) +#define AV_CPU_FLAG_RVF (1 << 1) ///< F (single precision FP) +#define AV_CPU_FLAG_RVD (1 << 2) ///< D (double precision FP) + /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h index 650d47fc96..634f28bac4 100644 --- a/libavutil/cpu_internal.h +++ b/libavutil/cpu_internal.h @@ -48,6 +48,7 @@ int ff_get_cpu_flags_mips(void); int ff_get_cpu_flags_aarch64(void); int ff_get_cpu_flags_arm(void); int ff_get_cpu_flags_ppc(void); +int ff_get_cpu_flags_riscv(void); int ff_get_cpu_flags_x86(void); int ff_get_cpu_flags_loongarch(void); diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile new file mode 100644 index 0000000000..1f818043dc --- /dev/null +++ b/libavutil/riscv/Makefile @@ -0,0 +1 @@ +OBJS += riscv/cpu.o diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c new file mode 100644 index 0000000000..6803f035e5 --- /dev/null +++ b/libavutil/riscv/cpu.c @@ -0,0 +1,56 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 "libavutil/cpu.h" +#include "libavutil/cpu_internal.h" +#include "libavutil/log.h" +#include "config.h" + +#if HAVE_GETAUXVAL +#include +#define HWCAP_RV(letter) (1ul << ((letter) - 'A')) +#endif + +int ff_get_cpu_flags_riscv(void) +{ + int ret = 0; +#if HAVE_GETAUXVAL + const unsigned long hwcap = getauxval(AT_HWCAP); + + if (hwcap & HWCAP_RV('I')) + ret |= AV_CPU_FLAG_RVI; + if (hwcap & HWCAP_RV('F')) + ret |= AV_CPU_FLAG_RVF; + if (hwcap & HWCAP_RV('D')) + ret |= AV_CPU_FLAG_RVD; +#endif + +#ifdef __riscv_i + ret |= AV_CPU_FLAG_RVI; +#endif +#if defined (__riscv_flen) && (__riscv_flen >= 32) + ret |= AV_CPU_FLAG_RVF; +#if (__riscv_flen >= 64) + ret |= AV_CPU_FLAG_RVD; +#endif +#endif + + return ret; +} diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 8fd9bba0b0..e1135a84ac 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -232,6 +232,10 @@ static const struct { { "ALTIVEC", "altivec", AV_CPU_FLAG_ALTIVEC }, { "VSX", "vsx", AV_CPU_FLAG_VSX }, { "POWER8", "power8", AV_CPU_FLAG_POWER8 }, +#elif ARCH_RISCV + { "RVI", "rvi", AV_CPU_FLAG_RVI }, + { "RVF", "rvf", AV_CPU_FLAG_RVF }, + { "RVD", "rvd", AV_CPU_FLAG_RVD }, #elif ARCH_MIPS { "MMI", "mmi", AV_CPU_FLAG_MMI }, { "MSA", "msa", AV_CPU_FLAG_MSA }, From 746f1ff36ac0d232687820fbde4e4efc79093af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:22 +0300 Subject: [PATCH 506/590] lavu/riscv: initial common header for assembler macros --- libavutil/riscv/asm.S | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 libavutil/riscv/asm.S diff --git a/libavutil/riscv/asm.S b/libavutil/riscv/asm.S new file mode 100644 index 0000000000..dbd97f40a4 --- /dev/null +++ b/libavutil/riscv/asm.S @@ -0,0 +1,77 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * Loosely based on earlier work copyrighted by Måns Rullgård, 2008. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#if defined (__riscv_float_abi_soft) +#define NOHWF +#define NOHWD +#define HWF # +#define HWD # +#elif defined (__riscv_float_abi_single) +#define NOHWF # +#define NOHWD +#define HWF +#define HWD # +#else +#define NOHWF # +#define NOHWD # +#define HWF +#define HWD +#endif + + .macro func sym, ext= + .text + .align 2 + + .option push + .ifnb \ext + .option arch, +\ext + .endif + + .global \sym + .hidden \sym + .type \sym, %function + \sym: + + .macro endfunc + .size \sym, . - \sym + .option pop + .previous + .purgem endfunc + .endm + .endm + + .macro const sym, align=3, relocate=0 + .if \relocate + .pushsection .data.rel.ro + .else + .pushsection .rodata + .endif + .align \align + \sym: + + .macro endconst + .size \sym, . - \sym + .popsection + .purgem endconst + .endm + .endm From 04d092e7d5204f1aebb7e61f92bb263873e0f735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:23 +0300 Subject: [PATCH 507/590] lavc/audiodsp: RISC-V F vector_clipf RV64G supports MIN & MAX instructions natively only on floating point registers, not general purpose ones. The later would require the Zbb extension. Due to that, it is actually faster to perform the clipping "properly" in FPU. Benchmarks on SiFive U74-MC (courtesy of Shanghai StarFive Tech): audiodsp.vector_clipf_c: 29551.5 audiodsp.vector_clipf_rvf: 17871.0 Also tried unrolling with 2 or 8 elements but it gets worse either way. --- libavcodec/audiodsp.c | 2 ++ libavcodec/audiodsp.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/audiodsp_init.c | 33 +++++++++++++++++++++ libavcodec/riscv/audiodsp_rvf.S | 49 ++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 libavcodec/riscv/Makefile create mode 100644 libavcodec/riscv/audiodsp_init.c create mode 100644 libavcodec/riscv/audiodsp_rvf.S diff --git a/libavcodec/audiodsp.c b/libavcodec/audiodsp.c index ff43e87dce..eba6e809fd 100644 --- a/libavcodec/audiodsp.c +++ b/libavcodec/audiodsp.c @@ -113,6 +113,8 @@ av_cold void ff_audiodsp_init(AudioDSPContext *c) ff_audiodsp_init_arm(c); #elif ARCH_PPC ff_audiodsp_init_ppc(c); +#elif ARCH_RISCV + ff_audiodsp_init_riscv(c); #elif ARCH_X86 ff_audiodsp_init_x86(c); #endif diff --git a/libavcodec/audiodsp.h b/libavcodec/audiodsp.h index aa6fa7898b..485b512839 100644 --- a/libavcodec/audiodsp.h +++ b/libavcodec/audiodsp.h @@ -55,6 +55,7 @@ typedef struct AudioDSPContext { void ff_audiodsp_init(AudioDSPContext *c); void ff_audiodsp_init_arm(AudioDSPContext *c); void ff_audiodsp_init_ppc(AudioDSPContext *c); +void ff_audiodsp_init_riscv(AudioDSPContext *c); void ff_audiodsp_init_x86(AudioDSPContext *c); #endif /* AVCODEC_AUDIODSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile new file mode 100644 index 0000000000..414a9e9bd8 --- /dev/null +++ b/libavcodec/riscv/Makefile @@ -0,0 +1,2 @@ +OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ + riscv/audiodsp_rvf.o diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c new file mode 100644 index 0000000000..c5842815d6 --- /dev/null +++ b/libavcodec/riscv/audiodsp_init.c @@ -0,0 +1,33 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/audiodsp.h" + +void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max); + +av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) +{ + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVF) + c->vector_clipf = ff_vector_clipf_rvf; +} diff --git a/libavcodec/riscv/audiodsp_rvf.S b/libavcodec/riscv/audiodsp_rvf.S new file mode 100644 index 0000000000..2ec8a11691 --- /dev/null +++ b/libavcodec/riscv/audiodsp_rvf.S @@ -0,0 +1,49 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 "libavutil/riscv/asm.S" + +func ff_vector_clipf_rvf, f +NOHWF fmv.w.x fa0, a3 +NOHWF fmv.w.x fa1, a4 +1: + flw ft0, (a1) + flw ft1, 4(a1) + fmax.s ft0, ft0, fa0 + flw ft2, 8(a1) + fmax.s ft1, ft1, fa0 + flw ft3, 12(a1) + fmax.s ft2, ft2, fa0 + addi a2, a2, -4 + fmax.s ft3, ft3, fa0 + addi a1, a1, 16 + fmin.s ft0, ft0, fa1 + fmin.s ft1, ft1, fa1 + fsw ft0, (a0) + fmin.s ft2, ft2, fa1 + fsw ft1, 4(a0) + fmin.s ft3, ft3, fa1 + fsw ft2, 8(a0) + fsw ft3, 12(a0) + addi a0, a0, 16 + bnez a2, 1b + + ret +endfunc From 1edac8eb468cb9a769ded6197dbce515b71b137e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:24 +0300 Subject: [PATCH 508/590] lavc/pixblockdsp: RISC-V I get_pixels Benchmarks on SiFive U74-MC (courtesy of Shanghai StarFive Tech): get_pixels_c: 180.0 get_pixels_rvi: 136.7 --- libavcodec/pixblockdsp.c | 2 + libavcodec/pixblockdsp.h | 2 + libavcodec/riscv/Makefile | 2 + libavcodec/riscv/pixblockdsp_init.c | 45 ++++++++++++++++++++++ libavcodec/riscv/pixblockdsp_rvi.S | 59 +++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 libavcodec/riscv/pixblockdsp_init.c create mode 100644 libavcodec/riscv/pixblockdsp_rvi.S diff --git a/libavcodec/pixblockdsp.c b/libavcodec/pixblockdsp.c index 17c487da1e..4294075cee 100644 --- a/libavcodec/pixblockdsp.c +++ b/libavcodec/pixblockdsp.c @@ -109,6 +109,8 @@ av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) ff_pixblockdsp_init_arm(c, avctx, high_bit_depth); #elif ARCH_PPC ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth); +#elif ARCH_RISCV + ff_pixblockdsp_init_riscv(c, avctx, high_bit_depth); #elif ARCH_X86 ff_pixblockdsp_init_x86(c, avctx, high_bit_depth); #elif ARCH_MIPS diff --git a/libavcodec/pixblockdsp.h b/libavcodec/pixblockdsp.h index 07c2ec4f40..9b002aa3d6 100644 --- a/libavcodec/pixblockdsp.h +++ b/libavcodec/pixblockdsp.h @@ -52,6 +52,8 @@ void ff_pixblockdsp_init_arm(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); void ff_pixblockdsp_init_x86(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 414a9e9bd8..da07f1fe96 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,2 +1,4 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o +OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ + riscv/pixblockdsp_rvi.o diff --git a/libavcodec/riscv/pixblockdsp_init.c b/libavcodec/riscv/pixblockdsp_init.c new file mode 100644 index 0000000000..04bf52649f --- /dev/null +++ b/libavcodec/riscv/pixblockdsp_init.c @@ -0,0 +1,45 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/pixblockdsp.h" + +void ff_get_pixels_8_rvi(int16_t *block, const uint8_t *pixels, + ptrdiff_t stride); +void ff_get_pixels_16_rvi(int16_t *block, const uint8_t *pixels, + ptrdiff_t stride); + +av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, + AVCodecContext *avctx, + unsigned high_bit_depth) +{ + int cpu_flags = av_get_cpu_flags(); + + if (cpu_flags & AV_CPU_FLAG_RVI) { + if (high_bit_depth) + c->get_pixels = ff_get_pixels_16_rvi; + else + c->get_pixels = ff_get_pixels_8_rvi; + } +} diff --git a/libavcodec/riscv/pixblockdsp_rvi.S b/libavcodec/riscv/pixblockdsp_rvi.S new file mode 100644 index 0000000000..93ece4405e --- /dev/null +++ b/libavcodec/riscv/pixblockdsp_rvi.S @@ -0,0 +1,59 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "../libavutil/riscv/asm.S" + +func ff_get_pixels_8_rvi +.irp row, 0, 1, 2, 3, 4, 5, 6, 7 + ld t0, (a1) + add a1, a1, a2 + sd zero, ((\row * 16) + 0)(a0) + addi t6, t6, -1 + sd zero, ((\row * 16) + 8)(a0) + srli t1, t0, 8 + sb t0, ((\row * 16) + 0)(a0) + srli t2, t0, 16 + sb t1, ((\row * 16) + 2)(a0) + srli t3, t0, 24 + sb t2, ((\row * 16) + 4)(a0) + srli t4, t0, 32 + sb t3, ((\row * 16) + 6)(a0) + srli t1, t0, 40 + sb t4, ((\row * 16) + 8)(a0) + srli t2, t0, 48 + sb t1, ((\row * 16) + 10)(a0) + srli t3, t0, 56 + sb t2, ((\row * 16) + 12)(a0) + sb t3, ((\row * 16) + 14)(a0) +.endr + ret +endfunc + +func ff_get_pixels_16_rvi +.irp row, 0, 1, 2, 3, 4, 5, 6, 7 + ld t0, 0(a1) + ld t1, 8(a1) + add a1, a1, a2 + sd t0, ((\row * 16) + 0)(a0) + sd t1, ((\row * 16) + 8)(a0) +.endr + ret +endfunc From 0c0a3deb1826638915775daa7cefb891a300060b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:25 +0300 Subject: [PATCH 509/590] lavu/cpu: CPU flags for the RISC-V Vector extension RVV defines a total of 12 different extensions, including: - 5 different instruction subsets: - Zve32x: 8-, 16- and 32-bit integers, - Zve32f: Zve32x plus single precision floats, - Zve64x: Zve32x plus 64-bit integers, - Zve64f: Zve32f plus Zve64x, - Zve64d: Zve64f plus double precision floats. - 6 different vector lengths: - Zvl32b (embedded only), - Zvl64b (embedded only), - Zvl128b, - Zvl256b, - Zvl512b, - Zvl1024b, - and the V extension proper: equivalent to Zve64f and Zvl128b. In total, there are 6 different possible sets of supported instructions (including the empty set), but for convenience we allocate one bit for each type sets: up-to-32-bit ints (RVV_I32), floats (RVV_F32), 64-bit ints (RVV_I64) and doubles (RVV_F64). Whence the vector size is needed, it can be retrieved by reading the unprivileged read-only vlenb CSR. This should probably be a separate helper macro if needed at a later point. --- libavutil/cpu.c | 4 ++++ libavutil/cpu.h | 4 ++++ libavutil/riscv/cpu.c | 19 +++++++++++++++++++ tests/checkasm/checkasm.c | 4 ++++ 4 files changed, 31 insertions(+) diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 8b6eef9873..5818fd9c1c 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -184,6 +184,10 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "rvi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVI }, .unit = "flags" }, { "rvf", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVF }, .unit = "flags" }, { "rvd", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVD }, .unit = "flags" }, + { "rvv-i32", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I32 }, .unit = "flags" }, + { "rvv-f32", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32 }, .unit = "flags" }, + { "rvv-i64", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I64 }, .unit = "flags" }, + { "rvv", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64 }, .unit = "flags" }, #endif { NULL }, }; diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 9aae2ccc7a..18f42af015 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -82,6 +82,10 @@ #define AV_CPU_FLAG_RVI (1 << 0) ///< I (full GPR bank) #define AV_CPU_FLAG_RVF (1 << 1) ///< F (single precision FP) #define AV_CPU_FLAG_RVD (1 << 2) ///< D (double precision FP) +#define AV_CPU_FLAG_RVV_I32 (1 << 3) ///< Vectors of 8/16/32-bit int's */ +#define AV_CPU_FLAG_RVV_F32 (1 << 4) ///< Vectors of float's */ +#define AV_CPU_FLAG_RVV_I64 (1 << 5) ///< Vectors of 64-bit int's */ +#define AV_CPU_FLAG_RVV_F64 (1 << 6) ///< Vectors of double's /** * Return the flags which specify extensions supported by the CPU. diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c index 6803f035e5..e234201395 100644 --- a/libavutil/riscv/cpu.c +++ b/libavutil/riscv/cpu.c @@ -40,6 +40,11 @@ int ff_get_cpu_flags_riscv(void) ret |= AV_CPU_FLAG_RVF; if (hwcap & HWCAP_RV('D')) ret |= AV_CPU_FLAG_RVD; + + /* The V extension implies all Zve* functional subsets */ + if (hwcap & HWCAP_RV('V')) + ret |= AV_CPU_FLAG_RVV_I32 | AV_CPU_FLAG_RVV_I64 + | AV_CPU_FLAG_RVV_F32 | AV_CPU_FLAG_RVV_F64; #endif #ifdef __riscv_i @@ -50,6 +55,20 @@ int ff_get_cpu_flags_riscv(void) #if (__riscv_flen >= 64) ret |= AV_CPU_FLAG_RVD; #endif +#endif + + /* If RV-V is enabled statically at compile-time, check the details. */ +#ifdef __riscv_vectors + ret |= AV_CPU_FLAG_RVV_I32; +#if __riscv_v_elen >= 64 + ret |= AV_CPU_FLAG_RVV_I64; +#endif +#if __riscv_v_elen_fp >= 32 + ret |= AV_CPU_FLAG_RVV_F32; +#if __riscv_v_elen_fp >= 64 + ret |= AV_CPU_FLAG_RVV_F64; +#endif +#endif #endif return ret; diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e1135a84ac..90dd7e4634 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -236,6 +236,10 @@ static const struct { { "RVI", "rvi", AV_CPU_FLAG_RVI }, { "RVF", "rvf", AV_CPU_FLAG_RVF }, { "RVD", "rvd", AV_CPU_FLAG_RVD }, + { "RVVi32", "rvv_i32", AV_CPU_FLAG_RVV_I32 }, + { "RVVf32", "rvv_f32", AV_CPU_FLAG_RVV_F32 }, + { "RVVi64", "rvv_i64", AV_CPU_FLAG_RVV_I64 }, + { "RVVf64", "rvv_f64", AV_CPU_FLAG_RVV_F64 }, #elif ARCH_MIPS { "MMI", "mmi", AV_CPU_FLAG_MMI }, { "MSA", "msa", AV_CPU_FLAG_MSA }, From 1b6aee52a5634976c6fd212a28175512eb7865f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:26 +0300 Subject: [PATCH 510/590] configure: probe RISC-V Vector extension --- Makefile | 2 +- configure | 15 +++++++++++++++ ffbuild/arch.mak | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 61f79e27ae..1fb742f390 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ ffbuild/.config: $(CONFIGURABLE_COMPONENTS) SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS \ HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \ ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \ - ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \ + ALTIVEC-OBJS VSX-OBJS RVV-OBJS MMX-OBJS X86ASM-OBJS \ MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \ MMI-OBJS LSX-OBJS LASX-OBJS OBJS SLIBOBJS SHLIBOBJS \ STLIBOBJS HOSTOBJS TESTOBJS diff --git a/configure b/configure index c157338b1f..a41ebda6d4 100755 --- a/configure +++ b/configure @@ -462,6 +462,7 @@ Optimization options (experts only): --disable-mmi disable Loongson MMI optimizations --disable-lsx disable Loongson LSX optimizations --disable-lasx disable Loongson LASX optimizations + --disable-rvv disable RISC-V Vector optimizations --disable-fast-unaligned consider unaligned accesses slow Developer options (useful when working on FFmpeg itself): @@ -2126,6 +2127,10 @@ ARCH_EXT_LIST_PPC=" vsx " +ARCH_EXT_LIST_RISCV=" + rvv +" + ARCH_EXT_LIST_X86=" $ARCH_EXT_LIST_X86_SIMD cpunop @@ -2135,6 +2140,7 @@ ARCH_EXT_LIST_X86=" ARCH_EXT_LIST=" $ARCH_EXT_LIST_ARM $ARCH_EXT_LIST_PPC + $ARCH_EXT_LIST_RISCV $ARCH_EXT_LIST_X86 $ARCH_EXT_LIST_MIPS $ARCH_EXT_LIST_LOONGSON @@ -2642,6 +2648,8 @@ ppc4xx_deps="ppc" vsx_deps="altivec" power8_deps="vsx" +rvv_deps="riscv" + loongson2_deps="mips" loongson3_deps="mips" mmi_deps_any="loongson2 loongson3" @@ -6110,6 +6118,10 @@ elif enabled ppc; then check_cpp_condition power8 "altivec.h" "defined(_ARCH_PWR8)" fi +elif enabled riscv; then + + enabled rvv && check_inline_asm rvv '".option arch, +v\nvsetivli zero, 0, e8, m1, ta, ma"' + elif enabled x86; then check_builtin rdtsc intrin.h "__rdtsc()" @@ -7596,6 +7608,9 @@ if enabled loongarch; then echo "LSX enabled ${lsx-no}" echo "LASX enabled ${lasx-no}" fi +if enabled riscv; then + echo "RISC-V Vector enabled ${rvv-no}" +fi echo "debug symbols ${debug-no}" echo "strip symbols ${stripping-no}" echo "optimize for size ${small-no}" diff --git a/ffbuild/arch.mak b/ffbuild/arch.mak index 997e31e85e..39d76ee152 100644 --- a/ffbuild/arch.mak +++ b/ffbuild/arch.mak @@ -15,5 +15,7 @@ OBJS-$(HAVE_LASX) += $(LASX-OBJS) $(LASX-OBJS-yes) OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes) OBJS-$(HAVE_VSX) += $(VSX-OBJS) $(VSX-OBJS-yes) +OBJS-$(HAVE_RVV) += $(RVV-OBJS) $(RVV-OBJS-yes) + OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes) OBJS-$(HAVE_X86ASM) += $(X86ASM-OBJS) $(X86ASM-OBJS-yes) From 39357cad37e865b723c7a97adc27d4a6b4388008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:27 +0300 Subject: [PATCH 511/590] lavu/riscv: fallback macros for SH{1, 2, 3}ADD Those mnemonics require the very latest binutils release at the time of writing. These macros provide seamless backward compatibility. --- libavutil/riscv/asm.S | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libavutil/riscv/asm.S b/libavutil/riscv/asm.S index dbd97f40a4..de5e1ad0a6 100644 --- a/libavutil/riscv/asm.S +++ b/libavutil/riscv/asm.S @@ -75,3 +75,22 @@ .purgem endconst .endm .endm + +#if !defined (__riscv_zba) + /* SH{1,2,3}ADD definitions for pre-Zba assemblers */ + .macro shnadd n, rd, rs1, rs2 + .insn r OP, 2 * \n, 16, \rd, \rs1, \rs2 + .endm + + .macro sh1add rd, rs1, rs2 + shnadd 1, \rd, \rs1, \rs2 + .endm + + .macro sh2add rd, rs1, rs2 + shnadd 2, \rd, \rs1, \rs2 + .endm + + .macro sh3add rd, rs1, rs2 + shnadd 3, \rd, \rs1, \rs2 + .endm +#endif From a6c10d05fe26dcfb5920fa4ce8ea8f74bf5f82dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:28 +0300 Subject: [PATCH 512/590] lavu/floatdsp: RISC-V V vector_fmul_scalar This is based on existing code from the VLC git tree with two minor changes to account for the different function prototypes. --- libavutil/float_dsp.c | 2 ++ libavutil/float_dsp.h | 1 + libavutil/riscv/Makefile | 4 +++- libavutil/riscv/float_dsp_init.c | 39 ++++++++++++++++++++++++++++++++ libavutil/riscv/float_dsp_rvv.S | 39 ++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 libavutil/riscv/float_dsp_init.c create mode 100644 libavutil/riscv/float_dsp_rvv.S diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c index 8676c8b0f8..742dd679d2 100644 --- a/libavutil/float_dsp.c +++ b/libavutil/float_dsp.c @@ -156,6 +156,8 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) ff_float_dsp_init_arm(fdsp); #elif ARCH_PPC ff_float_dsp_init_ppc(fdsp, bit_exact); +#elif ARCH_RISCV + ff_float_dsp_init_riscv(fdsp); #elif ARCH_X86 ff_float_dsp_init_x86(fdsp); #elif ARCH_MIPS diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h index 9c664592bd..7cad9fc622 100644 --- a/libavutil/float_dsp.h +++ b/libavutil/float_dsp.h @@ -205,6 +205,7 @@ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len); void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp); void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp); void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict); +void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp); void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp); void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp); diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile index 1f818043dc..89a8d0d990 100644 --- a/libavutil/riscv/Makefile +++ b/libavutil/riscv/Makefile @@ -1 +1,3 @@ -OBJS += riscv/cpu.o +OBJS += riscv/float_dsp_init.o \ + riscv/cpu.o +RVV-OBJS += riscv/float_dsp_rvv.o diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c new file mode 100644 index 0000000000..f4299049b0 --- /dev/null +++ b/libavutil/riscv/float_dsp_init.c @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/float_dsp.h" + +void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, + int len); + +av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_F32) + fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; +#endif +} diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S new file mode 100644 index 0000000000..50cb1fa90f --- /dev/null +++ b/libavutil/riscv/float_dsp_rvv.S @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "asm.S" + +// (a0) = (a1) * fa0 [0..a2-1] +func ff_vector_fmul_scalar_rvv, zve32f +NOHWF fmv.w.x fa0, a2 +NOHWF mv a2, a3 +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v16, (a1) + sub a2, a2, t0 + vfmul.vf v16, v16, fa0 + sh2add a1, t0, a1 + vse32.v v16, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc From 89b7ec65a8c50a88ca730c666410f5743f600634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:29 +0300 Subject: [PATCH 513/590] lavu/floatdsp: RISC-V V vector_dmul_scalar --- libavutil/riscv/float_dsp_init.c | 6 ++++++ libavutil/riscv/float_dsp_rvv.S | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index f4299049b0..3386139d49 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -28,6 +28,9 @@ void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); +void ff_vector_dmul_scalar_rvv(double *dst, const double *src, double mul, + int len); + av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) { #if HAVE_RVV @@ -35,5 +38,8 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) if (flags & AV_CPU_FLAG_RVV_F32) fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; + + if (flags & AV_CPU_FLAG_RVV_F64) + fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_rvv; #endif } diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 50cb1fa90f..17dda471b4 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -37,3 +37,20 @@ NOHWF mv a2, a3 ret endfunc + +// (a0) = (a1) * fa0 [0..a2-1] +func ff_vector_dmul_scalar_rvv, zve64d +NOHWD fmv.d.x fa0, a2 +NOHWD mv a2, a3 +1: + vsetvli t0, a2, e64, m1, ta, ma + vle64.v v16, (a1) + sub a2, a2, t0 + vfmul.vf v16, v16, fa0 + sh3add a1, t0, a1 + vse64.v v16, (a0) + sh3add a0, t0, a0 + bnez a2, 1b + + ret +endfunc From 7058af9969b737adbb1cd302cf8fa5feb7bc9e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:30 +0300 Subject: [PATCH 514/590] lavu/floatdsp: RISC-V V vector_fmul --- libavutil/riscv/float_dsp_init.c | 6 +++++- libavutil/riscv/float_dsp_rvv.S | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 3386139d49..2482094ab4 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -25,6 +25,8 @@ #include "libavutil/cpu.h" #include "libavutil/float_dsp.h" +void ff_vector_fmul_rvv(float *dst, const float *src0, const float *src1, + int len); void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); @@ -36,8 +38,10 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) #if HAVE_RVV int flags = av_get_cpu_flags(); - if (flags & AV_CPU_FLAG_RVV_F32) + if (flags & AV_CPU_FLAG_RVV_F32) { + fdsp->vector_fmul = ff_vector_fmul_rvv; fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; + } if (flags & AV_CPU_FLAG_RVV_F64) fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_rvv; diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 17dda471b4..00fb7354bb 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -21,6 +21,23 @@ #include "config.h" #include "asm.S" +// (a0) = (a1) * (a2) [0..a3-1] +func ff_vector_fmul_rvv, zve32f +1: + vsetvli t0, a3, e32, m1, ta, ma + vle32.v v16, (a1) + sub a3, a3, t0 + vle32.v v24, (a2) + sh2add a1, t0, a1 + vfmul.vv v16, v16, v24 + sh2add a2, t0, a2 + vse32.v v16, (a0) + sh2add a0, t0, a0 + bnez a3, 1b + + ret +endfunc + // (a0) = (a1) * fa0 [0..a2-1] func ff_vector_fmul_scalar_rvv, zve32f NOHWF fmv.w.x fa0, a2 From da169a210dbd33d5d34baaf3d188ca5388b1b267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:31 +0300 Subject: [PATCH 515/590] lavu/floatdsp: RISC-V V vector_dmul --- libavutil/riscv/float_dsp_init.c | 6 +++++- libavutil/riscv/float_dsp_rvv.S | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 2482094ab4..29114dfb82 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -30,6 +30,8 @@ void ff_vector_fmul_rvv(float *dst, const float *src0, const float *src1, void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); +void ff_vector_dmul_rvv(double *dst, const double *src0, const double *src1, + int len); void ff_vector_dmul_scalar_rvv(double *dst, const double *src, double mul, int len); @@ -43,7 +45,9 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; } - if (flags & AV_CPU_FLAG_RVV_F64) + if (flags & AV_CPU_FLAG_RVV_F64) { + fdsp->vector_dmul = ff_vector_dmul_rvv; fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_rvv; + } #endif } diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 00fb7354bb..710e122444 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -55,6 +55,23 @@ NOHWF mv a2, a3 ret endfunc +// (a0) = (a1) * (a2) [0..a3-1] +func ff_vector_dmul_rvv, zve64d +1: + vsetvli t0, a3, e64, m1, ta, ma + vle64.v v16, (a1) + sub a3, a3, t0 + vle64.v v24, (a2) + sh3add a1, t0, a1 + vfmul.vv v16, v16, v24 + sh3add a2, t0, a2 + vse64.v v16, (a0) + sh3add a0, t0, a0 + bnez a3, 1b + + ret +endfunc + // (a0) = (a1) * fa0 [0..a2-1] func ff_vector_dmul_scalar_rvv, zve64d NOHWD fmv.d.x fa0, a2 From c3db27ba9552fc3cb764bf9eb717840d981c5779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:32 +0300 Subject: [PATCH 516/590] lavu/floatdsp: RISC-V V vector_fmac_scalar --- libavutil/riscv/float_dsp_init.c | 3 +++ libavutil/riscv/float_dsp_rvv.S | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 29114dfb82..9e19413d5d 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -27,6 +27,8 @@ void ff_vector_fmul_rvv(float *dst, const float *src0, const float *src1, int len); +void ff_vector_fmac_scalar_rvv(float *dst, const float *src, float mul, + int len); void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); @@ -42,6 +44,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) if (flags & AV_CPU_FLAG_RVV_F32) { fdsp->vector_fmul = ff_vector_fmul_rvv; + fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_rvv; fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; } diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 710e122444..4c325db9fd 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -38,6 +38,25 @@ func ff_vector_fmul_rvv, zve32f ret endfunc +// (a0) += (a1) * fa0 [0..a2-1] +func ff_vector_fmac_scalar_rvv, zve32f +NOHWF fmv.w.x fa0, a2 +NOHWF mv a2, a3 +1: + vsetvli t0, a2, e32, m1, ta, ma + slli t1, t0, 2 + vle32.v v24, (a1) + sub a2, a2, t0 + vle32.v v16, (a0) + sh2add a1, t0, a1 + vfmacc.vf v16, fa0, v24 + vse32.v v16, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc + // (a0) = (a1) * fa0 [0..a2-1] func ff_vector_fmul_scalar_rvv, zve32f NOHWF fmv.w.x fa0, a2 From d120ab5b915fb422247f9e4dd5b823d1b47d6adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:33 +0300 Subject: [PATCH 517/590] lavu/floatdsp: RISC-V V vector_dmac_scalar --- libavutil/riscv/float_dsp_init.c | 3 +++ libavutil/riscv/float_dsp_rvv.S | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 9e19413d5d..a559bbb32b 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -34,6 +34,8 @@ void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, void ff_vector_dmul_rvv(double *dst, const double *src0, const double *src1, int len); +void ff_vector_dmac_scalar_rvv(double *dst, const double *src, double mul, + int len); void ff_vector_dmul_scalar_rvv(double *dst, const double *src, double mul, int len); @@ -50,6 +52,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) if (flags & AV_CPU_FLAG_RVV_F64) { fdsp->vector_dmul = ff_vector_dmul_rvv; + fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_rvv; fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_rvv; } #endif diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 4c325db9fd..048ec0bc40 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -91,6 +91,24 @@ func ff_vector_dmul_rvv, zve64d ret endfunc +// (a0) += (a1) * fa0 [0..a2-1] +func ff_vector_dmac_scalar_rvv, zve64d +NOHWD fmv.d.x fa0, a2 +NOHWD mv a2, a3 +1: + vsetvli t0, a2, e64, m1, ta, ma + vle64.v v24, (a1) + sub a2, a2, t0 + vle64.v v16, (a0) + sh3add a1, t0, a1 + vfmacc.vf v16, fa0, v24 + vse64.v v16, (a0) + sh3add a0, t0, a0 + bnez a2, 1b + + ret +endfunc + // (a0) = (a1) * fa0 [0..a2-1] func ff_vector_dmul_scalar_rvv, zve64d NOHWD fmv.d.x fa0, a2 From f4ea45040f4c0d896fce66a6f52deb53249ed77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:34 +0300 Subject: [PATCH 518/590] lavu/floatdsp: RISC-V V vector_fmul_add --- libavutil/riscv/float_dsp_init.c | 3 +++ libavutil/riscv/float_dsp_rvv.S | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index a559bbb32b..8982436647 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -31,6 +31,8 @@ void ff_vector_fmac_scalar_rvv(float *dst, const float *src, float mul, int len); void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); +void ff_vector_fmul_add_rvv(float *dst, const float *src0, const float *src1, + const float *src2, int len); void ff_vector_dmul_rvv(double *dst, const double *src0, const double *src1, int len); @@ -48,6 +50,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_fmul = ff_vector_fmul_rvv; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_rvv; fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; + fdsp->vector_fmul_add = ff_vector_fmul_add_rvv; } if (flags & AV_CPU_FLAG_RVV_F64) { diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 048ec0bc40..db62402878 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -74,6 +74,25 @@ NOHWF mv a2, a3 ret endfunc +// (a0) = (a1) * (a2) + (a3) [0..a4-1] +func ff_vector_fmul_add_rvv, zve32f +1: + vsetvli t0, a4, e32, m1, ta, ma + vle32.v v8, (a1) + sub a4, a4, t0 + vle32.v v16, (a2) + sh2add a1, t0, a1 + vle32.v v24, (a3) + sh2add a2, t0, a2 + vfmadd.vv v8, v16, v24 + sh2add a3, t0, a3 + vse32.v v8, (a0) + sh2add a0, t0, a0 + bnez a4, 1b + + ret +endfunc + // (a0) = (a1) * (a2) [0..a3-1] func ff_vector_dmul_rvv, zve64d 1: From 47ce9735cc8362ea6b3a508dd660233af28d77ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:35 +0300 Subject: [PATCH 519/590] lavu/floatdsp: RISC-V V butterflies_float --- libavutil/riscv/float_dsp_init.c | 2 ++ libavutil/riscv/float_dsp_rvv.S | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 8982436647..a1cd180cdc 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -33,6 +33,7 @@ void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); void ff_vector_fmul_add_rvv(float *dst, const float *src0, const float *src1, const float *src2, int len); +void ff_butterflies_float_rvv(float *v1, float *v2, int len); void ff_vector_dmul_rvv(double *dst, const double *src0, const double *src1, int len); @@ -51,6 +52,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_rvv; fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; fdsp->vector_fmul_add = ff_vector_fmul_add_rvv; + fdsp->butterflies_float = ff_butterflies_float_rvv; } if (flags & AV_CPU_FLAG_RVV_F64) { diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index db62402878..a721c44667 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -93,6 +93,24 @@ func ff_vector_fmul_add_rvv, zve32f ret endfunc +// (a0) = (a0) + (a1), (a1) = (a0) - (a1) [0..a2-1] +func ff_butterflies_float_rvv, zve32f +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v16, (a0) + sub a2, a2, t0 + vle32.v v24, (a1) + vfadd.vv v0, v16, v24 + vfsub.vv v8, v16, v24 + vse32.v v0, (a0) + sh2add a0, t0, a0 + vse32.v v8, (a1) + sh2add a1, t0, a1 + bnez a2, 1b + + ret +endfunc + // (a0) = (a1) * (a2) [0..a3-1] func ff_vector_dmul_rvv, zve64d 1: From 9aeb6aca3a9fa8caf8db263de4fa9f8077ba6634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:36 +0300 Subject: [PATCH 520/590] lavu/floatdsp: RISC-V V vector_fmul_reverse --- libavutil/riscv/float_dsp_init.c | 3 +++ libavutil/riscv/float_dsp_rvv.S | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index a1cd180cdc..b99e3080c9 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -33,6 +33,8 @@ void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); void ff_vector_fmul_add_rvv(float *dst, const float *src0, const float *src1, const float *src2, int len); +void ff_vector_fmul_reverse_rvv(float *dst, const float *src0, + const float *src1, int len); void ff_butterflies_float_rvv(float *v1, float *v2, int len); void ff_vector_dmul_rvv(double *dst, const double *src0, const double *src1, @@ -52,6 +54,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_rvv; fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; fdsp->vector_fmul_add = ff_vector_fmul_add_rvv; + fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_rvv; fdsp->butterflies_float = ff_butterflies_float_rvv; } diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index a721c44667..fbd2777463 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -93,6 +93,27 @@ func ff_vector_fmul_add_rvv, zve32f ret endfunc +// (a0) = (a1) * reverse(a2) [0..a3-1] +func ff_vector_fmul_reverse_rvv, zve32f + sh2add a2, a3, a2 + li t2, -4 // byte stride + addi a2, a2, -4 +1: + vsetvli t0, a3, e32, m1, ta, ma + slli t1, t0, 2 + vle32.v v16, (a1) + sub a3, a3, t0 + vlse32.v v24, (a2), t2 + add a1, a1, t1 + vfmul.vv v16, v16, v24 + sub a2, a2, t1 + vse32.v v16, (a0) + add a0, a0, t1 + bnez a3, 1b + + ret +endfunc + // (a0) = (a0) + (a1), (a1) = (a0) - (a1) [0..a2-1] func ff_butterflies_float_rvv, zve32f 1: From b493370662eaa87f84450e876b8b61b34d91f23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:37 +0300 Subject: [PATCH 521/590] lavu/floatdsp: RISC-V V vector_fmul_window --- libavutil/riscv/float_dsp_init.c | 3 +++ libavutil/riscv/float_dsp_rvv.S | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index b99e3080c9..44a505308d 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -31,6 +31,8 @@ void ff_vector_fmac_scalar_rvv(float *dst, const float *src, float mul, int len); void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, int len); +void ff_vector_fmul_window_rvv(float *dst, const float *src0, + const float *src1, const float *win, int len); void ff_vector_fmul_add_rvv(float *dst, const float *src0, const float *src1, const float *src2, int len); void ff_vector_fmul_reverse_rvv(float *dst, const float *src0, @@ -53,6 +55,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_fmul = ff_vector_fmul_rvv; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_rvv; fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; + fdsp->vector_fmul_window = ff_vector_fmul_window_rvv; fdsp->vector_fmul_add = ff_vector_fmul_add_rvv; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_rvv; fdsp->butterflies_float = ff_butterflies_float_rvv; diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index fbd2777463..ce530f6108 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -74,6 +74,39 @@ NOHWF mv a2, a3 ret endfunc +func ff_vector_fmul_window_rvv, zve32f + // a0: dst, a1: src0, a2: src1, a3: window, a4: length + addi t0, a4, -1 + add t1, t0, a4 + sh2add a2, t0, a2 + sh2add t0, t1, a0 + sh2add t3, t1, a3 + li t1, -4 // byte stride +1: + vsetvli t2, a4, e32, m1, ta, ma + vle32.v v16, (a1) + slli t4, t2, 2 + vlse32.v v20, (a2), t1 + sub a4, a4, t2 + vle32.v v24, (a3) + add a1, a1, t4 + vlse32.v v28, (t3), t1 + sub a2, a2, t4 + vfmul.vv v0, v16, v28 + add a3, a3, t4 + vfmul.vv v8, v16, v24 + sub t3, t3, t4 + vfnmsac.vv v0, v20, v24 + vfmacc.vv v8, v20, v28 + vse32.v v0, (a0) + add a0, a0, t4 + vsse32.v v8, (t0), t1 + sub t0, t0, t4 + bnez a4, 1b + + ret +endfunc + // (a0) = (a1) * (a2) + (a3) [0..a4-1] func ff_vector_fmul_add_rvv, zve32f 1: From cd77662953942cf166f0115b21cb8619e2e8f630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:38 +0300 Subject: [PATCH 522/590] lavu/floatdsp: RISC-V V scalarproduct_float --- libavutil/riscv/float_dsp_init.c | 2 ++ libavutil/riscv/float_dsp_rvv.S | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c index 44a505308d..e61f887862 100644 --- a/libavutil/riscv/float_dsp_init.c +++ b/libavutil/riscv/float_dsp_init.c @@ -38,6 +38,7 @@ void ff_vector_fmul_add_rvv(float *dst, const float *src0, const float *src1, void ff_vector_fmul_reverse_rvv(float *dst, const float *src0, const float *src1, int len); void ff_butterflies_float_rvv(float *v1, float *v2, int len); +float ff_scalarproduct_float_rvv(const float *v1, const float *v2, int len); void ff_vector_dmul_rvv(double *dst, const double *src0, const double *src1, int len); @@ -59,6 +60,7 @@ av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) fdsp->vector_fmul_add = ff_vector_fmul_add_rvv; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_rvv; fdsp->butterflies_float = ff_butterflies_float_rvv; + fdsp->scalarproduct_float = ff_scalarproduct_float_rvv; } if (flags & AV_CPU_FLAG_RVV_F64) { diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index ce530f6108..ab2e0c42d7 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -165,6 +165,26 @@ func ff_butterflies_float_rvv, zve32f ret endfunc +// a0 = (a0).(a1) [0..a2-1] +func ff_scalarproduct_float_rvv, zve32f + vsetvli zero, zero, e32, m1, ta, ma + vmv.s.x v8, zero +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v16, (a0) + sub a2, a2, t0 + vle32.v v24, (a1) + sh2add a0, t0, a0 + vfmul.vv v16, v16, v24 + sh2add a1, t0, a1 + vfredusum.vs v8, v16, v8 + bnez a2, 1b + + vfmv.f.s fa0, v8 +NOHWF fmv.x.w a0, fa0 + ret +endfunc + // (a0) = (a1) * (a2) [0..a3-1] func ff_vector_dmul_rvv, zve64d 1: From c1bb19e263e14887ad286c16352edbaa39be4f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:39 +0300 Subject: [PATCH 523/590] lavu/fixeddsp: RISC-V V butterflies_fixed --- libavutil/fixed_dsp.c | 4 +++- libavutil/fixed_dsp.h | 1 + libavutil/riscv/Makefile | 4 +++- libavutil/riscv/fixed_dsp_init.c | 38 ++++++++++++++++++++++++++++++ libavutil/riscv/fixed_dsp_rvv.S | 40 ++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 libavutil/riscv/fixed_dsp_init.c create mode 100644 libavutil/riscv/fixed_dsp_rvv.S diff --git a/libavutil/fixed_dsp.c b/libavutil/fixed_dsp.c index 154f3bc2d3..bc847949dc 100644 --- a/libavutil/fixed_dsp.c +++ b/libavutil/fixed_dsp.c @@ -162,7 +162,9 @@ AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact) fdsp->butterflies_fixed = butterflies_fixed_c; fdsp->scalarproduct_fixed = scalarproduct_fixed_c; -#if ARCH_X86 +#if ARCH_RISCV + ff_fixed_dsp_init_riscv(fdsp); +#elif ARCH_X86 ff_fixed_dsp_init_x86(fdsp); #endif diff --git a/libavutil/fixed_dsp.h b/libavutil/fixed_dsp.h index fec806ff2d..1217d3a53b 100644 --- a/libavutil/fixed_dsp.h +++ b/libavutil/fixed_dsp.h @@ -161,6 +161,7 @@ typedef struct AVFixedDSPContext { */ AVFixedDSPContext * avpriv_alloc_fixed_dsp(int strict); +void ff_fixed_dsp_init_riscv(AVFixedDSPContext *fdsp); void ff_fixed_dsp_init_x86(AVFixedDSPContext *fdsp); /** diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile index 89a8d0d990..1597154ba5 100644 --- a/libavutil/riscv/Makefile +++ b/libavutil/riscv/Makefile @@ -1,3 +1,5 @@ OBJS += riscv/float_dsp_init.o \ + riscv/fixed_dsp_init.o \ riscv/cpu.o -RVV-OBJS += riscv/float_dsp_rvv.o +RVV-OBJS += riscv/float_dsp_rvv.o \ + riscv/fixed_dsp_rvv.o diff --git a/libavutil/riscv/fixed_dsp_init.c b/libavutil/riscv/fixed_dsp_init.c new file mode 100644 index 0000000000..e2915f1fcd --- /dev/null +++ b/libavutil/riscv/fixed_dsp_init.c @@ -0,0 +1,38 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/fixed_dsp.h" + +void ff_butterflies_fixed_rvv(int *v1, int *v2, int len); + +av_cold void ff_fixed_dsp_init_riscv(AVFixedDSPContext *fdsp) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) + fdsp->butterflies_fixed = ff_butterflies_fixed_rvv; +#endif +} diff --git a/libavutil/riscv/fixed_dsp_rvv.S b/libavutil/riscv/fixed_dsp_rvv.S new file mode 100644 index 0000000000..0e78734b4c --- /dev/null +++ b/libavutil/riscv/fixed_dsp_rvv.S @@ -0,0 +1,40 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "asm.S" + +// (a0) = (a0) + (a1), (a1) = (a0) - (a1) [0..a2-1] +func ff_butterflies_fixed_rvv, zve32x +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v16, (a0) + sub a2, a2, t0 + vle32.v v24, (a1) + vadd.vv v0, v16, v24 + vsub.vv v8, v16, v24 + vse32.v v0, (a0) + sh2add a0, t0, a0 + vse32.v v8, (a1) + sh2add a1, t0, a1 + bnez a2, 1b + + ret +endfunc From 27da9514c3a7b506e3c3e0ada5dee67566c5aadf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:40 +0300 Subject: [PATCH 524/590] lavc/audiodsp: RISC-V V vector_clip_int32 --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/audiodsp_init.c | 9 ++++++++ libavcodec/riscv/audiodsp_rvv.S | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 libavcodec/riscv/audiodsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index da07f1fe96..99541b075e 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,4 +1,5 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o +RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c index c5842815d6..ac06848a82 100644 --- a/libavcodec/riscv/audiodsp_init.c +++ b/libavcodec/riscv/audiodsp_init.c @@ -18,16 +18,25 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavcodec/audiodsp.h" void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max); +void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); + av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) { int flags = av_get_cpu_flags(); if (flags & AV_CPU_FLAG_RVF) c->vector_clipf = ff_vector_clipf_rvf; +#if HAVE_RVV + if (flags & AV_CPU_FLAG_RVV_I32) + c->vector_clip_int32 = ff_vector_clip_int32_rvv; +#endif } diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S new file mode 100644 index 0000000000..49546ee3c4 --- /dev/null +++ b/libavcodec/riscv/audiodsp_rvv.S @@ -0,0 +1,36 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 "libavutil/riscv/asm.S" + +func ff_vector_clip_int32_rvv, zve32x +1: + vsetvli t0, a4, e32, m1, ta, ma + vle32.v v8, (a1) + sub a4, a4, t0 + vmax.vx v8, v8, a2 + sh2add a1, t0, a1 + vmin.vx v8, v8, a3 + vse32.v v8, (a0) + sh2add a0, t0, a0 + bnez a4, 1b + + ret +endfunc From f127a5d29d7aee99cb4dd4d576d375c678b3c388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:41 +0300 Subject: [PATCH 525/590] lavc/audiodsp: RISC-V V vector_clipf --- libavcodec/riscv/audiodsp_init.c | 3 +++ libavcodec/riscv/audiodsp_rvv.S | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c index ac06848a82..9c9265531d 100644 --- a/libavcodec/riscv/audiodsp_init.c +++ b/libavcodec/riscv/audiodsp_init.c @@ -28,6 +28,7 @@ void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min, int32_t max, unsigned int len); +void ff_vector_clipf_rvv(float *dst, const float *src, int len, float min, float max); av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) { @@ -38,5 +39,7 @@ av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) #if HAVE_RVV if (flags & AV_CPU_FLAG_RVV_I32) c->vector_clip_int32 = ff_vector_clip_int32_rvv; + if (flags & AV_CPU_FLAG_RVV_F32) + c->vector_clipf = ff_vector_clipf_rvv; #endif } diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S index 49546ee3c4..427b424cb9 100644 --- a/libavcodec/riscv/audiodsp_rvv.S +++ b/libavcodec/riscv/audiodsp_rvv.S @@ -34,3 +34,20 @@ func ff_vector_clip_int32_rvv, zve32x ret endfunc + +func ff_vector_clipf_rvv, zve32f +NOHWF fmv.w.x fa0, a3 +NOHWF fmv.w.x fa1, a4 +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v8, (a1) + sub a2, a2, t0 + vfmax.vf v8, v8, fa0 + sh2add a1, t0, a1 + vfmin.vf v8, v8, fa1 + vse32.v v8, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc From f41ae62f39ad1f91a3817325fdbba7304aba4641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:42 +0300 Subject: [PATCH 526/590] lavc/audiodsp: RISC-V V scalarproduct_int16 --- libavcodec/riscv/audiodsp_init.c | 5 ++++- libavcodec/riscv/audiodsp_rvv.S | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c index 9c9265531d..32c3c6794d 100644 --- a/libavcodec/riscv/audiodsp_init.c +++ b/libavcodec/riscv/audiodsp_init.c @@ -26,6 +26,7 @@ void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max); +int32_t ff_scalarproduct_int16_rvv(const int16_t *v1, const int16_t *v2, int len); void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min, int32_t max, unsigned int len); void ff_vector_clipf_rvv(float *dst, const float *src, int len, float min, float max); @@ -37,8 +38,10 @@ av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) if (flags & AV_CPU_FLAG_RVF) c->vector_clipf = ff_vector_clipf_rvf; #if HAVE_RVV - if (flags & AV_CPU_FLAG_RVV_I32) + if (flags & AV_CPU_FLAG_RVV_I32) { + c->scalarproduct_int16 = ff_scalarproduct_int16_rvv; c->vector_clip_int32 = ff_vector_clip_int32_rvv; + } if (flags & AV_CPU_FLAG_RVV_F32) c->vector_clipf = ff_vector_clipf_rvv; #endif diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S index 427b424cb9..f4308f27c5 100644 --- a/libavcodec/riscv/audiodsp_rvv.S +++ b/libavcodec/riscv/audiodsp_rvv.S @@ -20,6 +20,25 @@ #include "libavutil/riscv/asm.S" +func ff_scalarproduct_int16_rvv, zve32x + vsetvli zero, zero, e16, m1, ta, ma + vmv.s.x v8, zero +1: + vsetvli t0, a2, e16, m1, ta, ma + vle16.v v16, (a0) + sub a2, a2, t0 + vle16.v v24, (a1) + sh1add a0, t0, a0 + vwmul.vv v0, v16, v24 + sh1add a1, t0, a1 + vsetvli zero, t0, e32, m2, ta, ma + vredsum.vs v8, v0, v8 + bnez a2, 1b + + vmv.x.s a0, v8 + ret +endfunc + func ff_vector_clip_int32_rvv, zve32x 1: vsetvli t0, a4, e32, m1, ta, ma From 47a10b9a99130457c27b220afba7d7de4a69bb18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:43 +0300 Subject: [PATCH 527/590] lavc/fmtconvert: RISC-V V int32_to_float_fmul_scalar --- libavcodec/fmtconvert.c | 2 ++ libavcodec/fmtconvert.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/fmtconvert_init.c | 39 ++++++++++++++++++++++++++++++ libavcodec/riscv/fmtconvert_rvv.S | 39 ++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 libavcodec/riscv/fmtconvert_init.c create mode 100644 libavcodec/riscv/fmtconvert_rvv.S diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c index cedfd61138..d889e61aca 100644 --- a/libavcodec/fmtconvert.c +++ b/libavcodec/fmtconvert.c @@ -52,6 +52,8 @@ av_cold void ff_fmt_convert_init(FmtConvertContext *c) ff_fmt_convert_init_arm(c); #elif ARCH_PPC ff_fmt_convert_init_ppc(c); +#elif ARCH_RISCV + ff_fmt_convert_init_riscv(c); #elif ARCH_X86 ff_fmt_convert_init_x86(c); #endif diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h index da244e05a5..1cb4628a64 100644 --- a/libavcodec/fmtconvert.h +++ b/libavcodec/fmtconvert.h @@ -61,6 +61,7 @@ void ff_fmt_convert_init(FmtConvertContext *c); void ff_fmt_convert_init_aarch64(FmtConvertContext *c); void ff_fmt_convert_init_arm(FmtConvertContext *c); void ff_fmt_convert_init_ppc(FmtConvertContext *c); +void ff_fmt_convert_init_riscv(FmtConvertContext *c); void ff_fmt_convert_init_x86(FmtConvertContext *c); void ff_fmt_convert_init_mips(FmtConvertContext *c); diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 99541b075e..682174e875 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,5 +1,7 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o +OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o +RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o diff --git a/libavcodec/riscv/fmtconvert_init.c b/libavcodec/riscv/fmtconvert_init.c new file mode 100644 index 0000000000..b2c240c1ce --- /dev/null +++ b/libavcodec/riscv/fmtconvert_init.c @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/fmtconvert.h" + +void ff_int32_to_float_fmul_scalar_rvv(float *dst, const int32_t *src, + float mul, int len); + +av_cold void ff_fmt_convert_init_riscv(FmtConvertContext *c) +{ +#ifdef HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_F32) + c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_rvv; +#endif +} diff --git a/libavcodec/riscv/fmtconvert_rvv.S b/libavcodec/riscv/fmtconvert_rvv.S new file mode 100644 index 0000000000..b7c78831a0 --- /dev/null +++ b/libavcodec/riscv/fmtconvert_rvv.S @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "../libavutil/riscv/asm.S" + +func ff_int32_to_float_fmul_scalar_rvv, zve32f +NOHWF fmv.w.x fa0, a2 +NOHWF mv a2, a3 +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v24, (a1) + sub a2, a2, t0 + vfcvt.f.x.v v24, v24 + sh2add a1, t0, a1 + vfmul.vf v24, v24, fa0 + vse32.v v24, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc From 220dfd0945ee8481d8cdbf713f515a94ceee9992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:44 +0300 Subject: [PATCH 528/590] lavc/fmtconvert: RISC-V V int32_to_float_fmul_array8 --- libavcodec/riscv/fmtconvert_init.c | 7 ++++++- libavcodec/riscv/fmtconvert_rvv.S | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/fmtconvert_init.c b/libavcodec/riscv/fmtconvert_init.c index b2c240c1ce..fd1a8e0ca1 100644 --- a/libavcodec/riscv/fmtconvert_init.c +++ b/libavcodec/riscv/fmtconvert_init.c @@ -27,13 +27,18 @@ void ff_int32_to_float_fmul_scalar_rvv(float *dst, const int32_t *src, float mul, int len); +void ff_int32_to_float_fmul_array8_rvv(FmtConvertContext *c, float *dst, + const int32_t *src, const float *mul, + int len); av_cold void ff_fmt_convert_init_riscv(FmtConvertContext *c) { #ifdef HAVE_RVV int flags = av_get_cpu_flags(); - if (flags & AV_CPU_FLAG_RVV_F32) + if (flags & AV_CPU_FLAG_RVV_F32) { c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_rvv; + c->int32_to_float_fmul_array8 = ff_int32_to_float_fmul_array8_rvv; + } #endif } diff --git a/libavcodec/riscv/fmtconvert_rvv.S b/libavcodec/riscv/fmtconvert_rvv.S index b7c78831a0..c79f80cc47 100644 --- a/libavcodec/riscv/fmtconvert_rvv.S +++ b/libavcodec/riscv/fmtconvert_rvv.S @@ -37,3 +37,31 @@ NOHWF mv a2, a3 ret endfunc + +func ff_int32_to_float_fmul_array8_rvv, zve32f + srai a4, a4, 3 + +1: vsetvli t0, a4, e32, m1, ta, ma + vle32.v v24, (a3) + slli t2, t0, 2 + 3 + vlseg8e32.v v16, (a2) + vsetvli t3, zero, e32, m8, ta, ma + vfcvt.f.x.v v16, v16 + vsetvli zero, a4, e32, m1, ta, ma + vfmul.vv v16, v16, v24 + sub a4, a4, t0 + vfmul.vv v17, v17, v24 + sh2add a3, t0, a3 + vfmul.vv v18, v18, v24 + add a2, a2, t2 + vfmul.vv v19, v19, v24 + vfmul.vv v20, v20, v24 + vfmul.vv v21, v21, v24 + vfmul.vv v22, v22, v24 + vfmul.vv v23, v23, v24 + vsseg8e32.v v16, (a1) + add a1, a1, t2 + bnez a4, 1b + + ret +endfunc From 453aba71e6db37d367269cc080dae4c1548db33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:45 +0300 Subject: [PATCH 529/590] lavc/vorbisdsp: RISC-V V inverse_coupling This uses the following vectorisation: for (i = 0; i < blocksize; i++) { ang[i] = mag[i] - copysignf(fmaxf(ang[i], 0.f), mag[i]); mag[i] = mag[i] - copysignf(fminf(ang[i], 0.f), mag[i]); } --- libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/vorbisdsp_init.c | 37 ++++++++++++++++++++++++++ libavcodec/riscv/vorbisdsp_rvv.S | 44 +++++++++++++++++++++++++++++++ libavcodec/vorbisdsp.c | 2 ++ libavcodec/vorbisdsp.h | 1 + 5 files changed, 86 insertions(+) create mode 100644 libavcodec/riscv/vorbisdsp_init.c create mode 100644 libavcodec/riscv/vorbisdsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 682174e875..03a95301d7 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -5,3 +5,5 @@ OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o +OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o +RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o diff --git a/libavcodec/riscv/vorbisdsp_init.c b/libavcodec/riscv/vorbisdsp_init.c new file mode 100644 index 0000000000..0c56ffcb9b --- /dev/null +++ b/libavcodec/riscv/vorbisdsp_init.c @@ -0,0 +1,37 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/vorbisdsp.h" + +void ff_vorbis_inverse_coupling_rvv(float *mag, float *ang, + ptrdiff_t blocksize); + +av_cold void ff_vorbisdsp_init_riscv(VorbisDSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) + c->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_rvv; +#endif +} diff --git a/libavcodec/riscv/vorbisdsp_rvv.S b/libavcodec/riscv/vorbisdsp_rvv.S new file mode 100644 index 0000000000..e8953fb548 --- /dev/null +++ b/libavcodec/riscv/vorbisdsp_rvv.S @@ -0,0 +1,44 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "../libavutil/riscv/asm.S" + +func ff_vorbis_inverse_coupling_rvv, zve32f + fmv.w.x ft0, zero +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v16, (a1) + sub a2, a2, t0 + vle32.v v24, (a0) + vfmax.vf v8, v16, ft0 + vfmin.vf v16, v16, ft0 + vfsgnj.vv v8, v8, v24 + vfsgnj.vv v16, v16, v24 + vfsub.vv v8, v24, v8 + vfsub.vv v24, v24, v16 + vse32.v v8, (a1) + sh2add a1, t0, a1 + vse32.v v24, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc diff --git a/libavcodec/vorbisdsp.c b/libavcodec/vorbisdsp.c index 693c44dfcb..70022bd262 100644 --- a/libavcodec/vorbisdsp.c +++ b/libavcodec/vorbisdsp.c @@ -53,6 +53,8 @@ av_cold void ff_vorbisdsp_init(VorbisDSPContext *dsp) ff_vorbisdsp_init_arm(dsp); #elif ARCH_PPC ff_vorbisdsp_init_ppc(dsp); +#elif ARCH_RISCV + ff_vorbisdsp_init_riscv(dsp); #elif ARCH_X86 ff_vorbisdsp_init_x86(dsp); #endif diff --git a/libavcodec/vorbisdsp.h b/libavcodec/vorbisdsp.h index 1775a92cf2..5c369ecf22 100644 --- a/libavcodec/vorbisdsp.h +++ b/libavcodec/vorbisdsp.h @@ -34,5 +34,6 @@ void ff_vorbisdsp_init_aarch64(VorbisDSPContext *dsp); void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp); void ff_vorbisdsp_init_arm(VorbisDSPContext *dsp); void ff_vorbisdsp_init_ppc(VorbisDSPContext *dsp); +void ff_vorbisdsp_init_riscv(VorbisDSPContext *dsp); #endif /* AVCODEC_VORBISDSP_H */ From b0cacf4c3f8fe451e22a43462ea68ffa1e2e09ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:46 +0300 Subject: [PATCH 530/590] lavc/aacpsdsp: RISC-V V add_squares --- libavcodec/aacpsdsp.h | 1 + libavcodec/aacpsdsp_template.c | 2 ++ libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/aacpsdsp_init.c | 37 ++++++++++++++++++++++++++++++++ libavcodec/riscv/aacpsdsp_rvv.S | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 libavcodec/riscv/aacpsdsp_init.c create mode 100644 libavcodec/riscv/aacpsdsp_rvv.S diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h index 917ac5303f..8b32761bdb 100644 --- a/libavcodec/aacpsdsp.h +++ b/libavcodec/aacpsdsp.h @@ -55,6 +55,7 @@ void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s); void ff_psdsp_init_arm(PSDSPContext *s); void ff_psdsp_init_aarch64(PSDSPContext *s); void ff_psdsp_init_mips(PSDSPContext *s); +void ff_psdsp_init_riscv(PSDSPContext *s); void ff_psdsp_init_x86(PSDSPContext *s); #endif /* AVCODEC_AACPSDSP_H */ diff --git a/libavcodec/aacpsdsp_template.c b/libavcodec/aacpsdsp_template.c index e3cbf3feec..c063788b89 100644 --- a/libavcodec/aacpsdsp_template.c +++ b/libavcodec/aacpsdsp_template.c @@ -230,6 +230,8 @@ av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s) ff_psdsp_init_aarch64(s); #elif ARCH_MIPS ff_psdsp_init_mips(s); +#elif ARCH_RISCV + ff_psdsp_init_riscv(s); #elif ARCH_X86 ff_psdsp_init_x86(s); #endif diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 03a95301d7..829a1823d2 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,3 +1,5 @@ +OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_init.o +RVV-OBJS-$(CONFIG_AAC_DECODER) += riscv/aacpsdsp_rvv.o OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c new file mode 100644 index 0000000000..83f6d9b16b --- /dev/null +++ b/libavcodec/riscv/aacpsdsp_init.c @@ -0,0 +1,37 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/aacpsdsp.h" + +void ff_ps_add_squares_rvv(float *dst, const float (*src)[2], int n); + +av_cold void ff_psdsp_init_riscv(PSDSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_F32) + c->add_squares = ff_ps_add_squares_rvv; +#endif +} diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S new file mode 100644 index 0000000000..b516063ea7 --- /dev/null +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -0,0 +1,37 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 "libavutil/riscv/asm.S" + +func ff_ps_add_squares_rvv, zve32f +1: + vsetvli t0, a2, e32, m1, ta, ma + vlseg2e32.v v24, (a1) + sub a2, a2, t0 + vle32.v v16, (a0) + sh3add a1, t0, a1 + vfmacc.vv v16, v24, v24 + vfmacc.vv v16, v25, v25 + vse32.v v16, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc From e180326a0b72bbbdee51810592b16178a48797f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:47 +0300 Subject: [PATCH 531/590] lavc/aacpsdsp: RISC-V V mul_pair_single --- libavcodec/riscv/aacpsdsp_init.c | 6 +++++- libavcodec/riscv/aacpsdsp_rvv.S | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c index 83f6d9b16b..21fd5b8470 100644 --- a/libavcodec/riscv/aacpsdsp_init.c +++ b/libavcodec/riscv/aacpsdsp_init.c @@ -25,13 +25,17 @@ #include "libavcodec/aacpsdsp.h" void ff_ps_add_squares_rvv(float *dst, const float (*src)[2], int n); +void ff_ps_mul_pair_single_rvv(float (*dst)[2], float (*src0)[2], float *src1, + int n); av_cold void ff_psdsp_init_riscv(PSDSPContext *c) { #if HAVE_RVV int flags = av_get_cpu_flags(); - if (flags & AV_CPU_FLAG_RVV_F32) + if (flags & AV_CPU_FLAG_RVV_F32) { c->add_squares = ff_ps_add_squares_rvv; + c->mul_pair_single = ff_ps_mul_pair_single_rvv; + } #endif } diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index b516063ea7..70b7b72218 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -35,3 +35,20 @@ func ff_ps_add_squares_rvv, zve32f ret endfunc + +func ff_ps_mul_pair_single_rvv, zve32f +1: + vsetvli t0, a3, e32, m1, ta, ma + vlseg2e32.v v24, (a1) + sub a3, a3, t0 + vle32.v v16, (a2) + sh3add a1, t0, a1 + vfmul.vv v24, v24, v16 + sh2add a2, t0, a2 + vfmul.vv v25, v25, v16 + vsseg2e32.v v24, (a0) + sh3add a0, t0, a0 + bnez a3, 1b + + ret +endfunc From 15c3a0bd6ec1383e26ca6a41ea8daa95dc0e1736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:48 +0300 Subject: [PATCH 532/590] lavc/aacpsdsp: RISC-V V hybrid_analysis This starts with one-time initialisation of the 26 constant factors like 08edacc248bce3f8946d75e97188d189c74a6de6. That is done with the scalar instruction set. While the formula can readily be vectored, the gains would (probably) be more than lost in transfering the results back to FP registers (or suitably reshuffling them into vector registers). Note that the main loop could likely be scheduled sligthly better by expanding the filter macro and interleaving loads with arithmetic. It is not clear yet if that would be relevant for vector processing (as opposed to traditional SIMD). We could also use fewer vectors, but there is not much point in sparing them (they are *all* callee-clobbered). --- libavcodec/riscv/aacpsdsp_init.c | 3 + libavcodec/riscv/aacpsdsp_rvv.S | 97 ++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c index 21fd5b8470..09f16f1041 100644 --- a/libavcodec/riscv/aacpsdsp_init.c +++ b/libavcodec/riscv/aacpsdsp_init.c @@ -27,6 +27,8 @@ void ff_ps_add_squares_rvv(float *dst, const float (*src)[2], int n); void ff_ps_mul_pair_single_rvv(float (*dst)[2], float (*src0)[2], float *src1, int n); +void ff_ps_hybrid_analysis_rvv(float (*out)[2], float (*in)[2], + const float (*filter)[8][2], ptrdiff_t, int n); av_cold void ff_psdsp_init_riscv(PSDSPContext *c) { @@ -36,6 +38,7 @@ av_cold void ff_psdsp_init_riscv(PSDSPContext *c) if (flags & AV_CPU_FLAG_RVV_F32) { c->add_squares = ff_ps_add_squares_rvv; c->mul_pair_single = ff_ps_mul_pair_single_rvv; + c->hybrid_analysis = ff_ps_hybrid_analysis_rvv; } #endif } diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index 70b7b72218..65e5e0be4f 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -52,3 +52,100 @@ func ff_ps_mul_pair_single_rvv, zve32f ret endfunc + +func ff_ps_hybrid_analysis_rvv, zve32f + /* We need 26 FP registers, for 20 scratch ones. Spill fs0-fs5. */ + addi sp, sp, -32 + .irp n, 0, 1, 2, 3, 4, 5 + fsw fs\n, (4 * \n)(sp) + .endr + + .macro input, j, fd0, fd1, fd2, fd3 + flw \fd0, (4 * ((\j * 2) + 0))(a1) + flw fs4, (4 * (((12 - \j) * 2) + 0))(a1) + flw \fd1, (4 * ((\j * 2) + 1))(a1) + fsub.s \fd3, \fd0, fs4 + flw fs5, (4 * (((12 - \j) * 2) + 1))(a1) + fadd.s \fd2, \fd1, fs5 + fadd.s \fd0, \fd0, fs4 + fsub.s \fd1, \fd1, fs5 + .endm + + // re0, re1, im0, im1 + input 0, ft0, ft1, ft2, ft3 + input 1, ft4, ft5, ft6, ft7 + input 2, ft8, ft9, ft10, ft11 + input 3, fa0, fa1, fa2, fa3 + input 4, fa4, fa5, fa6, fa7 + input 5, fs0, fs1, fs2, fs3 + flw fs4, (4 * ((6 * 2) + 0))(a1) + flw fs5, (4 * ((6 * 2) + 1))(a1) + + add a2, a2, 6 * 2 * 4 // point to filter[i][6][0] + li t4, 8 * 2 * 4 // filter byte stride + slli a3, a3, 3 // output byte stride +1: + .macro filter, vs0, vs1, fo0, fo1, fo2, fo3 + vfmacc.vf v8, \fo0, \vs0 + vfmacc.vf v9, \fo2, \vs0 + vfnmsac.vf v8, \fo1, \vs1 + vfmacc.vf v9, \fo3, \vs1 + .endm + + vsetvli t0, a4, e32, m1, ta, ma + /* + * The filter (a2) has 16 segments, of which 13 need to be extracted. + * R-V V supports only up to 8 segments, so unrolling is unavoidable. + */ + addi t1, a2, -48 + vlse32.v v22, (a2), t4 + addi t2, a2, -44 + vlse32.v v16, (t1), t4 + addi t1, a2, -40 + vfmul.vf v8, v22, fs4 + vlse32.v v24, (t2), t4 + addi t2, a2, -36 + vfmul.vf v9, v22, fs5 + vlse32.v v17, (t1), t4 + addi t1, a2, -32 + vlse32.v v25, (t2), t4 + addi t2, a2, -28 + filter v16, v24, ft0, ft1, ft2, ft3 + vlse32.v v18, (t1), t4 + addi t1, a2, -24 + vlse32.v v26, (t2), t4 + addi t2, a2, -20 + filter v17, v25, ft4, ft5, ft6, ft7 + vlse32.v v19, (t1), t4 + addi t1, a2, -16 + vlse32.v v27, (t2), t4 + addi t2, a2, -12 + filter v18, v26, ft8, ft9, ft10, ft11 + vlse32.v v20, (t1), t4 + addi t1, a2, -8 + vlse32.v v28, (t2), t4 + addi t2, a2, -4 + filter v19, v27, fa0, fa1, fa2, fa3 + vlse32.v v21, (t1), t4 + sub a4, a4, t0 + vlse32.v v29, (t2), t4 + slli t1, t0, 3 + 1 + 2 // ctz(8 * 2 * 4) + add a2, a2, t1 + filter v20, v28, fa4, fa5, fa6, fa7 + filter v21, v29, fs0, fs1, fs2, fs3 + + add t2, a0, 4 + vsse32.v v8, (a0), a3 + mul t0, t0, a3 + vsse32.v v9, (t2), a3 + add a0, a0, t0 + bnez a4, 1b + + .irp n, 5, 4, 3, 2, 1, 0 + flw fs\n, (4 * \n)(sp) + .endr + addi sp, sp, 32 + ret + .purgem input + .purgem filter +endfunc From 09f907999f6ff4204d5848e5fd01e1143cb76d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:49 +0300 Subject: [PATCH 533/590] lavc/aacpsdsp: RISC-V V hybrid_analysis_ileave --- libavcodec/riscv/aacpsdsp_init.c | 5 +++++ libavcodec/riscv/aacpsdsp_rvv.S | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c index 09f16f1041..1d36f89f6e 100644 --- a/libavcodec/riscv/aacpsdsp_init.c +++ b/libavcodec/riscv/aacpsdsp_init.c @@ -29,6 +29,8 @@ void ff_ps_mul_pair_single_rvv(float (*dst)[2], float (*src0)[2], float *src1, int n); void ff_ps_hybrid_analysis_rvv(float (*out)[2], float (*in)[2], const float (*filter)[8][2], ptrdiff_t, int n); +void ff_ps_hybrid_analysis_ileave_rvv(float (*out)[32][2], float L[2][38][64], + int i, int len); av_cold void ff_psdsp_init_riscv(PSDSPContext *c) { @@ -40,5 +42,8 @@ av_cold void ff_psdsp_init_riscv(PSDSPContext *c) c->mul_pair_single = ff_ps_mul_pair_single_rvv; c->hybrid_analysis = ff_ps_hybrid_analysis_rvv; } + + if (flags & AV_CPU_FLAG_RVV_I32) + c->hybrid_analysis_ileave = ff_ps_hybrid_analysis_ileave_rvv; #endif } diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index 65e5e0be4f..c9cc15e73d 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -149,3 +149,38 @@ func ff_ps_hybrid_analysis_rvv, zve32f .purgem input .purgem filter endfunc + +func ff_ps_hybrid_analysis_ileave_rvv, zve32x /* no needs for zve32f here */ + slli t0, a2, 5 + 1 + 2 // ctz(32 * 2 * 4) + sh2add a1, a2, a1 + add a0, a0, t0 + addi a2, a2, -64 + li t1, 38 * 64 * 4 + li t6, 64 * 4 // (uint8_t *)L[x][j+1][i] - L[x][j][i] + add a4, a1, t1 // &L[1] + beqz a2, 3f +1: + mv t0, a0 + mv t1, a1 + mv t3, a3 + mv t4, a4 + addi a2, a2, 1 +2: + vsetvli t5, t3, e32, m1, ta, ma + vlse32.v v16, (t1), t6 + sub t3, t3, t5 + vlse32.v v17, (t4), t6 + mul t2, t5, t6 + vsseg2e32.v v16, (t0) + sh3add t0, t5, t0 + add t1, t1, t2 + add t4, t4, t2 + bnez t3, 2b + + add a0, a0, 32 * 2 * 4 + add a1, a1, 4 + add a4, a4, 4 + bnez a2, 1b +3: + ret +endfunc From a15edb0bc0108362fa3c71de3bf763072341b8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:50 +0300 Subject: [PATCH 534/590] lavc/aacpsdsp: RISC-V V hybrid_synthesis_deint --- libavcodec/riscv/aacpsdsp_init.c | 6 +++++- libavcodec/riscv/aacpsdsp_rvv.S | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c index 1d36f89f6e..c2201ffb6a 100644 --- a/libavcodec/riscv/aacpsdsp_init.c +++ b/libavcodec/riscv/aacpsdsp_init.c @@ -31,6 +31,8 @@ void ff_ps_hybrid_analysis_rvv(float (*out)[2], float (*in)[2], const float (*filter)[8][2], ptrdiff_t, int n); void ff_ps_hybrid_analysis_ileave_rvv(float (*out)[32][2], float L[2][38][64], int i, int len); +void ff_ps_hybrid_synthesis_deint_rvv(float out[2][38][64], float (*in)[32][2], + int i, int len); av_cold void ff_psdsp_init_riscv(PSDSPContext *c) { @@ -43,7 +45,9 @@ av_cold void ff_psdsp_init_riscv(PSDSPContext *c) c->hybrid_analysis = ff_ps_hybrid_analysis_rvv; } - if (flags & AV_CPU_FLAG_RVV_I32) + if (flags & AV_CPU_FLAG_RVV_I32) { c->hybrid_analysis_ileave = ff_ps_hybrid_analysis_ileave_rvv; + c->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_rvv; + } #endif } diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index c9cc15e73d..0cbe4c1d3c 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -184,3 +184,38 @@ func ff_ps_hybrid_analysis_ileave_rvv, zve32x /* no needs for zve32f here */ 3: ret endfunc + +func ff_ps_hybrid_synthesis_deint_rvv, zve32x + slli t1, a2, 5 + 1 + 2 + sh2add a0, a2, a0 + add a1, a1, t1 + addi a2, a2, -64 + li t1, 38 * 64 * 4 + li t6, 64 * 4 + add a4, a0, t1 + beqz a2, 3f +1: + mv t0, a0 + mv t1, a1 + mv t3, a3 + mv t4, a4 + addi a2, a2, 1 +2: + vsetvli t5, t3, e32, m1, ta, ma + vlseg2e32.v v16, (t1) + sub t3, t3, t5 + vsse32.v v16, (t0), t6 + mul t2, t5, t6 + vsse32.v v17, (t4), t6 + sh3add t1, t5, t1 + add t0, t0, t2 + add t4, t4, t2 + bnez t3, 2b + + add a0, a0, 4 + add a1, a1, 32 * 2 * 4 + add a4, a4, 4 + bnez a2, 1b +3: + ret +endfunc From c03f9654c997b33b8028eb71c9e7ba61fd53a813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Mon, 26 Sep 2022 17:52:51 +0300 Subject: [PATCH 535/590] lavc/aacpsdsp: RISC-V V stereo_interpolate[0] --- libavcodec/riscv/aacpsdsp_init.c | 4 +++ libavcodec/riscv/aacpsdsp_rvv.S | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c index c2201ffb6a..f42baf4251 100644 --- a/libavcodec/riscv/aacpsdsp_init.c +++ b/libavcodec/riscv/aacpsdsp_init.c @@ -34,6 +34,9 @@ void ff_ps_hybrid_analysis_ileave_rvv(float (*out)[32][2], float L[2][38][64], void ff_ps_hybrid_synthesis_deint_rvv(float out[2][38][64], float (*in)[32][2], int i, int len); +void ff_ps_stereo_interpolate_rvv(float (*l)[2], float (*r)[2], + float h[2][4], float h_step[2][4], int len); + av_cold void ff_psdsp_init_riscv(PSDSPContext *c) { #if HAVE_RVV @@ -43,6 +46,7 @@ av_cold void ff_psdsp_init_riscv(PSDSPContext *c) c->add_squares = ff_ps_add_squares_rvv; c->mul_pair_single = ff_ps_mul_pair_single_rvv; c->hybrid_analysis = ff_ps_hybrid_analysis_rvv; + c->stereo_interpolate[0] = ff_ps_stereo_interpolate_rvv; } if (flags & AV_CPU_FLAG_RVV_I32) { diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index 0cbe4c1d3c..1d6e73fd2d 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -219,3 +219,59 @@ func ff_ps_hybrid_synthesis_deint_rvv, zve32x 3: ret endfunc + +func ff_ps_stereo_interpolate_rvv, zve32f + vsetvli t0, zero, e32, m1, ta, ma + vid.v v24 + flw ft0, (a2) + vadd.vi v24, v24, 1 // v24[i] = i + 1 + flw ft1, 4(a2) + vfcvt.f.xu.v v24, v24 + flw ft2, 8(a2) + vfmv.v.f v16, ft0 + flw ft3, 12(a2) + vfmv.v.f v17, ft1 + flw ft0, (a3) + vfmv.v.f v18, ft2 + flw ft1, 4(a3) + vfmv.v.f v19, ft3 + flw ft2, 8(a3) + vfmv.v.f v20, ft0 + flw ft3, 12(a3) + vfmv.v.f v21, ft1 + fcvt.s.wu ft4, t0 // (float)(vlenb / sizeof (float)) + vfmv.v.f v22, ft2 + fmul.s ft0, ft0, ft4 + vfmv.v.f v23, ft3 + fmul.s ft1, ft1, ft4 + vfmacc.vv v16, v24, v20 // h0 += (i + 1) * h0_step + fmul.s ft2, ft2, ft4 + vfmacc.vv v17, v24, v21 + fmul.s ft3, ft3, ft4 + vfmacc.vv v18, v24, v22 + vfmacc.vv v19, v24, v23 +1: + vsetvli t0, a4, e32, m1, ta, ma + vlseg2e32.v v8, (a0) // v8:l_re, v9:l_im + sub a4, a4, t0 + vlseg2e32.v v10, (a1) // v10:r_re, v11:r_im + vfmul.vv v12, v8, v16 + vfmul.vv v13, v9, v16 + vfmul.vv v14, v8, v17 + vfmul.vv v15, v9, v17 + vfmacc.vv v12, v10, v18 + vfmacc.vv v13, v11, v18 + vfmacc.vv v14, v10, v19 + vfmacc.vv v15, v11, v19 + vsseg2e32.v v12, (a0) + sh3add a0, t0, a0 + vsseg2e32.v v14, (a1) + sh3add a1, t0, a1 + vfadd.vf v16, v16, ft0 // h0 += (vlenb / sizeof (float)) * h0_step + vfadd.vf v17, v17, ft1 + vfadd.vf v18, v18, ft2 + vfadd.vf v19, v19, ft3 + bnez a4, 1b + + ret +endfunc From f5cd00bf5265cb1d10de925c4d0b3ebb191f0d74 Mon Sep 17 00:00:00 2001 From: Derek Buitenhuis Date: Thu, 22 Sep 2022 14:11:31 +0100 Subject: [PATCH 536/590] ffprobe: Check for invalid matrix error when printing rotation av_display_rotation_get will return NAN when the display matrix is invalid, which would end up printing NAN as an integer in the rotation field. This is poor for multiple reasons: * Users of ffprobe have no way of discerning "valid but ugly rotation from display matrix" from "invalid display matrix". * It can have unintended consequences on some platforms, such as Linux x86_64, where NAN is equal to INT64_MIN, which, for example, when printed as JSON, which uses floating point for all numbers, can end up as invalid JSON or wit a number that cannot be reserialized as an integer at all. Since NAN is av_display_rotation_get's error case, just print 0 (no rotation) when that happens. Signed-off-by: Derek Buitenhuis --- fftools/ffprobe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 8ee1b1036c..421ada5bd8 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -27,6 +27,7 @@ #include "libavutil/ffversion.h" #include +#include #include "libavformat/avformat.h" #include "libavformat/version.h" @@ -2282,8 +2283,11 @@ static void print_pkt_side_data(WriterContext *w, writer_print_section_header(w, id_data); print_str("side_data_type", name ? name : "unknown"); if (sd->type == AV_PKT_DATA_DISPLAYMATRIX && sd->size >= 9*4) { + double rotation = av_display_rotation_get((int32_t *)sd->data); + if (isnan(rotation)) + rotation = 0; writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1); - print_int("rotation", av_display_rotation_get((int32_t *)sd->data)); + print_int("rotation", rotation); } else if (sd->type == AV_PKT_DATA_STEREO3D) { const AVStereo3D *stereo = (AVStereo3D *)sd->data; print_str("type", av_stereo3d_type_name(stereo->type)); @@ -2639,8 +2643,11 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, name = av_frame_side_data_name(sd->type); print_str("side_data_type", name ? name : "unknown"); if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX && sd->size >= 9*4) { + double rotation = av_display_rotation_get((int32_t *)sd->data); + if (isnan(rotation)) + rotation = 0; writer_print_integers(w, "displaymatrix", sd->data, 9, " %11d", 3, 4, 1); - print_int("rotation", av_display_rotation_get((int32_t *)sd->data)); + print_int("rotation", rotation); } else if (sd->type == AV_FRAME_DATA_AFD && sd->size > 0) { print_int("active_format", *sd->data); } else if (sd->type == AV_FRAME_DATA_GOP_TIMECODE && sd->size >= 8) { From 59cb0bd23d61f6ea3bfd86558346e2720aba7f06 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Tue, 27 Sep 2022 19:35:37 +0200 Subject: [PATCH 537/590] avfilter/vf_extractplanes: add missing break; statement --- libavfilter/vf_extractplanes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c index 3c794eaa28..08737d6415 100644 --- a/libavfilter/vf_extractplanes.c +++ b/libavfilter/vf_extractplanes.c @@ -284,6 +284,7 @@ static void extract_from_packed(uint8_t *dst, int dst_linesize, dst[x * 2 ] = src[x * step + comp * 2 ]; dst[x * 2 + 1] = src[x * step + comp * 2 + 1]; } + break; case 4: for (x = 0; x < width; x++) { dst[x * 4 ] = src[x * step + comp * 4 ]; From 2664b39d54aa44ba185ea39c3933b80d9dfcb542 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 27 Sep 2022 01:40:24 +0200 Subject: [PATCH 538/590] avocdec/snowenc: Fix left shift of negative number Fixes the vsynth(1|2|_lena)-snow-ll FATE-tests. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt --- libavcodec/snowenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c index b647fc9016..c5ff50639e 100644 --- a/libavcodec/snowenc.c +++ b/libavcodec/snowenc.c @@ -1814,7 +1814,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, if(s->qlog == LOSSLESS_QLOG){ for(y=0; yspatial_idwt_buffer[y*w + x]<<=FRAC_BITS; + s->spatial_idwt_buffer[y*w + x] *= 1 << FRAC_BITS; } } } From 0bc7ba448868f74866800f956ad7e4835b976f47 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 28 Sep 2022 00:07:53 +0200 Subject: [PATCH 539/590] configure: remove mdct15 from the encoder/decoder's list of requirements --- configure | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configure b/configure index a41ebda6d4..6712d045d9 100755 --- a/configure +++ b/configure @@ -2921,8 +2921,7 @@ notchlc_decoder_select="lzf" nuv_decoder_select="idctdsp" on2avc_decoder_select="mdct" opus_decoder_deps="swresample" -opus_decoder_select="mdct15" -opus_encoder_select="audio_frame_queue mdct15" +opus_encoder_select="audio_frame_queue" png_decoder_select="inflate_wrapper" png_encoder_select="deflate_wrapper llvidencdsp" prores_decoder_select="blockdsp idctdsp" From 0e402ebf487075727187c78f85908a492eed3e59 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Mon, 19 Sep 2022 08:26:18 -0700 Subject: [PATCH 540/590] format/imfdec: improve error handling when selecting tracks for playback Reviewed-by: Zane van Iperen --- libavformat/imfdec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index fde91a6419..4e60dcc4ba 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -686,8 +686,11 @@ static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVForma { IMFContext *c = s->priv_data; IMFVirtualTrackPlaybackCtx *track; - AVRational minimum_timestamp = av_make_q(INT32_MAX, 1); + + if (!c->track_count) + return NULL; + for (uint32_t i = c->track_count; i > 0; i--) { av_log(s, AV_LOG_TRACE, "Compare track %d timestamp " AVRATIONAL_FORMAT " to minimum " AVRATIONAL_FORMAT @@ -702,8 +705,6 @@ static IMFVirtualTrackPlaybackCtx *get_next_track_with_minimum_timestamp(AVForma } } - av_log(s, AV_LOG_DEBUG, "Found next track to read: %d (timestamp: %lf / %lf)\n", - track->index, av_q2d(track->current_timestamp), av_q2d(minimum_timestamp)); return track; } @@ -766,6 +767,14 @@ static int imf_read_packet(AVFormatContext *s, AVPacket *pkt) track = get_next_track_with_minimum_timestamp(s); + if (!track) { + av_log(s, AV_LOG_ERROR, "No track found for playback\n"); + return AVERROR_INVALIDDATA; + } + + av_log(s, AV_LOG_DEBUG, "Found track %d to read at timestamp %lf\n", + track->index, av_q2d(track->current_timestamp)); + ret = get_resource_context_for_timestamp(s, track, &resource); if (ret) return ret; From dd2e524ffa10aba1939acdfa43a0fca06db65921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 28 Sep 2022 10:12:42 +0300 Subject: [PATCH 541/590] riscv: Use the correct path for including asm.S MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/riscv/fmtconvert_rvv.S | 2 +- libavcodec/riscv/pixblockdsp_rvi.S | 2 +- libavcodec/riscv/vorbisdsp_rvv.S | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/riscv/fmtconvert_rvv.S b/libavcodec/riscv/fmtconvert_rvv.S index c79f80cc47..49893ec8d7 100644 --- a/libavcodec/riscv/fmtconvert_rvv.S +++ b/libavcodec/riscv/fmtconvert_rvv.S @@ -19,7 +19,7 @@ */ #include "config.h" -#include "../libavutil/riscv/asm.S" +#include "libavutil/riscv/asm.S" func ff_int32_to_float_fmul_scalar_rvv, zve32f NOHWF fmv.w.x fa0, a2 diff --git a/libavcodec/riscv/pixblockdsp_rvi.S b/libavcodec/riscv/pixblockdsp_rvi.S index 93ece4405e..e84170244b 100644 --- a/libavcodec/riscv/pixblockdsp_rvi.S +++ b/libavcodec/riscv/pixblockdsp_rvi.S @@ -19,7 +19,7 @@ */ #include "config.h" -#include "../libavutil/riscv/asm.S" +#include "libavutil/riscv/asm.S" func ff_get_pixels_8_rvi .irp row, 0, 1, 2, 3, 4, 5, 6, 7 diff --git a/libavcodec/riscv/vorbisdsp_rvv.S b/libavcodec/riscv/vorbisdsp_rvv.S index e8953fb548..bbe9c7dc6d 100644 --- a/libavcodec/riscv/vorbisdsp_rvv.S +++ b/libavcodec/riscv/vorbisdsp_rvv.S @@ -19,7 +19,7 @@ */ #include "config.h" -#include "../libavutil/riscv/asm.S" +#include "libavutil/riscv/asm.S" func ff_vorbis_inverse_coupling_rvv, zve32f fmv.w.x ft0, zero From c47ebfa141565a6bcaf6eeb699f135f81efacc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:21 +0300 Subject: [PATCH 542/590] lavu/riscv: helper to read the vector length --- libavutil/riscv/cpu.h | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 libavutil/riscv/cpu.h diff --git a/libavutil/riscv/cpu.h b/libavutil/riscv/cpu.h new file mode 100644 index 0000000000..56035f8556 --- /dev/null +++ b/libavutil/riscv/cpu.h @@ -0,0 +1,45 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 AVUTIL_RISCV_CPU_H +#define AVUTIL_RISCV_CPU_H + +#include "config.h" +#include +#include "libavutil/cpu.h" + +#if HAVE_RVV +/** + * Returns the vector size in bytes (always a power of two and at least 4). + * This is undefined behaviour if vectors are not implemented. + */ +static inline size_t ff_get_rv_vlenb(void) +{ + size_t vlenb; + + __asm__ ( + ".option push\n" + ".option arch, +v\n" + " csrr %0, vlenb\n" + ".option pop\n" : "=r" (vlenb)); + return vlenb; +} +#endif +#endif From b29ee63a1b70263c8e69cd1b66ec9a44bcb8f0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:22 +0300 Subject: [PATCH 543/590] lavc/idctdsp: RISC-V V put_pixels_clamped function --- libavcodec/idctdsp.c | 2 ++ libavcodec/idctdsp.h | 2 ++ libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/idctdsp_init.c | 41 +++++++++++++++++++++++++++++++ libavcodec/riscv/idctdsp_rvv.S | 43 +++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 libavcodec/riscv/idctdsp_init.c create mode 100644 libavcodec/riscv/idctdsp_rvv.S diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c index 9035003b72..4ee9c3aa74 100644 --- a/libavcodec/idctdsp.c +++ b/libavcodec/idctdsp.c @@ -312,6 +312,8 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) ff_idctdsp_init_arm(c, avctx, high_bit_depth); #elif ARCH_PPC ff_idctdsp_init_ppc(c, avctx, high_bit_depth); +#elif ARCH_RISCV + ff_idctdsp_init_riscv(c, avctx, high_bit_depth); #elif ARCH_X86 ff_idctdsp_init_x86(c, avctx, high_bit_depth); #elif ARCH_MIPS diff --git a/libavcodec/idctdsp.h b/libavcodec/idctdsp.h index e8f20acaf2..2bd9820f72 100644 --- a/libavcodec/idctdsp.h +++ b/libavcodec/idctdsp.h @@ -114,6 +114,8 @@ void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 829a1823d2..96925afdab 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -5,6 +5,8 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o +OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o +RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o diff --git a/libavcodec/riscv/idctdsp_init.c b/libavcodec/riscv/idctdsp_init.c new file mode 100644 index 0000000000..1a6add80da --- /dev/null +++ b/libavcodec/riscv/idctdsp_init.c @@ -0,0 +1,41 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/idctdsp.h" + +void ff_put_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels, + ptrdiff_t stride); + +av_cold void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) + c->put_pixels_clamped = ff_put_pixels_clamped_rvv; +#endif +} diff --git a/libavcodec/riscv/idctdsp_rvv.S b/libavcodec/riscv/idctdsp_rvv.S new file mode 100644 index 0000000000..1987c8a8f6 --- /dev/null +++ b/libavcodec/riscv/idctdsp_rvv.S @@ -0,0 +1,43 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libavutil/riscv/asm.S" + +func ff_put_pixels_clamped_rvv, zve32x + vsetivli zero, 8, e16, m1, ta, ma + vlseg8e16.v v24, (a0) + /* RVV only has signed-signed and unsigned-unsigned clipping. + * We need two steps for signed-to-unsigned clipping. */ + vsetvli t0, zero, e16, m8, ta, ma + vmax.vx v24, v24, zero + + vsetivli zero, 8, e8, mf2, ta, ma + vnclipu.wi v16, v24, 0 + vnclipu.wi v17, v25, 0 + vnclipu.wi v18, v26, 0 + vnclipu.wi v19, v27, 0 + vnclipu.wi v20, v28, 0 + vnclipu.wi v21, v29, 0 + vnclipu.wi v22, v30, 0 + vnclipu.wi v23, v31, 0 + vssseg8e8.v v16, (a1), a2 + ret +endfunc From fa983b56560ede2d9e3e3e21c80bbe0352b8794d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:23 +0300 Subject: [PATCH 544/590] lavc/idctdsp: RISC-V V add_pixels_clamped function --- libavcodec/riscv/idctdsp_init.c | 6 +++++- libavcodec/riscv/idctdsp_rvv.S | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/idctdsp_init.c b/libavcodec/riscv/idctdsp_init.c index 1a6add80da..58b8a6c97a 100644 --- a/libavcodec/riscv/idctdsp_init.c +++ b/libavcodec/riscv/idctdsp_init.c @@ -28,6 +28,8 @@ void ff_put_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels, ptrdiff_t stride); +void ff_add_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels, + ptrdiff_t stride); av_cold void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) @@ -35,7 +37,9 @@ av_cold void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx, #if HAVE_RVV int flags = av_get_cpu_flags(); - if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) + if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) { c->put_pixels_clamped = ff_put_pixels_clamped_rvv; + c->add_pixels_clamped = ff_add_pixels_clamped_rvv; + } #endif } diff --git a/libavcodec/riscv/idctdsp_rvv.S b/libavcodec/riscv/idctdsp_rvv.S index 1987c8a8f6..3b504f5866 100644 --- a/libavcodec/riscv/idctdsp_rvv.S +++ b/libavcodec/riscv/idctdsp_rvv.S @@ -24,6 +24,7 @@ func ff_put_pixels_clamped_rvv, zve32x vsetivli zero, 8, e16, m1, ta, ma vlseg8e16.v v24, (a0) +1: /* RVV only has signed-signed and unsigned-unsigned clipping. * We need two steps for signed-to-unsigned clipping. */ vsetvli t0, zero, e16, m8, ta, ma @@ -41,3 +42,18 @@ func ff_put_pixels_clamped_rvv, zve32x vssseg8e8.v v16, (a1), a2 ret endfunc + +func ff_add_pixels_clamped_rvv, zve32x + vsetivli zero, 8, e8, mf2, ta, ma + vlseg8e16.v v24, (a0) + vlsseg8e8.v v16, (a1), a2 + vwaddu.wv v24, v24, v16 + vwaddu.wv v25, v25, v17 + vwaddu.wv v26, v26, v18 + vwaddu.wv v27, v27, v19 + vwaddu.wv v28, v28, v20 + vwaddu.wv v29, v29, v21 + vwaddu.wv v30, v30, v22 + vwaddu.wv v31, v31, v23 + j 1b +endfunc From 2746329ce25fb3d30bbf2aab187e90e21ae98064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:24 +0300 Subject: [PATCH 545/590] lavc/idctdsp: RISC-V V put_signed_pixels_clamped function --- libavcodec/riscv/idctdsp_init.c | 3 +++ libavcodec/riscv/idctdsp_rvv.S | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libavcodec/riscv/idctdsp_init.c b/libavcodec/riscv/idctdsp_init.c index 58b8a6c97a..e6e616a555 100644 --- a/libavcodec/riscv/idctdsp_init.c +++ b/libavcodec/riscv/idctdsp_init.c @@ -28,6 +28,8 @@ void ff_put_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels, ptrdiff_t stride); +void ff_put_signed_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels, + ptrdiff_t stride); void ff_add_pixels_clamped_rvv(const int16_t *block, uint8_t *pixels, ptrdiff_t stride); @@ -39,6 +41,7 @@ av_cold void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx, if ((flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) { c->put_pixels_clamped = ff_put_pixels_clamped_rvv; + c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_rvv; c->add_pixels_clamped = ff_add_pixels_clamped_rvv; } #endif diff --git a/libavcodec/riscv/idctdsp_rvv.S b/libavcodec/riscv/idctdsp_rvv.S index 3b504f5866..f5e1165eee 100644 --- a/libavcodec/riscv/idctdsp_rvv.S +++ b/libavcodec/riscv/idctdsp_rvv.S @@ -43,6 +43,27 @@ func ff_put_pixels_clamped_rvv, zve32x ret endfunc +func ff_put_signed_pixels_clamped_rvv, zve32x + vsetivli zero, 8, e16, m1, ta, ma + vlseg8e16.v v24, (a0) + + li t1, 128 + vsetivli zero, 8, e8, mf2, ta, ma + vnclip.wi v16, v24, 0 + vnclip.wi v17, v25, 0 + vnclip.wi v18, v26, 0 + vnclip.wi v19, v27, 0 + vnclip.wi v20, v28, 0 + vnclip.wi v21, v29, 0 + vnclip.wi v22, v30, 0 + vnclip.wi v23, v31, 0 + vsetvli t0, zero, e8, m8, ta, ma + vadd.vx v16, v16, t1 + vsetivli zero, 8, e8, mf2, ta, ma + vssseg8e8.v v16, (a1), a2 + ret +endfunc + func ff_add_pixels_clamped_rvv, zve32x vsetivli zero, 8, e8, mf2, ta, ma vlseg8e16.v v24, (a0) From 676b08cb703d412e4b60a598615365928489300b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:25 +0300 Subject: [PATCH 546/590] lavc/pixblockdsp: RISC-V V 8-bit get_pixels & get_pixels_unaligned --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/pixblockdsp_init.c | 12 ++++++++++ libavcodec/riscv/pixblockdsp_rvv.S | 37 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 libavcodec/riscv/pixblockdsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 96925afdab..0fb2c81c75 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -9,5 +9,6 @@ OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o +RVV-OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_rvv.o OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o diff --git a/libavcodec/riscv/pixblockdsp_init.c b/libavcodec/riscv/pixblockdsp_init.c index 04bf52649f..69dbd18918 100644 --- a/libavcodec/riscv/pixblockdsp_init.c +++ b/libavcodec/riscv/pixblockdsp_init.c @@ -20,8 +20,10 @@ #include +#include "config.h" #include "libavutil/attributes.h" #include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/pixblockdsp.h" @@ -30,6 +32,9 @@ void ff_get_pixels_8_rvi(int16_t *block, const uint8_t *pixels, void ff_get_pixels_16_rvi(int16_t *block, const uint8_t *pixels, ptrdiff_t stride); +void ff_get_pixels_8_rvv(int16_t *block, const uint8_t *pixels, + ptrdiff_t stride); + av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) @@ -42,4 +47,11 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, else c->get_pixels = ff_get_pixels_8_rvi; } + +#if HAVE_RVV + if ((cpu_flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) { + if (!high_bit_depth) + c->get_pixels_unaligned = c->get_pixels = ff_get_pixels_8_rvv; + } +#endif } diff --git a/libavcodec/riscv/pixblockdsp_rvv.S b/libavcodec/riscv/pixblockdsp_rvv.S new file mode 100644 index 0000000000..8d4322d8bc --- /dev/null +++ b/libavcodec/riscv/pixblockdsp_rvv.S @@ -0,0 +1,37 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "libavutil/riscv/asm.S" + +func ff_get_pixels_8_rvv, zve32x + vsetivli zero, 8, e8, mf2, ta, ma + vlsseg8e8.v v16, (a1), a2 + vwcvtu.x.x.v v8, v16 + vwcvtu.x.x.v v9, v17 + vwcvtu.x.x.v v10, v18 + vwcvtu.x.x.v v11, v19 + vwcvtu.x.x.v v12, v20 + vwcvtu.x.x.v v13, v21 + vwcvtu.x.x.v v14, v22 + vwcvtu.x.x.v v15, v23 + vsseg8e16.v v8, (a0) + ret +endfunc From ebee25855a453de56ff3bd06e666d07b26fa15b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:26 +0300 Subject: [PATCH 547/590] lavc/pixblockdsp: RISC-V V 16-bit get_pixels & get_pixels_unaligned --- libavcodec/riscv/pixblockdsp_init.c | 6 +++++- libavcodec/riscv/pixblockdsp_rvv.S | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/pixblockdsp_init.c b/libavcodec/riscv/pixblockdsp_init.c index 69dbd18918..bbda381c12 100644 --- a/libavcodec/riscv/pixblockdsp_init.c +++ b/libavcodec/riscv/pixblockdsp_init.c @@ -34,6 +34,8 @@ void ff_get_pixels_16_rvi(int16_t *block, const uint8_t *pixels, void ff_get_pixels_8_rvv(int16_t *block, const uint8_t *pixels, ptrdiff_t stride); +void ff_get_pixels_16_rvv(int16_t *block, const uint8_t *pixels, + ptrdiff_t stride); av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, AVCodecContext *avctx, @@ -50,7 +52,9 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, #if HAVE_RVV if ((cpu_flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) { - if (!high_bit_depth) + if (high_bit_depth) + c->get_pixels_unaligned = c->get_pixels = ff_get_pixels_16_rvv; + else c->get_pixels_unaligned = c->get_pixels = ff_get_pixels_8_rvv; } #endif diff --git a/libavcodec/riscv/pixblockdsp_rvv.S b/libavcodec/riscv/pixblockdsp_rvv.S index 8d4322d8bc..3392b4b2eb 100644 --- a/libavcodec/riscv/pixblockdsp_rvv.S +++ b/libavcodec/riscv/pixblockdsp_rvv.S @@ -35,3 +35,10 @@ func ff_get_pixels_8_rvv, zve32x vsseg8e16.v v8, (a0) ret endfunc + +func ff_get_pixels_16_rvv, zve32x + vsetivli zero, 8, e16, m1, ta, ma + vlsseg8e16.v v0, (a1), a2 + vsseg8e16.v v0, (a0) + ret +endfunc From d31013166ac3727ae7c7ebbb756e1e5800bc2b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Sep 2022 23:04:27 +0300 Subject: [PATCH 548/590] lavc/pixblockdsp: RISC-V diff_pixels & diff_pixels_unaligned --- libavcodec/riscv/pixblockdsp_init.c | 4 ++++ libavcodec/riscv/pixblockdsp_rvv.S | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libavcodec/riscv/pixblockdsp_init.c b/libavcodec/riscv/pixblockdsp_init.c index bbda381c12..aa39a8a665 100644 --- a/libavcodec/riscv/pixblockdsp_init.c +++ b/libavcodec/riscv/pixblockdsp_init.c @@ -36,6 +36,8 @@ void ff_get_pixels_8_rvv(int16_t *block, const uint8_t *pixels, ptrdiff_t stride); void ff_get_pixels_16_rvv(int16_t *block, const uint8_t *pixels, ptrdiff_t stride); +void ff_diff_pixels_rvv(int16_t *block, const uint8_t *s1, const uint8_t *s2, + ptrdiff_t stride); av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, AVCodecContext *avctx, @@ -56,6 +58,8 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, c->get_pixels_unaligned = c->get_pixels = ff_get_pixels_16_rvv; else c->get_pixels_unaligned = c->get_pixels = ff_get_pixels_8_rvv; + + c->diff_pixels_unaligned = c->diff_pixels = ff_diff_pixels_rvv; } #endif } diff --git a/libavcodec/riscv/pixblockdsp_rvv.S b/libavcodec/riscv/pixblockdsp_rvv.S index 3392b4b2eb..c125408523 100644 --- a/libavcodec/riscv/pixblockdsp_rvv.S +++ b/libavcodec/riscv/pixblockdsp_rvv.S @@ -42,3 +42,19 @@ func ff_get_pixels_16_rvv, zve32x vsseg8e16.v v0, (a0) ret endfunc + +func ff_diff_pixels_rvv, zve32x + vsetivli zero, 8, e8, mf2, ta, ma + vlsseg8e8.v v16, (a1), a3 + vlsseg8e8.v v24, (a2), a3 + vwsubu.vv v8, v16, v24 + vwsubu.vv v9, v17, v25 + vwsubu.vv v10, v18, v26 + vwsubu.vv v11, v19, v27 + vwsubu.vv v12, v20, v28 + vwsubu.vv v13, v21, v29 + vwsubu.vv v14, v22, v30 + vwsubu.vv v15, v23, v31 + vsseg8e16.v v8, (a0) + ret +endfunc From 4f022e67822c286e0974fe27191186d80342feb1 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 25 Sep 2022 19:17:25 +0200 Subject: [PATCH 549/590] avcodec/mjpegdec: check that index is not negative --- libavcodec/mjpegdec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index c594950500..559bda5e6f 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -373,7 +373,10 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->v_max = 1; for (i = 0; i < nb_components; i++) { /* component id */ - s->component_id[i] = get_bits(&s->gb, 8) - 1; + int id = get_bits(&s->gb, 8); + if (id == 0) + return AVERROR_INVALIDDATA; + s->component_id[i] = id - 1; h_count[i] = get_bits(&s->gb, 4); v_count[i] = get_bits(&s->gb, 4); /* compute hmax and vmax (only used in interleaved case) */ @@ -1677,7 +1680,10 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, return AVERROR_INVALIDDATA; } for (i = 0; i < nb_components; i++) { - id = get_bits(&s->gb, 8) - 1; + id = get_bits(&s->gb, 8); + if (id == 0) + return AVERROR_INVALIDDATA; + id -= 1; av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id); /* find component index */ for (index = 0; index < s->nb_components; index++) From bcd2e7d685730838a07c0e88650ea8bbbe460df1 Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 28 Sep 2022 12:15:42 -0300 Subject: [PATCH 550/590] avutil/version: bump minor for the new RISC-V cpu flags Forgotten in 0c0a3deb1826638915775daa7cefb891a300060b. Signed-off-by: James Almer --- libavutil/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/version.h b/libavutil/version.h index 9c44cef6aa..5aca550f45 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MINOR 38 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From 299253ae1b010eeee81d5a2f291a490627fa482d Mon Sep 17 00:00:00 2001 From: James Almer Date: Sun, 25 Sep 2022 20:00:46 -0300 Subject: [PATCH 551/590] avutil/channel_layout: move and improve the comment about unknown orders Don't place it as doxy specific for the order field, and generalize it both to also cover already defined orders and to not make it seem like the user is required to handle a layout they don't fully support or understand. Signed-off-by: James Almer --- libavutil/channel_layout.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 9e685fab72..ff2b57bbe3 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -266,6 +266,9 @@ typedef struct AVChannelCustom { * A channel layout here is defined as a set of channels ordered in a specific * way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an * AVChannelLayout carries only the channel count). + * All orders may be treated as if they were AV_CHANNEL_ORDER_UNSPEC by + * ignoring everything but the channel count, as long as av_channel_layout_check() + * considers they are valid. * * Unlike most structures in Libav, sizeof(AVChannelLayout) is a part of the * public ABI and may be used by the caller. E.g. it may be allocated on stack @@ -290,9 +293,6 @@ typedef struct AVChannelCustom { typedef struct AVChannelLayout { /** * Channel order used in this layout. - * Any value not defined in the AVChannelOrder enum in a layout that - * av_channel_layout_check() doesn't reject must be treated as if it was - * AV_CHANNEL_ORDER_UNSPEC. * This is a mandatory field. */ enum AVChannelOrder order; From a91ddce6894af70ed7389eaf2a84f844e9f7b7e9 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 19:56:35 +0200 Subject: [PATCH 552/590] avcodec/dirac_dwt(_template): Don't use ff_-prefix for static func Reviewed-by: Lynne Signed-off-by: Andreas Rheinhardt --- libavcodec/dirac_dwt.c | 6 +++--- libavcodec/dirac_dwt_template.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/dirac_dwt.c b/libavcodec/dirac_dwt.c index af29932c6d..4039899cf0 100644 --- a/libavcodec/dirac_dwt.c +++ b/libavcodec/dirac_dwt.c @@ -45,11 +45,11 @@ int ff_spatial_idwt_init(DWTContext *d, DWTPlane *p, enum dwt_type type, d->decomposition_count = decomposition_count; if (bit_depth == 8) - ret = ff_spatial_idwt_init_8bit(d, type); + ret = spatial_idwt_init_8bit(d, type); else if (bit_depth == 10) - ret = ff_spatial_idwt_init_10bit(d, type); + ret = spatial_idwt_init_10bit(d, type); else if (bit_depth == 12) - ret = ff_spatial_idwt_init_12bit(d, type); + ret = spatial_idwt_init_12bit(d, type); else av_log(NULL, AV_LOG_WARNING, "Unsupported bit depth = %i\n", bit_depth); diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c index 5d55d932a1..f1d7f8b22f 100644 --- a/libavcodec/dirac_dwt_template.c +++ b/libavcodec/dirac_dwt_template.c @@ -516,7 +516,7 @@ static void RENAME(spatial_compose_dd137i_init)(DWTCompose *cs, uint8_t *buffer, cs->y = -5; } -static int RENAME(ff_spatial_idwt_init)(DWTContext *d, enum dwt_type type) +static int RENAME(spatial_idwt_init)(DWTContext *d, enum dwt_type type) { int level; From 4393331250d1f61be0d159de2a7976087a118c25 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 23:19:42 +0200 Subject: [PATCH 553/590] avcodec/dirac_dwt: Avoid conversions between function pointers and void* Pointers to void can be converted to any pointer to incomplete or object type and back; but they are nevertheless not completely generic pointers: There is no provision in the C standard that guarantees their convertibility with function pointers. C90 lacks a generic function pointer, C99 made every function pointer a generic function pointer and still disallows the convertibility with void *. Both GCC as well as Clang warn about this when using -pedantic. Therefore use unions to avoid these conversions. Signed-off-by: Andreas Rheinhardt --- libavcodec/dirac_dwt.h | 13 +++++---- libavcodec/dirac_dwt_template.c | 52 ++++++++++++++++----------------- libavcodec/x86/dirac_dwt_init.c | 16 +++++----- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h index 994dc21d70..84f71d9120 100644 --- a/libavcodec/dirac_dwt.h +++ b/libavcodec/dirac_dwt.h @@ -61,11 +61,14 @@ typedef struct DWTContext { int support; void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride); - void (*vertical_compose_l0)(void); - void (*vertical_compose_h0)(void); - void (*vertical_compose_l1)(void); - void (*vertical_compose_h1)(void); - void (*vertical_compose)(void); ///< one set of lowpass and highpass combined + union { + vertical_compose_3tap tap3; + vertical_compose_5tap tap5; + vertical_compose_9tap tap9; + } vertical_compose_l0, vertical_compose_h0; + vertical_compose_3tap vertical_compose_l1; + vertical_compose_3tap vertical_compose_h1; + vertical_compose_2tap vertical_compose; ///< one set of lowpass and highpass combined void (*horizontal_compose)(uint8_t *b, uint8_t *tmp, int width); DWTCompose cs[MAX_DECOMPOSITIONS]; diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c index f1d7f8b22f..0d39754ed8 100644 --- a/libavcodec/dirac_dwt_template.c +++ b/libavcodec/dirac_dwt_template.c @@ -338,8 +338,8 @@ static void RENAME(vertical_compose_daub97iL1)(uint8_t *_b0, uint8_t *_b1, uint8 static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width, int height, int stride) { - vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0; - vertical_compose_5tap vertical_compose_h0 = (void*)d->vertical_compose_h0; + vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3; + vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0.tap5; DWTCompose *cs = d->cs + level; int i, y = cs->y; @@ -362,8 +362,8 @@ static void RENAME(spatial_compose_dd97i_dy)(DWTContext *d, int level, int width static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int width, int height, int stride) { - vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0; - vertical_compose_3tap vertical_compose_h0 = (void*)d->vertical_compose_h0; + vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3; + vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0.tap3; DWTCompose *cs = d->cs + level; int y= cs->y; @@ -384,8 +384,8 @@ static void RENAME(spatial_compose_dirac53i_dy)(DWTContext *d, int level, int wi static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int width, int height, int stride) { - vertical_compose_5tap vertical_compose_l0 = (void*)d->vertical_compose_l0; - vertical_compose_5tap vertical_compose_h0 = (void*)d->vertical_compose_h0; + vertical_compose_5tap vertical_compose_l0 = d->vertical_compose_l0.tap5; + vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0.tap5; DWTCompose *cs = d->cs + level; int i, y = cs->y; @@ -409,7 +409,7 @@ static void RENAME(spatial_compose_dd137i_dy)(DWTContext *d, int level, int widt // haar makes the assumption that height is even (always true for dirac) static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width, int height, int stride) { - vertical_compose_2tap vertical_compose = (void*)d->vertical_compose; + vertical_compose_2tap vertical_compose = d->vertical_compose; int y = d->cs[level].y; uint8_t *b0 = d->buffer + (y-1)*stride; uint8_t *b1 = d->buffer + (y )*stride; @@ -425,8 +425,8 @@ static void RENAME(spatial_compose_haari_dy)(DWTContext *d, int level, int width // Fortunately, this filter isn't used in practice. static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width, int height, int stride) { - vertical_compose_9tap vertical_compose_l0 = (void*)d->vertical_compose_l0; - vertical_compose_9tap vertical_compose_h0 = (void*)d->vertical_compose_h0; + vertical_compose_9tap vertical_compose_l0 = d->vertical_compose_l0.tap9; + vertical_compose_9tap vertical_compose_h0 = d->vertical_compose_h0.tap9; int i, y; uint8_t *b[8]; @@ -450,10 +450,10 @@ static void RENAME(spatial_compose_fidelity)(DWTContext *d, int level, int width static void RENAME(spatial_compose_daub97i_dy)(DWTContext *d, int level, int width, int height, int stride) { - vertical_compose_3tap vertical_compose_l0 = (void*)d->vertical_compose_l0; - vertical_compose_3tap vertical_compose_h0 = (void*)d->vertical_compose_h0; - vertical_compose_3tap vertical_compose_l1 = (void*)d->vertical_compose_l1; - vertical_compose_3tap vertical_compose_h1 = (void*)d->vertical_compose_h1; + vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0.tap3; + vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0.tap3; + vertical_compose_3tap vertical_compose_l1 = d->vertical_compose_l1; + vertical_compose_3tap vertical_compose_h1 = d->vertical_compose_h1; DWTCompose *cs = d->cs + level; int i, y = cs->y; @@ -552,29 +552,29 @@ static int RENAME(spatial_idwt_init)(DWTContext *d, enum dwt_type type) switch (type) { case DWT_DIRAC_DD9_7: d->spatial_compose = RENAME(spatial_compose_dd97i_dy); - d->vertical_compose_l0 = (void*)RENAME(vertical_compose53iL0); - d->vertical_compose_h0 = (void*)RENAME(vertical_compose_dd97iH0); + d->vertical_compose_l0.tap3 = RENAME(vertical_compose53iL0); + d->vertical_compose_h0.tap5 = RENAME(vertical_compose_dd97iH0); d->horizontal_compose = RENAME(horizontal_compose_dd97i); d->support = 7; break; case DWT_DIRAC_LEGALL5_3: d->spatial_compose = RENAME(spatial_compose_dirac53i_dy); - d->vertical_compose_l0 = (void*)RENAME(vertical_compose53iL0); - d->vertical_compose_h0 = (void*)RENAME(vertical_compose_dirac53iH0); + d->vertical_compose_l0.tap3 = RENAME(vertical_compose53iL0); + d->vertical_compose_h0.tap3 = RENAME(vertical_compose_dirac53iH0); d->horizontal_compose = RENAME(horizontal_compose_dirac53i); d->support = 3; break; case DWT_DIRAC_DD13_7: d->spatial_compose = RENAME(spatial_compose_dd137i_dy); - d->vertical_compose_l0 = (void*)RENAME(vertical_compose_dd137iL0); - d->vertical_compose_h0 = (void*)RENAME(vertical_compose_dd97iH0); + d->vertical_compose_l0.tap5 = RENAME(vertical_compose_dd137iL0); + d->vertical_compose_h0.tap5 = RENAME(vertical_compose_dd97iH0); d->horizontal_compose = RENAME(horizontal_compose_dd137i); d->support = 7; break; case DWT_DIRAC_HAAR0: case DWT_DIRAC_HAAR1: d->spatial_compose = RENAME(spatial_compose_haari_dy); - d->vertical_compose = (void*)RENAME(vertical_compose_haar); + d->vertical_compose = RENAME(vertical_compose_haar); if (type == DWT_DIRAC_HAAR0) d->horizontal_compose = RENAME(horizontal_compose_haar0i); else @@ -583,17 +583,17 @@ static int RENAME(spatial_idwt_init)(DWTContext *d, enum dwt_type type) break; case DWT_DIRAC_FIDELITY: d->spatial_compose = RENAME(spatial_compose_fidelity); - d->vertical_compose_l0 = (void*)RENAME(vertical_compose_fidelityiL0); - d->vertical_compose_h0 = (void*)RENAME(vertical_compose_fidelityiH0); + d->vertical_compose_l0.tap9 = RENAME(vertical_compose_fidelityiL0); + d->vertical_compose_h0.tap9 = RENAME(vertical_compose_fidelityiH0); d->horizontal_compose = RENAME(horizontal_compose_fidelityi); d->support = 0; // not really used break; case DWT_DIRAC_DAUB9_7: d->spatial_compose = RENAME(spatial_compose_daub97i_dy); - d->vertical_compose_l0 = (void*)RENAME(vertical_compose_daub97iL0); - d->vertical_compose_h0 = (void*)RENAME(vertical_compose_daub97iH0); - d->vertical_compose_l1 = (void*)RENAME(vertical_compose_daub97iL1); - d->vertical_compose_h1 = (void*)RENAME(vertical_compose_daub97iH1); + d->vertical_compose_l0.tap3 = RENAME(vertical_compose_daub97iL0); + d->vertical_compose_h0.tap3 = RENAME(vertical_compose_daub97iH0); + d->vertical_compose_l1 = RENAME(vertical_compose_daub97iL1); + d->vertical_compose_h1 = RENAME(vertical_compose_daub97iH1); d->horizontal_compose = RENAME(horizontal_compose_daub97i); d->support = 5; break; diff --git a/libavcodec/x86/dirac_dwt_init.c b/libavcodec/x86/dirac_dwt_init.c index 9200618283..13b42b60cb 100644 --- a/libavcodec/x86/dirac_dwt_init.c +++ b/libavcodec/x86/dirac_dwt_init.c @@ -165,23 +165,23 @@ void ff_spatial_idwt_init_x86(DWTContext *d, enum dwt_type type) switch (type) { case DWT_DIRAC_DD9_7: - d->vertical_compose_l0 = (void*)vertical_compose53iL0_sse2; - d->vertical_compose_h0 = (void*)vertical_compose_dd97iH0_sse2; + d->vertical_compose_l0.tap3 = vertical_compose53iL0_sse2; + d->vertical_compose_h0.tap5 = vertical_compose_dd97iH0_sse2; break; case DWT_DIRAC_LEGALL5_3: - d->vertical_compose_l0 = (void*)vertical_compose53iL0_sse2; - d->vertical_compose_h0 = (void*)vertical_compose_dirac53iH0_sse2; + d->vertical_compose_l0.tap3 = vertical_compose53iL0_sse2; + d->vertical_compose_h0.tap3 = vertical_compose_dirac53iH0_sse2; break; case DWT_DIRAC_DD13_7: - d->vertical_compose_l0 = (void*)vertical_compose_dd137iL0_sse2; - d->vertical_compose_h0 = (void*)vertical_compose_dd97iH0_sse2; + d->vertical_compose_l0.tap5 = vertical_compose_dd137iL0_sse2; + d->vertical_compose_h0.tap5 = vertical_compose_dd97iH0_sse2; break; case DWT_DIRAC_HAAR0: - d->vertical_compose = (void*)vertical_compose_haar_sse2; + d->vertical_compose = vertical_compose_haar_sse2; d->horizontal_compose = horizontal_compose_haar0i_sse2; break; case DWT_DIRAC_HAAR1: - d->vertical_compose = (void*)vertical_compose_haar_sse2; + d->vertical_compose = vertical_compose_haar_sse2; d->horizontal_compose = horizontal_compose_haar1i_sse2; break; } From fdff1b9cbfd8cf5a9810c29efa4baf13a4786742 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 01:10:51 +0200 Subject: [PATCH 554/590] avcodec/codec_internal: Avoid deprecation warnings for channel_layouts AVCodec.channel_layouts is deprecated and Clang (unlike GCC) warns when setting this field in a codec definition. Fortunately, Clang (unlike GCC) allows to use FF_DISABLE_DEPRECATION_WARNINGS inside a definition (of an FFCodec), so that one can create simple macros to set AVCodec.channel_layouts that also suppress deprecation warnings for Clang. (Notice that some of the codec definitions were already inside FF_DISABLE/ENABLE_DEPRECATION_WARNINGS (that were not guarded by FF_API_OLD_CHANNEL_LAYOUT); these have been removed. Also notice that setting AVCodec.channel_layouts was not guarded by FF_API_OLD_CHANNEL_LAYOUT either, so testing disabling it it without removing all the codeblocks would not have worked.) Signed-off-by: Andreas Rheinhardt --- libavcodec/aacdec.c | 8 ++------ libavcodec/aacdec_fixed.c | 4 +--- libavcodec/ac3enc_fixed.c | 6 +----- libavcodec/ac3enc_float.c | 6 +----- libavcodec/alacenc.c | 6 +----- libavcodec/aptxdec.c | 8 ++------ libavcodec/aptxenc.c | 8 ++------ libavcodec/audiotoolboxenc.c | 2 +- libavcodec/codec_internal.h | 19 +++++++++++++++++++ libavcodec/dcaenc.c | 11 +++-------- libavcodec/eac3enc.c | 6 +----- libavcodec/g722enc.c | 4 +--- libavcodec/libcodec2.c | 8 ++------ libavcodec/libfdk-aacenc.c | 4 +--- libavcodec/libgsmenc.c | 8 ++------ libavcodec/libmp3lame.c | 6 +----- libavcodec/libshine.c | 6 +----- libavcodec/libspeexenc.c | 6 +----- libavcodec/libtwolame.c | 7 +------ libavcodec/mlpenc.c | 8 ++------ libavcodec/mpegaudioenc_fixed.c | 6 +----- libavcodec/mpegaudioenc_float.c | 6 +----- libavcodec/opusenc.c | 5 +---- libavcodec/pcm-blurayenc.c | 7 ++----- libavcodec/pcm-dvdenc.c | 9 ++------- libavcodec/ra144enc.c | 4 +--- libavcodec/s302menc.c | 5 ----- libavcodec/sbcdec.c | 5 +---- libavcodec/sbcenc.c | 5 +---- libavcodec/vorbisdec.c | 4 +--- 30 files changed, 57 insertions(+), 140 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 2d448103df..2fdfd6b221 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -566,9 +566,7 @@ const FFCodec ff_aac_decoder = { }, .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = aac_channel_layout, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(aac_channel_layout) .p.ch_layouts = aac_ch_layout, .flush = flush, .p.priv_class = &aac_decoder_class, @@ -594,9 +592,7 @@ const FFCodec ff_aac_latm_decoder = { }, .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = aac_channel_layout, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(aac_channel_layout) .p.ch_layouts = aac_ch_layout, .flush = flush, .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c index 4b2085335d..8c5dad2813 100644 --- a/libavcodec/aacdec_fixed.c +++ b/libavcodec/aacdec_fixed.c @@ -464,9 +464,7 @@ const FFCodec ff_aac_fixed_decoder = { }, .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = aac_channel_layout, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(aac_channel_layout) .p.ch_layouts = aac_ch_layout, .p.priv_class = &aac_decoder_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index a22d3b4abf..a52a598152 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -119,7 +119,6 @@ static av_cold int ac3_fixed_encode_init(AVCodecContext *avctx) } -FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_ac3_fixed_encoder = { .p.name = "ac3_fixed", CODEC_LONG_NAME("ATSC A/52A (AC-3)"), @@ -135,10 +134,7 @@ const FFCodec ff_ac3_fixed_encoder = { .p.priv_class = &ff_ac3enc_class, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.supported_samplerates = ff_ac3_sample_rate_tab, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = ff_ac3_channel_layouts, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(ff_ac3_channel_layouts) .p.ch_layouts = ff_ac3_ch_layouts, .defaults = ff_ac3_enc_defaults, }; -FF_ENABLE_DEPRECATION_WARNINGS diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index 6238980690..3ca7d113c2 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -123,7 +123,6 @@ av_cold int ff_ac3_float_encode_init(AVCodecContext *avctx) return ff_ac3_encode_init(avctx); } -FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_ac3_encoder = { .p.name = "ac3", CODEC_LONG_NAME("ATSC A/52A (AC-3)"), @@ -138,11 +137,8 @@ const FFCodec ff_ac3_encoder = { AV_SAMPLE_FMT_NONE }, .p.priv_class = &ff_ac3enc_class, .p.supported_samplerates = ff_ac3_sample_rate_tab, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = ff_ac3_channel_layouts, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(ff_ac3_channel_layouts) .p.ch_layouts = ff_ac3_ch_layouts, .defaults = ff_ac3_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -FF_ENABLE_DEPRECATION_WARNINGS diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 362d4f8ba6..0f685d71d6 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -648,7 +648,6 @@ static const AVClass alacenc_class = { .version = LIBAVUTIL_VERSION_INT, }; -FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_alac_encoder = { .p.name = "alac", CODEC_LONG_NAME("ALAC (Apple Lossless Audio Codec)"), @@ -660,12 +659,9 @@ const FFCodec ff_alac_encoder = { .init = alac_encode_init, FF_CODEC_ENCODE_CB(alac_encode_frame), .close = alac_encode_close, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = alac_channel_layouts, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(alac_channel_layouts) .p.ch_layouts = ff_alac_ch_layouts, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, }; -FF_ENABLE_DEPRECATION_WARNINGS diff --git a/libavcodec/aptxdec.c b/libavcodec/aptxdec.c index d254b3026b..3ae7a00803 100644 --- a/libavcodec/aptxdec.c +++ b/libavcodec/aptxdec.c @@ -183,9 +183,7 @@ const FFCodec ff_aptx_decoder = { .init = ff_aptx_init, FF_CODEC_DECODE_CB(aptx_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, @@ -202,9 +200,7 @@ const FFCodec ff_aptx_hd_decoder = { .init = ff_aptx_init, FF_CODEC_DECODE_CB(aptx_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index 114e286fe2..5fc0378f5d 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -276,9 +276,7 @@ const FFCodec ff_aptx_encoder = { .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), .close = aptx_close, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, @@ -297,9 +295,7 @@ const FFCodec ff_aptx_hd_encoder = { .init = aptx_encode_init, FF_CODEC_ENCODE_CB(aptx_encode_frame), .close = aptx_close, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_STEREO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index 02a863bf03..1ccfda4d20 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -627,7 +627,7 @@ static const AVOption options[] = { .p.priv_class = &ffat_##NAME##_enc_class, \ .p.capabilities = AV_CODEC_CAP_DELAY | \ AV_CODEC_CAP_ENCODER_FLUSH CAPS, \ - .p.channel_layouts = CHANNEL_LAYOUTS, \ + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(CHANNEL_LAYOUTS) \ .p.ch_layouts = CH_LAYOUTS, \ .p.sample_fmts = (const enum AVSampleFormat[]) { \ AV_SAMPLE_FMT_S16, \ diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 2d9b4f6460..e3b77e6dea 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -276,6 +276,25 @@ typedef struct FFCodec { .update_thread_context_for_user = NULL #endif +#if FF_API_OLD_CHANNEL_LAYOUT +#define CODEC_OLD_CHANNEL_LAYOUTS(...) CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(((const uint64_t[]) { __VA_ARGS__, 0 })) +#if defined(__clang__) +#define CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(array) \ + FF_DISABLE_DEPRECATION_WARNINGS \ + .p.channel_layouts = (array), \ + FF_ENABLE_DEPRECATION_WARNINGS +#else +#define CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(array) .p.channel_layouts = (array), +#endif +#else +/* This is only provided to allow to test disabling FF_API_OLD_CHANNEL_LAYOUT + * without removing all the FF_API_OLD_CHANNEL_LAYOUT codeblocks. + * It is of course still expected to be removed when FF_API_OLD_CHANNEL_LAYOUT + * will be finally removed (along with all usages of these macros). */ +#define CODEC_OLD_CHANNEL_LAYOUTS(...) +#define CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(array) +#endif + #define FF_CODEC_DECODE_CB(func) \ .cb_type = FF_CODEC_CB_TYPE_DECODE, \ .cb.decode = (func) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 46618c13f9..eec6965b5f 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -1324,14 +1324,9 @@ const FFCodec ff_dca_encoder = { .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, .p.supported_samplerates = sample_rates, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - AV_CH_LAYOUT_2_2, - AV_CH_LAYOUT_5POINT0, - AV_CH_LAYOUT_5POINT1, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_2_2, AV_CH_LAYOUT_5POINT0, + AV_CH_LAYOUT_5POINT1) .p.ch_layouts = (const AVChannelLayout[]){ AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 648c93dcaa..78d4f1399a 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -249,7 +249,6 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) } -FF_DISABLE_DEPRECATION_WARNINGS const FFCodec ff_eac3_encoder = { .p.name = "eac3", CODEC_LONG_NAME("ATSC A/52 E-AC-3"), @@ -264,11 +263,8 @@ const FFCodec ff_eac3_encoder = { AV_SAMPLE_FMT_NONE }, .p.priv_class = &eac3enc_class, .p.supported_samplerates = ff_ac3_sample_rate_tab, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = ff_ac3_channel_layouts, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(ff_ac3_channel_layouts) .p.ch_layouts = ff_ac3_ch_layouts, .defaults = ff_ac3_enc_defaults, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; -FF_ENABLE_DEPRECATION_WARNINGS diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index dc044c320d..bc08211b1d 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -381,9 +381,7 @@ const FFCodec ff_adpcm_g722_encoder = { .close = g722_encode_close, FF_CODEC_ENCODE_CB(g722_encode_frame), .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO) .p.ch_layouts = (const AVChannelLayout[]){ AV_CHANNEL_LAYOUT_MONO, { 0 } }, diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 581ef04ce2..5728d915c2 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -189,9 +189,7 @@ const FFCodec ff_libcodec2_decoder = { .init = libcodec2_init_decoder, .close = libcodec2_close, FF_CODEC_DECODE_CB(libcodec2_decode), -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO) }; const FFCodec ff_libcodec2_encoder = { @@ -209,7 +207,5 @@ const FFCodec ff_libcodec2_encoder = { .init = libcodec2_init_encoder, .close = libcodec2_close, FF_CODEC_ENCODE_CB(libcodec2_encode), -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO) }; diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c index fc2e71c51f..d589964453 100644 --- a/libavcodec/libfdk-aacenc.c +++ b/libavcodec/libfdk-aacenc.c @@ -494,8 +494,6 @@ const FFCodec ff_libfdk_aac_encoder = { .p.profiles = profiles, .p.supported_samplerates = aac_sample_rates, .p.wrapper_name = "libfdk", -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = aac_channel_layout, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(aac_channel_layout) .p.ch_layouts = aac_ch_layouts, }; diff --git a/libavcodec/libgsmenc.c b/libavcodec/libgsmenc.c index 9ad430bf62..bd3b1420aa 100644 --- a/libavcodec/libgsmenc.c +++ b/libavcodec/libgsmenc.c @@ -127,9 +127,7 @@ const FFCodec ff_libgsm_encoder = { FF_CODEC_ENCODE_CB(libgsm_encode_frame), .close = libgsm_encode_close, .defaults = libgsm_defaults, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, @@ -148,9 +146,7 @@ const FFCodec ff_libgsm_ms_encoder = { FF_CODEC_ENCODE_CB(libgsm_encode_frame), .close = libgsm_encode_close, .defaults = libgsm_defaults, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index c8a6eb8c33..26e58baa3d 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -345,11 +345,7 @@ const FFCodec ff_libmp3lame_encoder = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .p.supported_samplerates = libmp3lame_sample_rates, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 }, diff --git a/libavcodec/libshine.c b/libavcodec/libshine.c index e266229f03..2f6a9233e0 100644 --- a/libavcodec/libshine.c +++ b/libavcodec/libshine.c @@ -140,11 +140,7 @@ const FFCodec ff_libshine_encoder = { .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .p.supported_samplerates = libshine_sample_rates, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 }, diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 2191e7dac7..9fdb247863 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -354,11 +354,7 @@ const FFCodec ff_libspeex_encoder = { .close = encode_close, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 }, diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c index 2168b3cdf6..9c0156aa25 100644 --- a/libavcodec/libtwolame.c +++ b/libavcodec/libtwolame.c @@ -228,12 +228,7 @@ const FFCodec ff_libtwolame_encoder = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { - AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index a8b0486cf3..1bc8995c58 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -2252,9 +2252,7 @@ const FFCodec ff_mlp_encoder = { .close = mlp_encode_close, .p.sample_fmts = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .p.supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = ff_mlp_channel_layouts, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(ff_mlp_channel_layouts) .p.ch_layouts = ff_mlp_ch_layouts, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; @@ -2274,9 +2272,7 @@ const FFCodec ff_truehd_encoder = { .close = mlp_encode_close, .p.sample_fmts = (const enum AVSampleFormat[]) {AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .p.supported_samplerates = (const int[]) {44100, 48000, 88200, 96000, 176400, 192000, 0}, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, diff --git a/libavcodec/mpegaudioenc_fixed.c b/libavcodec/mpegaudioenc_fixed.c index 3b2bcb3594..afbffe766b 100644 --- a/libavcodec/mpegaudioenc_fixed.c +++ b/libavcodec/mpegaudioenc_fixed.c @@ -37,11 +37,7 @@ const FFCodec ff_mp2fixed_encoder = { .p.supported_samplerates = (const int[]){ 44100, 48000, 32000, 22050, 24000, 16000, 0 }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]){ AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 } }, diff --git a/libavcodec/mpegaudioenc_float.c b/libavcodec/mpegaudioenc_float.c index 64b5bbda6e..212709c291 100644 --- a/libavcodec/mpegaudioenc_float.c +++ b/libavcodec/mpegaudioenc_float.c @@ -38,11 +38,7 @@ const FFCodec ff_mp2_encoder = { .p.supported_samplerates = (const int[]){ 44100, 48000, 32000, 22050, 24000, 16000, 0 }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]){ AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 } }, diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c index 8cdd27d930..58e3f5fa38 100644 --- a/libavcodec/opusenc.c +++ b/libavcodec/opusenc.c @@ -743,10 +743,7 @@ const FFCodec ff_opus_encoder = { .close = opus_encode_end, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.supported_samplerates = (const int []){ 48000, 0 }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t []){ AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout []){ AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 } }, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, diff --git a/libavcodec/pcm-blurayenc.c b/libavcodec/pcm-blurayenc.c index 03ed88b8ae..62e86e722f 100644 --- a/libavcodec/pcm-blurayenc.c +++ b/libavcodec/pcm-blurayenc.c @@ -279,8 +279,7 @@ const FFCodec ff_pcm_bluray_encoder = { .init = pcm_bluray_encode_init, FF_CODEC_ENCODE_CB(pcm_bluray_encode_frame), .p.supported_samplerates = (const int[]) { 48000, 96000, 192000, 0 }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { + CODEC_OLD_CHANNEL_LAYOUTS( AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_SURROUND, @@ -290,9 +289,7 @@ const FFCodec ff_pcm_bluray_encoder = { AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_7POINT0, - AV_CH_LAYOUT_7POINT1, - 0 }, -#endif + AV_CH_LAYOUT_7POINT1) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index e9349680e8..011d0a2f00 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -181,13 +181,8 @@ const FFCodec ff_pcm_dvd_encoder = { .init = pcm_dvd_encode_init, FF_CODEC_ENCODE_CB(pcm_dvd_encode_frame), .p.supported_samplerates = (const int[]) { 48000, 96000, 0}, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - AV_CH_LAYOUT_5POINT1, - AV_CH_LAYOUT_7POINT1, - 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_7POINT1) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, AV_CHANNEL_LAYOUT_5POINT1, diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index d9448e88c8..ea537f3f80 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -549,8 +549,6 @@ const FFCodec ff_ra_144_encoder = { .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .p.supported_samplerates = (const int[]){ 8000, 0 }, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 }, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO) .p.ch_layouts = (const AVChannelLayout[]){ AV_CHANNEL_LAYOUT_MONO, { 0 } }, }; diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c index ad59325ec4..3bd657f945 100644 --- a/libavcodec/s302menc.c +++ b/libavcodec/s302menc.c @@ -184,9 +184,4 @@ const FFCodec ff_s302m_encoder = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .p.supported_samplerates = (const int[]) { 48000, 0 }, - /* .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, - AV_CH_LAYOUT_QUAD, - AV_CH_LAYOUT_5POINT1_BACK, - AV_CH_LAYOUT_5POINT1_BACK | AV_CH_LAYOUT_STEREO_DOWNMIX, - 0 }, */ }; diff --git a/libavcodec/sbcdec.c b/libavcodec/sbcdec.c index 51411eb16b..3fac2f5016 100644 --- a/libavcodec/sbcdec.c +++ b/libavcodec/sbcdec.c @@ -374,10 +374,7 @@ const FFCodec ff_sbc_decoder = { .init = sbc_decode_init, FF_CODEC_DECODE_CB(sbc_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, 0}, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 } }, diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c index d7e9fb4198..721c97e1ea 100644 --- a/libavcodec/sbcenc.c +++ b/libavcodec/sbcenc.c @@ -352,10 +352,7 @@ const FFCodec ff_sbc_encoder = { .priv_data_size = sizeof(SBCEncContext), .init = sbc_encode_init, FF_CODEC_ENCODE_CB(sbc_encode_frame), -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, 0}, -#endif + CODEC_OLD_CHANNEL_LAYOUTS(AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO) .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, { 0 } }, diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 0d04e7c2c4..4a85500c10 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1876,9 +1876,7 @@ const FFCodec ff_vorbis_decoder = { .flush = vorbis_decode_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, -#if FF_API_OLD_CHANNEL_LAYOUT - .p.channel_layouts = ff_vorbis_channel_layouts, -#endif + CODEC_OLD_CHANNEL_LAYOUTS_ARRAY(ff_vorbis_channel_layouts) .p.ch_layouts = ff_vorbis_ch_layouts, .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, From 6573e65ac00e22ba7c5add70f8f499a3d946f601 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 02:14:45 +0200 Subject: [PATCH 555/590] avcodec/aacdectab: Remove empty channel layouts They will be mistaken for the sentinel of the arrays they are in, thereby hiding the 6.1, 7.1 and 22.2 layouts. (This doesn't really matter, as these arrays are informational only for decoders.) Signed-off-by: Andreas Rheinhardt --- libavcodec/aacdectab.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h index e03026806d..e38b93a534 100644 --- a/libavcodec/aacdectab.h +++ b/libavcodec/aacdectab.h @@ -73,7 +73,7 @@ static const uint8_t aac_channel_layout_map[16][16][3] = { }; #if FF_API_OLD_CHANNEL_LAYOUT -static const uint64_t aac_channel_layout[16] = { +static const uint64_t aac_channel_layout[] = { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_SURROUND, @@ -81,9 +81,6 @@ static const uint64_t aac_channel_layout[16] = { AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_5POINT1_BACK, AV_CH_LAYOUT_7POINT1_WIDE_BACK, - 0, - 0, - 0, AV_CH_LAYOUT_6POINT1, AV_CH_LAYOUT_7POINT1, AV_CH_LAYOUT_22POINT2, @@ -92,7 +89,7 @@ static const uint64_t aac_channel_layout[16] = { }; #endif -static const AVChannelLayout aac_ch_layout[16] = { +static const AVChannelLayout aac_ch_layout[] = { AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_STEREO, AV_CHANNEL_LAYOUT_SURROUND, @@ -100,9 +97,6 @@ static const AVChannelLayout aac_ch_layout[16] = { AV_CHANNEL_LAYOUT_5POINT0_BACK, AV_CHANNEL_LAYOUT_5POINT1_BACK, AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK, - { 0 }, - { 0 }, - { 0 }, AV_CHANNEL_LAYOUT_6POINT1, AV_CHANNEL_LAYOUT_7POINT1, AV_CHANNEL_LAYOUT_22POINT2, From ba07c84bf961e034b8b8f80603358f8ebab6c171 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 16:09:01 +0200 Subject: [PATCH 556/590] avcodec/amrwbdec,lsp: Include mips headers only #if ARCH_MIPS Signed-off-by: Andreas Rheinhardt --- libavcodec/amrwbdec.c | 4 ++++ libavcodec/lsp.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index ea3812cd9a..b59066adcf 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -24,6 +24,8 @@ * AMR wideband decoder */ +#include "config.h" + #include "libavutil/channel_layout.h" #include "libavutil/common.h" #include "libavutil/lfg.h" @@ -42,7 +44,9 @@ #include "amr.h" #include "amrwbdata.h" +#if ARCH_MIPS #include "mips/amrwbdec_mips.h" +#endif /* ARCH_MIPS */ typedef struct AMRWBContext { AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index 90f2efaafe..9e7bc5f87a 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -23,11 +23,15 @@ #include +#include "config.h" + #define FRAC_BITS 14 #include "libavutil/macros.h" #include "mathops.h" #include "lsp.h" +#if ARCH_MIPS #include "libavcodec/mips/lsp_mips.h" +#endif /* ARCH_MIPS */ #include "libavutil/avassert.h" void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order) From e0980629d8ef1970488eaaaa56a55e198d5549d4 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 16:14:53 +0200 Subject: [PATCH 557/590] avcodec/lsp: Move ff_lsp2polyf() upwards in lsp.c Will avoid a forward declaration lateron. Also adapt the function to modern style while at it. Signed-off-by: Andreas Rheinhardt --- libavcodec/lsp.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index 9e7bc5f87a..9536d8078b 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -124,6 +124,22 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) } } +#ifndef ff_lsp2polyf +void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) +{ + f[0] = 1.0; + f[1] = -2 * lsp[0]; + lsp -= 2; + for (int i = 2; i <= lp_half_order; i++) { + double val = -2 * lsp[2*i]; + f[i] = val * f[i-1] + 2*f[i-2]; + for (int j = i-1; j > 1; j--) + f[j] += f[j-1] * val + f[j-2]; + f[1] += val; + } +} +#endif /* ff_lsp2polyf */ + void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) { int i; @@ -191,25 +207,6 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1); } -#ifndef ff_lsp2polyf -void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) -{ - int i, j; - - f[0] = 1.0; - f[1] = -2 * lsp[0]; - lsp -= 2; - for(i=2; i<=lp_half_order; i++) - { - double val = -2 * lsp[2*i]; - f[i] = val * f[i-1] + 2*f[i-2]; - for(j=i-1; j>1; j--) - f[j] += f[j-1] * val + f[j-2]; - f[1] += val; - } -} -#endif /* ff_lsp2polyf */ - void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order) { double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1]; From c35a6709d077c3221f50235446c88d7c96234d5b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 16:22:21 +0200 Subject: [PATCH 558/590] avcodec/lsp: Make ff_lsp2polyf() static Possible since 48ac225db2563fe534b1d9e999bf8e70d5a577f8. Furthermore, the current code would not work on mips in case ff_lsp2polyf() were used outside of lsp.c, because it is not compiled on mips since commit 3827a86eacd04d9d7b356f769be553f7b8cca361 at all; instead it is overridden with a static av_always_inline function which only works for the callers in lsp.c. Signed-off-by: Andreas Rheinhardt --- libavcodec/lsp.c | 24 +++++++++++++++++------- libavcodec/lsp.h | 12 ------------ libavcodec/mips/lsp_mips.h | 12 ++++++------ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index 9536d8078b..275984097d 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -124,8 +124,18 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) } } -#ifndef ff_lsp2polyf -void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) +#ifndef lsp2polyf +/** + * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients + * needed for LSP to LPC conversion. + * We only need to calculate the 6 first elements of the polynomial. + * + * @param lsp line spectral pairs in cosine domain + * @param[out] f polynomial input/output as a vector + * + * TIA/EIA/IS-733 2.4.3.3.5-1/2 + */ +static void lsp2polyf(const double *lsp, double *f, int lp_half_order) { f[0] = 1.0; f[1] = -2 * lsp[0]; @@ -138,7 +148,7 @@ void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) f[1] += val; } } -#endif /* ff_lsp2polyf */ +#endif /* lsp2polyf */ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) { @@ -172,8 +182,8 @@ void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order) qa[-1] = 0.0; - ff_lsp2polyf(lsp , pa, lp_half_order ); - ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1); + lsp2polyf(lsp , pa, lp_half_order ); + lsp2polyf(lsp + 1, qa, lp_half_order - 1); for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) { double paf = pa[i] * (1 + lsp[lp_order - 1]); @@ -214,8 +224,8 @@ void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order) av_assert2(lp_half_order <= MAX_LP_HALF_ORDER); - ff_lsp2polyf(lsp, pa, lp_half_order); - ff_lsp2polyf(lsp + 1, qa, lp_half_order); + lsp2polyf(lsp, pa, lp_half_order); + lsp2polyf(lsp + 1, qa, lp_half_order); while (lp_half_order--) { double paf = pa[lp_half_order+1] + pa[lp_half_order]; diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h index 621ebeaebe..26b1382eda 100644 --- a/libavcodec/lsp.h +++ b/libavcodec/lsp.h @@ -115,16 +115,4 @@ void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order); */ void ff_sort_nearly_sorted_floats(float *vals, int len); -/** - * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients - * needed for LSP to LPC conversion. - * We only need to calculate the 6 first elements of the polynomial. - * - * @param lsp line spectral pairs in cosine domain - * @param[out] f polynomial input/output as a vector - * - * TIA/EIA/IS-733 2.4.3.3.5-1/2 - */ -void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order); - #endif /* AVCODEC_LSP_H */ diff --git a/libavcodec/mips/lsp_mips.h b/libavcodec/mips/lsp_mips.h index c69f8b770c..2d67403888 100644 --- a/libavcodec/mips/lsp_mips.h +++ b/libavcodec/mips/lsp_mips.h @@ -61,7 +61,7 @@ #include "libavutil/attributes.h" #include "libavutil/mips/asmdefs.h" -static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int lp_half_order) +static av_always_inline void lsp2polyf_mips(const double *lsp, double *f, int lp_half_order) { int i, j = 0; double * p_fi = f; @@ -88,8 +88,8 @@ static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int "addiu %[j], %[i], -2 \n\t" "ldc1 %[f_j_2], -8(%[p_f]) \n\t" "sdc1 %[tmp], 16(%[p_f]) \n\t" - "beqz %[j], ff_lsp2polyf_lp_j_end%= \n\t" - "ff_lsp2polyf_lp_j%=: \n\t" + "beqz %[j], lsp2polyf_lp_j_end%= \n\t" + "lsp2polyf_lp_j%=: \n\t" "add.d %[tmp], %[f_j], %[f_j_2] \n\t" "madd.d %[tmp], %[tmp], %[f_j_1], %[val] \n\t" "mov.d %[f_j], %[f_j_1] \n\t" @@ -98,8 +98,8 @@ static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int "ldc1 %[f_j_2], -16(%[p_f]) \n\t" "sdc1 %[tmp], 8(%[p_f]) \n\t" PTR_ADDIU "%[p_f], -8 \n\t" - "bgtz %[j], ff_lsp2polyf_lp_j%= \n\t" - "ff_lsp2polyf_lp_j_end%=: \n\t" + "bgtz %[j], lsp2polyf_lp_j%= \n\t" + "lsp2polyf_lp_j_end%=: \n\t" : [f_j_2]"=&f"(f_j_2), [f_j_1]"=&f"(f_j_1), [val]"+f"(val), [tmp]"=&f"(tmp), [f_j]"=&f"(f_j), [p_f]"+r"(p_f), @@ -110,7 +110,7 @@ static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int f[1] += val; } } -#define ff_lsp2polyf ff_lsp2polyf_mips +#define lsp2polyf lsp2polyf_mips #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */ #endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM */ #endif /* AVCODEC_MIPS_LSP_MIPS_H */ From 3d8754cd091d81ed8e39978618cb441ebbc69ea5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 19:09:51 +0200 Subject: [PATCH 559/590] avutil/display: Drop wrong comments about matrices being allocated These functions work just as well with stack based matrices. Signed-off-by: Andreas Rheinhardt --- libavutil/display.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/display.h b/libavutil/display.h index 31d8bef361..0c73bff5da 100644 --- a/libavutil/display.h +++ b/libavutil/display.h @@ -90,8 +90,8 @@ double av_display_rotation_get(const int32_t matrix[9]); * Initialize a transformation matrix describing a pure clockwise * rotation by the specified angle (in degrees). * - * @param matrix an allocated transformation matrix (will be fully overwritten - * by this function) + * @param[out] matrix a transformation matrix (will be fully overwritten + * by this function) * @param angle rotation angle in degrees. */ void av_display_rotation_set(int32_t matrix[9], double angle); @@ -99,7 +99,7 @@ void av_display_rotation_set(int32_t matrix[9], double angle); /** * Flip the input matrix horizontally and/or vertically. * - * @param matrix an allocated transformation matrix + * @param[in,out] matrix a transformation matrix * @param hflip whether the matrix should be flipped horizontally * @param vflip whether the matrix should be flipped vertically */ From fff010591b35874b4c7a7e9fe00d7541f0b7c994 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 27 Sep 2022 01:09:59 +0200 Subject: [PATCH 560/590] avcodec/jpeg2000dwt: Fix left shift of negative number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the j2k-dwt FATE-test; also fixes #9945. (I don't know whether the multiplication can overflow.) Reviewed-by: Tomas Härdin Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeg2000dwt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c index f2da7307c4..34e33553f7 100644 --- a/libavcodec/jpeg2000dwt.c +++ b/libavcodec/jpeg2000dwt.c @@ -81,7 +81,7 @@ static void sd_1d53(int *p, int i0, int i1) if (i1 <= i0 + 1) { if (i0 == 1) - p[1] <<= 1; + p[1] *= 2; return; } From 6059ea2a14747a44e937a3409ff3cfcab7aa1468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 29 Sep 2022 08:02:40 +0300 Subject: [PATCH 561/590] riscv: Fix linking without RVV; change #ifdef into #if MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/riscv/fmtconvert_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/riscv/fmtconvert_init.c b/libavcodec/riscv/fmtconvert_init.c index fd1a8e0ca1..2ded9d3615 100644 --- a/libavcodec/riscv/fmtconvert_init.c +++ b/libavcodec/riscv/fmtconvert_init.c @@ -33,7 +33,7 @@ void ff_int32_to_float_fmul_array8_rvv(FmtConvertContext *c, float *dst, av_cold void ff_fmt_convert_init_riscv(FmtConvertContext *c) { -#ifdef HAVE_RVV +#if HAVE_RVV int flags = av_get_cpu_flags(); if (flags & AV_CPU_FLAG_RVV_F32) { From 86519234b8df379948fde1493f6a6679632f6d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 28 Sep 2022 10:17:02 +0300 Subject: [PATCH 562/590] arm: vc1dsp: Canonicalize the syntax for aligned NEON loads/stores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hopefully should fix building with older toolchains, hopefully fixing the fate failures on http://fate.ffmpeg.org/history.cgi?slot=armel5tej-qemu-debian-gcc4.4. Signed-off-by: Martin Storsjö --- libavcodec/arm/vc1dsp_neon.S | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavcodec/arm/vc1dsp_neon.S b/libavcodec/arm/vc1dsp_neon.S index 96014fbebc..cdfb4a3f6c 100644 --- a/libavcodec/arm/vc1dsp_neon.S +++ b/libavcodec/arm/vc1dsp_neon.S @@ -1310,17 +1310,17 @@ endfunc function ff_vc1_v_loop_filter8_neon, export=1 sub r3, r0, r1, lsl #2 vldr d0, .Lcoeffs - vld1.32 {d1}, [r0 :64], r1 @ P5 - vld1.32 {d2}, [r3 :64], r1 @ P1 - vld1.32 {d3}, [r3 :64], r1 @ P2 - vld1.32 {d4}, [r0 :64], r1 @ P6 - vld1.32 {d5}, [r3 :64], r1 @ P3 - vld1.32 {d6}, [r0 :64], r1 @ P7 + vld1.32 {d1}, [r0, :64], r1 @ P5 + vld1.32 {d2}, [r3, :64], r1 @ P1 + vld1.32 {d3}, [r3, :64], r1 @ P2 + vld1.32 {d4}, [r0, :64], r1 @ P6 + vld1.32 {d5}, [r3, :64], r1 @ P3 + vld1.32 {d6}, [r0, :64], r1 @ P7 vshll.u8 q8, d1, #1 @ 2*P5 vshll.u8 q9, d2, #1 @ 2*P1 - vld1.32 {d7}, [r3 :64] @ P4 + vld1.32 {d7}, [r3, :64] @ P4 vmovl.u8 q1, d3 @ P2 - vld1.32 {d20}, [r0 :64] @ P8 + vld1.32 {d20}, [r0, :64] @ P8 vmovl.u8 q11, d4 @ P6 vdup.16 q12, r2 @ pq vmovl.u8 q13, d5 @ P3 @@ -1375,8 +1375,8 @@ function ff_vc1_v_loop_filter8_neon, export=1 vmla.i16 q1, q0, q2 @ invert d depending on clip_sign & a0_sign, or zero it if they match, and accumulate into P5 vqmovun.s16 d0, q3 vqmovun.s16 d1, q1 - vst1.32 {d0}, [r3 :64], r1 - vst1.32 {d1}, [r3 :64] + vst1.32 {d0}, [r3, :64], r1 + vst1.32 {d1}, [r3, :64] 1: bx lr endfunc @@ -1491,17 +1491,17 @@ function ff_vc1_v_loop_filter16_neon, export=1 vpush {d8-d15} sub r3, r0, r1, lsl #2 vldr d0, .Lcoeffs - vld1.64 {q1}, [r0 :128], r1 @ P5 - vld1.64 {q2}, [r3 :128], r1 @ P1 - vld1.64 {q3}, [r3 :128], r1 @ P2 - vld1.64 {q4}, [r0 :128], r1 @ P6 - vld1.64 {q5}, [r3 :128], r1 @ P3 - vld1.64 {q6}, [r0 :128], r1 @ P7 + vld1.64 {q1}, [r0, :128], r1 @ P5 + vld1.64 {q2}, [r3, :128], r1 @ P1 + vld1.64 {q3}, [r3, :128], r1 @ P2 + vld1.64 {q4}, [r0, :128], r1 @ P6 + vld1.64 {q5}, [r3, :128], r1 @ P3 + vld1.64 {q6}, [r0, :128], r1 @ P7 vshll.u8 q7, d2, #1 @ 2*P5[0..7] vshll.u8 q8, d4, #1 @ 2*P1[0..7] - vld1.64 {q9}, [r3 :128] @ P4 + vld1.64 {q9}, [r3, :128] @ P4 vmovl.u8 q10, d6 @ P2[0..7] - vld1.64 {q11}, [r0 :128] @ P8 + vld1.64 {q11}, [r0, :128] @ P8 vmovl.u8 q12, d8 @ P6[0..7] vdup.16 q13, r2 @ pq vshll.u8 q2, d5, #1 @ 2*P1[8..15] @@ -1611,8 +1611,8 @@ function ff_vc1_v_loop_filter16_neon, export=1 vqmovun.s16 d0, q6 vqmovun.s16 d5, q9 vqmovun.s16 d1, q1 - vst1.64 {q2}, [r3 :128], r1 - vst1.64 {q0}, [r3 :128] + vst1.64 {q2}, [r3, :128], r1 + vst1.64 {q0}, [r3, :128] 1: vpop {d8-d15} bx lr endfunc From 6f2ad7f951a8d4949b4dcbbc5675d96f571c519c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 28 Sep 2022 11:20:02 +0300 Subject: [PATCH 563/590] aarch64: me_cmp: Avoid redundant loads in ff_pix_abs16_y2_neon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids one redundant load per row; pix3 from the previous iteration can be used as pix2 in the next one. Before: Cortex A53 A72 A73 pix_abs_0_2_neon: 138.0 59.7 48.0 After: pix_abs_0_2_neon: 109.7 50.2 39.5 Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_neon.S | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 11af4849f9..832a7cb22d 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -326,9 +326,9 @@ function ff_pix_abs16_y2_neon, export=1 // w4 int h // initialize buffers + ld1 {v1.16b}, [x2], x3 // Load pix2 movi v29.8h, #0 // clear the accumulator movi v28.8h, #0 // clear the accumulator - add x5, x2, x3 // pix2 + stride cmp w4, #4 b.lt 2f @@ -339,29 +339,25 @@ function ff_pix_abs16_y2_neon, export=1 // avg2(a, b) = (((a) + (b) + 1) >> 1) // abs(x) = (x < 0 ? (-x) : (x)) - ld1 {v1.16b}, [x2], x3 // Load pix2 for first iteration - ld1 {v2.16b}, [x5], x3 // Load pix3 for first iteration + ld1 {v2.16b}, [x2], x3 // Load pix3 for first iteration ld1 {v0.16b}, [x1], x3 // Load pix1 for first iteration urhadd v30.16b, v1.16b, v2.16b // Rounding halving add, first iteration - ld1 {v4.16b}, [x2], x3 // Load pix2 for second iteration - ld1 {v5.16b}, [x5], x3 // Load pix3 for second iteartion + ld1 {v5.16b}, [x2], x3 // Load pix3 for second iteartion uabal v29.8h, v0.8b, v30.8b // Absolute difference of lower half, first iteration uabal2 v28.8h, v0.16b, v30.16b // Absolute difference of upper half, first iteration ld1 {v3.16b}, [x1], x3 // Load pix1 for second iteration - urhadd v27.16b, v4.16b, v5.16b // Rounding halving add, second iteration - ld1 {v7.16b}, [x2], x3 // Load pix2 for third iteration - ld1 {v20.16b}, [x5], x3 // Load pix3 for third iteration + urhadd v27.16b, v2.16b, v5.16b // Rounding halving add, second iteration + ld1 {v20.16b}, [x2], x3 // Load pix3 for third iteration uabal v29.8h, v3.8b, v27.8b // Absolute difference of lower half for second iteration uabal2 v28.8h, v3.16b, v27.16b // Absolute difference of upper half for second iteration ld1 {v6.16b}, [x1], x3 // Load pix1 for third iteration - urhadd v26.16b, v7.16b, v20.16b // Rounding halving add, third iteration - ld1 {v22.16b}, [x2], x3 // Load pix2 for fourth iteration - ld1 {v23.16b}, [x5], x3 // Load pix3 for fourth iteration + urhadd v26.16b, v5.16b, v20.16b // Rounding halving add, third iteration + ld1 {v1.16b}, [x2], x3 // Load pix3 for fourth iteration uabal v29.8h, v6.8b, v26.8b // Absolute difference of lower half for third iteration uabal2 v28.8h, v6.16b, v26.16b // Absolute difference of upper half for third iteration ld1 {v21.16b}, [x1], x3 // Load pix1 for fourth iteration sub w4, w4, #4 // h-= 4 - urhadd v25.16b, v22.16b, v23.16b // Rounding halving add + urhadd v25.16b, v20.16b, v1.16b // Rounding halving add cmp w4, #4 uabal v29.8h, v21.8b, v25.8b // Absolute difference of lower half for fourth iteration uabal2 v28.8h, v21.16b, v25.16b // Absolute difference of upper half for fourth iteration @@ -372,11 +368,11 @@ function ff_pix_abs16_y2_neon, export=1 // iterate by one 2: - ld1 {v1.16b}, [x2], x3 // Load pix2 - ld1 {v2.16b}, [x5], x3 // Load pix3 + ld1 {v2.16b}, [x2], x3 // Load pix3 subs w4, w4, #1 ld1 {v0.16b}, [x1], x3 // Load pix1 urhadd v30.16b, v1.16b, v2.16b // Rounding halving add + mov v1.16b, v2.16b // Shift pix3->pix2 uabal v29.8h, v30.8b, v0.8b uabal2 v28.8h, v30.16b, v0.16b From 8089fe072e4552348a215d9fb4a0545ccf830763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 28 Sep 2022 11:55:51 +0300 Subject: [PATCH 564/590] aarch64: me_cmp: Avoid using the non-unrolled codepath for the minimum unroll size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavcodec/aarch64/me_cmp_neon.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 832a7cb22d..c710358ab7 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -471,7 +471,7 @@ function sse8_neon, export=1 movi v21.4s, #0 movi v20.4s, #0 cmp w4, #4 - b.le 2f + b.lt 2f // make 4 iterations at once 1: @@ -534,7 +534,7 @@ function sse4_neon, export=1 movi v16.4s, #0 // clear the result accumulator cmp w4, #4 - b.le 2f + b.lt 2f // make 4 iterations at once 1: @@ -663,7 +663,7 @@ function vsse16_neon, export=1 cmp w4, #3 // check if we can make 3 iterations at once usubl v31.8h, v0.8b, v1.8b // Signed difference of pix1[0] - pix2[0], first iteration usubl2 v30.8h, v0.16b, v1.16b // Signed difference of pix1[0] - pix2[0], first iteration - b.le 2f + b.lt 2f 1: From 76d8f0dd143ce72b4f3de2a55f9efa9d8ffd358e Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 15:04:26 +0200 Subject: [PATCH 565/590] avcodec/ac3dsp: Remove unused parameter Forgotten in fd98594a8831ce037a495b6d7e090bd8f81e83a1. Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3dec.c | 2 +- libavcodec/ac3dsp.c | 8 ++++---- libavcodec/ac3dsp.h | 8 ++++---- libavcodec/ac3enc.c | 2 +- libavcodec/arm/ac3dsp_init_arm.c | 2 +- libavcodec/mips/ac3dsp_mips.c | 3 ++- libavcodec/x86/ac3dsp_init.c | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index aba8e0fb7f..340f6e1e37 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -236,7 +236,7 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) if (!s->fdsp) return AVERROR(ENOMEM); - ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT); + ff_ac3dsp_init(&s->ac3dsp); av_lfg_init(&s->dith_state, 0); if (USE_FIXED) diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c index afd6b557bf..22cb5f242e 100644 --- a/libavcodec/ac3dsp.c +++ b/libavcodec/ac3dsp.c @@ -374,7 +374,7 @@ void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix, ac3_downmix_c(samples, matrix, out_ch, in_ch, len); } -av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact) +av_cold void ff_ac3dsp_init(AC3DSPContext *c) { c->ac3_exponent_min = ac3_exponent_min_c; c->float_to_fixed24 = float_to_fixed24_c; @@ -390,10 +390,10 @@ av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact) c->downmix_fixed = NULL; #if ARCH_ARM - ff_ac3dsp_init_arm(c, bit_exact); + ff_ac3dsp_init_arm(c); #elif ARCH_X86 - ff_ac3dsp_init_x86(c, bit_exact); + ff_ac3dsp_init_x86(c); #elif ARCH_MIPS - ff_ac3dsp_init_mips(c, bit_exact); + ff_ac3dsp_init_mips(c); #endif } diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h index a23b11526e..33e51e202e 100644 --- a/libavcodec/ac3dsp.h +++ b/libavcodec/ac3dsp.h @@ -105,10 +105,10 @@ typedef struct AC3DSPContext { void (*downmix_fixed)(int32_t **samples, int16_t **matrix, int len); } AC3DSPContext; -void ff_ac3dsp_init (AC3DSPContext *c, int bit_exact); -void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact); -void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact); -void ff_ac3dsp_init_mips(AC3DSPContext *c, int bit_exact); +void ff_ac3dsp_init (AC3DSPContext *c); +void ff_ac3dsp_init_arm(AC3DSPContext *c); +void ff_ac3dsp_init_x86(AC3DSPContext *c); +void ff_ac3dsp_init_mips(AC3DSPContext *c); void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix, int out_ch, int in_ch, int len); diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index a090576823..279dd5c20e 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2613,7 +2613,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) ff_audiodsp_init(&s->adsp); ff_me_cmp_init(&s->mecc, avctx); - ff_ac3dsp_init(&s->ac3dsp, avctx->flags & AV_CODEC_FLAG_BITEXACT); + ff_ac3dsp_init(&s->ac3dsp); dprint_options(s); diff --git a/libavcodec/arm/ac3dsp_init_arm.c b/libavcodec/arm/ac3dsp_init_arm.c index 9217a7d0c2..a64aa6ae82 100644 --- a/libavcodec/arm/ac3dsp_init_arm.c +++ b/libavcodec/arm/ac3dsp_init_arm.c @@ -44,7 +44,7 @@ void ff_ac3_bit_alloc_calc_bap_armv6(int16_t *mask, int16_t *psd, void ff_ac3_update_bap_counts_arm(uint16_t mant_cnt[16], uint8_t *bap, int len); -av_cold void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact) +av_cold void ff_ac3dsp_init_arm(AC3DSPContext *c) { int cpu_flags = av_get_cpu_flags(); diff --git a/libavcodec/mips/ac3dsp_mips.c b/libavcodec/mips/ac3dsp_mips.c index 8f62c03aaf..a5eaaf8eb2 100644 --- a/libavcodec/mips/ac3dsp_mips.c +++ b/libavcodec/mips/ac3dsp_mips.c @@ -401,7 +401,8 @@ static void ac3_downmix_mips(float **samples, float (*matrix)[2], #endif /* HAVE_MIPSFPU */ #endif /* HAVE_INLINE_ASM */ -void ff_ac3dsp_init_mips(AC3DSPContext *c, int bit_exact) { +void ff_ac3dsp_init_mips(AC3DSPContext *c) +{ #if HAVE_INLINE_ASM #if HAVE_MIPSDSP c->bit_alloc_calc_bap = ac3_bit_alloc_calc_bap_mips; diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c index 75a341bc95..43b3b4ac85 100644 --- a/libavcodec/x86/ac3dsp_init.c +++ b/libavcodec/x86/ac3dsp_init.c @@ -33,7 +33,7 @@ int ff_ac3_compute_mantissa_size_sse2(uint16_t mant_cnt[6][16]); void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs); void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs); -av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) +av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c) { int cpu_flags = av_get_cpu_flags(); From 17df61083dc79e90fa0180811dc69fab077096aa Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Fri, 23 Sep 2022 10:44:10 +0800 Subject: [PATCH 566/590] libavcodec/qsvenc: Add framerate reset support to qsv Signed-off-by: Wenbin Chen --- doc/encoders.texi | 3 +++ libavcodec/qsvenc.c | 26 ++++++++++++++++++++++++++ libavcodec/qsvenc.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 5a5579d5e5..cc5abccaa4 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3362,6 +3362,9 @@ Change these value to reset qsv codec's max/min qp configuration. @item @var{low_delay_brc} Supported in h264_qsv and hevc_qsv. Change this value to reset qsv codec's low_delay_brc configuration. + +@item @var{framerate} +Change this value to reset qsv codec's framerate configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 8bd9272dc6..98d38fd2c7 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -705,6 +705,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.FrameInfo.FrameRateExtN = avctx->time_base.den; q->param.mfx.FrameInfo.FrameRateExtD = avctx->time_base.num; } + q->old_framerate = avctx->framerate; ret = select_rc_mode(avctx, q); if (ret < 0) @@ -1838,6 +1839,30 @@ static int update_low_delay_brc(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_frame_rate(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + UPDATE_PARAM(q->old_framerate.num, avctx->framerate.num); + UPDATE_PARAM(q->old_framerate.den, avctx->framerate.den); + if (!updated) + return 0; + + if (avctx->framerate.den > 0 && avctx->framerate.num > 0) { + q->param.mfx.FrameInfo.FrameRateExtN = avctx->framerate.num; + q->param.mfx.FrameInfo.FrameRateExtD = avctx->framerate.den; + } else { + q->param.mfx.FrameInfo.FrameRateExtN = avctx->time_base.den; + q->param.mfx.FrameInfo.FrameRateExtD = avctx->time_base.num; + } + av_log(avctx, AV_LOG_DEBUG, "Reset framerate: %d/%d (%.2f fps).\n", + q->param.mfx.FrameInfo.FrameRateExtN, + q->param.mfx.FrameInfo.FrameRateExtD, + (double)q->param.mfx.FrameInfo.FrameRateExtN / q->param.mfx.FrameInfo.FrameRateExtD); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1851,6 +1876,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_gop_size(avctx, q); needReset |= update_rir(avctx, q); needReset |= update_low_delay_brc(avctx, q); + needReset |= update_frame_rate(avctx, q); ret = update_min_max_qp(avctx, q); if (ret < 0) return ret; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index f2b7ee361f..960197f159 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -271,6 +271,8 @@ typedef struct QSVEncContext { int old_min_qp_b; // This is used for low_delay_brc reset int old_low_delay_brc; + // This is used for framerate reset + AVRational old_framerate; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From 29a3ba869317054b3a795eddf632857a77485755 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Fri, 23 Sep 2022 10:44:11 +0800 Subject: [PATCH 567/590] libavcodec/qsvenc: Add bitrate reset support to qsvenc Signed-off-by: Wenbin Chen --- doc/encoders.texi | 6 ++++++ libavcodec/qsvenc.c | 38 ++++++++++++++++++++++++++++++++++++++ libavcodec/qsvenc.h | 5 +++++ 3 files changed, 49 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index cc5abccaa4..e8ee676473 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3365,6 +3365,12 @@ Change this value to reset qsv codec's low_delay_brc configuration. @item @var{framerate} Change this value to reset qsv codec's framerate configuration. + +@item @var{bit_rate} +@item @var{rc_buffer_size} +@item @var{rc_initial_buffer_occupancy} +@item @var{rc_max_rate} +Change these value to reset qsv codec's bitrate control configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 98d38fd2c7..54ed2a5f63 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -718,6 +718,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) max_bitrate_kbps = avctx->rc_max_rate / 1000; brc_param_multiplier = (FFMAX(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes), initial_delay_in_kilobytes) + 0x10000) / 0x10000; + q->old_rc_buffer_size = avctx->rc_buffer_size; + q->old_rc_initial_buffer_occupancy = avctx->rc_initial_buffer_occupancy; + q->old_bit_rate = avctx->bit_rate; + q->old_rc_max_rate = avctx->rc_max_rate; switch (q->param.mfx.RateControlMethod) { case MFX_RATECONTROL_CBR: @@ -1863,6 +1867,39 @@ static int update_frame_rate(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_bitrate(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + int target_bitrate_kbps, max_bitrate_kbps, brc_param_multiplier; + int buffer_size_in_kilobytes, initial_delay_in_kilobytes; + + UPDATE_PARAM(q->old_rc_buffer_size, avctx->rc_buffer_size); + UPDATE_PARAM(q->old_rc_initial_buffer_occupancy, avctx->rc_initial_buffer_occupancy); + UPDATE_PARAM(q->old_bit_rate, avctx->bit_rate); + UPDATE_PARAM(q->old_rc_max_rate, avctx->rc_max_rate); + if (!updated) + return 0; + + buffer_size_in_kilobytes = avctx->rc_buffer_size / 8000; + initial_delay_in_kilobytes = avctx->rc_initial_buffer_occupancy / 8000; + target_bitrate_kbps = avctx->bit_rate / 1000; + max_bitrate_kbps = avctx->rc_max_rate / 1000; + brc_param_multiplier = (FFMAX(FFMAX3(target_bitrate_kbps, max_bitrate_kbps, buffer_size_in_kilobytes), + initial_delay_in_kilobytes) + 0x10000) / 0x10000; + + q->param.mfx.BufferSizeInKB = buffer_size_in_kilobytes / brc_param_multiplier; + q->param.mfx.InitialDelayInKB = initial_delay_in_kilobytes / brc_param_multiplier; + q->param.mfx.TargetKbps = target_bitrate_kbps / brc_param_multiplier; + q->param.mfx.MaxKbps = max_bitrate_kbps / brc_param_multiplier; + q->param.mfx.BRCParamMultiplier = brc_param_multiplier; + av_log(avctx, AV_LOG_VERBOSE, + "Reset BufferSizeInKB: %d; InitialDelayInKB: %d; " + "TargetKbps: %d; MaxKbps: %d; BRCParamMultiplier: %d\n", + q->param.mfx.BufferSizeInKB, q->param.mfx.InitialDelayInKB, + q->param.mfx.TargetKbps, q->param.mfx.MaxKbps, q->param.mfx.BRCParamMultiplier); + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1877,6 +1914,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_rir(avctx, q); needReset |= update_low_delay_brc(avctx, q); needReset |= update_frame_rate(avctx, q); + needReset |= update_bitrate(avctx, q); ret = update_min_max_qp(avctx, q); if (ret < 0) return ret; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 960197f159..6e1132d2e3 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -273,6 +273,11 @@ typedef struct QSVEncContext { int old_low_delay_brc; // This is used for framerate reset AVRational old_framerate; + // These are used for bitrate control reset + int old_bit_rate; + int old_rc_buffer_size; + int old_rc_initial_buffer_occupancy; + int old_rc_max_rate; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From 3771d54989d761cab02bbd8a7c03dbc2add05a81 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Fri, 23 Sep 2022 10:44:12 +0800 Subject: [PATCH 568/590] libavcodec/qsvenc: Add pic_timing_sei reset support to qsv Signed-off-by: Wenbin Chen --- doc/encoders.texi | 4 ++++ libavcodec/qsvenc.c | 21 +++++++++++++++++++++ libavcodec/qsvenc.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index e8ee676473..1a5216f8eb 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3371,6 +3371,10 @@ Change this value to reset qsv codec's framerate configuration. @item @var{rc_initial_buffer_occupancy} @item @var{rc_max_rate} Change these value to reset qsv codec's bitrate control configuration. + +@item @var{pic_timing_sei} +Supported in h264_qsv and hevc_qsv. +Change this value to reset qsv codec's pic_timing_sei configuration. @end table @subsection H264 options diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 54ed2a5f63..398fa6ff22 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -784,6 +784,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extco.PicTimingSEI = q->pic_timing_sei ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; + q->old_pic_timing_sei = q->pic_timing_sei; if (q->rdo >= 0) q->extco.RateDistortionOpt = q->rdo > 0 ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; @@ -1900,6 +1901,25 @@ static int update_bitrate(AVCodecContext *avctx, QSVEncContext *q) return updated; } +static int update_pic_timing_sei(AVCodecContext *avctx, QSVEncContext *q) +{ + int updated = 0; + + if (avctx->codec_id != AV_CODEC_ID_H264 && avctx->codec_id != AV_CODEC_ID_HEVC) + return 0; + + UPDATE_PARAM(q->old_pic_timing_sei, q->pic_timing_sei); + if (!updated) + return 0; + + q->extco.PicTimingSEI = q->pic_timing_sei ? + MFX_CODINGOPTION_ON : MFX_CODINGOPTION_UNKNOWN; + av_log(avctx, AV_LOG_DEBUG, "Reset PicTimingSEI: %s\n", + print_threestate(q->extco.PicTimingSEI)); + + return updated; +} + static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { @@ -1915,6 +1935,7 @@ static int update_parameters(AVCodecContext *avctx, QSVEncContext *q, needReset |= update_low_delay_brc(avctx, q); needReset |= update_frame_rate(avctx, q); needReset |= update_bitrate(avctx, q); + needReset |= update_pic_timing_sei(avctx, q); ret = update_min_max_qp(avctx, q); if (ret < 0) return ret; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 6e1132d2e3..486c996fc6 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -278,6 +278,8 @@ typedef struct QSVEncContext { int old_rc_buffer_size; int old_rc_initial_buffer_occupancy; int old_rc_max_rate; + // This is used for SEI Timing reset + int old_pic_timing_sei; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); From a3c0a3ec604da635fba5d356d7ec53bbd7c38d78 Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Mon, 26 Sep 2022 17:36:29 +0800 Subject: [PATCH 569/590] libavcodec/qsvenc: Let runtime to set default parameter. Unset qsv_h264 and qsv_hevc's default settings. Let runtime to decide these parameters, so that it can choose the best parameter and ffmpeg-qsv can keep up with runtime's update. Signed-off-by: Wenbin Chen --- libavcodec/qsvenc_h264.c | 5 ++--- libavcodec/qsvenc_hevc.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 85826ae4be..11aaabbd1b 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -176,9 +176,8 @@ static const AVClass class = { static const FFCodecDefault qsv_enc_defaults[] = { { "b", "1M" }, { "refs", "0" }, - // same as the x264 default - { "g", "250" }, - { "bf", "3" }, + { "g", "-1" }, + { "bf", "-1" }, { "qmin", "-1" }, { "qmax", "-1" }, { "trellis", "-1" }, diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 6ec6230999..a5bf915954 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -289,8 +289,7 @@ static const AVClass class = { static const FFCodecDefault qsv_enc_defaults[] = { { "b", "1M" }, { "refs", "0" }, - // same as the x264 default - { "g", "248" }, + { "g", "-1" }, { "bf", "-1" }, { "qmin", "-1" }, { "qmax", "-1" }, From 5682046ce5ee16bca3159a766fb3f9caf537fe0c Mon Sep 17 00:00:00 2001 From: Wenbin Chen Date: Mon, 26 Sep 2022 17:36:30 +0800 Subject: [PATCH 570/590] libavcodec/qsvenc: Let runtime to decide targetUsage Set preset default value to MFX_TARGETUSAGE_UNKNOWN. Let runtime to decide the targetUsage, so that ffmpeg-qsv can keep up with runtime's update. Signed-off-by: Wenbin Chen --- libavcodec/qsvenc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 486c996fc6..d77bc0aee1 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -52,7 +52,7 @@ #define QSV_COMMON_OPTS \ { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE }, \ -{ "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ +{ "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_UNKNOWN }, MFX_TARGETUSAGE_UNKNOWN, MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ { "veryfast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, \ { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_6 }, INT_MIN, INT_MAX, VE, "preset" }, \ { "fast", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_5 }, INT_MIN, INT_MAX, VE, "preset" }, \ From 87cc318bc27dc478b01bc2f97595b0394323d45d Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 25 Sep 2022 20:19:10 +0200 Subject: [PATCH 571/590] avcodec/tiff: Remove commented-out code Also remove a variable that is only used in this commented-out codeblock. This fixes a -Wunused-variable warning. Signed-off-by: Andreas Rheinhardt --- libavcodec/tiff.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 3a610ada85..fd9db18c0b 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1882,7 +1882,7 @@ static void camera_xyz_coeff(TiffContext *s, float rgb2cam[3][4], double cam2xyz[4][3]) { - double cam2rgb[4][3], inverse[4][3], num; + double cam2rgb[4][3], num; int i, j, k; for (i = 0; i < 3; i++) { @@ -1900,11 +1900,6 @@ static void camera_xyz_coeff(TiffContext *s, cam2rgb[i][j] /= num; s->premultiply[i] = 1.f / num; } - -// pseudoinverse(cam2rgb, inverse, colors); -// for (i = 0; i < 3; i++) -// for (j = 0; j < 3; j++) -// rgb2cam[i][j] = inverse[j][i]; } static int decode_frame(AVCodecContext *avctx, AVFrame *p, From fe3c2c8bbe017ac2fd2cc9cab2ccb29bad52a30b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 28 Sep 2022 19:55:42 +0200 Subject: [PATCH 572/590] avcodec/jrevdct: Fix UB left shifts of negative numbers Affected the rv20-1239 FATE test. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt --- libavcodec/jrevdct.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/jrevdct.c b/libavcodec/jrevdct.c index 36160cb663..7f1863515f 100644 --- a/libavcodec/jrevdct.c +++ b/libavcodec/jrevdct.c @@ -255,7 +255,7 @@ void ff_j_rev_dct(DCTBLOCK data) if (d0) { /* Compute a 32 bit value to assign. */ int16_t dcval = (int16_t) (d0 * (1 << PASS1_BITS)); - register int v = (dcval & 0xffff) | ((dcval * (1 << 16)) & 0xffff0000); + register unsigned v = (dcval & 0xffff) | ((uint32_t)dcval << 16); AV_WN32A(&idataptr[ 0], v); AV_WN32A(&idataptr[ 4], v); @@ -988,8 +988,8 @@ void ff_j_rev_dct4(DCTBLOCK data) /* AC terms all zero */ if (d0) { /* Compute a 32 bit value to assign. */ - int16_t dcval = (int16_t) (d0 << PASS1_BITS); - register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000); + int16_t dcval = (int16_t) (d0 * (1 << PASS1_BITS)); + register unsigned v = (dcval & 0xffff) | ((uint32_t)dcval << 16); AV_WN32A(&idataptr[0], v); AV_WN32A(&idataptr[4], v); @@ -1008,8 +1008,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1020,8 +1020,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1034,8 +1034,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1043,8 +1043,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = (d0 + d4) << CONST_BITS; - tmp11 = tmp12 = (d0 - d4) << CONST_BITS; + tmp10 = tmp13 = (d0 + d4) * (1 << CONST_BITS); + tmp11 = tmp12 = (d0 - d4) * (1 << CONST_BITS); } } @@ -1086,8 +1086,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065); tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1098,8 +1098,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(-d6, FIX_1_306562965); tmp3 = MULTIPLY(d6, FIX_0_541196100); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1112,8 +1112,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp2 = MULTIPLY(d2, FIX_0_541196100); tmp3 = MULTIPLY(d2, FIX_1_306562965); - tmp0 = (d0 + d4) << CONST_BITS; - tmp1 = (d0 - d4) << CONST_BITS; + tmp0 = (d0 + d4) * (1 << CONST_BITS); + tmp1 = (d0 - d4) * (1 << CONST_BITS); tmp10 = tmp0 + tmp3; tmp13 = tmp0 - tmp3; @@ -1121,8 +1121,8 @@ void ff_j_rev_dct4(DCTBLOCK data) tmp12 = tmp1 - tmp2; } else { /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */ - tmp10 = tmp13 = (d0 + d4) << CONST_BITS; - tmp11 = tmp12 = (d0 - d4) << CONST_BITS; + tmp10 = tmp13 = (d0 + d4) * (1 << CONST_BITS); + tmp11 = tmp12 = (d0 - d4) * (1 << CONST_BITS); } } From e5f6918cbd5d7b6024f83ff86075d5e762c38034 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 28 Sep 2022 20:00:41 +0200 Subject: [PATCH 573/590] avcodec/mpegvideo: Fix undefined left shift of negative numbers Fixes the rv20-1239 FATE-test. Reviewed-by: Michael Niedermayer Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegvideo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index d8c7bc687d..5095149eaa 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -843,7 +843,7 @@ static inline int hpel_motion_lowres(MpegEncContext *s, s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src, s->linesize, s->linesize, w + 1, (h + 1) << field_based, - src_x, src_y << field_based, + src_x, src_y * (1 << field_based), h_edge_pos, v_edge_pos); src = s->sc.edge_emu_buffer; emu = 1; @@ -945,7 +945,7 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y, linesize >> field_based, linesize >> field_based, 17, 17 + field_based, - src_x, src_y << field_based, h_edge_pos, + src_x, src_y * (1 << field_based), h_edge_pos, v_edge_pos); ptr_y = s->sc.edge_emu_buffer; if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) { @@ -956,12 +956,12 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, s->vdsp.emulated_edge_mc(ubuf, ptr_cb, uvlinesize >> field_based, uvlinesize >> field_based, 9, 9 + field_based, - uvsrc_x, uvsrc_y << field_based, + uvsrc_x, uvsrc_y * (1 << field_based), h_edge_pos >> 1, v_edge_pos >> 1); s->vdsp.emulated_edge_mc(vbuf, ptr_cr, uvlinesize >> field_based,uvlinesize >> field_based, 9, 9 + field_based, - uvsrc_x, uvsrc_y << field_based, + uvsrc_x, uvsrc_y * (1 << field_based), h_edge_pos >> 1, v_edge_pos >> 1); ptr_cb = ubuf; ptr_cr = vbuf; From 66a03f405316a0e1a4a60cacd1d32ec540604a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 28 Sep 2022 18:29:59 +0300 Subject: [PATCH 574/590] sws/rgb2rgb: RISC-V V shuffle_bytes_xxxx functions --- libswscale/rgb2rgb.c | 2 + libswscale/rgb2rgb.h | 1 + libswscale/riscv/Makefile | 2 + libswscale/riscv/rgb2rgb.c | 47 ++++++++++++++++++++ libswscale/riscv/rgb2rgb_rvv.S | 78 ++++++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 libswscale/riscv/Makefile create mode 100644 libswscale/riscv/rgb2rgb.c create mode 100644 libswscale/riscv/rgb2rgb_rvv.S diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 3af775b389..e98fdac8ea 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -139,6 +139,8 @@ av_cold void ff_sws_rgb2rgb_init(void) rgb2rgb_init_c(); #if ARCH_AARCH64 rgb2rgb_init_aarch64(); +#elif ARCH_RISCV + rgb2rgb_init_riscv(); #elif ARCH_X86 rgb2rgb_init_x86(); #elif ARCH_LOONGARCH64 diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h index db85bfc42f..f3951d523e 100644 --- a/libswscale/rgb2rgb.h +++ b/libswscale/rgb2rgb.h @@ -167,6 +167,7 @@ extern void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const u void ff_sws_rgb2rgb_init(void); void rgb2rgb_init_aarch64(void); +void rgb2rgb_init_riscv(void); void rgb2rgb_init_x86(void); void rgb2rgb_init_loongarch(void); diff --git a/libswscale/riscv/Makefile b/libswscale/riscv/Makefile new file mode 100644 index 0000000000..214d877b62 --- /dev/null +++ b/libswscale/riscv/Makefile @@ -0,0 +1,2 @@ +OBJS += riscv/rgb2rgb.o +RVV-OBJS += riscv/rgb2rgb_rvv.o diff --git a/libswscale/riscv/rgb2rgb.c b/libswscale/riscv/rgb2rgb.c new file mode 100644 index 0000000000..5654154494 --- /dev/null +++ b/libswscale/riscv/rgb2rgb.c @@ -0,0 +1,47 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libswscale/rgb2rgb.h" + +void ff_shuffle_bytes_0321_rvv(const uint8_t *src, uint8_t *dst, int src_len); +void ff_shuffle_bytes_2103_rvv(const uint8_t *src, uint8_t *dst, int src_len); +void ff_shuffle_bytes_1230_rvv(const uint8_t *src, uint8_t *dst, int src_len); +void ff_shuffle_bytes_3012_rvv(const uint8_t *src, uint8_t *dst, int src_len); +void ff_shuffle_bytes_3210_rvv(const uint8_t *src, uint8_t *dst, int src_len); + +av_cold void rgb2rgb_init_riscv(void) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) { + shuffle_bytes_0321 = ff_shuffle_bytes_0321_rvv; + shuffle_bytes_2103 = ff_shuffle_bytes_2103_rvv; + shuffle_bytes_1230 = ff_shuffle_bytes_1230_rvv; + shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv; + shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvv; + } +#endif +} diff --git a/libswscale/riscv/rgb2rgb_rvv.S b/libswscale/riscv/rgb2rgb_rvv.S new file mode 100644 index 0000000000..3eb11262c0 --- /dev/null +++ b/libswscale/riscv/rgb2rgb_rvv.S @@ -0,0 +1,78 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 "libavutil/riscv/asm.S" + +func ff_shuffle_bytes_0321_rvv, zve32x + addi t1, a0, 3 + addi t2, a0, 2 + addi t3, a0, 1 +1: + srai a2, a2, 2 + li t4, 4 +2: + vsetvli t0, a2, e8, m1, ta, ma + sub a2, a2, t0 + vlse8.v v8, (a0), t4 + sh2add a0, t0, a0 + vlse8.v v9, (t1), t4 + sh2add t1, t0, t1 + vlse8.v v10, (t2), t4 + sh2add t2, t0, t2 + vlse8.v v11, (t3), t4 + sh2add t3, t0, t3 + vsseg4e8.v v8, (a1) + sh2add a1, t0, a1 + bnez a2, 2b + + ret +endfunc + +func ff_shuffle_bytes_2103_rvv, zve32x + addi t1, a0, 1 + addi t2, a0, 0 + addi t3, a0, 3 + addi a0, a0, 2 + j 1b +endfunc + +func ff_shuffle_bytes_1230_rvv, zve32x + addi t1, a0, 2 + addi t2, a0, 3 + addi t3, a0, 0 + addi a0, a0, 1 + j 1b +endfunc + +func ff_shuffle_bytes_3012_rvv, zve32x + addi t1, a0, 0 + addi t2, a0, 1 + addi t3, a0, 2 + addi a0, a0, 3 + j 1b +endfunc + +func ff_shuffle_bytes_3210_rvv, zve32x + addi t1, a0, 2 + addi t2, a0, 1 + addi t3, a0, 0 + addi a0, a0, 3 + j 1b +endfunc From 9181835a249405ec492d26bba58d3881eded95bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 28 Sep 2022 18:30:00 +0300 Subject: [PATCH 575/590] sws/rgb2rgb: RISC-V V interleaveBytes --- libswscale/riscv/rgb2rgb.c | 4 ++++ libswscale/riscv/rgb2rgb_rvv.S | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/libswscale/riscv/rgb2rgb.c b/libswscale/riscv/rgb2rgb.c index 5654154494..32c1546827 100644 --- a/libswscale/riscv/rgb2rgb.c +++ b/libswscale/riscv/rgb2rgb.c @@ -30,6 +30,9 @@ void ff_shuffle_bytes_2103_rvv(const uint8_t *src, uint8_t *dst, int src_len); void ff_shuffle_bytes_1230_rvv(const uint8_t *src, uint8_t *dst, int src_len); void ff_shuffle_bytes_3012_rvv(const uint8_t *src, uint8_t *dst, int src_len); void ff_shuffle_bytes_3210_rvv(const uint8_t *src, uint8_t *dst, int src_len); +void ff_interleave_bytes_rvv(const uint8_t *src1, const uint8_t *src2, + uint8_t *dst, int width, int height, int s1stride, + int s2stride, int dstride); av_cold void rgb2rgb_init_riscv(void) { @@ -42,6 +45,7 @@ av_cold void rgb2rgb_init_riscv(void) shuffle_bytes_1230 = ff_shuffle_bytes_1230_rvv; shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv; shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvv; + interleaveBytes = ff_interleave_bytes_rvv; } #endif } diff --git a/libswscale/riscv/rgb2rgb_rvv.S b/libswscale/riscv/rgb2rgb_rvv.S index 3eb11262c0..7f8c2efd80 100644 --- a/libswscale/riscv/rgb2rgb_rvv.S +++ b/libswscale/riscv/rgb2rgb_rvv.S @@ -76,3 +76,29 @@ func ff_shuffle_bytes_3210_rvv, zve32x addi a0, a0, 3 j 1b endfunc + +func ff_interleave_bytes_rvv, zve32x +1: + mv t0, a0 + mv t1, a1 + mv t2, a2 + mv t3, a3 + addi a4, a4, -1 +2: + vsetvli t4, t3, e8, ta, ma + sub t3, t3, t4 + vle8.v v8, (t0) + add t0, t4, t0 + vle8.v v9, (t1) + add t1, t4, t1 + vsseg2e8.v v8, (t2) + sh1add t2, t4, t2 + bnez t4, 2b + + add a0, a0, a5 + add a1, a1, a6 + add a2, a2, a7 + bnez a4, 1b + + ret +endfunc From a1bfb5290e58afa3d38e4d3f986302a2668fbfbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 28 Sep 2022 18:30:01 +0300 Subject: [PATCH 576/590] sws/rgb2rgb: RISC-V 64-bit V packed YUYV/UYVY to planar 4:2:2 This is currently 64-bit only because the stack spilling code would not assemble on RV32I (and it would corrupt s0 and s1 on RV128I, in theory). This could be added later in the unlikely that someone wants it. --- libswscale/riscv/rgb2rgb.c | 10 +++++++ libswscale/riscv/rgb2rgb_rvv.S | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/libswscale/riscv/rgb2rgb.c b/libswscale/riscv/rgb2rgb.c index 32c1546827..37a2cd5ea1 100644 --- a/libswscale/riscv/rgb2rgb.c +++ b/libswscale/riscv/rgb2rgb.c @@ -33,6 +33,12 @@ void ff_shuffle_bytes_3210_rvv(const uint8_t *src, uint8_t *dst, int src_len); void ff_interleave_bytes_rvv(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int width, int height, int s1stride, int s2stride, int dstride); +void ff_uyvytoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + const uint8_t *src, int width, int height, + int ystride, int uvstride, int src_stride); +void ff_yuyvtoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + const uint8_t *src, int width, int height, + int ystride, int uvstride, int src_stride); av_cold void rgb2rgb_init_riscv(void) { @@ -46,6 +52,10 @@ av_cold void rgb2rgb_init_riscv(void) shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv; shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvv; interleaveBytes = ff_interleave_bytes_rvv; +#if (__riscv_xlen == 64) + uyvytoyuv422 = ff_uyvytoyuv422_rvv; + yuyvtoyuv422 = ff_yuyvtoyuv422_rvv; +#endif } #endif } diff --git a/libswscale/riscv/rgb2rgb_rvv.S b/libswscale/riscv/rgb2rgb_rvv.S index 7f8c2efd80..5626d906eb 100644 --- a/libswscale/riscv/rgb2rgb_rvv.S +++ b/libswscale/riscv/rgb2rgb_rvv.S @@ -102,3 +102,56 @@ func ff_interleave_bytes_rvv, zve32x ret endfunc + +#if (__riscv_xlen == 64) +.macro yuy2_to_i422p v_y0, v_y1, v_u, v_v + addi sp, sp, -16 + sd s0, (sp) + sd s1, 8(sp) + addi a4, a4, 1 + lw s0, 16(sp) + srai a4, a4, 1 // pixel width -> chroma width + li s1, 2 +1: + mv t4, a4 + mv t3, a3 + mv t0, a0 + addi t6, a0, 1 + mv t1, a1 + mv t2, a2 + addi a5, a5, -1 +2: + vsetvli t5, t4, e8, m1, ta, ma + sub t4, t4, t5 + vlseg4e8.v v8, (t3) + sh2add t3, t5, t3 + vsse8.v \v_y0, (t0), s1 + sh1add t0, t5, t0 + vsse8.v \v_y1, (t6), s1 + sh1add t6, t5, t6 + vse8.v \v_u, (t1) + add t1, t5, t1 + vse8.v \v_v, (t2) + add t2, t5, t2 + bnez t4, 2b + + add a3, a3, s0 + add a0, a0, a6 + add a1, a1, a7 + add a2, a2, a7 + bnez a5, 1b + + ld s1, 8(sp) + ld s0, (sp) + addi sp, sp, 16 + ret +.endm + +func ff_uyvytoyuv422_rvv, zve32x + yuy2_to_i422p v9, v11, v8, v10 +endfunc + +func ff_yuyvtoyuv422_rvv, zve32x + yuy2_to_i422p v8, v10, v9, v11 +endfunc +#endif From 6d0a7e96e746a8a0fc03725a0f5e2c908c82b7c3 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 19:37:25 +0200 Subject: [PATCH 577/590] avutil/pixdesc: Remove always-false checks ff_check_pixfmt_descriptors() was added in commit 20e99a9c10cdbe9ad659dce5bdec569d744f8219. At this time, the values of enum AVPixelFormat were not contiguous; instead there was a jump from 111 to 291 (or from 115 to 295 depending upon AV_PIX_FMT_ABI_GIT_MASTER). ff_check_pixfmt_descriptors() accounts for this by skipping empty descriptors. Yet this issue no longer exists: There are no holes. The check for said holes makes GCC believe that the name can be NULL; because it is used as argument corresponding to %s in a log statement, it therefore emits a warning (since d75c4693fef51e8f0a1b88798530f4c5147ea906). Therefore this commit simply removes these checks. Also move the checks for name before the log statement. Signed-off-by: Andreas Rheinhardt --- libavutil/pixdesc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 3ac44614a7..c42a0242c5 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2922,13 +2922,11 @@ void ff_check_pixfmt_descriptors(void){ int linesize[4] = {0,0,0,0}; uint16_t tmp[2]; - if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags) - continue; + av_assert0(d->name && d->name[0]); av_log(NULL, AV_LOG_INFO, "Checking: %s\n", d->name); av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); - av_assert0(d->name && d->name[0]); av_assert2(av_get_pix_fmt(d->name) == i); for (j=0; jcomp); j++) { From 571b670e7dfc90394ba1f3cf736f446976c832da Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 20:21:51 +0200 Subject: [PATCH 578/590] avutil/pixdesc: Avoid direct access to pix fmt desc array Instead use av_pix_fmt_desc_next(). It is still possible to check its return values by comparing it with the (currently) expected values and the code does so. Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt --- libavutil/pixdesc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index c42a0242c5..4f95f88aba 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2913,10 +2913,10 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt) } void ff_check_pixfmt_descriptors(void){ - int i, j; + const AVPixFmtDescriptor *d, *last = NULL; + int i; - for (i=0; ilog2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); - av_assert2(av_get_pix_fmt(d->name) == i); + av_assert2(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); + + /* The following two checks as well as the one after the loop + * would need to be changed if we changed the way the descriptors + * are stored. */ + av_assert0(i == av_pix_fmt_desc_get_id(d)); + av_assert0(!last || last + 1 == d); - for (j=0; jcomp); j++) { + for (int j = 0; j < FF_ARRAY_ELEMS(d->comp); j++) { const AVComponentDescriptor *c = &d->comp[j]; if(j>=d->nb_components) { av_assert0(!c->plane && !c->step && !c->offset && !c->shift && !c->depth); @@ -2947,7 +2953,9 @@ void ff_check_pixfmt_descriptors(void){ tmp[0] = tmp[1] = (1ULL << c->depth) - 1; av_write_image_line(tmp, data, linesize, d, 0, 0, j, 2); } + last = d; } + av_assert0(i == AV_PIX_FMT_NB); } From 5fe447bbb4a1dfebb6f19339764aeab0315ff17f Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 21:05:00 +0200 Subject: [PATCH 579/590] avutil/pixdesc: Move ff_check_pixfmt_descriptors() to its only user Namely to lavu/tests/pixelutils.c. This way, this function will not be included into actual binaries any more. Signed-off-by: Andreas Rheinhardt --- libavutil/internal.h | 2 -- libavutil/pixdesc.c | 49 --------------------------------- libavutil/tests/pixelutils.c | 53 +++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index c9e30bc5e9..454c59aa50 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -187,6 +187,4 @@ static av_always_inline av_const int avpriv_mirror(int x, int w) return x; } -void ff_check_pixfmt_descriptors(void); - #endif /* AVUTIL_INTERNAL_H */ diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 4f95f88aba..ca3e204a0b 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -22,12 +22,10 @@ #include #include -#include "avassert.h" #include "avstring.h" #include "common.h" #include "pixfmt.h" #include "pixdesc.h" -#include "internal.h" #include "intreadwrite.h" void av_read_image_line2(void *dst, @@ -2912,53 +2910,6 @@ int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt) return ret; } -void ff_check_pixfmt_descriptors(void){ - const AVPixFmtDescriptor *d, *last = NULL; - int i; - - for (i = AV_PIX_FMT_NONE, d = NULL; i++, d = av_pix_fmt_desc_next(d);) { - uint8_t fill[4][8+6+3] = {{0}}; - uint8_t *data[4] = {fill[0], fill[1], fill[2], fill[3]}; - int linesize[4] = {0,0,0,0}; - uint16_t tmp[2]; - - av_assert0(d->name && d->name[0]); - av_log(NULL, AV_LOG_INFO, "Checking: %s\n", d->name); - av_assert0(d->log2_chroma_w <= 3); - av_assert0(d->log2_chroma_h <= 3); - av_assert0(d->nb_components <= 4); - av_assert2(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); - - /* The following two checks as well as the one after the loop - * would need to be changed if we changed the way the descriptors - * are stored. */ - av_assert0(i == av_pix_fmt_desc_get_id(d)); - av_assert0(!last || last + 1 == d); - - for (int j = 0; j < FF_ARRAY_ELEMS(d->comp); j++) { - const AVComponentDescriptor *c = &d->comp[j]; - if(j>=d->nb_components) { - av_assert0(!c->plane && !c->step && !c->offset && !c->shift && !c->depth); - continue; - } - if (d->flags & AV_PIX_FMT_FLAG_BITSTREAM) { - av_assert0(c->step >= c->depth); - } else { - av_assert0(8*c->step >= c->depth); - } - if (d->flags & AV_PIX_FMT_FLAG_BAYER) - continue; - av_read_image_line(tmp, (void*)data, linesize, d, 0, 0, j, 2, 0); - av_assert0(tmp[0] == 0 && tmp[1] == 0); - tmp[0] = tmp[1] = (1ULL << c->depth) - 1; - av_write_image_line(tmp, data, linesize, d, 0, 0, j, 2); - } - last = d; - } - av_assert0(i == AV_PIX_FMT_NB); -} - - enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); diff --git a/libavutil/tests/pixelutils.c b/libavutil/tests/pixelutils.c index 927c8d9217..41663d3eda 100644 --- a/libavutil/tests/pixelutils.c +++ b/libavutil/tests/pixelutils.c @@ -18,15 +18,66 @@ #include +#include "libavutil/avassert.h" #include "libavutil/internal.h" +#include "libavutil/log.h" #include "libavutil/mem.h" +#include "libavutil/pixdesc.h" #include "libavutil/pixelutils.c" +#include "libavutil/pixfmt.h" #define W1 320 #define H1 240 #define W2 640 #define H2 480 +static void check_pixfmt_descriptors(void) +{ + const AVPixFmtDescriptor *d, *last = NULL; + int i; + + for (i = AV_PIX_FMT_NONE, d = NULL; i++, d = av_pix_fmt_desc_next(d);) { + uint8_t fill[4][8 + 6 + 3] = {{ 0 }}; + uint8_t *data[4] = { fill[0], fill[1], fill[2], fill[3] }; + int linesize[4] = { 0, 0, 0, 0 }; + uint16_t tmp[2]; + + av_assert0(d->name && d->name[0]); + av_log(NULL, AV_LOG_INFO, "Checking: %s\n", d->name); + av_assert0(d->log2_chroma_w <= 3); + av_assert0(d->log2_chroma_h <= 3); + av_assert0(d->nb_components <= 4); + av_assert2(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); + + /* The following two checks as well as the one after the loop + * would need to be changed if we changed the way the descriptors + * are stored. */ + av_assert0(i == av_pix_fmt_desc_get_id(d)); + av_assert0(!last || last + 1 == d); + + for (int j = 0; j < FF_ARRAY_ELEMS(d->comp); j++) { + const AVComponentDescriptor *c = &d->comp[j]; + if (j >= d->nb_components) { + av_assert0(!c->plane && !c->step && !c->offset && !c->shift && !c->depth); + continue; + } + if (d->flags & AV_PIX_FMT_FLAG_BITSTREAM) { + av_assert0(c->step >= c->depth); + } else { + av_assert0(8*c->step >= c->depth); + } + if (d->flags & AV_PIX_FMT_FLAG_BAYER) + continue; + av_read_image_line(tmp, (void*)data, linesize, d, 0, 0, j, 2, 0); + av_assert0(tmp[0] == 0 && tmp[1] == 0); + tmp[0] = tmp[1] = (1ULL << c->depth) - 1; + av_write_image_line(tmp, data, linesize, d, 0, 0, j, 2); + } + last = d; + } + av_assert0(i == AV_PIX_FMT_NB); +} + static int run_single_test(const char *test, const uint8_t *block1, ptrdiff_t stride1, const uint8_t *block2, ptrdiff_t stride2, @@ -87,7 +138,7 @@ int main(void) goto end; } - ff_check_pixfmt_descriptors(); + check_pixfmt_descriptors(); #define RANDOM_INIT(buf, size) do { \ int k; \ From 36e805e9df012c20641fac5914a058f9c5ae15fd Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 21:24:15 +0200 Subject: [PATCH 580/590] avutil/tests/pixelutils: Use av_assert0 instead for test tools These are test tools, so they should be picky. Signed-off-by: Andreas Rheinhardt --- libavutil/tests/pixelutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/tests/pixelutils.c b/libavutil/tests/pixelutils.c index 41663d3eda..e1b7dd19b2 100644 --- a/libavutil/tests/pixelutils.c +++ b/libavutil/tests/pixelutils.c @@ -47,7 +47,7 @@ static void check_pixfmt_descriptors(void) av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); - av_assert2(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); + av_assert0(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); /* The following two checks as well as the one after the loop * would need to be changed if we changed the way the descriptors From 9d52844aba797343e27ba6c35ca47aec459bdf22 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 26 Sep 2022 21:42:31 +0200 Subject: [PATCH 581/590] avutil/tests/pixelutils: Test that all non-hw pix fmts have components Signed-off-by: Andreas Rheinhardt --- libavutil/tests/pixelutils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/tests/pixelutils.c b/libavutil/tests/pixelutils.c index e1b7dd19b2..f5ddeb329d 100644 --- a/libavutil/tests/pixelutils.c +++ b/libavutil/tests/pixelutils.c @@ -47,6 +47,7 @@ static void check_pixfmt_descriptors(void) av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); + av_assert0(d->nb_components || (d->flags & AV_PIX_FMT_FLAG_HWACCEL)); av_assert0(av_get_pix_fmt(d->name) == av_pix_fmt_desc_get_id(d)); /* The following two checks as well as the one after the loop From 9a494b82d998823d0de68cb6b8db83cc451d1781 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 30 Sep 2022 18:56:43 +0200 Subject: [PATCH 582/590] avcodec/mjpegdec: remove not needed operations on channel identifiers --- libavcodec/mjpegdec.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 559bda5e6f..85d1129f30 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -373,10 +373,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->v_max = 1; for (i = 0; i < nb_components; i++) { /* component id */ - int id = get_bits(&s->gb, 8); - if (id == 0) - return AVERROR_INVALIDDATA; - s->component_id[i] = id - 1; + s->component_id[i] = get_bits(&s->gb, 8); h_count[i] = get_bits(&s->gb, 4); v_count[i] = get_bits(&s->gb, 4); /* compute hmax and vmax (only used in interleaved case) */ @@ -401,10 +398,10 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->component_id[i], s->quant_index[i]); } if ( nb_components == 4 - && s->component_id[0] == 'C' - 1 - && s->component_id[1] == 'M' - 1 - && s->component_id[2] == 'Y' - 1 - && s->component_id[3] == 'K' - 1) + && s->component_id[0] == 'C' + && s->component_id[1] == 'M' + && s->component_id[2] == 'Y' + && s->component_id[3] == 'K') s->adobe_transform = 0; if (s->ls && (s->h_max > 1 || s->v_max > 1)) { @@ -526,7 +523,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_BGR48; else { if ( s->adobe_transform == 0 - || s->component_id[0] == 'R' - 1 && s->component_id[1] == 'G' - 1 && s->component_id[2] == 'B' - 1) { + || s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') { s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : AV_PIX_FMT_GBRP16; } else { if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; @@ -599,7 +596,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) case 0x14111100: case 0x22211100: case 0x22112100: - if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') { + if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[B] == 'B') { if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; else goto unk_pixfmt; @@ -614,7 +611,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) } break; case 0x21111100: - if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') { + if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') { if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; else goto unk_pixfmt; @@ -1681,9 +1678,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, } for (i = 0; i < nb_components; i++) { id = get_bits(&s->gb, 8); - if (id == 0) - return AVERROR_INVALIDDATA; - id -= 1; av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id); /* find component index */ for (index = 0; index < s->nb_components; index++) From 4b6b75c7526e644e3516a79f0379b2e2f75a054d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Wed, 21 Sep 2022 18:22:33 +0200 Subject: [PATCH 583/590] avcodec: add Media 100i decoder --- Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/media100.c | 224 ++++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 2 +- libavformat/isom_tags.c | 7 ++ 8 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 libavcodec/media100.c diff --git a/Changelog b/Changelog index 8360492abe..3c28bcd991 100644 --- a/Changelog +++ b/Changelog @@ -15,6 +15,7 @@ version : - Micronas SC-4 audio decoder - LAF demuxer - APAC decoder and demuxer +- Media 100i decoders version 5.1: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 14434dc06c..1946930c20 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -469,6 +469,7 @@ OBJS-$(CONFIG_MACE6_DECODER) += mace.o OBJS-$(CONFIG_MAGICYUV_DECODER) += magicyuv.o OBJS-$(CONFIG_MAGICYUV_ENCODER) += magicyuvenc.o OBJS-$(CONFIG_MDEC_DECODER) += mdec.o mpeg12.o mpeg12data.o +OBJS-$(CONFIG_MEDIA100_DECODER) += media100.o OBJS-$(CONFIG_METASOUND_DECODER) += metasound.o metasound_data.o \ twinvq.o OBJS-$(CONFIG_MICRODVD_DECODER) += microdvddec.o ass.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 3454823a05..cfeb01ac1c 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -194,6 +194,7 @@ extern const FFCodec ff_m101_decoder; extern const FFCodec ff_magicyuv_encoder; extern const FFCodec ff_magicyuv_decoder; extern const FFCodec ff_mdec_decoder; +extern const FFCodec ff_media100_decoder; extern const FFCodec ff_mimic_decoder; extern const FFCodec ff_mjpeg_encoder; extern const FFCodec ff_mjpeg_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index ee47489b75..93b18f9072 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1909,6 +1909,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("WBMP (Wireless Application Protocol Bitmap) image"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, }, + { + .id = AV_CODEC_ID_MEDIA100, + .type = AVMEDIA_TYPE_VIDEO, + .name = "media100", + .long_name = NULL_IF_CONFIG_SMALL("Media 100i"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index a0a720f9ff..82874daaa3 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -318,6 +318,7 @@ enum AVCodecID { AV_CODEC_ID_PHM, AV_CODEC_ID_RADIANCE_HDR, AV_CODEC_ID_WBMP, + AV_CODEC_ID_MEDIA100, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/media100.c b/libavcodec/media100.c new file mode 100644 index 0000000000..fdfce2cac1 --- /dev/null +++ b/libavcodec/media100.c @@ -0,0 +1,224 @@ +/* + * Media 100 decoder + * Copyright (c) 2022 Paul B Mahol + * + * 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 + */ + +/** + * @file + * Media 100 decoder. + */ + +#include + +#include "libavutil/intreadwrite.h" +#include "avcodec.h" +#include "bytestream.h" +#include "codec_internal.h" + +typedef struct Media100Context { + AVCodecContext *avctx; // wrapper context for mjpegb + AVPacket *pkt; +} Media100Context; + +static av_cold int media100_decode_init(AVCodecContext *avctx) +{ + Media100Context *ctx = avctx->priv_data; + const AVCodec *codec; + int ret; + + codec = avcodec_find_decoder(AV_CODEC_ID_MJPEGB); + if (!codec) + return AVERROR_BUG; + ctx->avctx = avcodec_alloc_context3(codec); + if (!ctx->avctx) + return AVERROR(ENOMEM); + ctx->avctx->thread_count = 1; + ctx->avctx->flags = avctx->flags; + ctx->avctx->flags2 = avctx->flags2; + ctx->avctx->width = ctx->avctx->coded_width = avctx->width; + ctx->avctx->height = ctx->avctx->coded_height = avctx->height; + + ret = avcodec_open2(ctx->avctx, codec, NULL); + if (ret < 0) + return ret; + + ctx->pkt = av_packet_alloc(); + if (!ctx->pkt) + return AVERROR(ENOMEM); + + return 0; +} + +static int media100_decode_frame(AVCodecContext *avctx, + AVFrame *frame, int *got_frame, + AVPacket *avpkt) +{ + Media100Context *ctx = avctx->priv_data; + unsigned second_field_offset = 0; + unsigned next_field = 0; + unsigned dht_offset[2]; + unsigned dqt_offset[2]; + unsigned sod_offset[2]; + unsigned sof_offset[2]; + unsigned sos_offset[2]; + unsigned field = 0; + GetByteContext gb; + PutByteContext pb; + AVPacket *pkt; + int ret; + + if (avpkt->size + 1024 > ctx->pkt->size) { + ret = av_grow_packet(ctx->pkt, avpkt->size + 1024 - ctx->pkt->size); + if (ret < 0) + return ret; + } + + ret = av_packet_make_writable(ctx->pkt); + if (ret < 0) + return ret; + + bytestream2_init(&gb, avpkt->data, avpkt->size); + bytestream2_init_writer(&pb, ctx->pkt->data, ctx->pkt->size); + +second_field: + bytestream2_put_be32(&pb, 0); + bytestream2_put_be32(&pb, AV_RB32("mjpg")); + bytestream2_put_be32(&pb, 0); + bytestream2_put_be32(&pb, 0); + for (int i = 0; i < 6; i++) + bytestream2_put_be32(&pb, 0); + + sof_offset[field] = bytestream2_tell_p(&pb); + bytestream2_put_be16(&pb, 17); + bytestream2_put_byte(&pb, 8); + bytestream2_put_be16(&pb, avctx->height / 2); + bytestream2_put_be16(&pb, avctx->width); + bytestream2_put_byte(&pb, 3); + bytestream2_put_byte(&pb, 1); + bytestream2_put_byte(&pb, 0x21); + bytestream2_put_byte(&pb, 0); + bytestream2_put_byte(&pb, 2); + bytestream2_put_byte(&pb, 0x11); + bytestream2_put_byte(&pb, 1); + bytestream2_put_byte(&pb, 3); + bytestream2_put_byte(&pb, 0x11); + bytestream2_put_byte(&pb, 1); + + sos_offset[field] = bytestream2_tell_p(&pb); + bytestream2_put_be16(&pb, 12); + bytestream2_put_byte(&pb, 3); + bytestream2_put_byte(&pb, 1); + bytestream2_put_byte(&pb, 0); + bytestream2_put_byte(&pb, 2); + bytestream2_put_byte(&pb, 0x11); + bytestream2_put_byte(&pb, 3); + bytestream2_put_byte(&pb, 0x11); + bytestream2_put_byte(&pb, 0); + bytestream2_put_byte(&pb, 0); + bytestream2_put_byte(&pb, 0); + + dqt_offset[field] = bytestream2_tell_p(&pb); + bytestream2_put_be16(&pb, 132); + bytestream2_put_byte(&pb, 0); + bytestream2_skip(&gb, 4); + for (int i = 0; i < 64; i++) + bytestream2_put_byte(&pb, bytestream2_get_be32(&gb)); + bytestream2_put_byte(&pb, 1); + for (int i = 0; i < 64; i++) + bytestream2_put_byte(&pb, bytestream2_get_be32(&gb)); + + dht_offset[field] = 0; + sod_offset[field] = bytestream2_tell_p(&pb); + + for (int i = bytestream2_tell(&gb) + 8; next_field == 0 && i < avpkt->size - 4; i++) { + if (AV_RB32(avpkt->data + i) == 0x00000001) { + next_field = i; + break; + } + } + + bytestream2_skip(&gb, 8); + bytestream2_copy_buffer(&pb, &gb, next_field - bytestream2_tell(&gb)); + bytestream2_put_be64(&pb, 0); + + if (field == 0) { + field = 1; + second_field_offset = bytestream2_tell_p(&pb); + next_field = avpkt->size; + goto second_field; + } + + pkt = ctx->pkt; + + AV_WB32(pkt->data + 8, second_field_offset); + AV_WB32(pkt->data + 12, second_field_offset); + AV_WB32(pkt->data + 16, second_field_offset); + AV_WB32(pkt->data + 20, dqt_offset[0]); + AV_WB32(pkt->data + 24, dht_offset[0]); + AV_WB32(pkt->data + 28, sof_offset[0]); + AV_WB32(pkt->data + 32, sos_offset[0]); + AV_WB32(pkt->data + 36, sod_offset[0]); + + AV_WB32(pkt->data + second_field_offset + 8, bytestream2_tell_p(&pb) - second_field_offset); + AV_WB32(pkt->data + second_field_offset + 12, bytestream2_tell_p(&pb) - second_field_offset); + AV_WB32(pkt->data + second_field_offset + 16, 0); + AV_WB32(pkt->data + second_field_offset + 20, dqt_offset[1] - second_field_offset); + AV_WB32(pkt->data + second_field_offset + 24, dht_offset[1]); + AV_WB32(pkt->data + second_field_offset + 28, sof_offset[1] - second_field_offset); + AV_WB32(pkt->data + second_field_offset + 32, sos_offset[1] - second_field_offset); + AV_WB32(pkt->data + second_field_offset + 36, sod_offset[1] - second_field_offset); + + pkt->size = bytestream2_tell_p(&pb); + + ret = avcodec_send_packet(ctx->avctx, pkt); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n"); + return ret; + } + + ret = avcodec_receive_frame(ctx->avctx, frame); + if (ret < 0) + return ret; + + *got_frame = 1; + + return avpkt->size; +} + +static av_cold int media100_decode_end(AVCodecContext *avctx) +{ + Media100Context *ctx = avctx->priv_data; + + avcodec_free_context(&ctx->avctx); + av_packet_free(&ctx->pkt); + + return 0; +} + +const FFCodec ff_media100_decoder = { + .p.name = "media100", + CODEC_LONG_NAME("Media 100"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_MEDIA100, + .priv_data_size = sizeof(Media100Context), + .init = media100_decode_init, + .close = media100_decode_end, + FF_CODEC_DECODE_CB(media100_decode_frame), + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index be26e9c364..39dd40fd2b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 48 +#define LIBAVCODEC_VERSION_MINOR 49 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c index 362cb77e8f..e2b80405cc 100644 --- a/libavformat/isom_tags.c +++ b/libavformat/isom_tags.c @@ -274,6 +274,13 @@ const AVCodecTag ff_codec_movvideo_tags[] = { { AV_CODEC_ID_RAWVIDEO, MKTAG('B', 'G', 'G', 'R') }, /* ASC Bayer BGGR */ + { AV_CODEC_ID_MEDIA100, MKTAG('6', '0', '1', 'N') }, + { AV_CODEC_ID_MEDIA100, MKTAG('6', '0', '1', 'P') }, + { AV_CODEC_ID_MEDIA100, MKTAG('d', 't', 'n', 't') }, + { AV_CODEC_ID_MEDIA100, MKTAG('d', 't', 'N', 'T') }, + { AV_CODEC_ID_MEDIA100, MKTAG('d', 't', 'p', 'a') }, + { AV_CODEC_ID_MEDIA100, MKTAG('d', 't', 'P', 'A') }, + { AV_CODEC_ID_NONE, 0 }, }; From b0c7352cd494c88d33f032be60b5e1c4e8b092a0 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Fri, 30 Sep 2022 19:22:05 +0200 Subject: [PATCH 584/590] avcodec/mjpegdec: Fix compilation Regression since 9a494b82d998823d0de68cb6b8db83cc451d1781. Reviewed-by: James Almer Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 85d1129f30..3374ae71bd 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -596,7 +596,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) case 0x14111100: case 0x22211100: case 0x22112100: - if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[B] == 'B') { + if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') { if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP; else goto unk_pixfmt; From 201b84fbe2a9bf4ac17deb4ec572e3b825282dd1 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Sat, 1 Oct 2022 22:16:22 -0700 Subject: [PATCH 585/590] Fix variable initialization --- libavformat/imf_cpl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 8c01e8396a..9bd409f7d0 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -118,10 +118,8 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value) { - xmlChar *element_text = NULL; int ret = 0; - - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") == 0) *value = 1; From 2a318c8e1997741f64466dea1ebe87660786b204 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Sat, 1 Oct 2022 22:42:32 -0700 Subject: [PATCH 586/590] avformat/imfdec: variable initialiaztion cosmetics --- libavformat/imf_cpl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 9bd409f7d0..57c9682ab3 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -72,10 +72,9 @@ xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *n int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); ret = av_uuid_urn_parse(element_text, uuid); if (ret) { av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n"); @@ -88,10 +87,9 @@ int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) { av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n"); ret = AVERROR_INVALIDDATA; @@ -103,10 +101,9 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (sscanf(element_text, "%" PRIu32, number) != 1) { av_log(NULL, AV_LOG_ERROR, "Invalid unsigned 32-bit integer"); ret = AVERROR_INVALIDDATA; From 1e291acfaf747a3a52dbc76459a160fa61220852 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Sat, 1 Oct 2022 22:43:04 -0700 Subject: [PATCH 587/590] Cosmetics --- libavformat/imf_cpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 57c9682ab3..efb07fa316 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -116,8 +116,8 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value) { int ret = 0; - xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") == 0) *value = 1; else if (xmlStrcmp(element_text, "false") == 0 || xmlStrcmp(element_text, "0") == 0) From 81c33244af5655281941af4c08caedab1ee7fe7b Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Mon, 25 Jul 2022 23:06:22 +0200 Subject: [PATCH 588/590] avformat/imfdec: use CPL start timecode if available --- libavformat/imf.h | 2 + libavformat/imf_cpl.c | 106 ++++++++++++++++++++++++++++++++++++++++++ libavformat/imfdec.c | 11 +++++ 3 files changed, 119 insertions(+) diff --git a/libavformat/imf.h b/libavformat/imf.h index 4271cd9582..70ed007312 100644 --- a/libavformat/imf.h +++ b/libavformat/imf.h @@ -59,6 +59,7 @@ #include "libavformat/avio.h" #include "libavutil/rational.h" #include "libavutil/uuid.h" +#include "libavutil/timecode.h" #include /** @@ -130,6 +131,7 @@ typedef struct FFIMFCPL { AVUUID id_uuid; /**< CompositionPlaylist/Id element */ xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ + AVTimecode *tc; /**< CompositionPlaylist/CompositionTimecode element */ FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ uint32_t main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 474db6b7f5..183e6dd84e 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -116,6 +116,22 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) return ret; } +static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value) +{ + int ret = 0; + + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") == 0) + *value = 1; + else if (xmlStrcmp(element_text, "false") == 0 || xmlStrcmp(element_text, "0") == 0) + *value = 0; + else + ret = 1; + xmlFree(element_text); + + return ret; +} + static void imf_base_virtual_track_init(FFIMFBaseVirtualTrack *track) { memset(track->id_uuid, 0, sizeof(track->id_uuid)); @@ -179,6 +195,90 @@ static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl) return 0; } +static int digit_to_int(char digit) +{ + if (digit >= '0' && digit <= '9') + return digit - '0'; + return -1; +} + +/** + * Parses a string that conform to the TimecodeType used in IMF CPL and defined + * in SMPTE ST 2067-3. + * @param[in] s string to parse + * @param[out] tc_comps pointer to an array of 4 integers where the parsed HH, + * MM, SS and FF fields of the timecode are returned. + * @return 0 on success, < 0 AVERROR code on error. + */ +static int parse_cpl_tc_type(const char *s, int *tc_comps) +{ + if (av_strnlen(s, 11) != 11) + return AVERROR(EINVAL); + + for (int i = 0; i < 4; i++) { + int hi; + int lo; + + hi = digit_to_int(s[i * 3]); + lo = digit_to_int(s[i * 3 + 1]); + + if (hi == -1 || lo == -1) + return AVERROR(EINVAL); + + tc_comps[i] = 10 * hi + lo; + } + + return 0; +} + +static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl) +{ + xmlNodePtr tc_element = NULL; + xmlNodePtr element = NULL; + xmlChar *tc_str = NULL; + int df = 0; + int comps[4]; + int ret = 0; + + tc_element = ff_imf_xml_get_child_element_by_name(cpl_element, "CompositionTimecode"); + if (!tc_element) + return 0; + + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeDropFrame"); + if (!element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeDropFrame child element\n"); + return AVERROR_INVALIDDATA; + } + + if (ff_imf_xml_read_boolean(element, &df)) { + av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n"); + return AVERROR_INVALIDDATA; + } + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeStartAddress"); + if (!element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeStartAddress child element\n"); + return AVERROR_INVALIDDATA; + } + + tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + ret = parse_cpl_tc_type(tc_str, comps); + xmlFree(tc_str); + if (ret) + return ret; + + cpl->tc = av_malloc(sizeof(AVTimecode)); + if (!cpl->tc) + return AVERROR(ENOMEM); + ret = av_timecode_init_from_components(cpl->tc, cpl->edit_rate, + df ? AV_TIMECODE_FLAG_DROPFRAME : 0, + comps[0], comps[1], comps[2], comps[3], + NULL); + + return ret; +} + static int fill_edit_rate(xmlNodePtr cpl_element, FFIMFCPL *cpl) { xmlNodePtr element = NULL; @@ -682,6 +782,8 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl) goto cleanup; if ((ret = fill_edit_rate(cpl_element, *cpl))) goto cleanup; + if ((ret = fill_timecode(cpl_element, *cpl))) + goto cleanup; if ((ret = fill_virtual_tracks(cpl_element, *cpl))) goto cleanup; @@ -731,6 +833,7 @@ static void imf_cpl_init(FFIMFCPL *cpl) av_uuid_nil(cpl->id_uuid); cpl->content_title_utf8 = NULL; cpl->edit_rate = av_make_q(0, 1); + cpl->tc = NULL; cpl->main_markers_track = NULL; cpl->main_image_2d_track = NULL; cpl->main_audio_track_count = 0; @@ -753,6 +856,9 @@ void ff_imf_cpl_free(FFIMFCPL *cpl) if (!cpl) return; + if (cpl->tc) + av_freep(&cpl->tc); + xmlFree(cpl->content_title_utf8); imf_marker_virtual_track_free(cpl->main_markers_track); diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 4e60dcc4ba..03de9ce151 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -627,6 +627,8 @@ static int imf_read_header(AVFormatContext *s) IMFContext *c = s->priv_data; char *asset_map_path; char *tmp_str; + AVDictionaryEntry* tcr; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret = 0; c->interrupt_callback = &s->interrupt_callback; @@ -646,6 +648,15 @@ static int imf_read_header(AVFormatContext *s) if ((ret = ff_imf_parse_cpl(s->pb, &c->cpl)) < 0) return ret; + tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + if (!tcr && c->cpl->tc) { + ret = av_dict_set(&s->metadata, "timecode", + av_timecode_make_string(c->cpl->tc, tc_buf, 0), 0); + if (ret) + return ret; + av_log(s, AV_LOG_INFO, "Setting timecode to IMF CPL timecode %s\n", tc_buf); + } + av_log(s, AV_LOG_DEBUG, "parsed IMF CPL: " AV_PRI_URN_UUID "\n", From c3c38ad5970872f33296ae70c493ed69629bfbee Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Mon, 22 Aug 2022 21:46:22 -0700 Subject: [PATCH 589/590] avformat/tests/imf: add CPL timecode test --- libavformat/tests/imf.c | 7 +++++++ tests/ref/fate/imf | 1 + 2 files changed, 8 insertions(+) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index a71de692f9..2cacb43f47 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -70,6 +70,11 @@ const char *cpl_doc = " urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f" " " "" + "" + "false" + "24" + "02:10:01.23" + "" "24000 1001" "" "" @@ -288,6 +293,7 @@ static int test_cpl_parsing(void) { xmlDocPtr doc; FFIMFCPL *cpl; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret; doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0); @@ -306,6 +312,7 @@ static int test_cpl_parsing(void) printf("%s\n", cpl->content_title_utf8); printf(AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->id_uuid)); printf("%i %i\n", cpl->edit_rate.num, cpl->edit_rate.den); + printf("%s\n", av_timecode_make_string(cpl->tc, tc_buf, 0)); printf("Marker resource count: %" PRIu32 "\n", cpl->main_markers_track->resource_count); for (uint32_t i = 0; i < cpl->main_markers_track->resource_count; i++) { diff --git a/tests/ref/fate/imf b/tests/ref/fate/imf index 90b461dc5d..5093167bc7 100644 --- a/tests/ref/fate/imf +++ b/tests/ref/fate/imf @@ -1,6 +1,7 @@ FFMPEG sample content urn:uuid:8713c020-2489-45f5-a9f7-87be539e20b5 24000 1001 +02:10:01:23 Marker resource count: 2 Marker resource 0 Marker 0 From 306c4bbb6abd6c58aa50514a0160f5a595ec6cf4 Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Sat, 1 Oct 2022 22:42:32 -0700 Subject: [PATCH 590/590] avformat/imfdec: variable initialiaztion cosmetics --- libavformat/imf_cpl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 183e6dd84e..ad84a68b13 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -72,10 +72,9 @@ xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *n int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); ret = av_uuid_urn_parse(element_text, uuid); if (ret) { av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n"); @@ -88,10 +87,9 @@ int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) { av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n"); ret = AVERROR_INVALIDDATA; @@ -103,10 +101,9 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (sscanf(element_text, "%" PRIu32, number) != 1) { av_log(NULL, AV_LOG_ERROR, "Invalid unsigned 32-bit integer"); ret = AVERROR_INVALIDDATA;