You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/libx264: Avoid duplicating strings
Also removes some unchecked allocations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -62,7 +62,8 @@ typedef struct X264Context {
|
|||||||
int sei_size;
|
int sei_size;
|
||||||
char *preset;
|
char *preset;
|
||||||
char *tune;
|
char *tune;
|
||||||
char *profile;
|
const char *profile;
|
||||||
|
char *profile_opt;
|
||||||
char *level;
|
char *level;
|
||||||
int fastfirstpass;
|
int fastfirstpass;
|
||||||
char *wpredp;
|
char *wpredp;
|
||||||
@@ -832,26 +833,27 @@ static av_cold int X264_init(AVCodecContext *avctx)
|
|||||||
if (x4->fastfirstpass)
|
if (x4->fastfirstpass)
|
||||||
x264_param_apply_fastfirstpass(&x4->params);
|
x264_param_apply_fastfirstpass(&x4->params);
|
||||||
|
|
||||||
|
x4->profile = x4->profile_opt;
|
||||||
/* Allow specifying the x264 profile through AVCodecContext. */
|
/* Allow specifying the x264 profile through AVCodecContext. */
|
||||||
if (!x4->profile)
|
if (!x4->profile)
|
||||||
switch (avctx->profile) {
|
switch (avctx->profile) {
|
||||||
case FF_PROFILE_H264_BASELINE:
|
case FF_PROFILE_H264_BASELINE:
|
||||||
x4->profile = av_strdup("baseline");
|
x4->profile = "baseline";
|
||||||
break;
|
break;
|
||||||
case FF_PROFILE_H264_HIGH:
|
case FF_PROFILE_H264_HIGH:
|
||||||
x4->profile = av_strdup("high");
|
x4->profile = "high";
|
||||||
break;
|
break;
|
||||||
case FF_PROFILE_H264_HIGH_10:
|
case FF_PROFILE_H264_HIGH_10:
|
||||||
x4->profile = av_strdup("high10");
|
x4->profile = "high10";
|
||||||
break;
|
break;
|
||||||
case FF_PROFILE_H264_HIGH_422:
|
case FF_PROFILE_H264_HIGH_422:
|
||||||
x4->profile = av_strdup("high422");
|
x4->profile = "high422";
|
||||||
break;
|
break;
|
||||||
case FF_PROFILE_H264_HIGH_444:
|
case FF_PROFILE_H264_HIGH_444:
|
||||||
x4->profile = av_strdup("high444");
|
x4->profile = "high444";
|
||||||
break;
|
break;
|
||||||
case FF_PROFILE_H264_MAIN:
|
case FF_PROFILE_H264_MAIN:
|
||||||
x4->profile = av_strdup("main");
|
x4->profile = "main";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -1098,7 +1100,7 @@ static av_cold void X264_init_static(FFCodec *codec)
|
|||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
{ "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), AV_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE},
|
{ "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},
|
{ "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},
|
{ "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},
|
{"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},
|
{"passlogfile", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
|
||||||
|
Reference in New Issue
Block a user