JM8.6解码端是如何从配置文件decoder.cfg获取数据的? (init_conf函数)

2024-02-06 16:38

本文主要是介绍JM8.6解码端是如何从配置文件decoder.cfg获取数据的? (init_conf函数),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

      在ldecod.c文件的main中调用了init_conf函数,这个函数实际上就实现了程序从配置文件读数据的过程. 之前说过,在JM8.6编码端,Configure函数起着做配置文件encoder_baseline.cfg数据的作用,现在来看看解码端的init_conf函数.

      main中是这样调用的:

init_conf(input, argv[1]);


     其中input是一个结构体指针,字符串指针argv[1]实际上就指向了字符串"decoder.cfg", 进入init_conf函数看看:

void init_conf(struct inp_par *inp,char *config_filename)
{FILE *fd;int NAL_mode;// read the decoder configuration fileif((fd=fopen(config_filename,"r")) == NULL){snprintf(errortext, ET_SIZE, "Error: Control file %s not found\n",config_filename);error(errortext, 300);}fscanf(fd,"%s",inp->infile);                // H.264 compressed input bitsream// 过滤配置文件中的“注释”fscanf(fd,"%*[^\n]");fscanf(fd,"%s",inp->outfile);               // YUV 4:2:2 input formatfscanf(fd,"%*[^\n]");fscanf(fd,"%s",inp->reffile);               // reference filefscanf(fd,"%*[^\n]");// Frame buffer sizefscanf(fd,"%d,",&inp->dpb_size);   // may be overwritten in case of RTP NALfscanf(fd,"%*[^\n]");if (inp->dpb_size < 1){snprintf(errortext, ET_SIZE, "Decoded Picture Buffer Size is %d. It has to be at least 1",inp->dpb_size);error(errortext,1);}fscanf(fd,"%d",&(NAL_mode));                // NAL modefscanf(fd,"%*[^\n]");switch(NAL_mode){case 0:inp->FileFormat = PAR_OF_ANNEXB;break;case 1:inp->FileFormat = PAR_OF_RTP;break;default:snprintf(errortext, ET_SIZE, "NAL mode %i is not supported", NAL_mode);error(errortext,400);}fscanf(fd,"%d,",&inp->ref_offset);   // offset used for SNR computationfscanf(fd,"%*[^\n]");fscanf(fd,"%d,",&inp->poc_scale);   // offset used for SNR computationfscanf(fd,"%*[^\n]");if (inp->poc_scale < 1 || inp->poc_scale > 2){snprintf(errortext, ET_SIZE, "Poc Scale is %d. It has to be 1 or 2",inp->poc_scale);error(errortext,1);}#ifdef _LEAKYBUCKET_fscanf(fd,"%ld,",&inp->R_decoder);             // Decoder ratefscanf(fd, "%*[^\n]");fscanf(fd,"%ld,",&inp->B_decoder);             // Decoder buffer sizefscanf(fd, "%*[^\n]");fscanf(fd,"%ld,",&inp->F_decoder);             // Decoder initial delayfscanf(fd, "%*[^\n]"); fscanf(fd,"%s",inp->LeakyBucketParamFile);    // file where Leaky Bucket params (computed by encoder) are storedfscanf(fd,"%*[^\n]");
#endiffclose (fd);#if TRACEif ((p_trace=fopen(TRACEFILE,"w"))==0)             // append new statistic at the end{snprintf(errortext, ET_SIZE, "Error open file %s!",TRACEFILE);error(errortext,500);}
#endifif ((p_out=fopen(inp->outfile,"wb"))==0){snprintf(errortext, ET_SIZE, "Error open file %s ",inp->outfile);error(errortext,500);}
/*  if ((p_out2=fopen("out.yuv","wb"))==0){snprintf(errortext, ET_SIZE, "Error open file %s ",inp->outfile);error(errortext,500);}*/fprintf(stdout,"--------------------------------------------------------------------------\n");fprintf(stdout," Decoder config file                    : %s \n",config_filename);fprintf(stdout,"--------------------------------------------------------------------------\n");fprintf(stdout," Input H.264 bitstream                  : %s \n",inp->infile);fprintf(stdout," Output decoded YUV 4:2:0               : %s \n",inp->outfile);fprintf(stdout," Output status file                     : %s \n",LOGFILE);if ((p_ref=fopen(inp->reffile,"rb"))==0){fprintf(stdout," Input reference file                   : %s does not exist \n",inp->reffile);fprintf(stdout,"                                          SNR values are not available\n");}elsefprintf(stdout," Input reference file                   : %s \n",inp->reffile);fprintf(stdout,"--------------------------------------------------------------------------\n");
#ifdef _LEAKYBUCKET_fprintf(stdout," Rate_decoder        : %8ld \n",inp->R_decoder);fprintf(stdout," B_decoder           : %8ld \n",inp->B_decoder);fprintf(stdout," F_decoder           : %8ld \n",inp->F_decoder);fprintf(stdout," LeakyBucketParamFile: %s \n",inp->LeakyBucketParamFile); // Leaky Bucket Param filecalc_buffer(inp);fprintf(stdout,"--------------------------------------------------------------------------\n");
#endiffprintf(stdout,"POC must = frame# or field# for SNRs to be correct\n");fprintf(stdout,"Frame    POC   QP  SnrY    SnrU    SnrV   Time(ms)\n");
}


       可见,通过调用init_conf函数,实际上就是把argv[1]对应的配置文件的数据往input对应的结构体中倾倒,像倒茶一般, 这样,程序中的全局的指针变量对应的结构体就获得了配置文件encoder.cfg中的数据.

      

       最后,附带给出配置文件decoder.cfg中的内容:

test.264                 ........H.264 coded bitstream
test_dec.yuv             ........Output file, YUV 4:2:0 format
test_rec.yuv             ........Ref sequence (for SNR)
10                       ........Decoded Picture Buffer size
0                        ........NAL mode (0=Annex B, 1: RTP packets)
0                        ........SNR computation offset
1                        ........Poc Scale (1 or 2)
500000                   ........Rate_Decoder
104000                   ........B_decoder
73000                    ........F_decoder
leakybucketparam.cfg     ........LeakyBucket Params

This is a file containing input parameters to the JVT H.264/AVC decoder.
The text line following each parameter is discarded by the decoder.

 

 

 

这篇关于JM8.6解码端是如何从配置文件decoder.cfg获取数据的? (init_conf函数)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/684916

相关文章

SpringBoot中配置文件的加载顺序解读

《SpringBoot中配置文件的加载顺序解读》:本文主要介绍SpringBoot中配置文件的加载顺序,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录SpringBoot配置文件的加载顺序1、命令⾏参数2、Java系统属性3、操作系统环境变量5、项目【外部】的ap

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

Spring Boot读取配置文件的五种方式小结

《SpringBoot读取配置文件的五种方式小结》SpringBoot提供了灵活多样的方式来读取配置文件,这篇文章为大家介绍了5种常见的读取方式,文中的示例代码简洁易懂,大家可以根据自己的需要进... 目录1. 配置文件位置与加载顺序2. 读取配置文件的方式汇总方式一:使用 @Value 注解读取配置方式二

Python正则表达式语法及re模块中的常用函数详解

《Python正则表达式语法及re模块中的常用函数详解》这篇文章主要给大家介绍了关于Python正则表达式语法及re模块中常用函数的相关资料,正则表达式是一种强大的字符串处理工具,可以用于匹配、切分、... 目录概念、作用和步骤语法re模块中的常用函数总结 概念、作用和步骤概念: 本身也是一个字符串,其中

一文带你搞懂Python中__init__.py到底是什么

《一文带你搞懂Python中__init__.py到底是什么》朋友们,今天我们来聊聊Python里一个低调却至关重要的文件——__init__.py,有些人可能听说过它是“包的标志”,也有人觉得它“没... 目录先搞懂 python 模块(module)Python 包(package)是啥?那么 __in

Python中__init__方法使用的深度解析

《Python中__init__方法使用的深度解析》在Python的面向对象编程(OOP)体系中,__init__方法如同建造房屋时的奠基仪式——它定义了对象诞生时的初始状态,下面我们就来深入了解下_... 目录一、__init__的基因图谱二、初始化过程的魔法时刻继承链中的初始化顺序self参数的奥秘默认

python3 gunicorn配置文件的用法解读

《python3gunicorn配置文件的用法解读》:本文主要介绍python3gunicorn配置文件的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录python3 gunicorn配置文件配置文件服务启动、重启、关闭启动重启关闭总结python3 gun

shell编程之函数与数组的使用详解

《shell编程之函数与数组的使用详解》:本文主要介绍shell编程之函数与数组的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录shell函数函数的用法俩个数求和系统资源监控并报警函数函数变量的作用范围函数的参数递归函数shell数组获取数组的长度读取某下的

MySQL高级查询之JOIN、子查询、窗口函数实际案例

《MySQL高级查询之JOIN、子查询、窗口函数实际案例》:本文主要介绍MySQL高级查询之JOIN、子查询、窗口函数实际案例的相关资料,JOIN用于多表关联查询,子查询用于数据筛选和过滤,窗口函... 目录前言1. JOIN(连接查询)1.1 内连接(INNER JOIN)1.2 左连接(LEFT JOI

MySQL中FIND_IN_SET函数与INSTR函数用法解析

《MySQL中FIND_IN_SET函数与INSTR函数用法解析》:本文主要介绍MySQL中FIND_IN_SET函数与INSTR函数用法解析,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一... 目录一、功能定义与语法1、FIND_IN_SET函数2、INSTR函数二、本质区别对比三、实际场景案例分