Unified · Split
| @@ -38,6 +38,7 @@ typedef struct X264Context { · 37 unmodified lines | ||
| 38 | 38 | const char *preset; |
| 39 | 39 | const char *tune; |
| 40 | 40 | const char *profile; |
| 41 | + const char *level; | |
| 41 | 42 | int fastfirstpass; |
| 42 | 43 | } X264Context; |
| 43 | 44 | |
| @@ -163,6 +164,15 @@ static av_cold int X264_close(AVCodecContext *avctx) · 119 unmodified lines | ||
| 163 | 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 | + | |
| 166 | 176 | static av_cold int X264_init(AVCodecContext *avctx) |
| 167 | 177 | { |
| 168 | 178 | X264Context *x4 = avctx->priv_data; |
| @@ -249,9 +259,6 @@ static av_cold int X264_init(AVCodecContext *avctx) · 80 unmodified lines | ||
| 249 | 259 | x4->params.analyse.i_trellis = avctx->trellis; |
| 250 | 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 | 262 | x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); |
| 256 | 263 | x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor); |
| 257 | 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 | 302 | (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size; |
| 296 | 303 | } |
| 297 | 304 | |
| 305 | + OPT_STR("level", x4->level); | |
| 306 | + | |
| 298 | 307 | if (x4->fastfirstpass) |
| 299 | 308 | x264_param_apply_fastfirstpass(&x4->params); |
| 300 | 309 | |
| @@ -361,6 +370,7 @@ static const AVOption options[] = { · 60 unmodified lines | ||
| 361 | 370 | {"tune", "Tune the encoding params", OFFSET(tune), FF_OPT_TYPE_STRING, 0, 0, 0, VE}, |
| 362 | 371 | {"fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, 1, 0, 1, VE}, |
| 363 | 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 | 374 | { NULL }, |
| 365 | 375 | }; |
| 366 | 376 | |