comparison libmpcodecs/ve_lavc.c @ 10779:1590742cf1c4

support for user specified intra/inter matrices
author alex
date Mon, 01 Sep 2003 14:04:41 +0000
parents c554ca1115de
children 5844bf004dec
comparison
equal deleted inserted replaced
10778:c554ca1115de 10779:1590742cf1c4
125 static int lavc_param_ibias= FF_DEFAULT_QUANT_BIAS; 125 static int lavc_param_ibias= FF_DEFAULT_QUANT_BIAS;
126 static int lavc_param_pbias= FF_DEFAULT_QUANT_BIAS; 126 static int lavc_param_pbias= FF_DEFAULT_QUANT_BIAS;
127 #endif 127 #endif
128 static int lavc_param_coder= 0; 128 static int lavc_param_coder= 0;
129 static int lavc_param_context= 0; 129 static int lavc_param_context= 0;
130 static char *lavc_param_intra_matrix = NULL;
131 static char *lavc_param_inter_matrix = NULL;
130 132
131 #include "m_option.h" 133 #include "m_option.h"
132 134
133 #ifdef USE_LIBAVCODEC 135 #ifdef USE_LIBAVCODEC
134 m_option_t lavcopts_conf[]={ 136 m_option_t lavcopts_conf[]={
216 #endif 218 #endif
217 #if LIBAVCODEC_BUILD >= 4669 219 #if LIBAVCODEC_BUILD >= 4669
218 {"coder", &lavc_param_coder, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL}, 220 {"coder", &lavc_param_coder, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL},
219 {"context", &lavc_param_context, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL}, 221 {"context", &lavc_param_context, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL},
220 #endif 222 #endif
223 #if LIBAVCODEC_BUILD >= 4675
224 {"intra_matrix", &lavc_param_intra_matrix, CONF_TYPE_STRING, 0, 0, 0, NULL},
225 {"inter_matrix", &lavc_param_inter_matrix, CONF_TYPE_STRING, 0, 0, 0, NULL},
226 #endif
221 {NULL, NULL, 0, 0, 0, 0, NULL} 227 {NULL, NULL, 0, 0, 0, 0, NULL}
222 }; 228 };
223 #endif 229 #endif
224 230
225 struct vf_priv_s { 231 struct vf_priv_s {
318 #endif 324 #endif
319 #if LIBAVCODEC_BUILD >= 4669 325 #if LIBAVCODEC_BUILD >= 4669
320 lavc_venc_context->coder_type= lavc_param_coder; 326 lavc_venc_context->coder_type= lavc_param_coder;
321 lavc_venc_context->context_model= lavc_param_context; 327 lavc_venc_context->context_model= lavc_param_context;
322 #endif 328 #endif
329 #if LIBAVCODEC_BUILD >= 4675
330 if (lavc_param_intra_matrix)
331 {
332 char *tmp;
333
334 lavc_venc_context->intra_matrix =
335 malloc(sizeof(*lavc_venc_context->intra_matrix)*64);
336
337 i = 0;
338 while ((tmp = strsep(&lavc_param_intra_matrix, ",")) && (i < 64))
339 {
340 if (!tmp || (tmp && !strlen(tmp)))
341 break;
342 lavc_venc_context->intra_matrix[i++] = atoi(tmp);
343 }
344
345 if (i != 64)
346 {
347 free(lavc_venc_context->intra_matrix);
348 lavc_venc_context->intra_matrix = NULL;
349 }
350 else
351 mp_msg(MSGT_MENCODER, MSGL_V, "Using user specified intra matrix\n");
352 }
353 if (lavc_param_inter_matrix)
354 {
355 char *tmp;
356
357 lavc_venc_context->inter_matrix =
358 malloc(sizeof(*lavc_venc_context->inter_matrix)*64);
359
360 i = 0;
361 while ((tmp = strsep(&lavc_param_inter_matrix, ",")) && (i < 64))
362 {
363 if (!tmp || (tmp && !strlen(tmp)))
364 break;
365 lavc_venc_context->inter_matrix[i++] = atoi(tmp);
366 }
367
368 if (i != 64)
369 {
370 free(lavc_venc_context->inter_matrix);
371 lavc_venc_context->inter_matrix = NULL;
372 }
373 else
374 mp_msg(MSGT_MENCODER, MSGL_V, "Using user specified inter matrix\n");
375 }
376 #endif
323 377
324 p= lavc_param_rc_override_string; 378 p= lavc_param_rc_override_string;
325 for(i=0; p; i++){ 379 for(i=0; p; i++){
326 int start, end, q; 380 int start, end, q;
327 int e=sscanf(p, "%d,%d,%d", &start, &end, &q); 381 int e=sscanf(p, "%d,%d,%d", &start, &end, &q);
646 psnr(lavc_venc_context->error[1]*4/f), 700 psnr(lavc_venc_context->error[1]*4/f),
647 psnr(lavc_venc_context->error[2]*4/f), 701 psnr(lavc_venc_context->error[2]*4/f),
648 psnr((lavc_venc_context->error[0]+lavc_venc_context->error[1]+lavc_venc_context->error[2])/(f*1.5)) 702 psnr((lavc_venc_context->error[0]+lavc_venc_context->error[1]+lavc_venc_context->error[2])/(f*1.5))
649 ); 703 );
650 } 704 }
705 #endif
706
707 #if LIBAVCODEC_BUILD >= 4675
708 if (lavc_venc_context->intra_matrix)
709 free(lavc_venc_context->intra_matrix);
710 lavc_venc_context->intra_matrix = NULL;
711 if (lavc_venc_context->inter_matrix)
712 free(lavc_venc_context->inter_matrix);
713 lavc_venc_context->inter_matrix = NULL;
651 #endif 714 #endif
652 715
653 avcodec_close(lavc_venc_context); 716 avcodec_close(lavc_venc_context);
654 717
655 if(stats_file) fclose(stats_file); 718 if(stats_file) fclose(stats_file);