History

In libx264 wrapper, add -level specific option.

Baptiste Coudurier committed 15 years ago

Commit f92b0081 parent 37c0a441 file · +13 −3Browse files

Unified · Split

libavcodec/libx264.c+13−3
@@ -38,6 +38,7 @@ typedef struct X264Context { · 37 unmodified lines
38 const char *preset;38 const char *preset;
39 const char *tune;39 const char *tune;
40 const char *profile;40 const char *profile;
41 const char *level;
41 int fastfirstpass;42 int fastfirstpass;
42} X264Context;43} X264Context;
43 44
@@ -163,6 +164,15 @@ static av_cold int X264_close(AVCodecContext *avctx) · 119 unmodified lines
163 return 0;164 return 0;
164}165}
165 166
167#define OPT_STR(opt, param) \
168 do { \
169 if (param && x264_param_parse(&x4->params, opt, param) < 0) { \
170 av_log(avctx, AV_LOG_ERROR, \
171 "bad value for '%s': '%s'\n", opt, param); \
172 return -1; \
173 } \
174 } while (0); \
175
166static av_cold int X264_init(AVCodecContext *avctx)176static av_cold int X264_init(AVCodecContext *avctx)
167{177{
168 X264Context *x4 = avctx->priv_data;178 X264Context *x4 = avctx->priv_data;
@@ -249,9 +259,6 @@ static av_cold int X264_init(AVCodecContext *avctx) · 80 unmodified lines
249 x4->params.analyse.i_trellis = avctx->trellis;259 x4->params.analyse.i_trellis = avctx->trellis;
250 x4->params.analyse.i_noise_reduction = avctx->noise_reduction;260 x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
251 261
252 if (avctx->level > 0)
253 x4->params.i_level_idc = avctx->level;
254
255 x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);262 x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
256 x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);263 x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
257 x4->params.rc.f_pb_factor = avctx->b_quant_factor;264 x4->params.rc.f_pb_factor = avctx->b_quant_factor;
@@ -295,6 +302,8 @@ static av_cold int X264_init(AVCodecContext *avctx) · 37 unmodified lines
295 (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;302 (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
296 }303 }
297 304
305 OPT_STR("level", x4->level);
306
298 if (x4->fastfirstpass)307 if (x4->fastfirstpass)
299 x264_param_apply_fastfirstpass(&x4->params);308 x264_param_apply_fastfirstpass(&x4->params);
300 309
@@ -361,6 +370,7 @@ static const AVOption options[] = { · 60 unmodified lines
361 {"tune", "Tune the encoding params", OFFSET(tune), FF_OPT_TYPE_STRING, 0, 0, 0, VE},370 {"tune", "Tune the encoding params", OFFSET(tune), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
362 {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE},371 {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE},
363 {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE},372 {"profile", "Set profile restrictions", OFFSET(profile), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
373 {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, 0, 0, 0, VE},
364 { NULL },374 { NULL },
365};375};
366 376

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t