* [FFmpeg-devel] [PATCH] avcodec/libx264: Avoid duplicating strings
@ 2022-06-24 9:58 Andreas Rheinhardt
0 siblings, 0 replies; only message in thread
From: Andreas Rheinhardt @ 2022-06-24 9:58 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Notice that the underlying allocations were unchecked.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/libx264.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 616d855067..98ec030865 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -62,7 +62,8 @@ typedef struct X264Context {
int sei_size;
char *preset;
char *tune;
- char *profile;
+ const char *profile;
+ char *profile_opt;
char *level;
int fastfirstpass;
char *wpredp;
@@ -832,26 +833,27 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (x4->fastfirstpass)
x264_param_apply_fastfirstpass(&x4->params);
+ x4->profile = x4->profile_opt;
/* Allow specifying the x264 profile through AVCodecContext. */
if (!x4->profile)
switch (avctx->profile) {
case FF_PROFILE_H264_BASELINE:
- x4->profile = av_strdup("baseline");
+ x4->profile = "baseline";
break;
case FF_PROFILE_H264_HIGH:
- x4->profile = av_strdup("high");
+ x4->profile = "high";
break;
case FF_PROFILE_H264_HIGH_10:
- x4->profile = av_strdup("high10");
+ x4->profile = "high10";
break;
case FF_PROFILE_H264_HIGH_422:
- x4->profile = av_strdup("high422");
+ x4->profile = "high422";
break;
case FF_PROFILE_H264_HIGH_444:
- x4->profile = av_strdup("high444");
+ x4->profile = "high444";
break;
case FF_PROFILE_H264_MAIN:
- x4->profile = av_strdup("main");
+ x4->profile = "main";
break;
default:
break;
@@ -1098,7 +1100,7 @@ static av_cold void X264_init_static(FFCodec *codec)
static const AVOption options[] = {
{ "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), AV_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE},
{ "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
- { "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
+ { "profile", "Set profile restrictions (cf. x264 --fullhelp)", OFFSET(profile_opt), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
{ "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE},
{"level", "Specify level (as defined by Annex A)", OFFSET(level), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
{"passlogfile", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-24 9:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 9:58 [FFmpeg-devel] [PATCH] avcodec/libx264: Avoid duplicating strings Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git