* [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-20 15:03 ` Andreas Rheinhardt
` (2 more replies)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 03/11] Makefile: Redo duplicating object files in shared builds Andreas Rheinhardt
` (13 subsequent siblings)
14 siblings, 3 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
libavcodec currently exports four avpriv symbols that deal with
PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
lists of PixelFormatTags, the former returns such a list and the second
searches a list for a pixel format that matches a given fourcc; only
one of the aforementioned three lists is ever searched.
Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
avpriv_find_pix_fmt the overhead of exporting these functions actually
exceeds the size of said objects (at least for ELF; the following numbers
are for x64 Ubuntu 20.10):
The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
yet exporting it adds a 20B string for the name alone to the exporting
as well as to each importing library; there is more: Four bytes in the
exporting libraries .gnu.hash; two bytes each for the exporting as well
as each importing libraries .gnu.version; 24B in the exporting as well
as each importing libraries .dynsym; 16B+24B for an entry in .plt as
well as the accompanying relocation entry in .rela.plt for each
importing library.
The overhead for the lists is similar: The strings are 23B and the
.plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
a relocation entry in .rela.dyn. These lists have a size of 80 resp.
72 bytes.
Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
duplicating it into libavformat and potentially libavdevice. Therefore
this commit replaces all library uses of the four symbols with a single
function that is exported for shared builds. It has an enum parameter
to choose the desired list besides the parameter for the fourcc. New
lists can be supported with new enum values.
Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
function remains.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
1. It would make sense to deduplicate avpriv_pix_fmt_bps_(mov|avi)
size-wise if it is preferred to keep the lists accessible to users.
2. One could handle the fourcc2pixfmt case in avpriv_pix_fmt_find(),
too, if one added another parameter (say count). In this case
avpriv_pix_fmt_find() will return the first pixfmt with the desired
fourcc if count is zero, the second one is count is 1 etc. (and
AV_PIX_FMT_NONE in case there is none any more). This would also make
this function more future-proof.
libavcodec/raw.c | 40 +++++++++++++++++++++++++++++++++++-----
libavcodec/raw.h | 13 +++++++------
libavcodec/rawdec.c | 8 ++++----
libavcodec/utils.c | 11 -----------
libavdevice/dshow.c | 2 +-
libavformat/avienc.c | 2 +-
libavformat/demux.c | 2 +-
libavformat/movenc.c | 2 +-
8 files changed, 50 insertions(+), 30 deletions(-)
diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index 079d5c5d10..5efc1eb465 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -28,7 +28,7 @@
#include "raw.h"
#include "libavutil/common.h"
-const PixelFormatTag ff_raw_pix_fmt_tags[] = {
+static const PixelFormatTag raw_pix_fmt_tags[] = {
{ AV_PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
{ AV_PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') },
{ AV_PIX_FMT_YUV420P, MKTAG('y', 'v', '1', '2') },
@@ -299,12 +299,12 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void)
{
- return ff_raw_pix_fmt_tags;
+ return raw_pix_fmt_tags;
}
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
{
- const PixelFormatTag *tags = ff_raw_pix_fmt_tags;
+ const PixelFormatTag *tags = raw_pix_fmt_tags;
while (tags->pix_fmt >= 0) {
if (tags->pix_fmt == fmt)
return tags->fourcc;
@@ -313,7 +313,7 @@ unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
return 0;
}
-const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
+static const PixelFormatTag pix_fmt_bps_avi[] = {
{ AV_PIX_FMT_PAL8, 1 },
{ AV_PIX_FMT_PAL8, 2 },
{ AV_PIX_FMT_PAL8, 4 },
@@ -326,7 +326,7 @@ const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
{ AV_PIX_FMT_NONE, 0 },
};
-const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
+static const PixelFormatTag pix_fmt_bps_mov[] = {
{ AV_PIX_FMT_PAL8, 1 },
{ AV_PIX_FMT_PAL8, 2 },
{ AV_PIX_FMT_PAL8, 4 },
@@ -337,3 +337,33 @@ const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
{ AV_PIX_FMT_PAL8, 33 },
{ AV_PIX_FMT_NONE, 0 },
};
+
+static enum AVPixelFormat find_pix_fmt(const PixelFormatTag *tags,
+ unsigned int fourcc)
+{
+ while (tags->pix_fmt != AV_PIX_FMT_NONE) {
+ if (tags->fourcc == fourcc)
+ return tags->pix_fmt;
+ tags++;
+ }
+ return AV_PIX_FMT_NONE;
+}
+
+enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
+ unsigned fourcc)
+{
+ const PixelFormatTag *tags;
+
+ switch (list) {
+ case PIX_FMT_LIST_RAW:
+ tags = raw_pix_fmt_tags;
+ break;
+ case PIX_FMT_LIST_AVI:
+ tags = pix_fmt_bps_avi;
+ break;
+ case PIX_FMT_LIST_MOV:
+ tags = pix_fmt_bps_mov;
+ break;
+ }
+ return find_pix_fmt(tags, fourcc);
+}
diff --git a/libavcodec/raw.h b/libavcodec/raw.h
index 6a041690b1..9a4ddef8fc 100644
--- a/libavcodec/raw.h
+++ b/libavcodec/raw.h
@@ -28,20 +28,21 @@
#define AVCODEC_RAW_H
#include "libavutil/pixfmt.h"
-#include "internal.h"
typedef struct PixelFormatTag {
enum AVPixelFormat pix_fmt;
unsigned int fourcc;
} PixelFormatTag;
-extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags()
-
const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void);
-enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc);
+enum PixelFormatTagLists {
+ PIX_FMT_LIST_RAW,
+ PIX_FMT_LIST_AVI,
+ PIX_FMT_LIST_MOV,
+};
-extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_avi[];
-extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_mov[];
+enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
+ unsigned fourcc);
#endif /* AVCODEC_RAW_H */
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index b22e36e984..9724cce13f 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -76,15 +76,15 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
if ( avctx->codec_tag == MKTAG('r','a','w',' ')
|| avctx->codec_tag == MKTAG('N','O','1','6'))
- avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
+ avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
avctx->bits_per_coded_sample);
else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
- avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
+ avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
avctx->bits_per_coded_sample);
else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0))
- avctx->pix_fmt = avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag);
+ avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, avctx->codec_tag);
else if (avctx->pix_fmt == AV_PIX_FMT_NONE && avctx->bits_per_coded_sample)
- avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
+ avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
avctx->bits_per_coded_sample);
desc = av_pix_fmt_desc_get(avctx->pix_fmt);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a91a54b0dc..4d236ff1cd 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -436,17 +436,6 @@ void ff_color_frame(AVFrame *frame, const int c[4])
}
}
-enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
- unsigned int fourcc)
-{
- while (tags->pix_fmt >= 0) {
- if (tags->fourcc == fourcc)
- return tags->pix_fmt;
- tags++;
- }
- return AV_PIX_FMT_NONE;
-}
-
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec){
return !!(codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM);
}
diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index ef78781865..ec1501ef8e 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -51,7 +51,7 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount)
return AV_PIX_FMT_0RGB32;
}
}
- return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others
+ return avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, biCompression); // all others
}
static int
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 3fbde0be1e..be2493ce55 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -448,7 +448,7 @@ static int avi_write_header(AVFormatContext *s)
par->bits_per_coded_sample = 16;
avist->pal_offset = avio_tell(pb) + 40;
ff_put_bmp_header(pb, par, 0, 0, avi->flipped_raw_rgb);
- pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
+ pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
par->bits_per_coded_sample);
if ( !par->codec_tag
&& par->codec_id == AV_CODEC_ID_RAWVIDEO
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 745dc8687c..360abd6014 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2795,7 +2795,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
if (avctx->codec_id == AV_CODEC_ID_RAWVIDEO && !avctx->codec_tag && !avctx->bits_per_coded_sample) {
uint32_t tag= avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
- if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == avctx->pix_fmt)
+ if (avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, tag) == avctx->pix_fmt)
avctx->codec_tag= tag;
}
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0f912dd012..7216331fa1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1636,7 +1636,7 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
}
}
- pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
+ pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
track->par->bits_per_coded_sample);
if (tag == MKTAG('r','a','w',' ') &&
track->par->format != pix_fmt &&
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols Andreas Rheinhardt
@ 2021-12-20 15:03 ` Andreas Rheinhardt
2021-12-30 9:55 ` Anton Khirnov
2022-01-03 10:38 ` Andreas Rheinhardt
2 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-20 15:03 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> libavcodec currently exports four avpriv symbols that deal with
> PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
> avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
> lists of PixelFormatTags, the former returns such a list and the second
> searches a list for a pixel format that matches a given fourcc; only
> one of the aforementioned three lists is ever searched.
>
> Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
> avpriv_find_pix_fmt the overhead of exporting these functions actually
> exceeds the size of said objects (at least for ELF; the following numbers
> are for x64 Ubuntu 20.10):
> The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
> yet exporting it adds a 20B string for the name alone to the exporting
> as well as to each importing library; there is more: Four bytes in the
> exporting libraries .gnu.hash; two bytes each for the exporting as well
> as each importing libraries .gnu.version; 24B in the exporting as well
> as each importing libraries .dynsym; 16B+24B for an entry in .plt as
> well as the accompanying relocation entry in .rela.plt for each
> importing library.
>
> The overhead for the lists is similar: The strings are 23B and the
> .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
> a relocation entry in .rela.dyn. These lists have a size of 80 resp.
> 72 bytes.
>
> Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
> duplicating it into libavformat and potentially libavdevice. Therefore
> this commit replaces all library uses of the four symbols with a single
> function that is exported for shared builds. It has an enum parameter
> to choose the desired list besides the parameter for the fourcc. New
> lists can be supported with new enum values.
>
> Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
> fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
> function remains.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> 1. It would make sense to deduplicate avpriv_pix_fmt_bps_(mov|avi)
> size-wise if it is preferred to keep the lists accessible to users.
> 2. One could handle the fourcc2pixfmt case in avpriv_pix_fmt_find(),
> too, if one added another parameter (say count). In this case
> avpriv_pix_fmt_find() will return the first pixfmt with the desired
> fourcc if count is zero, the second one is count is 1 etc. (and
> AV_PIX_FMT_NONE in case there is none any more). This would also make
> this function more future-proof.
>
> libavcodec/raw.c | 40 +++++++++++++++++++++++++++++++++++-----
> libavcodec/raw.h | 13 +++++++------
> libavcodec/rawdec.c | 8 ++++----
> libavcodec/utils.c | 11 -----------
> libavdevice/dshow.c | 2 +-
> libavformat/avienc.c | 2 +-
> libavformat/demux.c | 2 +-
> libavformat/movenc.c | 2 +-
> 8 files changed, 50 insertions(+), 30 deletions(-)
>
> diff --git a/libavcodec/raw.c b/libavcodec/raw.c
> index 079d5c5d10..5efc1eb465 100644
> --- a/libavcodec/raw.c
> +++ b/libavcodec/raw.c
> @@ -28,7 +28,7 @@
> #include "raw.h"
> #include "libavutil/common.h"
>
> -const PixelFormatTag ff_raw_pix_fmt_tags[] = {
> +static const PixelFormatTag raw_pix_fmt_tags[] = {
> { AV_PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
> { AV_PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') },
> { AV_PIX_FMT_YUV420P, MKTAG('y', 'v', '1', '2') },
> @@ -299,12 +299,12 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
>
> const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void)
> {
> - return ff_raw_pix_fmt_tags;
> + return raw_pix_fmt_tags;
> }
>
> unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
> {
> - const PixelFormatTag *tags = ff_raw_pix_fmt_tags;
> + const PixelFormatTag *tags = raw_pix_fmt_tags;
> while (tags->pix_fmt >= 0) {
> if (tags->pix_fmt == fmt)
> return tags->fourcc;
> @@ -313,7 +313,7 @@ unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
> return 0;
> }
>
> -const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
> +static const PixelFormatTag pix_fmt_bps_avi[] = {
> { AV_PIX_FMT_PAL8, 1 },
> { AV_PIX_FMT_PAL8, 2 },
> { AV_PIX_FMT_PAL8, 4 },
> @@ -326,7 +326,7 @@ const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
> { AV_PIX_FMT_NONE, 0 },
> };
>
> -const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
> +static const PixelFormatTag pix_fmt_bps_mov[] = {
> { AV_PIX_FMT_PAL8, 1 },
> { AV_PIX_FMT_PAL8, 2 },
> { AV_PIX_FMT_PAL8, 4 },
> @@ -337,3 +337,33 @@ const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
> { AV_PIX_FMT_PAL8, 33 },
> { AV_PIX_FMT_NONE, 0 },
> };
> +
> +static enum AVPixelFormat find_pix_fmt(const PixelFormatTag *tags,
> + unsigned int fourcc)
> +{
> + while (tags->pix_fmt != AV_PIX_FMT_NONE) {
> + if (tags->fourcc == fourcc)
> + return tags->pix_fmt;
> + tags++;
> + }
> + return AV_PIX_FMT_NONE;
> +}
> +
> +enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
> + unsigned fourcc)
> +{
> + const PixelFormatTag *tags;
> +
> + switch (list) {
> + case PIX_FMT_LIST_RAW:
> + tags = raw_pix_fmt_tags;
> + break;
> + case PIX_FMT_LIST_AVI:
> + tags = pix_fmt_bps_avi;
> + break;
> + case PIX_FMT_LIST_MOV:
> + tags = pix_fmt_bps_mov;
> + break;
> + }
> + return find_pix_fmt(tags, fourcc);
> +}
> diff --git a/libavcodec/raw.h b/libavcodec/raw.h
> index 6a041690b1..9a4ddef8fc 100644
> --- a/libavcodec/raw.h
> +++ b/libavcodec/raw.h
> @@ -28,20 +28,21 @@
> #define AVCODEC_RAW_H
>
> #include "libavutil/pixfmt.h"
> -#include "internal.h"
>
> typedef struct PixelFormatTag {
> enum AVPixelFormat pix_fmt;
> unsigned int fourcc;
> } PixelFormatTag;
>
> -extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags()
> -
> const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void);
>
> -enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc);
> +enum PixelFormatTagLists {
> + PIX_FMT_LIST_RAW,
> + PIX_FMT_LIST_AVI,
> + PIX_FMT_LIST_MOV,
> +};
>
> -extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_avi[];
> -extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_mov[];
> +enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
> + unsigned fourcc);
>
> #endif /* AVCODEC_RAW_H */
> diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
> index b22e36e984..9724cce13f 100644
> --- a/libavcodec/rawdec.c
> +++ b/libavcodec/rawdec.c
> @@ -76,15 +76,15 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
>
> if ( avctx->codec_tag == MKTAG('r','a','w',' ')
> || avctx->codec_tag == MKTAG('N','O','1','6'))
> - avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
> avctx->bits_per_coded_sample);
> else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
> - avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
> avctx->bits_per_coded_sample);
> else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0))
> - avctx->pix_fmt = avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag);
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, avctx->codec_tag);
> else if (avctx->pix_fmt == AV_PIX_FMT_NONE && avctx->bits_per_coded_sample)
> - avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
> avctx->bits_per_coded_sample);
>
> desc = av_pix_fmt_desc_get(avctx->pix_fmt);
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index a91a54b0dc..4d236ff1cd 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -436,17 +436,6 @@ void ff_color_frame(AVFrame *frame, const int c[4])
> }
> }
>
> -enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
> - unsigned int fourcc)
> -{
> - while (tags->pix_fmt >= 0) {
> - if (tags->fourcc == fourcc)
> - return tags->pix_fmt;
> - tags++;
> - }
> - return AV_PIX_FMT_NONE;
> -}
> -
> int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec){
> return !!(codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM);
> }
> diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
> index ef78781865..ec1501ef8e 100644
> --- a/libavdevice/dshow.c
> +++ b/libavdevice/dshow.c
> @@ -51,7 +51,7 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount)
> return AV_PIX_FMT_0RGB32;
> }
> }
> - return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others
> + return avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, biCompression); // all others
> }
>
> static int
> diff --git a/libavformat/avienc.c b/libavformat/avienc.c
> index 3fbde0be1e..be2493ce55 100644
> --- a/libavformat/avienc.c
> +++ b/libavformat/avienc.c
> @@ -448,7 +448,7 @@ static int avi_write_header(AVFormatContext *s)
> par->bits_per_coded_sample = 16;
> avist->pal_offset = avio_tell(pb) + 40;
> ff_put_bmp_header(pb, par, 0, 0, avi->flipped_raw_rgb);
> - pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
> + pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
> par->bits_per_coded_sample);
> if ( !par->codec_tag
> && par->codec_id == AV_CODEC_ID_RAWVIDEO
> diff --git a/libavformat/demux.c b/libavformat/demux.c
> index 745dc8687c..360abd6014 100644
> --- a/libavformat/demux.c
> +++ b/libavformat/demux.c
> @@ -2795,7 +2795,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
> if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> if (avctx->codec_id == AV_CODEC_ID_RAWVIDEO && !avctx->codec_tag && !avctx->bits_per_coded_sample) {
> uint32_t tag= avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
> - if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == avctx->pix_fmt)
> + if (avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, tag) == avctx->pix_fmt)
> avctx->codec_tag= tag;
> }
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 0f912dd012..7216331fa1 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1636,7 +1636,7 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
> }
> }
>
> - pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
> + pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
> track->par->bits_per_coded_sample);
> if (tag == MKTAG('r','a','w',' ') &&
> track->par->format != pix_fmt &&
>
Ping for this patchset. (I already applied the trivial first patch.)
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols
@ 2021-12-30 9:55 ` Anton Khirnov
2022-01-03 5:33 ` Andreas Rheinhardt
0 siblings, 1 reply; 23+ messages in thread
From: Anton Khirnov @ 2021-12-30 9:55 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt
Quoting Andreas Rheinhardt (2021-12-15 13:35:32)
> libavcodec currently exports four avpriv symbols that deal with
> PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
> avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
> lists of PixelFormatTags, the former returns such a list and the second
> searches a list for a pixel format that matches a given fourcc; only
> one of the aforementioned three lists is ever searched.
>
> Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
> avpriv_find_pix_fmt the overhead of exporting these functions actually
> exceeds the size of said objects (at least for ELF; the following numbers
> are for x64 Ubuntu 20.10):
> The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
> yet exporting it adds a 20B string for the name alone to the exporting
> as well as to each importing library; there is more: Four bytes in the
> exporting libraries .gnu.hash; two bytes each for the exporting as well
> as each importing libraries .gnu.version; 24B in the exporting as well
> as each importing libraries .dynsym; 16B+24B for an entry in .plt as
> well as the accompanying relocation entry in .rela.plt for each
> importing library.
>
> The overhead for the lists is similar: The strings are 23B and the
> .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
> a relocation entry in .rela.dyn. These lists have a size of 80 resp.
> 72 bytes.
>
> Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
> duplicating it into libavformat and potentially libavdevice. Therefore
> this commit replaces all library uses of the four symbols with a single
> function that is exported for shared builds. It has an enum parameter
> to choose the desired list besides the parameter for the fourcc. New
> lists can be supported with new enum values.
>
> Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
> fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
> function remains.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> 1. It would make sense to deduplicate avpriv_pix_fmt_bps_(mov|avi)
> size-wise if it is preferred to keep the lists accessible to users.
> 2. One could handle the fourcc2pixfmt case in avpriv_pix_fmt_find(),
> too, if one added another parameter (say count). In this case
> avpriv_pix_fmt_find() will return the first pixfmt with the desired
> fourcc if count is zero, the second one is count is 1 etc. (and
> AV_PIX_FMT_NONE in case there is none any more). This would also make
> this function more future-proof.
Would it not be simpler to add a second function returning a pointer to
the full table?
Also, I would prefer making this completely public rather than avpriv.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols
2021-12-30 9:55 ` Anton Khirnov
@ 2022-01-03 5:33 ` Andreas Rheinhardt
0 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2022-01-03 5:33 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Anton Khirnov:
> Quoting Andreas Rheinhardt (2021-12-15 13:35:32)
>> libavcodec currently exports four avpriv symbols that deal with
>> PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
>> avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
>> lists of PixelFormatTags, the former returns such a list and the second
>> searches a list for a pixel format that matches a given fourcc; only
>> one of the aforementioned three lists is ever searched.
>>
>> Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
>> avpriv_find_pix_fmt the overhead of exporting these functions actually
>> exceeds the size of said objects (at least for ELF; the following numbers
>> are for x64 Ubuntu 20.10):
>> The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
>> yet exporting it adds a 20B string for the name alone to the exporting
>> as well as to each importing library; there is more: Four bytes in the
>> exporting libraries .gnu.hash; two bytes each for the exporting as well
>> as each importing libraries .gnu.version; 24B in the exporting as well
>> as each importing libraries .dynsym; 16B+24B for an entry in .plt as
>> well as the accompanying relocation entry in .rela.plt for each
>> importing library.
>>
>> The overhead for the lists is similar: The strings are 23B and the
>> .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
>> a relocation entry in .rela.dyn. These lists have a size of 80 resp.
>> 72 bytes.
>>
>> Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
>> duplicating it into libavformat and potentially libavdevice. Therefore
>> this commit replaces all library uses of the four symbols with a single
>> function that is exported for shared builds. It has an enum parameter
>> to choose the desired list besides the parameter for the fourcc. New
>> lists can be supported with new enum values.
>>
>> Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
>> fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
>> function remains.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> 1. It would make sense to deduplicate avpriv_pix_fmt_bps_(mov|avi)
>> size-wise if it is preferred to keep the lists accessible to users.
>> 2. One could handle the fourcc2pixfmt case in avpriv_pix_fmt_find(),
>> too, if one added another parameter (say count). In this case
>> avpriv_pix_fmt_find() will return the first pixfmt with the desired
>> fourcc if count is zero, the second one is count is 1 etc. (and
>> AV_PIX_FMT_NONE in case there is none any more). This would also make
>> this function more future-proof.
>
> Would it not be simpler to add a second function returning a pointer to
> the full table?
>
There is already a function to return the full table:
avpriv_get_raw_pix_fmt_tags. It is what fourcc2pixfmt uses. The goal of
the above considerations is to reduce the number of exported symbols,
namely avpriv_get_raw_pix_fmt_tags.
> Also, I would prefer making this completely public rather than avpriv.
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols Andreas Rheinhardt
2021-12-20 15:03 ` Andreas Rheinhardt
2021-12-30 9:55 ` Anton Khirnov
@ 2022-01-03 10:38 ` Andreas Rheinhardt
2 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2022-01-03 10:38 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> libavcodec currently exports four avpriv symbols that deal with
> PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
> avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
> lists of PixelFormatTags, the former returns such a list and the second
> searches a list for a pixel format that matches a given fourcc; only
> one of the aforementioned three lists is ever searched.
>
> Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
> avpriv_find_pix_fmt the overhead of exporting these functions actually
> exceeds the size of said objects (at least for ELF; the following numbers
> are for x64 Ubuntu 20.10):
> The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
> yet exporting it adds a 20B string for the name alone to the exporting
> as well as to each importing library; there is more: Four bytes in the
> exporting libraries .gnu.hash; two bytes each for the exporting as well
> as each importing libraries .gnu.version; 24B in the exporting as well
> as each importing libraries .dynsym; 16B+24B for an entry in .plt as
> well as the accompanying relocation entry in .rela.plt for each
> importing library.
>
> The overhead for the lists is similar: The strings are 23B and the
> .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
> a relocation entry in .rela.dyn. These lists have a size of 80 resp.
> 72 bytes.
>
> Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
> duplicating it into libavformat and potentially libavdevice. Therefore
> this commit replaces all library uses of the four symbols with a single
> function that is exported for shared builds. It has an enum parameter
> to choose the desired list besides the parameter for the fourcc. New
> lists can be supported with new enum values.
>
> Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
> fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
> function remains.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> 1. It would make sense to deduplicate avpriv_pix_fmt_bps_(mov|avi)
> size-wise if it is preferred to keep the lists accessible to users.
> 2. One could handle the fourcc2pixfmt case in avpriv_pix_fmt_find(),
> too, if one added another parameter (say count). In this case
> avpriv_pix_fmt_find() will return the first pixfmt with the desired
> fourcc if count is zero, the second one is count is 1 etc. (and
> AV_PIX_FMT_NONE in case there is none any more). This would also make
> this function more future-proof.
>
> libavcodec/raw.c | 40 +++++++++++++++++++++++++++++++++++-----
> libavcodec/raw.h | 13 +++++++------
> libavcodec/rawdec.c | 8 ++++----
> libavcodec/utils.c | 11 -----------
> libavdevice/dshow.c | 2 +-
> libavformat/avienc.c | 2 +-
> libavformat/demux.c | 2 +-
> libavformat/movenc.c | 2 +-
> 8 files changed, 50 insertions(+), 30 deletions(-)
>
> diff --git a/libavcodec/raw.c b/libavcodec/raw.c
> index 079d5c5d10..5efc1eb465 100644
> --- a/libavcodec/raw.c
> +++ b/libavcodec/raw.c
> @@ -28,7 +28,7 @@
> #include "raw.h"
> #include "libavutil/common.h"
>
> -const PixelFormatTag ff_raw_pix_fmt_tags[] = {
> +static const PixelFormatTag raw_pix_fmt_tags[] = {
> { AV_PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
> { AV_PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') },
> { AV_PIX_FMT_YUV420P, MKTAG('y', 'v', '1', '2') },
> @@ -299,12 +299,12 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = {
>
> const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void)
> {
> - return ff_raw_pix_fmt_tags;
> + return raw_pix_fmt_tags;
> }
>
> unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
> {
> - const PixelFormatTag *tags = ff_raw_pix_fmt_tags;
> + const PixelFormatTag *tags = raw_pix_fmt_tags;
> while (tags->pix_fmt >= 0) {
> if (tags->pix_fmt == fmt)
> return tags->fourcc;
> @@ -313,7 +313,7 @@ unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
> return 0;
> }
>
> -const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
> +static const PixelFormatTag pix_fmt_bps_avi[] = {
> { AV_PIX_FMT_PAL8, 1 },
> { AV_PIX_FMT_PAL8, 2 },
> { AV_PIX_FMT_PAL8, 4 },
> @@ -326,7 +326,7 @@ const PixelFormatTag avpriv_pix_fmt_bps_avi[] = {
> { AV_PIX_FMT_NONE, 0 },
> };
>
> -const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
> +static const PixelFormatTag pix_fmt_bps_mov[] = {
> { AV_PIX_FMT_PAL8, 1 },
> { AV_PIX_FMT_PAL8, 2 },
> { AV_PIX_FMT_PAL8, 4 },
> @@ -337,3 +337,33 @@ const PixelFormatTag avpriv_pix_fmt_bps_mov[] = {
> { AV_PIX_FMT_PAL8, 33 },
> { AV_PIX_FMT_NONE, 0 },
> };
> +
> +static enum AVPixelFormat find_pix_fmt(const PixelFormatTag *tags,
> + unsigned int fourcc)
> +{
> + while (tags->pix_fmt != AV_PIX_FMT_NONE) {
> + if (tags->fourcc == fourcc)
> + return tags->pix_fmt;
> + tags++;
> + }
> + return AV_PIX_FMT_NONE;
> +}
> +
> +enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
> + unsigned fourcc)
> +{
> + const PixelFormatTag *tags;
> +
> + switch (list) {
> + case PIX_FMT_LIST_RAW:
> + tags = raw_pix_fmt_tags;
> + break;
> + case PIX_FMT_LIST_AVI:
> + tags = pix_fmt_bps_avi;
> + break;
> + case PIX_FMT_LIST_MOV:
> + tags = pix_fmt_bps_mov;
> + break;
> + }
> + return find_pix_fmt(tags, fourcc);
> +}
> diff --git a/libavcodec/raw.h b/libavcodec/raw.h
> index 6a041690b1..9a4ddef8fc 100644
> --- a/libavcodec/raw.h
> +++ b/libavcodec/raw.h
> @@ -28,20 +28,21 @@
> #define AVCODEC_RAW_H
>
> #include "libavutil/pixfmt.h"
> -#include "internal.h"
>
> typedef struct PixelFormatTag {
> enum AVPixelFormat pix_fmt;
> unsigned int fourcc;
> } PixelFormatTag;
>
> -extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags()
> -
> const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void);
>
> -enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc);
> +enum PixelFormatTagLists {
> + PIX_FMT_LIST_RAW,
> + PIX_FMT_LIST_AVI,
> + PIX_FMT_LIST_MOV,
> +};
>
> -extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_avi[];
> -extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_mov[];
> +enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
> + unsigned fourcc);
>
> #endif /* AVCODEC_RAW_H */
> diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
> index b22e36e984..9724cce13f 100644
> --- a/libavcodec/rawdec.c
> +++ b/libavcodec/rawdec.c
> @@ -76,15 +76,15 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
>
> if ( avctx->codec_tag == MKTAG('r','a','w',' ')
> || avctx->codec_tag == MKTAG('N','O','1','6'))
> - avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
> avctx->bits_per_coded_sample);
> else if (avctx->codec_tag == MKTAG('W', 'R', 'A', 'W'))
> - avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
> avctx->bits_per_coded_sample);
> else if (avctx->codec_tag && (avctx->codec_tag & 0xFFFFFF) != MKTAG('B','I','T', 0))
> - avctx->pix_fmt = avpriv_find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag);
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, avctx->codec_tag);
> else if (avctx->pix_fmt == AV_PIX_FMT_NONE && avctx->bits_per_coded_sample)
> - avctx->pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
> + avctx->pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
> avctx->bits_per_coded_sample);
>
> desc = av_pix_fmt_desc_get(avctx->pix_fmt);
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index a91a54b0dc..4d236ff1cd 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -436,17 +436,6 @@ void ff_color_frame(AVFrame *frame, const int c[4])
> }
> }
>
> -enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags,
> - unsigned int fourcc)
> -{
> - while (tags->pix_fmt >= 0) {
> - if (tags->fourcc == fourcc)
> - return tags->pix_fmt;
> - tags++;
> - }
> - return AV_PIX_FMT_NONE;
> -}
> -
> int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec){
> return !!(codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM);
> }
> diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
> index ef78781865..ec1501ef8e 100644
> --- a/libavdevice/dshow.c
> +++ b/libavdevice/dshow.c
> @@ -51,7 +51,7 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount)
> return AV_PIX_FMT_0RGB32;
> }
> }
> - return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others
> + return avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, biCompression); // all others
> }
>
> static int
> diff --git a/libavformat/avienc.c b/libavformat/avienc.c
> index 3fbde0be1e..be2493ce55 100644
> --- a/libavformat/avienc.c
> +++ b/libavformat/avienc.c
> @@ -448,7 +448,7 @@ static int avi_write_header(AVFormatContext *s)
> par->bits_per_coded_sample = 16;
> avist->pal_offset = avio_tell(pb) + 40;
> ff_put_bmp_header(pb, par, 0, 0, avi->flipped_raw_rgb);
> - pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
> + pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_AVI,
> par->bits_per_coded_sample);
> if ( !par->codec_tag
> && par->codec_id == AV_CODEC_ID_RAWVIDEO
> diff --git a/libavformat/demux.c b/libavformat/demux.c
> index 745dc8687c..360abd6014 100644
> --- a/libavformat/demux.c
> +++ b/libavformat/demux.c
> @@ -2795,7 +2795,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
> if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
> if (avctx->codec_id == AV_CODEC_ID_RAWVIDEO && !avctx->codec_tag && !avctx->bits_per_coded_sample) {
> uint32_t tag= avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
> - if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) == avctx->pix_fmt)
> + if (avpriv_pix_fmt_find(PIX_FMT_LIST_RAW, tag) == avctx->pix_fmt)
> avctx->codec_tag= tag;
> }
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 0f912dd012..7216331fa1 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1636,7 +1636,7 @@ static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
> }
> }
>
> - pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_mov,
> + pix_fmt = avpriv_pix_fmt_find(PIX_FMT_LIST_MOV,
> track->par->bits_per_coded_sample);
> if (tag == MKTAG('r','a','w',' ') &&
> track->par->format != pix_fmt &&
>
Will apply this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 03/11] Makefile: Redo duplicating object files in shared builds
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab Andreas Rheinhardt
` (12 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
In case of shared builds, some object files containing tables
are currently duplicated into other libraries: log2_tab.c,
golomb.c, reverse.c. The check for whether this is duplicated
is simply whether CONFIG_SHARED is true. Yet this is crude:
E.g. libavdevice includes reverse.c for shared builds, but only
needs it for the decklink input device, which given that decklink
is not enabled by default will be unused in most libavdevice.so.
This commit changes this by making it more explicit about what
to duplicate from other libraries. To do this, two new Makefile
variables were added: SHLIBOBJS and STLIBOBJS. SHLIBOBJS contains
the objects that are duplicated from other libraries in case of
shared builds; STLIBOBJS contains stuff that a library has to
provide for other libraries in case of static builds. These new
variables provide a way to enable/disable with a finer granularity
than just whether shared builds are enabled or not. E.g. lavd's
Makefile now contains: SHLIBOBJS-$(CONFIG_DECKLINK_INDEV) += reverse.o
Another example is provided by the golomb tables. These are provided
by lavc for static builds, even if one uses a build configuration
that makes only lavf use them. Therefore lavc's Makefile contains
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o, whereas lavf's Makefile
has a corresponding SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o.
E.g. in case the MXF muxer is the only component needing these tables
only libavformat.so will contain them for shared builds; currently
libavcodec.so does so, too.
(There is currently a CONFIG_EXTRA group for golomb. But actually
one would need two groups (golomb_avcodec and golomb_avformat) in
order to know when and where to include these tables. Therefore
this commit uses a Makefile-based approach for this and stops
using these groups for the users in libavformat.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Makefile | 2 +-
configure | 4 ++--
ffbuild/common.mak | 10 ++++++++--
ffbuild/library.mak | 22 +++++++++++++++++++---
libavcodec/Makefile | 10 ++++++++--
libavdevice/Makefile | 4 +++-
libavfilter/Makefile | 5 +++--
libavformat/Makefile | 6 +++++-
libswresample/Makefile | 4 +++-
libswscale/Makefile | 3 ++-
10 files changed, 54 insertions(+), 16 deletions(-)
diff --git a/Makefile b/Makefile
index 26c9107237..fd6a7f0230 100644
--- a/Makefile
+++ b/Makefile
@@ -89,7 +89,7 @@ SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS \
ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
- MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
+ MMI-OBJS OBJS SLIBOBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS
define RESET
$(1) :=
diff --git a/configure b/configure
index a7593ec2db..ab1b9f6b66 100755
--- a/configure
+++ b/configure
@@ -3419,7 +3419,7 @@ mp4_muxer_select="mov_muxer"
mpegts_demuxer_select="iso_media"
mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf hevc_mp4toannexb_bsf"
mpegtsraw_demuxer_select="mpegts_demuxer"
-mxf_muxer_select="golomb pcm_rechunk_bsf"
+mxf_muxer_select="pcm_rechunk_bsf"
mxf_d10_muxer_select="mxf_muxer"
mxf_opatom_muxer_select="mxf_muxer"
nut_muxer_select="riffenc"
@@ -3432,7 +3432,7 @@ ogv_muxer_select="ogg_muxer"
opus_muxer_select="ogg_muxer"
psp_muxer_select="mov_muxer"
rtp_demuxer_select="sdp_demuxer"
-rtp_muxer_select="golomb jpegtables"
+rtp_muxer_select="jpegtables"
rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
rtsp_demuxer_select="http_protocol rtpdec"
diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index 268ae61154..616d39ddba 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -140,6 +140,8 @@ include $(SRC_PATH)/ffbuild/arch.mak
OBJS += $(OBJS-yes)
SLIBOBJS += $(SLIBOBJS-yes)
+SHLIBOBJS += $(SHLIBOBJS-yes)
+STLIBOBJS += $(STLIBOBJS-yes)
FFLIBS := $($(NAME)_FFLIBS) $(FFLIBS-yes) $(FFLIBS)
TESTPROGS += $(TESTPROGS-yes)
@@ -148,6 +150,8 @@ FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(foreach lib,EXTRALIBS-$(NAME) $(FFLIBS:%=
OBJS := $(sort $(OBJS:%=$(SUBDIR)%))
SLIBOBJS := $(sort $(SLIBOBJS:%=$(SUBDIR)%))
+SHLIBOBJS := $(sort $(SHLIBOBJS:%=$(SUBDIR)%))
+STLIBOBJS := $(sort $(STLIBOBJS:%=$(SUBDIR)%))
TESTOBJS := $(TESTOBJS:%=$(SUBDIR)tests/%) $(TESTPROGS:%=$(SUBDIR)tests/%.o)
TESTPROGS := $(TESTPROGS:%=$(SUBDIR)tests/%$(EXESUF))
HOSTOBJS := $(HOSTPROGS:%=$(SUBDIR)%.o)
@@ -183,10 +187,12 @@ $(OBJS): | $(sort $(dir $(OBJS)))
$(HOBJS): | $(sort $(dir $(HOBJS)))
$(HOSTOBJS): | $(sort $(dir $(HOSTOBJS)))
$(SLIBOBJS): | $(sort $(dir $(SLIBOBJS)))
+$(SHLIBOBJS): | $(sort $(dir $(SHLIBOBJS)))
+$(STLIBOBJS): | $(sort $(dir $(STLIBOBJS)))
$(TESTOBJS): | $(sort $(dir $(TESTOBJS)))
$(TOOLOBJS): | tools
-OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
+OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(SHLIBOBJS) $(STLIBOBJS) $(TESTOBJS))
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.pc *.ptx *.ptx.gz *.ptx.c *.ver *.version *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
@@ -198,4 +204,4 @@ endef
$(eval $(RULES))
--include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)
+-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SHLIBOBJS:.o=.d) $(STLIBOBJS:.o=.d) $(SLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)
diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 612bacb980..ad09f20da9 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -14,10 +14,26 @@ INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(FULLNAME).pc
all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(FULLNAME).pc
-LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS)
+LIBOBJS := $(OBJS) $(SHLIBOBJS) $(STLIBOBJS) $(SUBDIR)%.h.o $(TESTOBJS)
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
-$(SUBDIR)$(LIBNAME): $(OBJS)
+ifdef CONFIG_SHARED
+# In case both shared libs and static libs are enabled, it can happen
+# that a user might want to link e.g. libavformat statically, but
+# libavcodec and the other libs dynamically. In this case
+# libavformat won't be able to access libavcodec's internal symbols,
+# so that they have to be duplicated into the archive just like
+# for purely shared builds.
+# Test programs are always statically linked against their library
+# to be able to access their library's internals, even with shared builds.
+# Yet linking against dependend libraries still uses dynamic linking.
+# This means that we are in the scenario described above.
+# In case only static libs are used, the linker will only use
+# one of these copies; this depends on the duplicated object files
+# containing exactly the same symbols.
+OBJS += $(SHLIBOBJS)
+endif
+$(SUBDIR)$(LIBNAME): $(OBJS) $(STLIBOBJS)
$(RM) $@
$(AR) $(ARFLAGS) $(AR_O) $^
$(RANLIB) $@
@@ -48,7 +64,7 @@ $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS)
$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
$(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
-$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
+$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SLIBOBJS) $(SUBDIR)lib$(NAME).ver
$(SLIB_CREATE_DEF_CMD)
$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
$(SLIB_EXTRA_CMD)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fb90ecea84..d855f5a229 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -139,7 +139,6 @@ OBJS-$(CONFIG_QSVENC) += qsvenc.o
OBJS-$(CONFIG_RANGECODER) += rangecoder.o
OBJS-$(CONFIG_RDFT) += rdft.o
OBJS-$(CONFIG_RV34DSP) += rv34dsp.o
-OBJS-$(CONFIG_SHARED) += log2_tab.o reverse.o
OBJS-$(CONFIG_SINEWIN) += sinewin.o
OBJS-$(CONFIG_SNAPPY) += snappy.o
OBJS-$(CONFIG_STARTCODE) += startcode.o
@@ -979,7 +978,10 @@ OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o
OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) += videotoolbox_vp9.o
OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o
-# libavformat dependencies
+# Objects duplicated from other libraries for shared builds
+SHLIBOBJS += log2_tab.o reverse.o
+
+# General libavformat dependencies
OBJS-$(CONFIG_ISO_MEDIA) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o
@@ -995,6 +997,10 @@ OBJS-$(CONFIG_SPDIF_MUXER) += dca.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o
+# libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
+STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o
+
# libavfilter dependencies
OBJS-$(CONFIG_ELBG_FILTER) += elbg.o
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 0dfe47a1f4..53efda0514 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -9,7 +9,6 @@ OBJS = alldevices.o \
utils.o \
OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o
-OBJS-$(CONFIG_SHARED) += reverse.o
# input/output devices
OBJS-$(CONFIG_ALSA_INDEV) += alsa_dec.o alsa.o timefilter.o
@@ -54,6 +53,9 @@ OBJS-$(CONFIG_XV_OUTDEV) += xv.o
OBJS-$(CONFIG_LIBCDIO_INDEV) += libcdio.o
OBJS-$(CONFIG_LIBDC1394_INDEV) += libdc1394.o
+# Objects duplicated from other libraries for shared builds
+SHLIBOBJS-$(CONFIG_DECKLINK_INDEV) += reverse.o
+
# Windows resource file
SLIBOBJS-$(HAVE_GNU_WINDRES) += avdeviceres.o
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 2fe495df28..f4f077af46 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -572,13 +572,14 @@ OBJS-$(CONFIG_SPECTRUMSYNTH_FILTER) += vaf_spectrumsynth.o
OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
OBJS-$(CONFIG_MOVIE_FILTER) += src_movie.o
+# Objects duplicated from other libraries for shared builds
+SHLIBOBJS += log2_tab.o
+
# Windows resource file
SLIBOBJS-$(HAVE_GNU_WINDRES) += avfilterres.o
SKIPHEADERS-$(CONFIG_LIBVIDSTAB) += vidstabutils.h
-OBJS-$(CONFIG_SHARED) += log2_tab.o
-
SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h
SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_vpp.h
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2b5caf9d33..2b5bb43745 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -61,7 +61,6 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \
rtpdec_vp9.o \
rtpdec_xiph.o
OBJS-$(CONFIG_RTPENC_CHAIN) += rtpenc_chain.o rtp.o
-OBJS-$(CONFIG_SHARED) += log2_tab.o golomb_tab.o
OBJS-$(CONFIG_SRTP) += srtp.o
# muxers/demuxers
@@ -677,6 +676,11 @@ OBJS-$(CONFIG_LIBSRT_PROTOCOL) += libsrt.o
OBJS-$(CONFIG_LIBSSH_PROTOCOL) += libssh.o
OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o
+# Objects duplicated from other libraries for shared builds
+SHLIBOBJS += log2_tab.o
+SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
+SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o
+
# libavdevice dependencies
OBJS-$(CONFIG_IEC61883_INDEV) += dv.o
diff --git a/libswresample/Makefile b/libswresample/Makefile
index 42666e4dd2..f528427f55 100644
--- a/libswresample/Makefile
+++ b/libswresample/Makefile
@@ -15,7 +15,9 @@ OBJS = audioconvert.o \
swresample_frame.o \
OBJS-$(CONFIG_LIBSOXR) += soxr_resample.o
-OBJS-$(CONFIG_SHARED) += log2_tab.o
+
+# Objects duplicated from other libraries for shared builds
+SHLIBOBJS += log2_tab.o
# Windows resource file
SLIBOBJS-$(HAVE_GNU_WINDRES) += swresampleres.o
diff --git a/libswscale/Makefile b/libswscale/Makefile
index 4b8f9de425..a0ec71e06f 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -19,7 +19,8 @@ OBJS = alphablend.o \
yuv2rgb.o \
vscale.o \
-OBJS-$(CONFIG_SHARED) += log2_tab.o
+# Objects duplicated from other libraries for shared builds
+SHLIBOBJS += log2_tab.o
# Windows resource file
SLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 02/11] avcodec/raw: Reduce number of avpriv symbols Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 03/11] Makefile: Redo duplicating object files in shared builds Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-30 10:12 ` Anton Khirnov
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 05/11] avcodec/dca: Unavpriv dca_sample_rates Andreas Rheinhardt
` (11 subsequent siblings)
14 siblings, 1 reply; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is small (16 B) and therefore the overhead of exporting it more
than outweighs the size savings from not having duplicated symbols:
When the symbol is no longer avpriv, one saves twice the size of
the string containing the symbols name (2x30 byte), two entries
in .dynsym (24 bytes each on x64), one entry in the importing libraries
.got and .rela.dyn (8 + 24 bytes on x64) and two entries for the
symbol version (2 bytes each) and one hash value in the exporting
library (4 bytes).
(The exact numbers are of course different for other platforms
(e.g. when using dlls), but given that the strings saved alone
more than outweigh the array size it can be presumed that this
is beneficial for all platforms.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 12 +++++---
libavcodec/ac3_channel_layout_tab.c | 22 +++++++++++++++
libavcodec/ac3_channel_layout_tab.h | 41 ++++++++++++++++++++++++++++
libavcodec/ac3_parser.c | 2 +-
libavcodec/ac3dec.c | 4 +--
libavcodec/ac3enc.h | 1 +
libavcodec/ac3tab.c | 14 ----------
libavcodec/ac3tab.h | 4 +--
libavcodec/eac3_data.c | 2 ++
libavformat/Makefile | 2 ++
libavformat/ac3_channel_layout_tab.c | 22 +++++++++++++++
libavformat/hls_sample_encryption.c | 4 ++-
libavformat/mov.c | 4 +--
13 files changed, 107 insertions(+), 27 deletions(-)
create mode 100644 libavcodec/ac3_channel_layout_tab.c
create mode 100644 libavcodec/ac3_channel_layout_tab.h
create mode 100644 libavformat/ac3_channel_layout_tab.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d855f5a229..36a1a1a4de 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -174,8 +174,10 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
psymodel.o mpeg4audio.o kbdwin.o
OBJS-$(CONFIG_AAC_MF_ENCODER) += mfenc.o mf_utils.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
-OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o
-OBJS-$(CONFIG_AC3_FIXED_DECODER) += ac3dec_fixed.o ac3dec_data.o ac3.o kbdwin.o ac3tab.o
+OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o \
+ kbdwin.o ac3tab.o ac3_channel_layout_tab.o
+OBJS-$(CONFIG_AC3_FIXED_DECODER) += ac3dec_fixed.o ac3dec_data.o ac3.o \
+ kbdwin.o ac3tab.o ac3_channel_layout_tab.o
OBJS-$(CONFIG_AC3_ENCODER) += ac3enc_float.o ac3enc.o ac3tab.o \
ac3.o kbdwin.o
OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o kbdwin.o
@@ -989,7 +991,6 @@ OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o
-OBJS-$(CONFIG_MOV_DEMUXER) += ac3tab.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o
@@ -998,6 +999,8 @@ OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o
# libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
+STLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o
@@ -1084,7 +1087,8 @@ OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o ass.o
OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \
mpeg4audio.o
-OBJS-$(CONFIG_AC3_PARSER) += ac3tab.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_AMR_PARSER) += amr_parser.o
OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o
diff --git a/libavcodec/ac3_channel_layout_tab.c b/libavcodec/ac3_channel_layout_tab.c
new file mode 100644
index 0000000000..4fed46b6e7
--- /dev/null
+++ b/libavcodec/ac3_channel_layout_tab.c
@@ -0,0 +1,22 @@
+/*
+ * AC-3 channel layout table
+ * copyright (c) 2001 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
+ */
+
+#include "ac3_channel_layout_tab.h"
diff --git a/libavcodec/ac3_channel_layout_tab.h b/libavcodec/ac3_channel_layout_tab.h
new file mode 100644
index 0000000000..46fa9ecdfe
--- /dev/null
+++ b/libavcodec/ac3_channel_layout_tab.h
@@ -0,0 +1,41 @@
+/*
+ * AC-3 channel layout table
+ * copyright (c) 2001 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_AC3_CHANNEL_LAYOUT_TAB_H
+#define AVCODEC_AC3_CHANNEL_LAYOUT_TAB_H
+
+#include <stdint.h>
+#include "libavutil/channel_layout.h"
+
+/**
+ * Map audio coding mode (acmod) to channel layout mask.
+ */
+const uint16_t ff_ac3_channel_layout_tab[8] = {
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_MONO,
+ AV_CH_LAYOUT_STEREO,
+ AV_CH_LAYOUT_SURROUND,
+ AV_CH_LAYOUT_2_1,
+ AV_CH_LAYOUT_4POINT0,
+ AV_CH_LAYOUT_2_2,
+ AV_CH_LAYOUT_5POINT0
+};
+#endif
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 9ed6ede5c3..f3c7d27d59 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -141,7 +141,7 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
(hdr->num_blocks * 256);
hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
}
- hdr->channel_layout = avpriv_ac3_channel_layout_tab[hdr->channel_mode];
+ hdr->channel_layout = ff_ac3_channel_layout_tab[hdr->channel_mode];
if (hdr->lfe_on)
hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index c7deb56e1c..ae00373dcb 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1616,7 +1616,7 @@ dependent_frame:
return AVERROR_INVALIDDATA;
}
avctx->channels = s->out_channels;
- avctx->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
+ avctx->channel_layout = ff_ac3_channel_layout_tab[s->output_mode & ~AC3_OUTPUT_LFEON];
if (s->output_mode & AC3_OUTPUT_LFEON)
avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
@@ -1700,7 +1700,7 @@ skip:
extended_channel_map[ch] = ch;
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
- uint64_t ich_layout = avpriv_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON];
+ uint64_t ich_layout = ff_ac3_channel_layout_tab[s->prev_output_mode & ~AC3_OUTPUT_LFEON];
int channel_map_size = ff_ac3_channels_tab[s->output_mode & ~AC3_OUTPUT_LFEON] + s->lfe_on;
uint64_t channel_layout;
int extend = 0;
diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
index ec9ead8a4e..39a41fe0b0 100644
--- a/libavcodec/ac3enc.h
+++ b/libavcodec/ac3enc.h
@@ -35,6 +35,7 @@
#include "ac3dsp.h"
#include "avcodec.h"
#include "fft.h"
+#include "internal.h"
#include "mathops.h"
#include "me_cmp.h"
#include "put_bits.h"
diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
index 5c5ea7e27e..766e293a1d 100644
--- a/libavcodec/ac3tab.c
+++ b/libavcodec/ac3tab.c
@@ -82,20 +82,6 @@ const uint8_t ff_ac3_channels_tab[8] = {
2, 1, 2, 3, 3, 4, 4, 5
};
-/**
- * Map audio coding mode (acmod) to channel layout mask.
- */
-const uint16_t avpriv_ac3_channel_layout_tab[8] = {
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_2_1,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_2_2,
- AV_CH_LAYOUT_5POINT0
-};
-
/**
* Table to remap channels from AC-3 order to SMPTE order.
* [channel_mode][lfe][ch]
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index ea8e3340c7..bc470204fe 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -24,13 +24,11 @@
#include <stdint.h>
-#include "libavutil/internal.h"
#include "ac3.h"
-#include "internal.h"
extern const uint16_t ff_ac3_frame_size_tab[38][3];
extern const uint8_t ff_ac3_channels_tab[8];
-extern av_export_avcodec const uint16_t avpriv_ac3_channel_layout_tab[8];
+extern const uint16_t ff_ac3_channel_layout_tab[8];
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
extern const int ff_ac3_sample_rate_tab[];
extern const uint16_t ff_ac3_bitrate_tab[19];
diff --git a/libavcodec/eac3_data.c b/libavcodec/eac3_data.c
index b159e1682f..2ef0e2053c 100644
--- a/libavcodec/eac3_data.c
+++ b/libavcodec/eac3_data.c
@@ -24,6 +24,8 @@
* Tables taken directly from the E-AC-3 spec.
*/
+#include <stddef.h>
+
#include "eac3_data.h"
#include "ac3.h"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 2b5bb43745..e30d34f924 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -678,6 +678,8 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o
# Objects duplicated from other libraries for shared builds
SHLIBOBJS += log2_tab.o
+SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
+SHLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o
diff --git a/libavformat/ac3_channel_layout_tab.c b/libavformat/ac3_channel_layout_tab.c
new file mode 100644
index 0000000000..cba198ccc5
--- /dev/null
+++ b/libavformat/ac3_channel_layout_tab.c
@@ -0,0 +1,22 @@
+/*
+ * AC-3 channel layout table
+ * copyright (c) 2001 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
+ */
+
+#include "libavcodec/ac3_channel_layout_tab.h"
diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c
index 38795c7fb0..3dbaff717e 100644
--- a/libavformat/hls_sample_encryption.c
+++ b/libavformat/hls_sample_encryption.c
@@ -26,6 +26,8 @@
* https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
*/
+#include "libavutil/channel_layout.h"
+
#include "hls_sample_encryption.h"
#include "libavcodec/adts_header.h"
@@ -129,7 +131,7 @@ int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info)
st->codecpar->sample_rate = eac3_sample_rate_tab[fscod];
- st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+ st->codecpar->channel_layout = ff_ac3_channel_layout_tab[acmod];
if (lfeon)
st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9ebfa0bcc7..1f11f0f7ae 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -810,7 +810,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
acmod = (ac3info >> 11) & 0x7;
lfeon = (ac3info >> 10) & 0x1;
st->codecpar->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
- st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+ st->codecpar->channel_layout = ff_ac3_channel_layout_tab[acmod];
if (lfeon)
st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
*ast = bsmod;
@@ -843,7 +843,7 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
bsmod = (eac3info >> 12) & 0x1f;
acmod = (eac3info >> 9) & 0x7;
lfeon = (eac3info >> 8) & 0x1;
- st->codecpar->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+ st->codecpar->channel_layout = ff_ac3_channel_layout_tab[acmod];
if (lfeon)
st->codecpar->channel_layout |= AV_CH_LOW_FREQUENCY;
st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout);
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab
@ 2021-12-30 10:12 ` Anton Khirnov
2021-12-31 13:28 ` Andreas Rheinhardt
0 siblings, 1 reply; 23+ messages in thread
From: Anton Khirnov @ 2021-12-30 10:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt
Quoting Andreas Rheinhardt (2021-12-15 13:35:34)
> It is small (16 B) and therefore the overhead of exporting it more
> than outweighs the size savings from not having duplicated symbols:
> When the symbol is no longer avpriv, one saves twice the size of
> the string containing the symbols name (2x30 byte), two entries
> in .dynsym (24 bytes each on x64), one entry in the importing libraries
> .got and .rela.dyn (8 + 24 bytes on x64) and two entries for the
> symbol version (2 bytes each) and one hash value in the exporting
> library (4 bytes).
> (The exact numbers are of course different for other platforms
> (e.g. when using dlls), but given that the strings saved alone
> more than outweigh the array size it can be presumed that this
> is beneficial for all platforms.)
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/Makefile | 12 +++++---
> libavcodec/ac3_channel_layout_tab.c | 22 +++++++++++++++
> libavcodec/ac3_channel_layout_tab.h | 41 ++++++++++++++++++++++++++++
> libavcodec/ac3_parser.c | 2 +-
> libavcodec/ac3dec.c | 4 +--
> libavcodec/ac3enc.h | 1 +
> libavcodec/ac3tab.c | 14 ----------
> libavcodec/ac3tab.h | 4 +--
> libavcodec/eac3_data.c | 2 ++
> libavformat/Makefile | 2 ++
> libavformat/ac3_channel_layout_tab.c | 22 +++++++++++++++
> libavformat/hls_sample_encryption.c | 4 ++-
> libavformat/mov.c | 4 +--
> 13 files changed, 107 insertions(+), 27 deletions(-)
> create mode 100644 libavcodec/ac3_channel_layout_tab.c
> create mode 100644 libavcodec/ac3_channel_layout_tab.h
> create mode 100644 libavformat/ac3_channel_layout_tab.c
>
> diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
> index ec9ead8a4e..39a41fe0b0 100644
> --- a/libavcodec/ac3enc.h
> +++ b/libavcodec/ac3enc.h
> @@ -35,6 +35,7 @@
> #include "ac3dsp.h"
> #include "avcodec.h"
> #include "fft.h"
> +#include "internal.h"
?
> diff --git a/libavcodec/eac3_data.c b/libavcodec/eac3_data.c
> index b159e1682f..2ef0e2053c 100644
> --- a/libavcodec/eac3_data.c
> +++ b/libavcodec/eac3_data.c
> @@ -24,6 +24,8 @@
> * Tables taken directly from the E-AC-3 spec.
> */
>
> +#include <stddef.h>
??
> diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c
> index 38795c7fb0..3dbaff717e 100644
> --- a/libavformat/hls_sample_encryption.c
> +++ b/libavformat/hls_sample_encryption.c
> @@ -26,6 +26,8 @@
> * https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
> */
>
> +#include "libavutil/channel_layout.h"
???
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab
2021-12-30 10:12 ` Anton Khirnov
@ 2021-12-31 13:28 ` Andreas Rheinhardt
0 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-31 13:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Anton Khirnov:
> Quoting Andreas Rheinhardt (2021-12-15 13:35:34)
>> It is small (16 B) and therefore the overhead of exporting it more
>> than outweighs the size savings from not having duplicated symbols:
>> When the symbol is no longer avpriv, one saves twice the size of
>> the string containing the symbols name (2x30 byte), two entries
>> in .dynsym (24 bytes each on x64), one entry in the importing libraries
>> .got and .rela.dyn (8 + 24 bytes on x64) and two entries for the
>> symbol version (2 bytes each) and one hash value in the exporting
>> library (4 bytes).
>> (The exact numbers are of course different for other platforms
>> (e.g. when using dlls), but given that the strings saved alone
>> more than outweigh the array size it can be presumed that this
>> is beneficial for all platforms.)
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> libavcodec/Makefile | 12 +++++---
>> libavcodec/ac3_channel_layout_tab.c | 22 +++++++++++++++
>> libavcodec/ac3_channel_layout_tab.h | 41 ++++++++++++++++++++++++++++
>> libavcodec/ac3_parser.c | 2 +-
>> libavcodec/ac3dec.c | 4 +--
>> libavcodec/ac3enc.h | 1 +
>> libavcodec/ac3tab.c | 14 ----------
>> libavcodec/ac3tab.h | 4 +--
>> libavcodec/eac3_data.c | 2 ++
>> libavformat/Makefile | 2 ++
>> libavformat/ac3_channel_layout_tab.c | 22 +++++++++++++++
>> libavformat/hls_sample_encryption.c | 4 ++-
>> libavformat/mov.c | 4 +--
>> 13 files changed, 107 insertions(+), 27 deletions(-)
>> create mode 100644 libavcodec/ac3_channel_layout_tab.c
>> create mode 100644 libavcodec/ac3_channel_layout_tab.h
>> create mode 100644 libavformat/ac3_channel_layout_tab.c
>>
>> diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h
>> index ec9ead8a4e..39a41fe0b0 100644
>> --- a/libavcodec/ac3enc.h
>> +++ b/libavcodec/ac3enc.h
>> @@ -35,6 +35,7 @@
>> #include "ac3dsp.h"
>> #include "avcodec.h"
>> #include "fft.h"
>> +#include "internal.h"
>
> ?
Before this commit, ac3tab.h included internal.h for av_export_avcodec
and ac3enc.h indirectly includes ac3tab.h via ac3.h. Yet ac3enc.h
provides ff_ac3_enc_defaults of type AVCodecDefaults. This type is
defined in internal.h, so ac3enc.h should properly include internal.h.
>
>> diff --git a/libavcodec/eac3_data.c b/libavcodec/eac3_data.c
>> index b159e1682f..2ef0e2053c 100644
>> --- a/libavcodec/eac3_data.c
>> +++ b/libavcodec/eac3_data.c
>> @@ -24,6 +24,8 @@
>> * Tables taken directly from the E-AC-3 spec.
>> */
>>
>> +#include <stddef.h>
>
> ??
This file has a NULL which it got implicitly via internal.h included by
ac3tab.h (yes, really). This has been changed, so this header needs to
be added.
>
>> diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c
>> index 38795c7fb0..3dbaff717e 100644
>> --- a/libavformat/hls_sample_encryption.c
>> +++ b/libavformat/hls_sample_encryption.c
>> @@ -26,6 +26,8 @@
>> * https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption
>> */
>>
>> +#include "libavutil/channel_layout.h"
This header (which uses e.g. AV_CH_LOW_FREQUENCY and
av_get_channel_layout_nb_channels()) is currently implicitly included
via libavcodec/internal.h included by ac3tab.h.
>
> ???
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 05/11] avcodec/dca: Unavpriv dca_sample_rates
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (2 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 04/11] avcodec/ac3tab: Unavpriv ac3_channel_layout_tab Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 06/11] avcodec/jpegtables: Unavpriv MJPEG-tables Andreas Rheinhardt
` (10 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Said table is 64 bytes long and exported so that it can be used both
in libavcodec and libavformat. This commit stops doing so and instead
duplicates it for shared builds, because the overhead of exporting the
symbol is bigger than 64 bytes. It consists of the length of the name of
the symbol (2x24 bytes), two entries in .dynsym (2x24 bytes), two
entries for symbol version (2x2 bytes), one hash value in the exporting
library (4 bytes) in addition to one entry in the importing library's
.got and .rela.dyn (8 + 24 bytes).
(The above numbers are for a Linux/GNU/Elf system; the numbers for other
platforms may be different.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 8 +++++---
libavcodec/dca.c | 7 +------
libavcodec/dca.h | 4 +---
libavcodec/dca_core.c | 2 +-
libavcodec/dca_parser.c | 2 +-
libavcodec/dca_sample_rate_tab.c | 25 +++++++++++++++++++++++
libavcodec/dca_sample_rate_tab.h | 33 +++++++++++++++++++++++++++++++
libavformat/Makefile | 1 +
libavformat/dca_sample_rate_tab.c | 25 +++++++++++++++++++++++
libavformat/spdifenc.c | 2 +-
10 files changed, 94 insertions(+), 15 deletions(-)
create mode 100644 libavcodec/dca_sample_rate_tab.c
create mode 100644 libavcodec/dca_sample_rate_tab.h
create mode 100644 libavformat/dca_sample_rate_tab.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 36a1a1a4de..e4a547ffaa 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -275,7 +275,8 @@ OBJS-$(CONFIG_CSCD_DECODER) += cscd.o
OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \
dca_core.o dca_exss.o dca_xll.o dca_lbr.o \
- dcadsp.o dcadct.o synth_filter.o
+ dcadsp.o dcadct.o dca_sample_rate_tab.o \
+ synth_filter.o
OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dcadata.o dcahuff.o \
dcaadpcm.o
OBJS-$(CONFIG_DDS_DECODER) += dds.o
@@ -994,7 +995,6 @@ OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o
-OBJS-$(CONFIG_SPDIF_MUXER) += dca.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o
@@ -1003,6 +1003,7 @@ STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o
+STLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o
# libavfilter dependencies
OBJS-$(CONFIG_ELBG_FILTER) += elbg.o
@@ -1098,7 +1099,8 @@ OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o
OBJS-$(CONFIG_CAVSVIDEO_PARSER) += cavs_parser.o
OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o
OBJS-$(CONFIG_CRI_PARSER) += cri_parser.o
-OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o dca_exss.o dca.o
+OBJS-$(CONFIG_DCA_PARSER) += dca_parser.o dca_exss.o dca.o \
+ dca_sample_rate_tab.o
OBJS-$(CONFIG_DIRAC_PARSER) += dirac_parser.o
OBJS-$(CONFIG_DNXHD_PARSER) += dnxhd_parser.o dnxhddata.o
OBJS-$(CONFIG_DOLBY_E_PARSER) += dolby_e_parser.o dolby_e_parse.o
diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index b2152524a5..fb359b2ff3 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -33,11 +33,6 @@
#include "get_bits.h"
#include "put_bits.h"
-const uint32_t avpriv_dca_sample_rates[16] = {
- 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
- 12000, 24000, 48000, 96000, 192000
-};
-
const uint32_t ff_dca_sampling_freqs[16] = {
8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
@@ -112,7 +107,7 @@ int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb)
return DCA_PARSE_ERROR_AMODE;
h->sr_code = get_bits(gb, 4);
- if (!avpriv_dca_sample_rates[h->sr_code])
+ if (!ff_dca_sample_rates[h->sr_code])
return DCA_PARSE_ERROR_SAMPLE_RATE;
h->br_code = get_bits(gb, 5);
diff --git a/libavcodec/dca.h b/libavcodec/dca.h
index e96c589c02..6be975fdfa 100644
--- a/libavcodec/dca.h
+++ b/libavcodec/dca.h
@@ -32,7 +32,6 @@
#include "libavutil/intreadwrite.h"
#include "get_bits.h"
-#include "internal.h"
#define DCA_CORE_FRAME_HEADER_SIZE 18
@@ -195,8 +194,7 @@ enum DCADownMixType {
DCA_DMIX_TYPE_COUNT
};
-extern av_export_avcodec const uint32_t avpriv_dca_sample_rates[16];
-
+extern const uint32_t ff_dca_sample_rates[16];
extern const uint32_t ff_dca_sampling_freqs[16];
extern const uint8_t ff_dca_freq_ranges[16];
extern const uint8_t ff_dca_bits_per_sample[8];
diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index f0a3c18d62..758e3447a6 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -129,7 +129,7 @@ static int parse_frame_header(DCACoreDecoder *s)
s->npcmblocks = h.npcmblocks;
s->frame_size = h.frame_size;
s->audio_mode = h.audio_mode;
- s->sample_rate = avpriv_dca_sample_rates[h.sr_code];
+ s->sample_rate = ff_dca_sample_rates[h.sr_code];
s->bit_rate = ff_dca_bit_rates[h.br_code];
s->drc_present = h.drc_present;
s->ts_present = h.ts_present;
diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index 8b5c354312..3148397b7d 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -267,7 +267,7 @@ static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
return AVERROR_INVALIDDATA;
*duration = h.npcmblocks * DCA_PCMBLOCK_SAMPLES;
- *sample_rate = avpriv_dca_sample_rates[h.sr_code];
+ *sample_rate = ff_dca_sample_rates[h.sr_code];
if (*profile != FF_PROFILE_UNKNOWN)
return 0;
diff --git a/libavcodec/dca_sample_rate_tab.c b/libavcodec/dca_sample_rate_tab.c
new file mode 100644
index 0000000000..16ee04b1d2
--- /dev/null
+++ b/libavcodec/dca_sample_rate_tab.c
@@ -0,0 +1,25 @@
+/*
+ * DCA sample rates
+ * Copyright (C) 2004 Gildas Bazin
+ * Copyright (C) 2004 Benjamin Zores
+ * Copyright (C) 2006 Benjamin Larsson
+ * Copyright (C) 2007 Konstantin Shishkov
+ *
+ * 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 "dca_sample_rate_tab.h"
diff --git a/libavcodec/dca_sample_rate_tab.h b/libavcodec/dca_sample_rate_tab.h
new file mode 100644
index 0000000000..93d9a13663
--- /dev/null
+++ b/libavcodec/dca_sample_rate_tab.h
@@ -0,0 +1,33 @@
+/*
+ * DCA sample rates
+ * Copyright (C) 2004 Gildas Bazin
+ * Copyright (C) 2004 Benjamin Zores
+ * Copyright (C) 2006 Benjamin Larssonb
+ * Copyright (C) 2007 Konstantin Shishkov
+ *
+ * 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_DCA_SAMPLE_RATE_TAB_H
+#define AVCODEC_DCA_SAMPLE_RATE_TAB_H
+#include <stdint.h>
+
+const uint32_t ff_dca_sample_rates[16] = {
+ 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
+ 12000, 24000, 48000, 96000, 192000
+};
+#endif
diff --git a/libavformat/Makefile b/libavformat/Makefile
index e30d34f924..8f05b8d83c 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -682,6 +682,7 @@ SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o
+SHLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o
# libavdevice dependencies
OBJS-$(CONFIG_IEC61883_INDEV) += dv.o
diff --git a/libavformat/dca_sample_rate_tab.c b/libavformat/dca_sample_rate_tab.c
new file mode 100644
index 0000000000..ed2380b0cd
--- /dev/null
+++ b/libavformat/dca_sample_rate_tab.c
@@ -0,0 +1,25 @@
+/*
+ * DCA sample rates
+ * Copyright (C) 2004 Gildas Bazin
+ * Copyright (C) 2004 Benjamin Zores
+ * Copyright (C) 2006 Benjamin Larsson
+ * Copyright (C) 2007 Konstantin Shishkov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/dca_sample_rate_tab.h"
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index e8f54bff4b..3be89328df 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -263,7 +263,7 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
case DCA_SYNCWORD_CORE_BE:
blocks = (AV_RB16(pkt->data + 4) >> 2) & 0x7f;
core_size = ((AV_RB24(pkt->data + 5) >> 4) & 0x3fff) + 1;
- sample_rate = avpriv_dca_sample_rates[(pkt->data[8] >> 2) & 0x0f];
+ sample_rate = ff_dca_sample_rates[(pkt->data[8] >> 2) & 0x0f];
break;
case DCA_SYNCWORD_CORE_LE:
blocks = (AV_RL16(pkt->data + 4) >> 2) & 0x7f;
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 06/11] avcodec/jpegtables: Unavpriv MJPEG-tables
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (3 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 05/11] avcodec/dca: Unavpriv dca_sample_rates Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 07/11] configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA group Andreas Rheinhardt
` (9 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
There are seven MJPEG-tables, five small (1x12, 4x17) and two
not small (2x162). These are all avpriv, despite this not being
worthwhile due to the overhead of exporting a symbol: The total
overhead for each symbol consists of two entries in .dynsym (24B each),
one entry in the importing library's .rela.dyn (24B) and one in .got
(8B) as well as 2x2B for symbol versions and 4B for symbol hashes
in the exporting library; in addition to that, the name of the symbol
is included in both exporting and importing libraries, using 2x210 bytes
in this case.
(The above numbers are for a x64 Elf/Linux/GNU system. Other platforms
will give different numbers.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
configure | 3 +-
libavcodec/Makefile | 3 +-
libavcodec/g2meet.c | 16 +++---
libavcodec/jpegtables.c | 66 +----------------------
libavcodec/jpegtables.h | 16 +++---
libavcodec/jpegtabs.h | 92 +++++++++++++++++++++++++++++++++
libavcodec/ljpegenc.c | 8 +--
libavcodec/mjpeg2jpeg_bsf.c | 12 ++---
libavcodec/mjpegdec.c | 24 ++++-----
libavcodec/mjpegenc.c | 16 +++---
libavcodec/mjpegenc_common.c | 18 +++----
libavcodec/mss4.c | 8 +--
libavcodec/vaapi_encode_mjpeg.c | 16 +++---
libavformat/Makefile | 3 +-
libavformat/jpegtables.c | 24 +++++++++
libavformat/rtpdec_jpeg.c | 16 +++---
libavformat/rtpenc_jpeg.c | 16 +++---
17 files changed, 204 insertions(+), 153 deletions(-)
create mode 100644 libavcodec/jpegtabs.h
create mode 100644 libavformat/jpegtables.c
diff --git a/configure b/configure
index ab1b9f6b66..b5888e845a 100755
--- a/configure
+++ b/configure
@@ -3432,9 +3432,8 @@ ogv_muxer_select="ogg_muxer"
opus_muxer_select="ogg_muxer"
psp_muxer_select="mov_muxer"
rtp_demuxer_select="sdp_demuxer"
-rtp_muxer_select="jpegtables"
rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
-rtpdec_select="asf_demuxer jpegtables mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
+rtpdec_select="asf_demuxer mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"
rtsp_demuxer_select="http_protocol rtpdec"
rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol rtpenc_chain"
sap_demuxer_select="sdp_demuxer"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e4a547ffaa..0b568138be 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1002,7 +1002,8 @@ OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
-STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o
+STLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
+STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o
STLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o
# libavfilter dependencies
diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index c9e8d11ab8..4c53838af5 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -164,20 +164,20 @@ static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)
{
int ret;
- ret = ff_mjpeg_build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc, 0, avctx);
+ ret = ff_mjpeg_build_vlc(&c->dc_vlc[0], ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc, 0, avctx);
if (ret)
return ret;
- ret = ff_mjpeg_build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc, 0, avctx);
+ ret = ff_mjpeg_build_vlc(&c->dc_vlc[1], ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc, 0, avctx);
if (ret)
return ret;
- ret = ff_mjpeg_build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance, 1, avctx);
+ ret = ff_mjpeg_build_vlc(&c->ac_vlc[0], ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance, 1, avctx);
if (ret)
return ret;
- ret = ff_mjpeg_build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance, 1, avctx);
+ ret = ff_mjpeg_build_vlc(&c->ac_vlc[1], ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance, 1, avctx);
if (ret)
return ret;
diff --git a/libavcodec/jpegtables.c b/libavcodec/jpegtables.c
index ef3f8dee20..e453fcf90d 100644
--- a/libavcodec/jpegtables.c
+++ b/libavcodec/jpegtables.c
@@ -30,8 +30,7 @@
* MJPEG encoder and decoder.
*/
-#include "jpegtables.h"
-
+#include "jpegtabs.h"
#if 0
/* These are the sample quantization tables given in JPEG spec section K.1.
@@ -59,66 +58,3 @@ static const unsigned char std_chrominance_quant_tbl[64] = {
99, 99, 99, 99, 99, 99, 99, 99
};
#endif
-
-/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
-/* IMPORTANT: these are only valid for 8-bit data precision! */
-const uint8_t avpriv_mjpeg_bits_dc_luminance[17] =
-{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
-const uint8_t avpriv_mjpeg_val_dc[12] =
-{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-
-const uint8_t avpriv_mjpeg_bits_dc_chrominance[17] =
-{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
-
-const uint8_t avpriv_mjpeg_bits_ac_luminance[17] =
-{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
-const uint8_t avpriv_mjpeg_val_ac_luminance[] =
-{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
- 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
- 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
- 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
- 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
- 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
- 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
- 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
- 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
- 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
- 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
- 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
- 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
- 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
- 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
- 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa
-};
-
-const uint8_t avpriv_mjpeg_bits_ac_chrominance[17] =
-{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
-
-const uint8_t avpriv_mjpeg_val_ac_chrominance[] =
-{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
- 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
- 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
- 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
- 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
- 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
- 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
- 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
- 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
- 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
- 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
- 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
- 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
- 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa
-};
diff --git a/libavcodec/jpegtables.h b/libavcodec/jpegtables.h
index 0907280445..49b5ecdeb0 100644
--- a/libavcodec/jpegtables.h
+++ b/libavcodec/jpegtables.h
@@ -23,17 +23,15 @@
#include <stdint.h>
-#include "internal.h"
+extern const uint8_t ff_mjpeg_bits_dc_luminance[];
+extern const uint8_t ff_mjpeg_val_dc[];
-extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_dc_luminance[];
-extern av_export_avcodec const uint8_t avpriv_mjpeg_val_dc[];
+extern const uint8_t ff_mjpeg_bits_dc_chrominance[];
-extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
+extern const uint8_t ff_mjpeg_bits_ac_luminance[];
+extern const uint8_t ff_mjpeg_val_ac_luminance[];
-extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_luminance[];
-extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_luminance[];
-
-extern av_export_avcodec const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
-extern av_export_avcodec const uint8_t avpriv_mjpeg_val_ac_chrominance[];
+extern const uint8_t ff_mjpeg_bits_ac_chrominance[];
+extern const uint8_t ff_mjpeg_val_ac_chrominance[];
#endif /* AVCODEC_JPEGTABLES_H */
diff --git a/libavcodec/jpegtabs.h b/libavcodec/jpegtabs.h
new file mode 100644
index 0000000000..7106f66df0
--- /dev/null
+++ b/libavcodec/jpegtabs.h
@@ -0,0 +1,92 @@
+/*
+ * MJPEG tables
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2003 Alex Beregszaszi
+ * Copyright (c) 2003-2004 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_JPEGTABS_H
+#define AVCODEC_JPEGTABS_H
+
+#include <stdint.h>
+#include "jpegtables.h"
+
+/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
+/* IMPORTANT: these are only valid for 8-bit data precision! */
+const uint8_t ff_mjpeg_bits_dc_luminance[17] =
+{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
+const uint8_t ff_mjpeg_val_dc[12] =
+{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
+
+const uint8_t ff_mjpeg_bits_dc_chrominance[17] =
+{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
+
+const uint8_t ff_mjpeg_bits_ac_luminance[17] =
+{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
+const uint8_t ff_mjpeg_val_ac_luminance[] =
+{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
+ 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
+ 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
+ 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
+ 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
+ 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+ 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
+ 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
+ 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
+ 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+};
+
+const uint8_t ff_mjpeg_bits_ac_chrominance[17] =
+{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
+
+const uint8_t ff_mjpeg_val_ac_chrominance[] =
+{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
+ 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
+ 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
+ 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
+ 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
+ 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
+ 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+ 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+ 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
+ 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
+ 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
+ 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
+ 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
+ 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa
+};
+#endif
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 968ba1fb60..ecdedeb6a3 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -293,12 +293,12 @@ static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance,
s->huff_code_dc_luminance,
- avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc);
+ ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc);
ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance,
s->huff_code_dc_chrominance,
- avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc);
+ ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc);
return 0;
}
diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
index b30f391bf9..2a972a7c37 100644
--- a/libavcodec/mjpeg2jpeg_bsf.c
+++ b/libavcodec/mjpeg2jpeg_bsf.c
@@ -65,15 +65,15 @@ static uint8_t *append(uint8_t *buf, const uint8_t *src, int size)
static uint8_t *append_dht_segment(uint8_t *buf)
{
buf = append(buf, dht_segment_head, sizeof(dht_segment_head));
- buf = append(buf, avpriv_mjpeg_bits_dc_luminance + 1, 16);
+ buf = append(buf, ff_mjpeg_bits_dc_luminance + 1, 16);
buf = append(buf, dht_segment_frag, sizeof(dht_segment_frag));
- buf = append(buf, avpriv_mjpeg_val_dc, 12);
+ buf = append(buf, ff_mjpeg_val_dc, 12);
*(buf++) = 0x10;
- buf = append(buf, avpriv_mjpeg_bits_ac_luminance + 1, 16);
- buf = append(buf, avpriv_mjpeg_val_ac_luminance, 162);
+ buf = append(buf, ff_mjpeg_bits_ac_luminance + 1, 16);
+ buf = append(buf, ff_mjpeg_val_ac_luminance, 162);
*(buf++) = 0x11;
- buf = append(buf, avpriv_mjpeg_bits_ac_chrominance + 1, 16);
- buf = append(buf, avpriv_mjpeg_val_ac_chrominance, 162);
+ buf = append(buf, ff_mjpeg_bits_ac_chrominance + 1, 16);
+ buf = append(buf, ff_mjpeg_val_ac_chrominance, 162);
return buf;
}
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 8b154ce0ab..d447ddce77 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -61,18 +61,18 @@ static int init_default_huffman_tables(MJpegDecodeContext *s)
const uint8_t *values;
int length;
} ht[] = {
- { 0, 0, avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc, 12 },
- { 0, 1, avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc, 12 },
- { 1, 0, avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance, 162 },
- { 1, 1, avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance, 162 },
- { 2, 0, avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance, 162 },
- { 2, 1, avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance, 162 },
+ { 0, 0, ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc, 12 },
+ { 0, 1, ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc, 12 },
+ { 1, 0, ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance, 162 },
+ { 1, 1, ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance, 162 },
+ { 2, 0, ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance, 162 },
+ { 2, 1, ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance, 162 },
};
int i, ret;
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 0ade66bc5f..30cbbddb59 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -288,20 +288,20 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
// they are needed at least right now for some processes like trellis.
ff_mjpeg_build_huffman_codes(m->huff_size_dc_luminance,
m->huff_code_dc_luminance,
- avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc);
+ ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc);
ff_mjpeg_build_huffman_codes(m->huff_size_dc_chrominance,
m->huff_code_dc_chrominance,
- avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc);
+ ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc);
ff_mjpeg_build_huffman_codes(m->huff_size_ac_luminance,
m->huff_code_ac_luminance,
- avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance);
+ ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance);
ff_mjpeg_build_huffman_codes(m->huff_size_ac_chrominance,
m->huff_code_ac_chrominance,
- avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance);
+ ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance);
init_uni_ac_vlc(m->huff_size_ac_luminance, m->uni_ac_vlc_len);
init_uni_ac_vlc(m->huff_size_ac_chrominance, m->uni_chroma_ac_vlc_len);
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index c1b842d547..368e87128c 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -121,15 +121,15 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
size += put_huffman_table(p, 1, 1, s->mjpeg_ctx->bits_ac_chrominance,
s->mjpeg_ctx->val_ac_chrominance);
} else {
- size += put_huffman_table(p, 0, 0, avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc);
- size += put_huffman_table(p, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc);
-
- size += put_huffman_table(p, 1, 0, avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance);
- size += put_huffman_table(p, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance);
+ size += put_huffman_table(p, 0, 0, ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc);
+ size += put_huffman_table(p, 0, 1, ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc);
+
+ size += put_huffman_table(p, 1, 0, ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance);
+ size += put_huffman_table(p, 1, 1, ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance);
}
AV_WB16(ptr, size);
}
diff --git a/libavcodec/mss4.c b/libavcodec/mss4.c
index 6c44c76c50..216df2852d 100644
--- a/libavcodec/mss4.c
+++ b/libavcodec/mss4.c
@@ -124,10 +124,10 @@ static av_cold void mss4_init_vlcs(void)
for (unsigned i = 0, offset = 0; i < 2; i++) {
mss4_init_vlc(&dc_vlc[i], &offset, mss4_dc_vlc_lens[i], NULL);
mss4_init_vlc(&ac_vlc[i], &offset,
- i ? avpriv_mjpeg_bits_ac_chrominance + 1
- : avpriv_mjpeg_bits_ac_luminance + 1,
- i ? avpriv_mjpeg_val_ac_chrominance
- : avpriv_mjpeg_val_ac_luminance);
+ i ? ff_mjpeg_bits_ac_chrominance + 1
+ : ff_mjpeg_bits_ac_luminance + 1,
+ i ? ff_mjpeg_val_ac_chrominance
+ : ff_mjpeg_val_ac_luminance);
mss4_init_vlc(&vec_entry_vlc[i], &offset, mss4_vec_entry_vlc_lens[i],
mss4_vec_entry_vlc_syms[i]);
}
diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
index d35f416ad7..6206b23e5f 100644
--- a/libavcodec/vaapi_encode_mjpeg.c
+++ b/libavcodec/vaapi_encode_mjpeg.c
@@ -327,20 +327,20 @@ static int vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx,
switch (t) {
case 0:
- lengths = avpriv_mjpeg_bits_dc_luminance + 1;
- values = avpriv_mjpeg_val_dc;
+ lengths = ff_mjpeg_bits_dc_luminance + 1;
+ values = ff_mjpeg_val_dc;
break;
case 1:
- lengths = avpriv_mjpeg_bits_ac_luminance + 1;
- values = avpriv_mjpeg_val_ac_luminance;
+ lengths = ff_mjpeg_bits_ac_luminance + 1;
+ values = ff_mjpeg_val_ac_luminance;
break;
case 2:
- lengths = avpriv_mjpeg_bits_dc_chrominance + 1;
- values = avpriv_mjpeg_val_dc;
+ lengths = ff_mjpeg_bits_dc_chrominance + 1;
+ values = ff_mjpeg_val_dc;
break;
case 3:
- lengths = avpriv_mjpeg_bits_ac_chrominance + 1;
- values = avpriv_mjpeg_val_ac_chrominance;
+ lengths = ff_mjpeg_bits_ac_chrominance + 1;
+ values = ff_mjpeg_val_ac_chrominance;
break;
}
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 8f05b8d83c..ee6a6370cd 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -681,7 +681,8 @@ SHLIBOBJS += log2_tab.o
SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
-SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o
+SHLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
+SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o
SHLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o
# libavdevice dependencies
diff --git a/libavformat/jpegtables.c b/libavformat/jpegtables.c
new file mode 100644
index 0000000000..57eae9f9a6
--- /dev/null
+++ b/libavformat/jpegtables.c
@@ -0,0 +1,24 @@
+/*
+ * MJPEG tables
+ * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2003 Alex Beregszaszi
+ * Copyright (c) 2003-2004 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
+ */
+
+#include "libavcodec/jpegtabs.h"
diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c
index b32d074136..81036247c1 100644
--- a/libavformat/rtpdec_jpeg.c
+++ b/libavformat/rtpdec_jpeg.c
@@ -144,14 +144,14 @@ static int jpeg_create_header(uint8_t *buf, int size, uint32_t type, uint32_t w,
bytestream2_put_be16(&pbc, 0);
dht_size = 2;
- dht_size += jpeg_create_huffman_table(&pbc, 0, 0,avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc);
- dht_size += jpeg_create_huffman_table(&pbc, 0, 1, avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc);
- dht_size += jpeg_create_huffman_table(&pbc, 1, 0, avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance);
- dht_size += jpeg_create_huffman_table(&pbc, 1, 1, avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance);
+ dht_size += jpeg_create_huffman_table(&pbc, 0, 0,ff_mjpeg_bits_dc_luminance,
+ ff_mjpeg_val_dc);
+ dht_size += jpeg_create_huffman_table(&pbc, 0, 1, ff_mjpeg_bits_dc_chrominance,
+ ff_mjpeg_val_dc);
+ dht_size += jpeg_create_huffman_table(&pbc, 1, 0, ff_mjpeg_bits_ac_luminance,
+ ff_mjpeg_val_ac_luminance);
+ dht_size += jpeg_create_huffman_table(&pbc, 1, 1, ff_mjpeg_bits_ac_chrominance,
+ ff_mjpeg_val_ac_chrominance);
AV_WB16(dht_size_ptr, dht_size);
/* SOF0 */
diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index 38eb2e68eb..91116832da 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -101,8 +101,8 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
switch (buf[i + 1]) {
case 0x00:
if ( dht_size >= 29
- && !memcmp(buf + i + 2, avpriv_mjpeg_bits_dc_luminance + 1, 16)
- && !memcmp(buf + i + 18, avpriv_mjpeg_val_dc, 12)) {
+ && !memcmp(buf + i + 2, ff_mjpeg_bits_dc_luminance + 1, 16)
+ && !memcmp(buf + i + 18, ff_mjpeg_val_dc, 12)) {
default_huffman_tables |= 1;
i += 29;
dht_size -= 29;
@@ -113,8 +113,8 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
break;
case 0x01:
if ( dht_size >= 29
- && !memcmp(buf + i + 2, avpriv_mjpeg_bits_dc_chrominance + 1, 16)
- && !memcmp(buf + i + 18, avpriv_mjpeg_val_dc, 12)) {
+ && !memcmp(buf + i + 2, ff_mjpeg_bits_dc_chrominance + 1, 16)
+ && !memcmp(buf + i + 18, ff_mjpeg_val_dc, 12)) {
default_huffman_tables |= 1 << 1;
i += 29;
dht_size -= 29;
@@ -125,8 +125,8 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
break;
case 0x10:
if ( dht_size >= 179
- && !memcmp(buf + i + 2, avpriv_mjpeg_bits_ac_luminance + 1, 16)
- && !memcmp(buf + i + 18, avpriv_mjpeg_val_ac_luminance, 162)) {
+ && !memcmp(buf + i + 2, ff_mjpeg_bits_ac_luminance + 1, 16)
+ && !memcmp(buf + i + 18, ff_mjpeg_val_ac_luminance, 162)) {
default_huffman_tables |= 1 << 2;
i += 179;
dht_size -= 179;
@@ -137,8 +137,8 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
break;
case 0x11:
if ( dht_size >= 179
- && !memcmp(buf + i + 2, avpriv_mjpeg_bits_ac_chrominance + 1, 16)
- && !memcmp(buf + i + 18, avpriv_mjpeg_val_ac_chrominance, 162)) {
+ && !memcmp(buf + i + 2, ff_mjpeg_bits_ac_chrominance + 1, 16)
+ && !memcmp(buf + i + 18, ff_mjpeg_val_ac_chrominance, 162)) {
default_huffman_tables |= 1 << 3;
i += 179;
dht_size -= 179;
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 07/11] configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA group
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (4 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 06/11] avcodec/jpegtables: Unavpriv MJPEG-tables Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 08/11] avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates Andreas Rheinhardt
` (8 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This group is mainly for the users of *_mpeg4audio_get_config2();
it is not for those who only use avpriv_mpeg4audio_sample_rates.
This is in preparation for splitting the latter into a file of its own;
if there were no CONFIG_EXTRA group for *_mpeg4audio_get_config2()
users, one would have to add a dependency to the new file for all
these users on top of the existing dependency on mpeg4audio.o.
Adding a new CONFIG_EXTRA group only takes effect after a reconfigure;
so in order to force a reconfigure some unnecessary headers from
libavdevice/alldevices.c have been removed.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
configure | 23 +++++++++++++----------
libavcodec/Makefile | 23 +++++++++--------------
libavdevice/alldevices.c | 2 --
3 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/configure b/configure
index b5888e845a..28e45b7e95 100755
--- a/configure
+++ b/configure
@@ -2467,6 +2467,7 @@ CONFIG_EXTRA="
mpegaudio
mpegaudiodsp
mpegaudioheader
+ mpeg4audio
mpegvideo
mpegvideoenc
mss34dsp
@@ -2704,6 +2705,7 @@ h264dsp_select="startcode"
hevcparse_select="atsc_a53 golomb"
frame_thread_encoder_deps="encoders threads"
intrax8_select="blockdsp idctdsp"
+iso_media_select="mpeg4audio"
mdct_select="fft"
mdct15_select="fft"
me_cmp_select="fdctdsp idctdsp pixblockdsp"
@@ -2716,8 +2718,8 @@ vc1dsp_select="h264chroma qpeldsp startcode"
rdft_select="fft"
# decoders / encoders
-aac_decoder_select="adts_header mdct15 mdct sinewin"
-aac_fixed_decoder_select="adts_header mdct"
+aac_decoder_select="adts_header mdct15 mdct mpeg4audio sinewin"
+aac_fixed_decoder_select="adts_header mdct mpeg4audio"
aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin"
aac_latm_decoder_select="aac_decoder aac_latm_parser"
ac3_decoder_select="ac3_parser ac3dsp bswapdsp fmtconvert mdct"
@@ -2729,7 +2731,7 @@ adpcm_g722_decoder_select="g722dsp"
adpcm_g722_encoder_select="g722dsp"
aic_decoder_select="golomb idctdsp"
alac_encoder_select="lpc"
-als_decoder_select="bswapdsp"
+als_decoder_select="bswapdsp mpeg4audio"
amrnb_decoder_select="lsp"
amrwb_decoder_select="lsp"
amv_decoder_select="sp5x_decoder exif"
@@ -2849,8 +2851,8 @@ mp3_decoder_select="mpegaudio"
mp3adu_decoder_select="mpegaudio"
mp3adufloat_decoder_select="mpegaudio"
mp3float_decoder_select="mpegaudio"
-mp3on4_decoder_select="mpegaudio"
-mp3on4float_decoder_select="mpegaudio"
+mp3on4_decoder_select="mpegaudio mpeg4audio"
+mp3on4float_decoder_select="mpegaudio mpeg4audio"
mpc7_decoder_select="bswapdsp mpegaudiodsp"
mpc8_decoder_select="mpegaudiodsp"
mpegvideo_decoder_select="mpegvideo"
@@ -3227,7 +3229,7 @@ wmv3_crystalhd_decoder_select="crystalhd"
av1_qsv_decoder_select="qsvdec"
# parsers
-aac_parser_select="adts_header"
+aac_parser_select="adts_header mpeg4audio"
av1_parser_select="cbs_av1"
h264_parser_select="atsc_a53 golomb h264dsp h264parse"
hevc_parser_select="hevcparse"
@@ -3237,7 +3239,7 @@ mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
vc1_parser_select="vc1dsp"
# bitstream_filters
-aac_adtstoasc_bsf_select="adts_header"
+aac_adtstoasc_bsf_select="adts_header mpeg4audio"
av1_frame_merge_bsf_select="cbs_av1"
av1_frame_split_bsf_select="cbs_av1"
av1_metadata_bsf_select="cbs_av1"
@@ -3370,6 +3372,7 @@ videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrame
# demuxers / muxers
ac3_demuxer_select="ac3_parser"
act_demuxer_select="riffdec"
+adts_muxer_select="mpeg4audio"
aiff_muxer_select="iso_media"
asf_demuxer_select="riffdec"
asf_o_demuxer_select="riffdec"
@@ -3403,11 +3406,11 @@ image2_brender_pix_demuxer_select="image2_demuxer"
ipod_muxer_select="mov_muxer"
ismv_muxer_select="mov_muxer"
ivf_muxer_select="av1_metadata_bsf vp9_superframe_bsf"
-latm_muxer_select="aac_adtstoasc_bsf"
+latm_muxer_select="aac_adtstoasc_bsf mpeg4audio"
matroska_audio_muxer_select="matroska_muxer"
matroska_demuxer_select="riffdec"
matroska_demuxer_suggest="bzlib lzo zlib"
-matroska_muxer_select="riffenc vp9_superframe_bsf aac_adtstoasc_bsf"
+matroska_muxer_select="mpeg4audio riffenc vp9_superframe_bsf aac_adtstoasc_bsf"
mlp_demuxer_select="mlp_parser"
mmf_muxer_select="riffenc"
mov_demuxer_select="iso_media riffdec"
@@ -3454,7 +3457,7 @@ w64_muxer_select="wav_muxer"
wav_demuxer_select="riffdec"
wav_muxer_select="riffenc"
webm_chunk_muxer_select="webm_muxer"
-webm_muxer_select="riffenc"
+webm_muxer_select="mpeg4audio riffenc"
webm_dash_manifest_demuxer_select="matroska_demuxer"
wtv_demuxer_select="mpegts_demuxer riffdec"
wtv_muxer_select="mpegts_muxer riffenc"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0b568138be..026b558d32 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -123,6 +123,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
mpegaudiodsp_fixed.o \
mpegaudiodsp_float.o
OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiodata.o
+OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.o
OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \
mpegvideo_motion.o mpegutils.o \
mpegvideodata.o mpegpicture.o
@@ -160,10 +161,10 @@ OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_common.o aacps_float.o \
- mpeg4audio.o kbdwin.o \
+ kbdwin.o \
sbrdsp.o aacpsdsp_float.o cbrt_data.o
OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_common.o aacps_fixed.o \
- mpeg4audio.o kbdwin.o \
+ kbdwin.o \
sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacpsy.o aactab.o \
@@ -189,7 +190,7 @@ OBJS-$(CONFIG_ALAC_DECODER) += alac.o alac_data.o alacdsp.o
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o alac_data.o
OBJS-$(CONFIG_ALIAS_PIX_DECODER) += aliaspixdec.o
OBJS-$(CONFIG_ALIAS_PIX_ENCODER) += aliaspixenc.o
-OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mlz.o mpeg4audio.o
+OBJS-$(CONFIG_ALS_DECODER) += alsdec.o bgmc.o mlz.o
OBJS-$(CONFIG_AMRNB_DECODER) += amrnbdec.o celp_filters.o \
celp_math.o acelp_filters.o \
acelp_vectors.o \
@@ -479,8 +480,8 @@ OBJS-$(CONFIG_MP3_MF_ENCODER) += mfenc.o mf_utils.o
OBJS-$(CONFIG_MP3ADU_DECODER) += mpegaudiodec_fixed.o
OBJS-$(CONFIG_MP3ADUFLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP3FLOAT_DECODER) += mpegaudiodec_float.o
-OBJS-$(CONFIG_MP3ON4_DECODER) += mpegaudiodec_fixed.o mpeg4audio.o
-OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o mpeg4audio.o
+OBJS-$(CONFIG_MP3ON4_DECODER) += mpegaudiodec_fixed.o
+OBJS-$(CONFIG_MP3ON4FLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o
OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
@@ -985,18 +986,13 @@ OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o
SHLIBOBJS += log2_tab.o reverse.o
# General libavformat dependencies
-OBJS-$(CONFIG_ISO_MEDIA) += mpeg4audio.o mpegaudiodata.o
+OBJS-$(CONFIG_ISO_MEDIA) += mpegaudiodata.o
-OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
-OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o
-OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += mpeg4audio.o
-OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
-OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o
# libavformat dependencies for static builds
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
@@ -1087,8 +1083,7 @@ OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o ass.o
# parsers
OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
-OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \
- mpeg4audio.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
@@ -1148,7 +1143,7 @@ OBJS-$(CONFIG_XBM_PARSER) += xbm_parser.o
OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o
# bitstream filters
-OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o
+OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o
OBJS-$(CONFIG_AV1_METADATA_BSF) += av1_metadata_bsf.o
OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF) += av1_frame_merge_bsf.o
OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF) += av1_frame_split_bsf.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index fbbe187a51..22323a0a44 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
-#include "libavutil/thread.h"
#include "libavformat/internal.h"
#include "avdevice.h"
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 08/11] avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (5 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 07/11] configure, avcodec/Makefile: Add new mpeg4audio CONFIG_EXTRA group Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 09/11] avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs Andreas Rheinhardt
` (7 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
avpriv_mpeg4audio_sample_rates has a size of 64B and it is currently
avpriv; a clone of it exists in aacenctab.h and from there it is inlined
in aacenc.c (which also uses the avpriv version) and in the FLV muxer.
This means that despite it being avpriv both libavformat as well as
libavcodec have copies already.
This situation is clearly suboptimal. Given the overhead of exporting
symbols (for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn,
8B .got, 4B hash + twice the size of the name (here 31B)) the object is
unavprived, i.e. duplicated into libavformat when creating a shared
build; but the duplicates in the AAC encoder and FLV muxer are removed.
This involves splitting of the sample rate table into a file of its own;
this allowed to break some spurious dependencies (e.g. both the AAC
encoder as well as the Matroska demuxer actually don't need the
mpeg4audio_get_config stuff).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 14 +++++++------
libavcodec/aacenc.c | 4 ++--
libavcodec/aacenctab.h | 7 -------
| 4 ++--
libavcodec/mpeg4audio.c | 9 +-------
libavcodec/mpeg4audio.h | 3 +--
libavcodec/mpeg4audio_sample_rates.c | 23 ++++++++++++++++++++
libavcodec/mpeg4audio_sample_rates.h | 30 +++++++++++++++++++++++++++
libavformat/Makefile | 5 ++++-
libavformat/flvenc.c | 4 ++--
libavformat/matroskadec.c | 4 ++--
libavformat/mpeg4audio_sample_rates.c | 23 ++++++++++++++++++++
libavformat/sdp.c | 2 +-
13 files changed, 99 insertions(+), 33 deletions(-)
create mode 100644 libavcodec/mpeg4audio_sample_rates.c
create mode 100644 libavcodec/mpeg4audio_sample_rates.h
create mode 100644 libavformat/mpeg4audio_sample_rates.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 026b558d32..42caa1d59c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -60,7 +60,7 @@ OBJS = ac3_parser.o \
# subsystems
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o
-OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o
+OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio_sample_rates.o
OBJS-$(CONFIG_AMF) += amfenc.o
OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o
OBJS-$(CONFIG_ATSC_A53) += atsc_a53.o
@@ -123,7 +123,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
mpegaudiodsp_fixed.o \
mpegaudiodsp_float.o
OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiodata.o
-OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.o
+OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.o mpeg4audio_sample_rates.o
OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \
mpegvideo_motion.o mpegutils.o \
mpegvideodata.o mpegpicture.o
@@ -172,7 +172,8 @@ OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacenc_tns.o \
aacenc_ltp.o \
aacenc_pred.o \
- psymodel.o mpeg4audio.o kbdwin.o
+ psymodel.o kbdwin.o \
+ mpeg4audio_sample_rates.o
OBJS-$(CONFIG_AAC_MF_ENCODER) += mfenc.o mf_utils.o
OBJS-$(CONFIG_AASC_DECODER) += aasc.o msrledec.o
OBJS-$(CONFIG_AC3_DECODER) += ac3dec_float.o ac3dec_data.o ac3.o \
@@ -989,17 +990,18 @@ SHLIBOBJS += log2_tab.o reverse.o
OBJS-$(CONFIG_ISO_MEDIA) += mpegaudiodata.o
OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
-OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
-OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
# libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
+STLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
STLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
-STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o
+STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o \
+ mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o
# libavfilter dependencies
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index e462566078..a1004c3e98 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -998,7 +998,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
/* Samplerate */
for (i = 0; i < 16; i++)
- if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i])
+ if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
break;
s->samplerate_index = i;
ERROR_IF(s->samplerate_index == 16 ||
@@ -1143,7 +1143,7 @@ const AVCodec ff_aac_encoder = {
.encode2 = aac_encode_frame,
.close = aac_encode_end,
.defaults = aac_encode_defaults,
- .supported_samplerates = mpeg4audio_sample_rates,
+ .supported_samplerates = ff_mpeg4audio_sample_rates,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
.capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h
index f54dd16bed..33cb7ae95b 100644
--- a/libavcodec/aacenctab.h
+++ b/libavcodec/aacenctab.h
@@ -81,13 +81,6 @@ static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
{ 2, 0, 1, 6, 7, 4, 5, 3 },
};
-/* duplicated from avpriv_mpeg4audio_sample_rates to avoid shared build
- * failures */
-static const int mpeg4audio_sample_rates[16] = {
- 96000, 88200, 64000, 48000, 44100, 32000,
- 24000, 22050, 16000, 12000, 11025, 8000, 7350
-};
-
/** bits needed to code codebook run value for long windows */
static const uint8_t run_value_bits_long[64] = {
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
--git a/libavcodec/adts_header.c b/libavcodec/adts_header.c
index e4454529c4..ff4efafbf7 100644
--- a/libavcodec/adts_header.c
+++ b/libavcodec/adts_header.c
@@ -40,7 +40,7 @@ int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
crc_abs = get_bits1(gbc); /* protection_absent */
aot = get_bits(gbc, 2); /* profile_objecttype */
sr = get_bits(gbc, 4); /* sample_frequency_index */
- if (!avpriv_mpeg4audio_sample_rates[sr])
+ if (!ff_mpeg4audio_sample_rates[sr])
return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
skip_bits1(gbc); /* private_bit */
ch = get_bits(gbc, 3); /* channel_configuration */
@@ -63,7 +63,7 @@ int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
hdr->crc_absent = crc_abs;
hdr->num_aac_frames = rdb + 1;
hdr->sampling_index = sr;
- hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr];
+ hdr->sample_rate = ff_mpeg4audio_sample_rates[sr];
hdr->samples = (rdb + 1) * 1024;
hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
hdr->frame_length = size;
diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index be50de9052..ed72a80f6d 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -57,13 +57,6 @@ static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c, void *logctx
return 0;
}
-/* XXX: make sure to update the copies in the different encoders if you change
- * this table */
-const int avpriv_mpeg4audio_sample_rates[16] = {
- 96000, 88200, 64000, 48000, 44100, 32000,
- 24000, 22050, 16000, 12000, 11025, 8000, 7350
-};
-
const uint8_t ff_mpeg4audio_channels[14] = {
0,
1, // mono (1/0)
@@ -93,7 +86,7 @@ static inline int get_sample_rate(GetBitContext *gb, int *index)
{
*index = get_bits(gb, 4);
return *index == 0x0f ? get_bits(gb, 24) :
- avpriv_mpeg4audio_sample_rates[*index];
+ ff_mpeg4audio_sample_rates[*index];
}
int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 3187df68d2..c486a3ddef 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -27,7 +27,6 @@
#include "libavutil/attributes.h"
#include "get_bits.h"
-#include "internal.h"
#include "put_bits.h"
typedef struct MPEG4AudioConfig {
@@ -45,7 +44,7 @@ typedef struct MPEG4AudioConfig {
int frame_length_short;
} MPEG4AudioConfig;
-extern av_export_avcodec const int avpriv_mpeg4audio_sample_rates[16];
+extern const int ff_mpeg4audio_sample_rates[16];
extern const uint8_t ff_mpeg4audio_channels[14];
/**
diff --git a/libavcodec/mpeg4audio_sample_rates.c b/libavcodec/mpeg4audio_sample_rates.c
new file mode 100644
index 0000000000..b5ceb59c6e
--- /dev/null
+++ b/libavcodec/mpeg4audio_sample_rates.c
@@ -0,0 +1,23 @@
+/*
+ * MPEG-4 Audio sample rates
+ * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
+ * Copyright (c) 2009 Alex Converse <alex.converse@gmail.com>
+ *
+ * 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 "mpeg4audio_sample_rates.h"
diff --git a/libavcodec/mpeg4audio_sample_rates.h b/libavcodec/mpeg4audio_sample_rates.h
new file mode 100644
index 0000000000..0b8caa6d76
--- /dev/null
+++ b/libavcodec/mpeg4audio_sample_rates.h
@@ -0,0 +1,30 @@
+/*
+ * MPEG-4 Audio sample rates
+ * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
+ * Copyright (c) 2009 Alex Converse <alex.converse@gmail.com>
+ *
+ * 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_MPEG4AUDIO_SAMPLE_RATES_H
+#define AVCODEC_MPEG4AUDIO_SAMPLE_RATES_H
+
+const int ff_mpeg4audio_sample_rates[16] = {
+ 96000, 88200, 64000, 48000, 44100, 32000,
+ 24000, 22050, 16000, 12000, 11025, 8000, 7350
+};
+#endif
diff --git a/libavformat/Makefile b/libavformat/Makefile
index ee6a6370cd..c89e413dda 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -678,11 +678,14 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o
# Objects duplicated from other libraries for shared builds
SHLIBOBJS += log2_tab.o
+SHLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
+SHLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
SHLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
SHLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
-SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o
+SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o \
+ mpeg4audio_sample_rates.o
SHLIBOBJS-$(CONFIG_SPDIF_MUXER) += dca_sample_rate_tab.o
# libavdevice dependencies
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 5130d429ad..f1ef15b1bb 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/mpeg4audio.h"
#include "avio_internal.h"
#include "avio.h"
#include "avc.h"
@@ -33,7 +34,6 @@
#include "metadata.h"
#include "libavutil/opt.h"
#include "libavcodec/put_bits.h"
-#include "libavcodec/aacenctab.h"
static const AVCodecTag flv_video_codec_ids[] = {
@@ -514,7 +514,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i
for (samplerate_index = 0; samplerate_index < 16;
samplerate_index++)
if (flv->audio_par->sample_rate
- == mpeg4audio_sample_rates[samplerate_index])
+ == ff_mpeg4audio_sample_rates[samplerate_index])
break;
init_put_bits(&pbc, data, sizeof(data));
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index a4bbbe954e..f823fb96b8 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2011,8 +2011,8 @@ static int matroska_aac_sri(int samplerate)
{
int sri;
- for (sri = 0; sri < FF_ARRAY_ELEMS(avpriv_mpeg4audio_sample_rates); sri++)
- if (avpriv_mpeg4audio_sample_rates[sri] == samplerate)
+ for (sri = 0; sri < FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++)
+ if (ff_mpeg4audio_sample_rates[sri] == samplerate)
break;
return sri;
}
diff --git a/libavformat/mpeg4audio_sample_rates.c b/libavformat/mpeg4audio_sample_rates.c
new file mode 100644
index 0000000000..212385f348
--- /dev/null
+++ b/libavformat/mpeg4audio_sample_rates.c
@@ -0,0 +1,23 @@
+/*
+ * MPEG-4 Audio sample rates
+ * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
+ * Copyright (c) 2009 Alex Converse <alex.converse@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/mpeg4audio_sample_rates.h"
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index e83616cfbe..e3617616c5 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -453,7 +453,7 @@ static char *latm_context2config(AVFormatContext *s, AVCodecParameters *par)
char *config;
for (rate_index = 0; rate_index < 16; rate_index++)
- if (avpriv_mpeg4audio_sample_rates[rate_index] == par->sample_rate)
+ if (ff_mpeg4audio_sample_rates[rate_index] == par->sample_rate)
break;
if (rate_index == 16) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 09/11] avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (6 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 08/11] avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 10/11] avcodec/internal: Remove unused av_export_avcodec Andreas Rheinhardt
` (6 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
These arrays have a size of 180 resp. six bytes. This does not
make it worthwhile to export them due to the overhead this occurs;
for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn,
8B .got, 4B hash + twice the size of the name (here 20+23B).
Therefore these symbols are unavprived and duplicated for shared
builds.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 16 ++++++-----
| 5 ++--
libavcodec/mpegaudiodata.c | 13 ---------
libavcodec/mpegaudiodata.h | 5 ++--
| 6 ++--
libavcodec/mpegaudioenc_template.c | 8 +++---
libavcodec/mpegaudiotabs.c | 22 +++++++++++++++
libavcodec/mpegaudiotabs.h | 39 ++++++++++++++++++++++++++
libavformat/Makefile | 3 ++
libavformat/isom.c | 2 +-
libavformat/mp3enc.c | 8 +++---
libavformat/mpegaudiotabs.c | 22 +++++++++++++++
libavformat/nutenc.c | 4 +--
13 files changed, 114 insertions(+), 39 deletions(-)
create mode 100644 libavcodec/mpegaudiotabs.c
create mode 100644 libavcodec/mpegaudiotabs.h
create mode 100644 libavformat/mpegaudiotabs.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 42caa1d59c..0b4aaf544e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -122,7 +122,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \
mpegaudiodsp_data.o \
mpegaudiodsp_fixed.o \
mpegaudiodsp_float.o
-OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiodata.o
+OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiotabs.o
OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.o mpeg4audio_sample_rates.o
OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \
mpegvideo_motion.o mpegutils.o \
@@ -472,9 +472,11 @@ OBJS-$(CONFIG_MP1_DECODER) += mpegaudiodec_fixed.o
OBJS-$(CONFIG_MP1FLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP2_DECODER) += mpegaudiodec_fixed.o
OBJS-$(CONFIG_MP2_ENCODER) += mpegaudioenc_float.o mpegaudio.o \
- mpegaudiodata.o mpegaudiodsp_data.o
+ mpegaudiodata.o mpegaudiodsp_data.o \
+ mpegaudiotabs.o
OBJS-$(CONFIG_MP2FIXED_ENCODER) += mpegaudioenc_fixed.o mpegaudio.o \
- mpegaudiodata.o mpegaudiodsp_data.o
+ mpegaudiodata.o mpegaudiodsp_data.o \
+ mpegaudiotabs.o
OBJS-$(CONFIG_MP2FLOAT_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec_fixed.o
OBJS-$(CONFIG_MP3_MF_ENCODER) += mfenc.o mf_utils.o
@@ -987,18 +989,18 @@ OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o
SHLIBOBJS += log2_tab.o reverse.o
# General libavformat dependencies
-OBJS-$(CONFIG_ISO_MEDIA) += mpegaudiodata.o
-
OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
-OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
# libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
STLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o
+STLIBOBJS-$(CONFIG_MP3_MUXER) += mpegaudiotabs.o
+STLIBOBJS-$(CONFIG_NUT_MUXER) += mpegaudiotabs.o
STLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
STLIBOBJS-$(CONFIG_RTP_MUXER) += golomb.o jpegtables.o \
mpeg4audio_sample_rates.o
@@ -1168,7 +1170,7 @@ OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o
OBJS-$(CONFIG_MPEG4_UNPACK_BFRAMES_BSF) += mpeg4_unpack_bframes_bsf.o
OBJS-$(CONFIG_MOV2TEXTSUB_BSF) += movsub_bsf.o
OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += mp3_header_decompress_bsf.o \
- mpegaudiodata.o
+ mpegaudiotabs.o
OBJS-$(CONFIG_MPEG2_METADATA_BSF) += mpeg2_metadata_bsf.o
OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o
OBJS-$(CONFIG_NULL_BSF) += null_bsf.o
--git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c
index 44c174c21c..ebf6bde1c2 100644
--- a/libavcodec/mp3_header_decompress_bsf.c
+++ b/libavcodec/mp3_header_decompress_bsf.c
@@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h"
#include "bsf.h"
#include "bsf_internal.h"
+#include "defs.h"
#include "mpegaudiodecheader.h"
#include "mpegaudiodata.h"
@@ -67,10 +68,10 @@ static int mp3_header_decompress(AVBSFContext *ctx, AVPacket *out)
goto fail;
}
- sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off
+ sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off
for(bitrate_index=2; bitrate_index<30; bitrate_index++){
- frame_size = avpriv_mpa_bitrate_tab[lsf][2][bitrate_index>>1];
+ frame_size = ff_mpa_bitrate_tab[lsf][2][bitrate_index>>1];
frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1);
if(frame_size == buf_size + 4)
break;
diff --git a/libavcodec/mpegaudiodata.c b/libavcodec/mpegaudiodata.c
index 0569281109..669590908f 100644
--- a/libavcodec/mpegaudiodata.c
+++ b/libavcodec/mpegaudiodata.c
@@ -26,19 +26,6 @@
#include "mpegaudiodata.h"
-
-const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = {
- { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
- { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
- }
-};
-
-const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 };
-
/*******************************************************/
/* layer 2 tables */
diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h
index 0a425ef6a8..a4148a1ffe 100644
--- a/libavcodec/mpegaudiodata.h
+++ b/libavcodec/mpegaudiodata.h
@@ -31,14 +31,13 @@
#include "config.h"
-#include "internal.h"
#include "vlc.h"
#define MODE_EXT_MS_STEREO 2
#define MODE_EXT_I_STEREO 1
-extern av_export_avcodec const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
-extern av_export_avcodec const uint16_t avpriv_mpa_freq_tab[3];
+extern const uint16_t ff_mpa_bitrate_tab[2][3][15];
+extern const uint16_t ff_mpa_freq_tab[3];
extern const int ff_mpa_sblimit_table[5];
extern const int ff_mpa_quant_steps[17];
extern const int ff_mpa_quant_bits[17];
--git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
index 93c5f3d8f8..446a6e29d8 100644
--- a/libavcodec/mpegaudiodecheader.c
+++ b/libavcodec/mpegaudiodecheader.c
@@ -52,9 +52,9 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
s->layer = 4 - ((header >> 17) & 3);
/* extract frequency */
sample_rate_index = (header >> 10) & 3;
- if (sample_rate_index >= FF_ARRAY_ELEMS(avpriv_mpa_freq_tab))
+ if (sample_rate_index >= FF_ARRAY_ELEMS(ff_mpa_freq_tab))
sample_rate_index = 0;
- sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
+ sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
sample_rate_index += 3 * (s->lsf + mpeg25);
s->sample_rate_index = sample_rate_index;
s->error_protection = ((header >> 16) & 1) ^ 1;
@@ -75,7 +75,7 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
s->nb_channels = 2;
if (bitrate_index != 0) {
- frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
+ frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
s->bit_rate = frame_size * 1000;
switch(s->layer) {
case 1:
diff --git a/libavcodec/mpegaudioenc_template.c b/libavcodec/mpegaudioenc_template.c
index 1df3cc704a..1ffd31f7cb 100644
--- a/libavcodec/mpegaudioenc_template.c
+++ b/libavcodec/mpegaudioenc_template.c
@@ -95,9 +95,9 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
/* encoding freq */
s->lsf = 0;
for(i=0;i<3;i++) {
- if (avpriv_mpa_freq_tab[i] == freq)
+ if (ff_mpa_freq_tab[i] == freq)
break;
- if ((avpriv_mpa_freq_tab[i] / 2) == freq) {
+ if ((ff_mpa_freq_tab[i] / 2) == freq) {
s->lsf = 1;
break;
}
@@ -110,12 +110,12 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx)
/* encoding bitrate & frequency */
for(i=1;i<15;i++) {
- if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
+ if (ff_mpa_bitrate_tab[s->lsf][1][i] == bitrate)
break;
}
if (i == 15 && !avctx->bit_rate) {
i = 14;
- bitrate = avpriv_mpa_bitrate_tab[s->lsf][1][i];
+ bitrate = ff_mpa_bitrate_tab[s->lsf][1][i];
avctx->bit_rate = bitrate * 1000;
}
if (i == 15){
diff --git a/libavcodec/mpegaudiotabs.c b/libavcodec/mpegaudiotabs.c
new file mode 100644
index 0000000000..eaa380c808
--- /dev/null
+++ b/libavcodec/mpegaudiotabs.c
@@ -0,0 +1,22 @@
+/*
+ * MPEG Audio common tables
+ * 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
+ */
+
+#include "mpegaudiotabs.h"
diff --git a/libavcodec/mpegaudiotabs.h b/libavcodec/mpegaudiotabs.h
new file mode 100644
index 0000000000..671b83848d
--- /dev/null
+++ b/libavcodec/mpegaudiotabs.h
@@ -0,0 +1,39 @@
+/*
+ * MPEG Audio common tables
+ * 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_MPEGAUDIOTABS_H
+#define AVCODEC_MPEGAUDIOTABS_H
+
+#include <stdint.h>
+
+const uint16_t ff_mpa_bitrate_tab[2][3][15] = {
+ { { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
+ { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
+ { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
+ { { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
+ { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
+ { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 }
+ }
+};
+
+const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 };
+
+#endif
diff --git a/libavformat/Makefile b/libavformat/Makefile
index c89e413dda..6e93d082d9 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -678,11 +678,14 @@ OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o
# Objects duplicated from other libraries for shared builds
SHLIBOBJS += log2_tab.o
+SHLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
SHLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
SHLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
SHLIBOBJS-$(CONFIG_MOV_DEMUXER) += ac3_channel_layout_tab.o
+SHLIBOBJS-$(CONFIG_MP3_MUXER) += mpegaudiotabs.o
SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o
+SHLIBOBJS-$(CONFIG_NUT_MUXER) += mpegaudiotabs.o
SHLIBOBJS-$(CONFIG_RTPDEC) += jpegtables.o
SHLIBOBJS-$(CONFIG_RTP_MUXER) += golomb_tab.o jpegtables.o \
mpeg4audio_sample_rates.o
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 300ba927c2..015c82e1bb 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -362,7 +362,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext
return ret;
st->codecpar->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
- st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
+ st->codecpar->sample_rate = ff_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
st->codecpar->sample_rate = cfg.ext_sample_rate;
else
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index e4b2a65b07..71e96a8651 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -159,8 +159,8 @@ static int mp3_write_xing(AVFormatContext *s)
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) || !mp3->write_xing)
return 0;
- for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
- const uint16_t base_freq = avpriv_mpa_freq_tab[i];
+ for (i = 0; i < FF_ARRAY_ELEMS(ff_mpa_freq_tab); i++) {
+ const uint16_t base_freq = ff_mpa_freq_tab[i];
if (par->sample_rate == base_freq) ver = 0x3; // MPEG 1
else if (par->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
@@ -170,7 +170,7 @@ static int mp3_write_xing(AVFormatContext *s)
srate_idx = i;
break;
}
- if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
+ if (i == FF_ARRAY_ELEMS(ff_mpa_freq_tab)) {
av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing header.\n");
return -1;
}
@@ -190,7 +190,7 @@ static int mp3_write_xing(AVFormatContext *s)
header |= channels << 6;
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
- int bit_rate = 1000 * avpriv_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
+ int bit_rate = 1000 * ff_mpa_bitrate_tab[ver != 3][3 - 1][bitrate_idx];
int error = FFABS(bit_rate - par->bit_rate);
if (error < best_bitrate_error) {
diff --git a/libavformat/mpegaudiotabs.c b/libavformat/mpegaudiotabs.c
new file mode 100644
index 0000000000..41ac76e21b
--- /dev/null
+++ b/libavformat/mpegaudiotabs.c
@@ -0,0 +1,22 @@
+/*
+ * MPEG Audio common tables
+ * 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
+ */
+
+#include "libavcodec/mpegaudiotabs.h"
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 7977980935..585ce953ca 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -70,11 +70,11 @@ static int find_expected_header(AVCodecParameters *p, int size, int key_frame,
else if (sample_rate < (44100 + 48000) / 2) sample_rate_index = 0;
else sample_rate_index = 1;
- sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25);
+ sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25);
for (bitrate_index = 2; bitrate_index < 30; bitrate_index++) {
frame_size =
- avpriv_mpa_bitrate_tab[lsf][layer - 1][bitrate_index >> 1];
+ ff_mpa_bitrate_tab[lsf][layer - 1][bitrate_index >> 1];
frame_size = (frame_size * 144000) / (sample_rate << lsf) +
(bitrate_index & 1);
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 10/11] avcodec/internal: Remove unused av_export_avcodec
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (7 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 09/11] avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 11/11] avcodec/utils: Unavpriv avpriv_toupper4() Andreas Rheinhardt
` (5 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/internal.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index a62f8dbd4e..d3ee0214c5 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -363,10 +363,4 @@ int ff_int_from_list_or_default(void *ctx, const char * val_name, int val,
void ff_dvdsub_parse_palette(uint32_t *palette, const char *p);
-#if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec)
-# define av_export_avcodec __declspec(dllimport)
-#else
-# define av_export_avcodec
-#endif
-
#endif /* AVCODEC_INTERNAL_H */
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 11/11] avcodec/utils: Unavpriv avpriv_toupper4()
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (8 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 10/11] avcodec/internal: Remove unused av_export_avcodec Andreas Rheinhardt
@ 2021-12-15 12:35 ` Andreas Rheinhardt
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 12/15] avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references Andreas Rheinhardt
` (4 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-15 12:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This function is quite small (96B with GCC 11.2 on x64 Ubuntu 21.10
at -O3), making it more economical to duplicate it into libavformat
instead of exporting it as avpriv: Doing so saves 2x24B in .dynsim,
2x16B in .dynstr, 2x2B .gnu.version, 24B in .rela.plt, 16B in .plt,
16B in .plt.sec (if enabled), 4B .gnu.hash; besides the actual
duplicated code this also adds 2x8B .eh_frame_hdr and 24B .eh_frame.
In other words: Duplicating is neutral size-wise (it is also presumed
neutral for other systems). Given that it avoids the runtime
overhead of dynamic symbols, it is advantageouos to duplicate the
function.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/Makefile | 4 +++-
libavcodec/internal.h | 2 +-
libavcodec/mpeg12dec.c | 2 +-
libavcodec/mpegvideo.c | 2 +-
libavcodec/to_upper4.c | 23 +++++++++++++++++++++++
libavcodec/to_upper4.h | 37 +++++++++++++++++++++++++++++++++++++
libavcodec/utils.c | 8 --------
libavformat/Makefile | 2 +-
libavformat/movenc.c | 2 +-
libavformat/mux.c | 2 +-
libavformat/to_upper4.c | 23 +++++++++++++++++++++++
libavformat/utils.c | 2 +-
12 files changed, 93 insertions(+), 16 deletions(-)
create mode 100644 libavcodec/to_upper4.c
create mode 100644 libavcodec/to_upper4.h
create mode 100644 libavformat/to_upper4.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0b4aaf544e..292a105266 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -126,7 +126,8 @@ OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiotabs.o
OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.o mpeg4audio_sample_rates.o
OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \
mpegvideo_motion.o mpegutils.o \
- mpegvideodata.o mpegpicture.o
+ mpegvideodata.o mpegpicture.o \
+ to_upper4.o
OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \
motion_est.o ratecontrol.o \
mpegvideoencdsp.o
@@ -993,6 +994,7 @@ OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
# libavformat dependencies for static builds
+STLIBOBJS-$(CONFIG_AVFORMAT) += to_upper4.o
STLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
STLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
STLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index d3ee0214c5..72ca1553f6 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -225,7 +225,7 @@ extern const uint8_t ff_log2_run[41];
*/
int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
-unsigned int avpriv_toupper4(unsigned int x);
+unsigned int ff_toupper4(unsigned int x);
void ff_color_frame(AVFrame *frame, const int color[4]);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 09b2902bca..172ea92b16 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2831,7 +2831,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data,
}
#endif
- s2->codec_tag = avpriv_toupper4(avctx->codec_tag);
+ s2->codec_tag = ff_toupper4(avctx->codec_tag);
if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
|| s2->codec_tag == AV_RL32("BW10")
))
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index ba5b51955e..90d0a9fd50 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -707,7 +707,7 @@ void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
s->workaround_bugs = avctx->workaround_bugs;
/* convert fourcc to upper case */
- s->codec_tag = avpriv_toupper4(avctx->codec_tag);
+ s->codec_tag = ff_toupper4(avctx->codec_tag);
}
/**
diff --git a/libavcodec/to_upper4.c b/libavcodec/to_upper4.c
new file mode 100644
index 0000000000..29f65bf5c3
--- /dev/null
+++ b/libavcodec/to_upper4.c
@@ -0,0 +1,23 @@
+/*
+ * Converting FOURCCs to uppercase
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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 "to_upper4.h"
diff --git a/libavcodec/to_upper4.h b/libavcodec/to_upper4.h
new file mode 100644
index 0000000000..d9648b5ef6
--- /dev/null
+++ b/libavcodec/to_upper4.h
@@ -0,0 +1,37 @@
+/*
+ * Converting FOURCCs to uppercase
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * 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_TO_UPPER4_H
+#define AVCODEC_TO_UPPER4_H
+
+#include "libavutil/avstring.h"
+#include "internal.h"
+
+unsigned int ff_toupper4(unsigned int x)
+{
+ return av_toupper(x & 0xFF) |
+ (av_toupper((x >> 8) & 0xFF) << 8) |
+ (av_toupper((x >> 16) & 0xFF) << 16) |
+((unsigned)av_toupper((x >> 24) & 0xFF) << 24);
+}
+
+#endif
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4d236ff1cd..b19befef21 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -863,14 +863,6 @@ const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index)
return &codec->hw_configs[index]->public;
}
-unsigned int avpriv_toupper4(unsigned int x)
-{
- return av_toupper(x & 0xFF) +
- (av_toupper((x >> 8) & 0xFF) << 8) +
- (av_toupper((x >> 16) & 0xFF) << 16) +
-((unsigned)av_toupper((x >> 24) & 0xFF) << 24);
-}
-
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
{
int ret;
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 6e93d082d9..c5c9e78fa8 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -677,7 +677,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL) += libssh.o
OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o
# Objects duplicated from other libraries for shared builds
-SHLIBOBJS += log2_tab.o
+SHLIBOBJS += log2_tab.o to_upper4.o
SHLIBOBJS-$(CONFIG_ISO_MEDIA) += mpegaudiotabs.o
SHLIBOBJS-$(CONFIG_FLV_MUXER) += mpeg4audio_sample_rates.o
SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7216331fa1..fc309fb416 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1716,7 +1716,7 @@ static unsigned int validate_codec_tag(const AVCodecTag *const *tags,
for (i = 0; tags && tags[i]; i++) {
const AVCodecTag *codec_tags = tags[i];
while (codec_tags->id != AV_CODEC_ID_NONE) {
- if (avpriv_toupper4(codec_tags->tag) == avpriv_toupper4(tag) &&
+ if (ff_toupper4(codec_tags->tag) == ff_toupper4(tag) &&
codec_tags->id == codec_id)
return codec_tags->tag;
codec_tags++;
diff --git a/libavformat/mux.c b/libavformat/mux.c
index d93dc73f8e..b9c4abb9cf 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -204,7 +204,7 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
for (int n = 0; s->oformat->codec_tag[n]; n++) {
avctag = s->oformat->codec_tag[n];
while (avctag->id != AV_CODEC_ID_NONE) {
- if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codecpar->codec_tag)) {
+ if (ff_toupper4(avctag->tag) == ff_toupper4(st->codecpar->codec_tag)) {
id = avctag->id;
if (id == st->codecpar->codec_id)
return 1;
diff --git a/libavformat/to_upper4.c b/libavformat/to_upper4.c
new file mode 100644
index 0000000000..e84c803675
--- /dev/null
+++ b/libavformat/to_upper4.c
@@ -0,0 +1,23 @@
+/*
+ * Converting FOURCCs to uppercase
+ * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/to_upper4.h"
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b5a4a09ae8..bd076d532b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -361,7 +361,7 @@ enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
if (tag == tags[i].tag)
return tags[i].id;
for (int i = 0; tags[i].id != AV_CODEC_ID_NONE; i++)
- if (avpriv_toupper4(tag) == avpriv_toupper4(tags[i].tag))
+ if (ff_toupper4(tag) == ff_toupper4(tags[i].tag))
return tags[i].id;
return AV_CODEC_ID_NONE;
}
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 12/15] avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (9 preceding siblings ...)
2021-12-15 12:35 ` [FFmpeg-devel] [PATCH 11/11] avcodec/utils: Unavpriv avpriv_toupper4() Andreas Rheinhardt
@ 2021-12-16 1:29 ` Andreas Rheinhardt
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket) Andreas Rheinhardt
` (3 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-16 1:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The packet given to muxers is not used afterwards; it is always
unreferenced by libavformat. Ergo muxers are allowed to keep
the references in the packets and e.g. move the ownership to
a packet list. This is what this commit does.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/aiffenc.c | 2 +-
libavformat/flacenc.c | 2 +-
libavformat/movenc.c | 4 +++-
libavformat/mp3enc.c | 3 ++-
libavformat/ttaenc.c | 3 ++-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 24bc17400e..7bb0978a53 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -219,7 +219,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
return 0;
return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end,
- pkt, av_packet_ref, 0);
+ pkt, NULL, 0);
}
return 0;
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index f884e5d2c8..e8f043729e 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -360,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == c->audio_stream_idx) {
if (c->waiting_pics) {
/* buffer audio packets until we get all the pictures */
- ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, av_packet_ref, 0);
+ ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, NULL, 0);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
c->waiting_pics = 0;
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index fc309fb416..033a6a9f52 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6197,9 +6197,11 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR(EINVAL);
}
+ /* The following will reset pkt and is only allowed to be used
+ * because we return immediately. afterwards. */
if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue,
&trk->squashed_packet_queue_end,
- pkt, av_packet_ref, 0)) < 0) {
+ pkt, NULL, 0)) < 0) {
return ret;
}
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 71e96a8651..0ffc79c025 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -524,7 +524,8 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == mp3->audio_stream_idx) {
if (mp3->pics_to_write) {
/* buffer audio packets until we get all the pictures */
- int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end, pkt, av_packet_ref, 0);
+ int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end,
+ pkt, NULL, 0);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n");
diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index 11855c32d9..5f21fdc144 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -95,10 +95,11 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt,
- av_packet_ref, 0);
+ NULL, 0);
if (ret < 0) {
return ret;
}
+ pkt = &tta->queue_end->pkt;
avio_wl32(tta->seek_table, pkt->size);
tta->nb_samples += pkt->duration;
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket)
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (10 preceding siblings ...)
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 12/15] avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references Andreas Rheinhardt
@ 2021-12-16 1:29 ` Andreas Rheinhardt
2021-12-21 13:52 ` Tomas Härdin
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 14/15] avcodec/packet_internal: Add proper PacketList struct Andreas Rheinhardt
` (2 subsequent siblings)
14 siblings, 1 reply; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-16 1:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This removes the last usage of sizeof(AVPacket) in the generic
muxing code.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/mux.c | 8 +-------
libavformat/mxfenc.c | 8 ++------
2 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/libavformat/mux.c b/libavformat/mux.c
index b9c4abb9cf..0500f636de 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1014,15 +1014,9 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
AVStream *const st = s->streams[pktl->pkt.stream_index];
FFStream *const sti = ffstream(st);
- *pkt = pktl->pkt;
-
- si->packet_buffer = pktl->next;
- if (!si->packet_buffer)
- si->packet_buffer_end = NULL;
-
if (sti->last_in_packet_buffer == pktl)
sti->last_in_packet_buffer = NULL;
- av_freep(&pktl);
+ avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, pkt);
return 1;
} else {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 00bbe58149..7635e183d0 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3125,14 +3125,10 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
pktl = si->packet_buffer;
}
- *out = pktl->pkt;
- av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts);
- si->packet_buffer = pktl->next;
if (ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer == pktl)
ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer = NULL;
- if (!si->packet_buffer)
- si->packet_buffer_end = NULL;
- av_freep(&pktl);
+ avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, out);
+ av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out->stream_index, out->dts);
return 1;
} else {
out:
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket)
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket) Andreas Rheinhardt
@ 2021-12-21 13:52 ` Tomas Härdin
0 siblings, 0 replies; 23+ messages in thread
From: Tomas Härdin @ 2021-12-21 13:52 UTC (permalink / raw)
To: FFmpeg development discussions and patches
tor 2021-12-16 klockan 02:29 +0100 skrev Andreas Rheinhardt:
> This removes the last usage of sizeof(AVPacket) in the generic
> muxing code.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavformat/mux.c | 8 +-------
> libavformat/mxfenc.c | 8 ++------
> 2 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/libavformat/mux.c b/libavformat/mux.c
> index b9c4abb9cf..0500f636de 100644
> --- a/libavformat/mux.c
> +++ b/libavformat/mux.c
> @@ -1014,15 +1014,9 @@ int
> ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
> AVStream *const st = s->streams[pktl->pkt.stream_index];
> FFStream *const sti = ffstream(st);
>
> - *pkt = pktl->pkt;
> -
> - si->packet_buffer = pktl->next;
> - if (!si->packet_buffer)
> - si->packet_buffer_end = NULL;
> -
> if (sti->last_in_packet_buffer == pktl)
> sti->last_in_packet_buffer = NULL;
> - av_freep(&pktl);
> + avpriv_packet_list_get(&si->packet_buffer, &si-
> >packet_buffer_end, pkt);
>
> return 1;
> } else {
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 00bbe58149..7635e183d0 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -3125,14 +3125,10 @@ static int
> mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
> pktl = si->packet_buffer;
> }
>
> - *out = pktl->pkt;
> - av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n",
> (*out).stream_index, (*out).dts);
> - si->packet_buffer = pktl->next;
> if (ffstream(s->streams[pktl->pkt.stream_index])-
> >last_in_packet_buffer == pktl)
> ffstream(s->streams[pktl->pkt.stream_index])-
> >last_in_packet_buffer = NULL;
> - if (!si->packet_buffer)
> - si->packet_buffer_end = NULL;
> - av_freep(&pktl);
> + avpriv_packet_list_get(&si->packet_buffer, &si-
> >packet_buffer_end, out);
> + av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out-
> >stream_index, out->dts);
> return 1;
> } else {
> out:
Looks like this makes the code simpler, which is fine by me
/Tomas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 14/15] avcodec/packet_internal: Add proper PacketList struct
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (11 preceding siblings ...)
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 13/15] avformat/mux, mxfenc: Don't use sizeof(AVPacket) Andreas Rheinhardt
@ 2021-12-16 1:29 ` Andreas Rheinhardt
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 15/15] avformat/movenc: Use dedicated pointer for access to MOVTrack Andreas Rheinhardt
2021-12-17 22:52 ` [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-16 1:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Up until now, we had a PacketList structure which is actually
a PacketListEntry; a proper PacketList did not exist
and all the related functions just passed pointers to pointers
to the head and tail elements around. All these pointers were
actually consecutive elements of their containing structs,
i.e. the users already treated them as if they were a struct.
So add a proper PacketList struct and rename the current PacketList
to PacketListEntry; also make the functions use this structure
instead of the pair of pointers.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
One can unavpriv these functions by using AVPacket.opaque as next
pointer. Shall I do so?
libavcodec/avpacket.c | 36 +++++++++++------------
libavcodec/packet_internal.h | 25 +++++++---------
libavdevice/decklink_common.h | 5 +++-
libavdevice/decklink_dec.cpp | 29 +++++++++----------
libavdevice/dshow.c | 10 +++----
libavdevice/dshow_capture.h | 2 +-
libavdevice/vfwcap.c | 12 ++++----
libavformat/aiffenc.c | 17 ++++++-----
libavformat/demux.c | 54 ++++++++++++++++-------------------
libavformat/flacenc.c | 10 +++----
libavformat/internal.h | 12 ++++----
libavformat/matroskadec.c | 19 ++++++------
libavformat/movenc.c | 8 ++----
libavformat/movenc.h | 2 +-
libavformat/movenc_ttml.c | 6 ++--
libavformat/mp3enc.c | 11 ++++---
libavformat/mux.c | 38 ++++++++++++------------
libavformat/mxfenc.c | 14 ++++-----
libavformat/ttaenc.c | 13 ++++-----
libavformat/utils.c | 7 ++---
20 files changed, 154 insertions(+), 176 deletions(-)
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index a0134e405c..4f7a6b255c 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -535,13 +535,12 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
}
-int avpriv_packet_list_put(PacketList **packet_buffer,
- PacketList **plast_pktl,
+int avpriv_packet_list_put(PacketList *packet_buffer,
AVPacket *pkt,
int (*copy)(AVPacket *dst, const AVPacket *src),
int flags)
{
- PacketList *pktl = av_malloc(sizeof(PacketList));
+ PacketListEntry *pktl = av_malloc(sizeof(*pktl));
int ret;
if (!pktl)
@@ -565,44 +564,41 @@ int avpriv_packet_list_put(PacketList **packet_buffer,
pktl->next = NULL;
- if (*packet_buffer)
- (*plast_pktl)->next = pktl;
+ if (packet_buffer->head)
+ packet_buffer->tail->next = pktl;
else
- *packet_buffer = pktl;
+ packet_buffer->head = pktl;
/* Add the packet in the buffered packet list. */
- *plast_pktl = pktl;
+ packet_buffer->tail = pktl;
return 0;
}
-int avpriv_packet_list_get(PacketList **pkt_buffer,
- PacketList **pkt_buffer_end,
+int avpriv_packet_list_get(PacketList *pkt_buffer,
AVPacket *pkt)
{
- PacketList *pktl;
- if (!*pkt_buffer)
+ PacketListEntry *pktl = pkt_buffer->head;
+ if (!pktl)
return AVERROR(EAGAIN);
- pktl = *pkt_buffer;
*pkt = pktl->pkt;
- *pkt_buffer = pktl->next;
- if (!pktl->next)
- *pkt_buffer_end = NULL;
+ pkt_buffer->head = pktl->next;
+ if (!pkt_buffer->head)
+ pkt_buffer->tail = NULL;
av_freep(&pktl);
return 0;
}
-void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end)
+void avpriv_packet_list_free(PacketList *pkt_buf)
{
- PacketList *tmp = *pkt_buf;
+ PacketListEntry *tmp = pkt_buf->head;
while (tmp) {
- PacketList *pktl = tmp;
+ PacketListEntry *pktl = tmp;
tmp = pktl->next;
av_packet_unref(&pktl->pkt);
av_freep(&pktl);
}
- *pkt_buf = NULL;
- *pkt_buf_end = NULL;
+ pkt_buf->head = pkt_buf->tail = NULL;
}
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
diff --git a/libavcodec/packet_internal.h b/libavcodec/packet_internal.h
index a10931c106..92a0d4e6d5 100644
--- a/libavcodec/packet_internal.h
+++ b/libavcodec/packet_internal.h
@@ -23,16 +23,19 @@
#include "packet.h"
-typedef struct PacketList {
- struct PacketList *next;
+typedef struct PacketListEntry {
+ struct PacketListEntry *next;
AVPacket pkt;
+} PacketListEntry;
+
+typedef struct PacketList {
+ PacketListEntry *head, *tail;
} PacketList;
/**
* Append an AVPacket to the list.
*
- * @param head List head element
- * @param tail List tail element
+ * @param list A PacketList
* @param pkt The packet being appended. The data described in it will
* be made reference counted if it isn't already.
* @param copy A callback to copy the contents of the packet to the list.
@@ -41,8 +44,7 @@ typedef struct PacketList {
* @return 0 on success, negative AVERROR value on failure. On failure,
the packet and the list are unchanged.
*/
-int avpriv_packet_list_put(PacketList **head, PacketList **tail,
- AVPacket *pkt,
+int avpriv_packet_list_put(PacketList *list, AVPacket *pkt,
int (*copy)(AVPacket *dst, const AVPacket *src),
int flags);
@@ -52,22 +54,17 @@ int avpriv_packet_list_put(PacketList **head, PacketList **tail,
* @note The pkt will be overwritten completely on success. The caller
* owns the packet and must unref it by itself.
*
- * @param head List head element
- * @param tail List tail element
+ * @param head A pointer to a PacketList struct
* @param pkt Pointer to an AVPacket struct
* @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if
* the list was empty.
*/
-int avpriv_packet_list_get(PacketList **head, PacketList **tail,
- AVPacket *pkt);
+int avpriv_packet_list_get(PacketList *list, AVPacket *pkt);
/**
* Wipe the list and unref all the packets in it.
- *
- * @param head List head element
- * @param tail List tail element
*/
-void avpriv_packet_list_free(PacketList **head, PacketList **tail);
+void avpriv_packet_list_free(PacketList *list);
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type);
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 5b11dcd46d..79d6ac5b38 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -29,6 +29,9 @@
#define IDeckLinkProfileAttributes IDeckLinkAttributes
#endif
+extern "C" {
+#include "libavcodec/packet_internal.h"
+}
#include "libavutil/thread.h"
#include "decklink_common_c.h"
#if CONFIG_LIBKLVANC
@@ -75,7 +78,7 @@ class decklink_output_callback;
class decklink_input_callback;
typedef struct AVPacketQueue {
- PacketList *first_pkt, *last_pkt;
+ PacketList pkt_list;
int nb_packets;
unsigned long long size;
int abort_request;
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 491fe4be3d..c97a72d93d 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -483,16 +483,16 @@ static void avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q)
static void avpacket_queue_flush(AVPacketQueue *q)
{
- PacketList *pkt, *pkt1;
+ PacketListEntry *pkt, *pkt1;
pthread_mutex_lock(&q->mutex);
- for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
+ for (pkt = q->pkt_list.head; pkt != NULL; pkt = pkt1) {
pkt1 = pkt->next;
av_packet_unref(&pkt->pkt);
av_freep(&pkt);
}
- q->last_pkt = NULL;
- q->first_pkt = NULL;
+ q->pkt_list.head = NULL;
+ q->pkt_list.tail = NULL;
q->nb_packets = 0;
q->size = 0;
pthread_mutex_unlock(&q->mutex);
@@ -516,7 +516,7 @@ static unsigned long long avpacket_queue_size(AVPacketQueue *q)
static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
{
- PacketList *pkt1;
+ PacketListEntry *pkt1;
// Drop Packet if queue size is > maximum queue size
if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) {
@@ -530,7 +530,7 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
return -1;
}
- pkt1 = (PacketList *)av_malloc(sizeof(PacketList));
+ pkt1 = (PacketListEntry *)av_malloc(sizeof(*pkt1));
if (!pkt1) {
av_packet_unref(pkt);
return -1;
@@ -540,13 +540,13 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
pthread_mutex_lock(&q->mutex);
- if (!q->last_pkt) {
- q->first_pkt = pkt1;
+ if (!q->pkt_list.tail) {
+ q->pkt_list.head = pkt1;
} else {
- q->last_pkt->next = pkt1;
+ q->pkt_list.tail->next = pkt1;
}
- q->last_pkt = pkt1;
+ q->pkt_list.tail = pkt1;
q->nb_packets++;
q->size += pkt1->pkt.size + sizeof(*pkt1);
@@ -558,17 +558,16 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
static int avpacket_queue_get(AVPacketQueue *q, AVPacket *pkt, int block)
{
- PacketList *pkt1;
int ret;
pthread_mutex_lock(&q->mutex);
for (;; ) {
- pkt1 = q->first_pkt;
+ PacketListEntry *pkt1 = q->pkt_list.head;
if (pkt1) {
- q->first_pkt = pkt1->next;
- if (!q->first_pkt) {
- q->last_pkt = NULL;
+ q->pkt_list.head = pkt1->next;
+ if (!q->pkt_list.head) {
+ q->pkt_list.tail = NULL;
}
q->nb_packets--;
q->size -= pkt1->pkt.size + sizeof(*pkt1);
diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index ec1501ef8e..2baf85857d 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -58,7 +58,7 @@ static int
dshow_read_close(AVFormatContext *s)
{
struct dshow_ctx *ctx = s->priv_data;
- PacketList *pktl;
+ PacketListEntry *pktl;
if (ctx->control) {
IMediaControl_Stop(ctx->control);
@@ -118,7 +118,7 @@ dshow_read_close(AVFormatContext *s)
pktl = ctx->pktl;
while (pktl) {
- PacketList *next = pktl->next;
+ PacketListEntry *next = pktl->next;
av_packet_unref(&pktl->pkt);
av_free(pktl);
pktl = next;
@@ -162,7 +162,7 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e
{
AVFormatContext *s = priv_data;
struct dshow_ctx *ctx = s->priv_data;
- PacketList **ppktl, *pktl_next;
+ PacketListEntry **ppktl, *pktl_next;
// dump_videohdr(s, vdhdr);
@@ -171,7 +171,7 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time, e
if(shall_we_drop(s, index, devtype))
goto fail;
- pktl_next = av_mallocz(sizeof(PacketList));
+ pktl_next = av_mallocz(sizeof(*pktl_next));
if(!pktl_next)
goto fail;
@@ -1254,7 +1254,7 @@ static int dshow_check_event_queue(IMediaEvent *media_event)
static int dshow_read_packet(AVFormatContext *s, AVPacket *pkt)
{
struct dshow_ctx *ctx = s->priv_data;
- PacketList *pktl = NULL;
+ PacketListEntry *pktl = NULL;
while (!ctx->eof && !pktl) {
WaitForSingleObject(ctx->mutex, INFINITE);
diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index 06ded2ba96..8f9f0b5245 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -321,7 +321,7 @@ struct dshow_ctx {
HANDLE mutex;
HANDLE event[2]; /* event[0] is set by DirectShow
* event[1] is set by callback() */
- PacketList *pktl;
+ PacketListEntry *pktl;
int eof;
diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c
index 6fad466f8a..86a40b4af4 100644
--- a/libavdevice/vfwcap.c
+++ b/libavdevice/vfwcap.c
@@ -45,7 +45,7 @@ struct vfw_ctx {
HWND hwnd;
HANDLE mutex;
HANDLE event;
- PacketList *pktl;
+ PacketListEntry *pktl;
unsigned int curbufsize;
unsigned int frame_num;
char *video_size; /**< A string describing video size, set by a private option. */
@@ -179,7 +179,7 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
{
AVFormatContext *s;
struct vfw_ctx *ctx;
- PacketList **ppktl, *pktl_next;
+ PacketListEntry **ppktl, *pktl_next;
s = (AVFormatContext *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
ctx = s->priv_data;
@@ -191,7 +191,7 @@ static LRESULT CALLBACK videostream_cb(HWND hwnd, LPVIDEOHDR vdhdr)
WaitForSingleObject(ctx->mutex, INFINITE);
- pktl_next = av_mallocz(sizeof(PacketList));
+ pktl_next = av_mallocz(sizeof(*pktl_next));
if(!pktl_next)
goto fail;
@@ -220,7 +220,7 @@ fail:
static int vfw_read_close(AVFormatContext *s)
{
struct vfw_ctx *ctx = s->priv_data;
- PacketList *pktl;
+ PacketListEntry *pktl;
if(ctx->hwnd) {
SendMessage(ctx->hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
@@ -234,7 +234,7 @@ static int vfw_read_close(AVFormatContext *s)
pktl = ctx->pktl;
while (pktl) {
- PacketList *next = pktl->next;
+ PacketListEntry *next = pktl->next;
av_packet_unref(&pktl->pkt);
av_free(pktl);
pktl = next;
@@ -440,7 +440,7 @@ fail:
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)
{
struct vfw_ctx *ctx = s->priv_data;
- PacketList *pktl = NULL;
+ PacketListEntry *pktl = NULL;
while(!pktl) {
WaitForSingleObject(ctx->mutex, INFINITE);
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 7bb0978a53..1fd6b8a70b 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -37,7 +37,7 @@ typedef struct AIFFOutputContext {
int64_t frames;
int64_t ssnd;
int audio_stream_idx;
- PacketList *pict_list, *pict_list_end;
+ PacketList pict_list;
int write_id3v2;
int id3v2_version;
} AIFFOutputContext;
@@ -48,9 +48,9 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff)
uint64_t pos, end, size;
ID3v2EncContext id3v2 = { 0 };
AVIOContext *pb = s->pb;
- PacketList *pict_list = aiff->pict_list;
+ PacketListEntry *list_entry = aiff->pict_list.head;
- if (!s->metadata && !s->nb_chapters && !aiff->pict_list)
+ if (!s->metadata && !s->nb_chapters && !list_entry)
return 0;
avio_wl32(pb, MKTAG('I', 'D', '3', ' '));
@@ -59,10 +59,10 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff)
ff_id3v2_start(&id3v2, pb, aiff->id3v2_version, ID3v2_DEFAULT_MAGIC);
ff_id3v2_write_metadata(s, &id3v2);
- while (pict_list) {
- if ((ret = ff_id3v2_write_apic(s, &id3v2, &pict_list->pkt)) < 0)
+ while (list_entry) {
+ if ((ret = ff_id3v2_write_apic(s, &id3v2, &list_entry->pkt)) < 0)
return ret;
- pict_list = pict_list->next;
+ list_entry = list_entry->next;
}
ff_id3v2_finish(&id3v2, pb, s->metadata_header_padding);
@@ -218,8 +218,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
if (s->streams[pkt->stream_index]->nb_frames >= 1)
return 0;
- return avpriv_packet_list_put(&aiff->pict_list, &aiff->pict_list_end,
- pkt, NULL, 0);
+ return avpriv_packet_list_put(&aiff->pict_list, pkt, NULL, 0);
}
return 0;
@@ -265,7 +264,7 @@ static void aiff_deinit(AVFormatContext *s)
{
AIFFOutputContext *aiff = s->priv_data;
- avpriv_packet_list_free(&aiff->pict_list, &aiff->pict_list_end);
+ avpriv_packet_list_free(&aiff->pict_list);
}
#define OFFSET(x) offsetof(AIFFOutputContext, x)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 360abd6014..4316bed9c0 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -537,7 +537,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
for (;;) {
- PacketList *pktl = si->raw_packet_buffer;
+ PacketListEntry *pktl = si->raw_packet_buffer.head;
AVStream *st;
FFStream *sti;
const AVPacket *pkt1;
@@ -548,8 +548,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
if (ffstream(st)->request_probe <= 0) {
- avpriv_packet_list_get(&si->raw_packet_buffer,
- &si->raw_packet_buffer_end, pkt);
+ avpriv_packet_list_get(&si->raw_packet_buffer, pkt);
si->raw_packet_buffer_size -= pkt->size;
return 0;
}
@@ -624,13 +623,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
err = avpriv_packet_list_put(&si->raw_packet_buffer,
- &si->raw_packet_buffer_end,
pkt, NULL, 0);
if (err < 0) {
av_packet_unref(pkt);
return err;
}
- pkt1 = &si->raw_packet_buffer_end->pkt;
+ pkt1 = &si->raw_packet_buffer.tail->pkt;
si->raw_packet_buffer_size += pkt1->size;
if ((err = probe_codec(s, st, pkt1)) < 0)
@@ -716,13 +714,14 @@ static int has_decode_delay_been_guessed(AVStream *st)
return sti->nb_decoded_frames >= 20;
}
-static PacketList *get_next_pkt(AVFormatContext *s, AVStream *st, PacketList *pktl)
+static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st,
+ PacketListEntry *pktl)
{
FFFormatContext *const si = ffformatcontext(s);
if (pktl->next)
return pktl->next;
- if (pktl == si->packet_buffer_end)
- return si->parse_queue;
+ if (pktl == si->packet_buffer.tail)
+ return si->parse_queue.head;
return NULL;
}
@@ -774,7 +773,7 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t
* of the packets in a window.
*/
static void update_dts_from_pts(AVFormatContext *s, int stream_index,
- PacketList *pkt_buffer)
+ PacketListEntry *pkt_buffer)
{
AVStream *const st = s->streams[stream_index];
int delay = ffstream(st)->avctx->has_b_frames;
@@ -804,7 +803,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
FFFormatContext *const si = ffformatcontext(s);
AVStream *const st = s->streams[stream_index];
FFStream *const sti = ffstream(st);
- PacketList *pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue;
+ PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head;
uint64_t shift;
@@ -823,7 +822,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
if (is_relative(pts))
pts += shift;
- for (PacketList *pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) {
+ for (PacketListEntry *pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) {
if (pktl_it->pkt.stream_index != stream_index)
continue;
if (is_relative(pktl_it->pkt.pts))
@@ -856,7 +855,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
{
FFFormatContext *const si = ffformatcontext(s);
FFStream *const sti = ffstream(st);
- PacketList *pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue;
+ PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head;
int64_t cur_dts = RELATIVE_TS_BASE;
if (sti->first_dts != AV_NOPTS_VALUE) {
@@ -882,7 +881,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(sti->first_dts));
return;
}
- pktl = si->packet_buffer ? si->packet_buffer : si->parse_queue;
+ pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head;
sti->first_dts = cur_dts;
} else if (sti->cur_dts != RELATIVE_TS_BASE)
return;
@@ -998,7 +997,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
}
}
- if (pkt->duration > 0 && (si->packet_buffer || si->parse_queue))
+ if (pkt->duration > 0 && (si->packet_buffer.head || si->parse_queue.head))
update_initial_durations(s, st, pkt->stream_index, pkt->duration);
/* Correct timestamps with byte offset if demuxers only have timestamps
@@ -1195,7 +1194,6 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt,
compute_pkt_fields(s, st, sti->parser, out_pkt, next_dts, next_pts);
ret = avpriv_packet_list_put(&si->parse_queue,
- &si->parse_queue_end,
out_pkt, NULL, 0);
if (ret < 0)
goto fail;
@@ -1225,7 +1223,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
int ret, got_packet = 0;
AVDictionary *metadata = NULL;
- while (!got_packet && !si->parse_queue) {
+ while (!got_packet && !si->parse_queue.head) {
AVStream *st;
FFStream *sti;
@@ -1338,8 +1336,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
}
}
- if (!got_packet && si->parse_queue)
- ret = avpriv_packet_list_get(&si->parse_queue, &si->parse_queue_end, pkt);
+ if (!got_packet && si->parse_queue.head)
+ ret = avpriv_packet_list_get(&si->parse_queue, pkt);
if (ret >= 0) {
AVStream *const st = s->streams[pkt->stream_index];
@@ -1420,9 +1418,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
AVStream *st;
if (!genpts) {
- ret = si->packet_buffer
- ? avpriv_packet_list_get(&si->packet_buffer,
- &si->packet_buffer_end, pkt)
+ ret = si->packet_buffer.head
+ ? avpriv_packet_list_get(&si->packet_buffer, pkt)
: read_frame_internal(s, pkt);
if (ret < 0)
return ret;
@@ -1430,7 +1427,7 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
}
for (;;) {
- PacketList *pktl = si->packet_buffer;
+ PacketListEntry *pktl = si->packet_buffer.head;
if (pktl) {
AVPacket *next_pkt = &pktl->pkt;
@@ -1463,15 +1460,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
// 3. the packets for this stream at the end of the files had valid dts.
next_pkt->pts = last_dts + next_pkt->duration;
}
- pktl = si->packet_buffer;
+ pktl = si->packet_buffer.head;
}
/* read packet from packet buffer, if there is data */
st = s->streams[next_pkt->stream_index];
if (!(next_pkt->pts == AV_NOPTS_VALUE && st->discard < AVDISCARD_ALL &&
next_pkt->dts != AV_NOPTS_VALUE && !eof)) {
- ret = avpriv_packet_list_get(&si->packet_buffer,
- &si->packet_buffer_end, pkt);
+ ret = avpriv_packet_list_get(&si->packet_buffer, pkt);
goto return_packet;
}
}
@@ -1486,7 +1482,6 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
}
ret = avpriv_packet_list_put(&si->packet_buffer,
- &si->packet_buffer_end,
pkt, NULL, 0);
if (ret < 0) {
av_packet_unref(pkt);
@@ -2601,12 +2596,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (!(ic->flags & AVFMT_FLAG_NOBUFFER)) {
ret = avpriv_packet_list_put(&si->packet_buffer,
- &si->packet_buffer_end,
pkt1, NULL, 0);
if (ret < 0)
goto unref_then_goto_end;
- pkt = &si->packet_buffer_end->pkt;
+ pkt = &si->packet_buffer.tail->pkt;
} else {
pkt = pkt1;
}
@@ -2754,8 +2748,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
// EOF already reached while reading the stream above.
// So continue with reoordering DTS with whatever delay we have.
- if (si->packet_buffer && !has_decode_delay_been_guessed(st)) {
- update_dts_from_pts(ic, stream_index, si->packet_buffer);
+ if (si->packet_buffer.head && !has_decode_delay_been_guessed(st)) {
+ update_dts_from_pts(ic, stream_index, si->packet_buffer.head);
}
}
}
diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index e8f043729e..b267197ccc 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -40,7 +40,7 @@ typedef struct FlacMuxerContext {
int audio_stream_idx;
int waiting_pics;
/* audio packets are queued here until we get all the attached pictures */
- PacketList *queue, *queue_end;
+ PacketList queue;
/* updated streaminfo sent by the encoder at the end */
uint8_t streaminfo[FLAC_STREAMINFO_SIZE];
@@ -306,8 +306,8 @@ static int flac_queue_flush(AVFormatContext *s)
if (ret < 0)
write = 0;
- while (c->queue) {
- avpriv_packet_list_get(&c->queue, &c->queue_end, pkt);
+ while (c->queue.head) {
+ avpriv_packet_list_get(&c->queue, pkt);
if (write && (ret = flac_write_audio_packet(s, pkt)) < 0)
write = 0;
av_packet_unref(pkt);
@@ -347,7 +347,7 @@ static void flac_deinit(struct AVFormatContext *s)
{
FlacMuxerContext *c = s->priv_data;
- avpriv_packet_list_free(&c->queue, &c->queue_end);
+ avpriv_packet_list_free(&c->queue);
for (unsigned i = 0; i < s->nb_streams; i++)
av_packet_free((AVPacket **)&s->streams[i]->priv_data);
}
@@ -360,7 +360,7 @@ static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == c->audio_stream_idx) {
if (c->waiting_pics) {
/* buffer audio packets until we get all the pictures */
- ret = avpriv_packet_list_put(&c->queue, &c->queue_end, pkt, NULL, 0);
+ ret = avpriv_packet_list_put(&c->queue, pkt, NULL, 0);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
c->waiting_pics = 0;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index eb8239cd3f..f6a93408e1 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -25,6 +25,7 @@
#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
+#include "libavcodec/packet_internal.h"
#include "avformat.h"
#include "os_support.h"
@@ -92,8 +93,7 @@ typedef struct FFFormatContext {
* not decoded, for example to get the codec parameters in MPEG
* streams.
*/
- struct PacketList *packet_buffer;
- struct PacketList *packet_buffer_end;
+ PacketList packet_buffer;
/* av_seek_frame() support */
int64_t data_offset; /**< offset of the first packet */
@@ -104,13 +104,11 @@ typedef struct FFFormatContext {
* be identified, as parsing cannot be done without knowing the
* codec.
*/
- struct PacketList *raw_packet_buffer;
- struct PacketList *raw_packet_buffer_end;
+ PacketList raw_packet_buffer;
/**
* Packets split by the parser get queued here.
*/
- struct PacketList *parse_queue;
- struct PacketList *parse_queue_end;
+ PacketList parse_queue;
/**
* The generic code uses this as a temporary packet
* to parse packets or for muxing, especially flushing.
@@ -393,7 +391,7 @@ typedef struct FFStream {
/**
* last packet in packet_buffer for this stream when muxing.
*/
- struct PacketList *last_in_packet_buffer;
+ PacketListEntry *last_in_packet_buffer;
int64_t last_IP_pts;
int last_IP_duration;
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index f823fb96b8..4fb1ea56e9 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -387,8 +387,7 @@ typedef struct MatroskaDemuxContext {
AVPacket *pkt;
/* the packet queue */
- PacketList *queue;
- PacketList *queue_end;
+ PacketList queue;
int done;
@@ -3058,11 +3057,11 @@ static int matroska_read_header(AVFormatContext *s)
static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
AVPacket *pkt)
{
- if (matroska->queue) {
+ if (matroska->queue.head) {
MatroskaTrack *tracks = matroska->tracks.elem;
MatroskaTrack *track;
- avpriv_packet_list_get(&matroska->queue, &matroska->queue_end, pkt);
+ avpriv_packet_list_get(&matroska->queue, pkt);
track = &tracks[pkt->stream_index];
if (track->has_palette) {
uint8_t *pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
@@ -3084,7 +3083,7 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
*/
static void matroska_clear_queue(MatroskaDemuxContext *matroska)
{
- avpriv_packet_list_free(&matroska->queue, &matroska->queue_end);
+ avpriv_packet_list_free(&matroska->queue);
}
static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
@@ -3250,7 +3249,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
track->audio.buf_timecode = AV_NOPTS_VALUE;
pkt->pos = pos;
pkt->stream_index = st->index;
- ret = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0);
+ ret = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0);
if (ret < 0) {
av_packet_unref(pkt);
return AVERROR(ENOMEM);
@@ -3472,7 +3471,7 @@ static int matroska_parse_webvtt(MatroskaDemuxContext *matroska,
pkt->duration = duration;
pkt->pos = pos;
- err = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0);
+ err = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0);
if (err < 0) {
av_packet_unref(pkt);
return AVERROR(ENOMEM);
@@ -3574,7 +3573,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
pkt->pos = pos;
pkt->duration = lace_duration;
- res = avpriv_packet_list_put(&matroska->queue, &matroska->queue_end, pkt, NULL, 0);
+ res = avpriv_packet_list_put(&matroska->queue, pkt, NULL, 0);
if (res < 0) {
av_packet_unref(pkt);
return AVERROR(ENOMEM);
@@ -3976,10 +3975,10 @@ static int webm_clusters_start_with_keyframe(AVFormatContext *s)
matroska_reset_status(matroska, 0, cluster_pos);
matroska_clear_queue(matroska);
if (matroska_parse_cluster(matroska) < 0 ||
- !matroska->queue) {
+ !matroska->queue.head) {
break;
}
- pkt = &matroska->queue->pkt;
+ pkt = &matroska->queue.head->pkt;
// 4 + read is the length of the cluster id and the cluster length field.
cluster_pos += 4 + read + cluster_length;
if (!(pkt->flags & AV_PKT_FLAG_KEY)) {
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 033a6a9f52..0ffc6395c3 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5349,7 +5349,7 @@ static int mov_write_squashed_packet(AVFormatContext *s, MOVTrack *track)
switch (track->st->codecpar->codec_id) {
case AV_CODEC_ID_TTML: {
- int had_packets = !!track->squashed_packet_queue;
+ int had_packets = !!track->squashed_packet_queue.head;
if ((ret = ff_mov_generate_squashed_ttml_packet(s, track, squashed_packet)) < 0) {
goto finish_squash;
@@ -6200,7 +6200,6 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
/* The following will reset pkt and is only allowed to be used
* because we return immediately. afterwards. */
if ((ret = avpriv_packet_list_put(&trk->squashed_packet_queue,
- &trk->squashed_packet_queue_end,
pkt, NULL, 0)) < 0) {
return ret;
}
@@ -6486,9 +6485,8 @@ static void mov_free(AVFormatContext *s)
ff_mov_cenc_free(&mov->tracks[i].cenc);
ffio_free_dyn_buf(&mov->tracks[i].mdat_buf);
- if (mov->tracks[i].squashed_packet_queue) {
- avpriv_packet_list_free(&(mov->tracks[i].squashed_packet_queue),
- &(mov->tracks[i].squashed_packet_queue_end));
+ if (mov->tracks[i].squashed_packet_queue.head) {
+ avpriv_packet_list_free(&mov->tracks[i].squashed_packet_queue);
}
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 40077b1afe..2ac84ed070 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -167,7 +167,7 @@ typedef struct MOVTrack {
unsigned int squash_fragment_samples_to_one; //< flag to note formats where all samples for a fragment are to be squashed
- PacketList *squashed_packet_queue, *squashed_packet_queue_end;
+ PacketList squashed_packet_queue;
} MOVTrack;
typedef enum {
diff --git a/libavformat/movenc_ttml.c b/libavformat/movenc_ttml.c
index 472572b45a..6deae49657 100644
--- a/libavformat/movenc_ttml.c
+++ b/libavformat/movenc_ttml.c
@@ -70,9 +70,7 @@ static int mov_write_ttml_document_from_queue(AVFormatContext *s,
return ret;
}
- while (!avpriv_packet_list_get(&track->squashed_packet_queue,
- &track->squashed_packet_queue_end,
- pkt)) {
+ while (!avpriv_packet_list_get(&track->squashed_packet_queue, pkt)) {
end_ts = FFMAX(end_ts, pkt->pts + pkt->duration);
// in case of the 'dfxp' muxing mode, each written document is offset
@@ -121,7 +119,7 @@ int ff_mov_generate_squashed_ttml_packet(AVFormatContext *s,
goto cleanup;
}
- if (!track->squashed_packet_queue) {
+ if (!track->squashed_packet_queue.head) {
// empty queue, write minimal empty document with zero duration
avio_write(ttml_ctx->pb, empty_ttml_document,
sizeof(empty_ttml_document) - 1);
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 0ffc79c025..3ff19da274 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -132,7 +132,7 @@ typedef struct MP3Context {
int pics_to_write;
/* audio packets are queued here until we get all the attached pictures */
- PacketList *queue, *queue_end;
+ PacketList queue;
} MP3Context;
static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}};
@@ -387,8 +387,8 @@ static int mp3_queue_flush(AVFormatContext *s)
ff_id3v2_finish(&mp3->id3, s->pb, s->metadata_header_padding);
mp3_write_xing(s);
- while (mp3->queue) {
- avpriv_packet_list_get(&mp3->queue, &mp3->queue_end, pkt);
+ while (mp3->queue.head) {
+ avpriv_packet_list_get(&mp3->queue, pkt);
if (write && (ret = mp3_write_audio_packet(s, pkt)) < 0)
write = 0;
av_packet_unref(pkt);
@@ -524,8 +524,7 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
if (pkt->stream_index == mp3->audio_stream_idx) {
if (mp3->pics_to_write) {
/* buffer audio packets until we get all the pictures */
- int ret = avpriv_packet_list_put(&mp3->queue, &mp3->queue_end,
- pkt, NULL, 0);
+ int ret = avpriv_packet_list_put(&mp3->queue, pkt, NULL, 0);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "Not enough memory to buffer audio. Skipping picture streams\n");
@@ -633,7 +632,7 @@ static void mp3_deinit(struct AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
- avpriv_packet_list_free(&mp3->queue, &mp3->queue_end);
+ avpriv_packet_list_free(&mp3->queue);
av_freep(&mp3->xing_frame);
}
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 0500f636de..c387f8ec6e 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -809,12 +809,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
{
int ret;
FFFormatContext *const si = ffformatcontext(s);
- PacketList **next_point, *this_pktl;
+ PacketListEntry **next_point, *this_pktl;
AVStream *st = s->streams[pkt->stream_index];
FFStream *const sti = ffstream(st);
int chunked = s->max_chunk_size || s->max_chunk_duration;
- this_pktl = av_malloc(sizeof(PacketList));
+ this_pktl = av_malloc(sizeof(*this_pktl));
if (!this_pktl) {
av_packet_unref(pkt);
return AVERROR(ENOMEM);
@@ -831,7 +831,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
if (sti->last_in_packet_buffer) {
next_point = &(sti->last_in_packet_buffer->next);
} else {
- next_point = &si->packet_buffer;
+ next_point = &si->packet_buffer.head;
}
if (chunked) {
@@ -855,7 +855,7 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
if (chunked && !(pkt->flags & CHUNK_START))
goto next_non_null;
- if (compare(s, &si->packet_buffer_end->pkt, pkt)) {
+ if (compare(s, &si->packet_buffer.tail->pkt, pkt)) {
while ( *next_point
&& ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
|| !compare(s, &(*next_point)->pkt, pkt)))
@@ -863,12 +863,12 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
if (*next_point)
goto next_non_null;
} else {
- next_point = &(si->packet_buffer_end->next);
+ next_point = &(si->packet_buffer.tail->next);
}
}
av_assert1(!*next_point);
- si->packet_buffer_end = this_pktl;
+ si->packet_buffer.tail = this_pktl;
next_non_null:
this_pktl->next = *next_point;
@@ -939,11 +939,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
flush = 1;
if (s->max_interleave_delta > 0 &&
- si->packet_buffer &&
+ si->packet_buffer.head &&
!flush &&
si->nb_interleaved_streams == stream_count+noninterleaved_count
) {
- AVPacket *const top_pkt = &si->packet_buffer->pkt;
+ AVPacket *const top_pkt = &si->packet_buffer.head->pkt;
int64_t delta_dts = INT64_MIN;
int64_t top_dts = av_rescale_q(top_pkt->dts,
s->streams[top_pkt->stream_index]->time_base,
@@ -952,7 +952,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
for (unsigned i = 0; i < s->nb_streams; i++) {
const AVStream *const st = s->streams[i];
const FFStream *const sti = cffstream(st);
- const PacketList *last = sti->last_in_packet_buffer;
+ const PacketListEntry *const last = sti->last_in_packet_buffer;
int64_t last_dts;
if (!last)
@@ -973,11 +973,11 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
}
}
- if (si->packet_buffer &&
+ if (si->packet_buffer.head &&
eof &&
(s->flags & AVFMT_FLAG_SHORTEST) &&
si->shortest_end == AV_NOPTS_VALUE) {
- AVPacket *const top_pkt = &si->packet_buffer->pkt;
+ AVPacket *const top_pkt = &si->packet_buffer.head->pkt;
si->shortest_end = av_rescale_q(top_pkt->dts,
s->streams[top_pkt->stream_index]->time_base,
@@ -985,8 +985,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
}
if (si->shortest_end != AV_NOPTS_VALUE) {
- while (si->packet_buffer) {
- PacketList *pktl = si->packet_buffer;
+ while (si->packet_buffer.head) {
+ PacketListEntry *pktl = si->packet_buffer.head;
AVPacket *const top_pkt = &pktl->pkt;
AVStream *const st = s->streams[top_pkt->stream_index];
FFStream *const sti = ffstream(st);
@@ -996,9 +996,9 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
if (si->shortest_end + 1 >= top_dts)
break;
- si->packet_buffer = pktl->next;
- if (!si->packet_buffer)
- si->packet_buffer_end = NULL;
+ si->packet_buffer.head = pktl->next;
+ if (!si->packet_buffer.head)
+ si->packet_buffer.tail = NULL;
if (sti->last_in_packet_buffer == pktl)
sti->last_in_packet_buffer = NULL;
@@ -1010,13 +1010,13 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
}
if (stream_count && flush) {
- PacketList *pktl = si->packet_buffer;
+ PacketListEntry *pktl = si->packet_buffer.head;
AVStream *const st = s->streams[pktl->pkt.stream_index];
FFStream *const sti = ffstream(st);
if (sti->last_in_packet_buffer == pktl)
sti->last_in_packet_buffer = NULL;
- avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, pkt);
+ avpriv_packet_list_get(&si->packet_buffer, pkt);
return 1;
} else {
@@ -1049,7 +1049,7 @@ int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset
const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
{
FFFormatContext *const si = ffformatcontext(s);
- PacketList *pktl = si->packet_buffer;
+ PacketListEntry *pktl = si->packet_buffer.head;
while (pktl) {
if (pktl->pkt.stream_index == stream) {
return &pktl->pkt;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 7635e183d0..146f8e3edc 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -3094,9 +3094,9 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
stream_count += !!ffstream(s->streams[i])->last_in_packet_buffer;
if (stream_count && (s->nb_streams == stream_count || flush)) {
- PacketList *pktl = si->packet_buffer;
+ PacketListEntry *pktl = si->packet_buffer.head;
if (s->nb_streams != stream_count) {
- PacketList *last = NULL;
+ PacketListEntry *last = NULL;
// find last packet in edit unit
while (pktl) {
if (!stream_count || pktl->pkt.stream_index == 0)
@@ -3110,7 +3110,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
}
// purge packet queue
while (pktl) {
- PacketList *next = pktl->next;
+ PacketListEntry *next = pktl->next;
av_packet_unref(&pktl->pkt);
av_freep(&pktl);
pktl = next;
@@ -3118,16 +3118,16 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, int flus
if (last)
last->next = NULL;
else {
- si->packet_buffer = NULL;
- si->packet_buffer_end = NULL;
+ si->packet_buffer.head = NULL;
+ si->packet_buffer.tail = NULL;
goto out;
}
- pktl = si->packet_buffer;
+ pktl = si->packet_buffer.head;
}
if (ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer == pktl)
ffstream(s->streams[pktl->pkt.stream_index])->last_in_packet_buffer = NULL;
- avpriv_packet_list_get(&si->packet_buffer, &si->packet_buffer_end, out);
+ avpriv_packet_list_get(&si->packet_buffer, out);
av_log(s, AV_LOG_TRACE, "out st:%d dts:%"PRId64"\n", out->stream_index, out->dts);
return 1;
} else {
diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index 5f21fdc144..486f8bdd10 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -30,7 +30,7 @@
typedef struct TTAMuxContext {
AVIOContext *seek_table;
- PacketList *queue, *queue_end;
+ PacketList queue;
uint32_t nb_samples;
int frame_size;
int last_frame;
@@ -94,12 +94,11 @@ static int tta_write_packet(AVFormatContext *s, AVPacket *pkt)
TTAMuxContext *tta = s->priv_data;
int ret;
- ret = avpriv_packet_list_put(&tta->queue, &tta->queue_end, pkt,
- NULL, 0);
+ ret = avpriv_packet_list_put(&tta->queue, pkt, NULL, 0);
if (ret < 0) {
return ret;
}
- pkt = &tta->queue_end->pkt;
+ pkt = &tta->queue.tail->pkt;
avio_wl32(tta->seek_table, pkt->size);
tta->nb_samples += pkt->duration;
@@ -126,8 +125,8 @@ static void tta_queue_flush(AVFormatContext *s)
TTAMuxContext *tta = s->priv_data;
AVPacket *const pkt = ffformatcontext(s)->pkt;
- while (tta->queue) {
- avpriv_packet_list_get(&tta->queue, &tta->queue_end, pkt);
+ while (tta->queue.head) {
+ avpriv_packet_list_get(&tta->queue, pkt);
avio_write(s->pb, pkt->data, pkt->size);
av_packet_unref(pkt);
}
@@ -163,7 +162,7 @@ static void tta_deinit(AVFormatContext *s)
TTAMuxContext *tta = s->priv_data;
ffio_free_dyn_buf(&tta->seek_table);
- avpriv_packet_list_free(&tta->queue, &tta->queue_end);
+ avpriv_packet_list_free(&tta->queue);
}
const AVOutputFormat ff_tta_muxer = {
diff --git a/libavformat/utils.c b/libavformat/utils.c
index bd076d532b..0105031681 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -239,7 +239,6 @@ int avformat_queue_attached_pictures(AVFormatContext *s)
}
ret = avpriv_packet_list_put(&si->raw_packet_buffer,
- &si->raw_packet_buffer_end,
&s->streams[i]->attached_pic,
av_packet_ref, 0);
if (ret < 0)
@@ -300,9 +299,9 @@ int ff_is_intra_only(enum AVCodecID id)
void ff_flush_packet_queue(AVFormatContext *s)
{
FFFormatContext *const si = ffformatcontext(s);
- avpriv_packet_list_free(&si->parse_queue, &si->parse_queue_end);
- avpriv_packet_list_free(&si->packet_buffer, &si->packet_buffer_end);
- avpriv_packet_list_free(&si->raw_packet_buffer, &si->raw_packet_buffer_end);
+ avpriv_packet_list_free(&si->parse_queue);
+ avpriv_packet_list_free(&si->packet_buffer);
+ avpriv_packet_list_free(&si->raw_packet_buffer);
si->raw_packet_buffer_size = 0;
}
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* [FFmpeg-devel] [PATCH 15/15] avformat/movenc: Use dedicated pointer for access to MOVTrack
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (12 preceding siblings ...)
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 14/15] avcodec/packet_internal: Add proper PacketList struct Andreas Rheinhardt
@ 2021-12-16 1:29 ` Andreas Rheinhardt
2021-12-17 22:52 ` [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-16 1:29 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Improves readability and slightly decreases codesize.
While just at it, also remove a check whether the packet list is
nonempty before freeing it, as freeing an empty list is fine
and basically a no-op.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/movenc.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0ffc6395c3..9f2f8414d5 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6466,28 +6466,28 @@ static void mov_free(AVFormatContext *s)
}
for (i = 0; i < mov->nb_streams; i++) {
- if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
- ff_mov_close_hinting(&mov->tracks[i]);
- else if (mov->tracks[i].tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd)
- av_freep(&mov->tracks[i].par);
- av_freep(&mov->tracks[i].cluster);
- av_freep(&mov->tracks[i].frag_info);
- av_packet_free(&mov->tracks[i].cover_image);
-
- if (mov->tracks[i].eac3_priv) {
- struct eac3_info *info = mov->tracks[i].eac3_priv;
+ MOVTrack *const track = &mov->tracks[i];
+
+ if (track->tag == MKTAG('r','t','p',' '))
+ ff_mov_close_hinting(track);
+ else if (track->tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd)
+ av_freep(&track->par);
+ av_freep(&track->cluster);
+ av_freep(&track->frag_info);
+ av_packet_free(&track->cover_image);
+
+ if (track->eac3_priv) {
+ struct eac3_info *info = track->eac3_priv;
av_packet_free(&info->pkt);
- av_freep(&mov->tracks[i].eac3_priv);
+ av_freep(&track->eac3_priv);
}
- if (mov->tracks[i].vos_len)
- av_freep(&mov->tracks[i].vos_data);
+ if (track->vos_len)
+ av_freep(&track->vos_data);
- ff_mov_cenc_free(&mov->tracks[i].cenc);
- ffio_free_dyn_buf(&mov->tracks[i].mdat_buf);
+ ff_mov_cenc_free(&track->cenc);
+ ffio_free_dyn_buf(&track->mdat_buf);
- if (mov->tracks[i].squashed_packet_queue.head) {
- avpriv_packet_list_free(&mov->tracks[i].squashed_packet_queue);
- }
+ avpriv_packet_list_free(&track->squashed_packet_queue);
}
av_freep(&mov->tracks);
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies
2021-12-15 12:29 [FFmpeg-devel] [PATCH 01/11] avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies Andreas Rheinhardt
` (13 preceding siblings ...)
2021-12-16 1:29 ` [FFmpeg-devel] [PATCH 15/15] avformat/movenc: Use dedicated pointer for access to MOVTrack Andreas Rheinhardt
@ 2021-12-17 22:52 ` Andreas Rheinhardt
14 siblings, 0 replies; 23+ messages in thread
From: Andreas Rheinhardt @ 2021-12-17 22:52 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> There is no mxfenc dependency any more since commit
> b9a26b9d55f77ebbff3596e46be54bb5fed469d3.
> Also remove a dnxhddata.h inclusion in mxfenc that was forgotten
> in the very same commit.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/Makefile | 2 --
> libavformat/mxfenc.c | 1 -
> 2 files changed, 3 deletions(-)
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 4122a9b144..fb90ecea84 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -983,14 +983,12 @@ OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o
> OBJS-$(CONFIG_ISO_MEDIA) += mpeg4audio.o mpegaudiodata.o
>
> OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o
> -OBJS-$(CONFIG_DNXHD_DEMUXER) += dnxhddata.o
> OBJS-$(CONFIG_FITS_DEMUXER) += fits.o
> OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o
> OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += mpeg4audio.o
> OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o
> OBJS-$(CONFIG_MOV_DEMUXER) += ac3tab.o
> OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o
> -OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o
> OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
> OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o
> OBJS-$(CONFIG_SPDIF_MUXER) += dca.o
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index fcd9afda2a..00bbe58149 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -48,7 +48,6 @@
> #include "libavutil/pixdesc.h"
> #include "libavutil/time_internal.h"
> #include "libavcodec/bytestream.h"
> -#include "libavcodec/dnxhddata.h"
> #include "libavcodec/dv_profile.h"
> #include "libavcodec/h264_ps.h"
> #include "libavcodec/golomb.h"
>
Ping for this patchset.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 23+ messages in thread