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

相关文章

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

C++中::SHCreateDirectoryEx函数使用方法

《C++中::SHCreateDirectoryEx函数使用方法》::SHCreateDirectoryEx用于创建多级目录,类似于mkdir-p命令,本文主要介绍了C++中::SHCreateDir... 目录1. 函数原型与依赖项2. 基本使用示例示例 1:创建单层目录示例 2:创建多级目录3. 关键注

SpringBoot3使用Jasypt实现加密配置文件

《SpringBoot3使用Jasypt实现加密配置文件》这篇文章主要为大家详细介绍了SpringBoot3如何使用Jasypt实现加密配置文件功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编... 目录一. 使用步骤1. 添加依赖2.配置加密密码3. 加密敏感信息4. 将加密信息存储到配置文件中5

C++中函数模板与类模板的简单使用及区别介绍

《C++中函数模板与类模板的简单使用及区别介绍》这篇文章介绍了C++中的模板机制,包括函数模板和类模板的概念、语法和实际应用,函数模板通过类型参数实现泛型操作,而类模板允许创建可处理多种数据类型的类,... 目录一、函数模板定义语法真实示例二、类模板三、关键区别四、注意事项 ‌在C++中,模板是实现泛型编程

kotlin的函数forEach示例详解

《kotlin的函数forEach示例详解》在Kotlin中,forEach是一个高阶函数,用于遍历集合中的每个元素并对其执行指定的操作,它的核心特点是简洁、函数式,适用于需要遍历集合且无需返回值的场... 目录一、基本用法1️⃣ 遍历集合2️⃣ 遍历数组3️⃣ 遍历 Map二、与 for 循环的区别三、高

SpringBoot中配置文件pom.xml的使用详解

《SpringBoot中配置文件pom.xml的使用详解》SpringBoot的pom.xml文件是Maven项目的核心配置文件,用于定义项目的依赖、插件、构建配置等信息,下面小编就来和大家详细介绍一... 目录1. 基本结构2. 关键部分详解2.1 <modelVersion>2.2 项目坐标2.3 <p

C语言字符函数和字符串函数示例详解

《C语言字符函数和字符串函数示例详解》本文详细介绍了C语言中字符分类函数、字符转换函数及字符串操作函数的使用方法,并通过示例代码展示了如何实现这些功能,通过这些内容,读者可以深入理解并掌握C语言中的字... 目录一、字符分类函数二、字符转换函数三、strlen的使用和模拟实现3.1strlen函数3.2st

MySQL中COALESCE函数示例详解

《MySQL中COALESCE函数示例详解》COALESCE是一个功能强大且常用的SQL函数,主要用来处理NULL值和实现灵活的值选择策略,能够使查询逻辑更清晰、简洁,:本文主要介绍MySQL中C... 目录语法示例1. 替换 NULL 值2. 用于字段默认值3. 多列优先级4. 结合聚合函数注意事项总结C

Java8需要知道的4个函数式接口简单教程

《Java8需要知道的4个函数式接口简单教程》:本文主要介绍Java8中引入的函数式接口,包括Consumer、Supplier、Predicate和Function,以及它们的用法和特点,文中... 目录什么是函数是接口?Consumer接口定义核心特点注意事项常见用法1.基本用法2.结合andThen链

MySQL 日期时间格式化函数 DATE_FORMAT() 的使用示例详解

《MySQL日期时间格式化函数DATE_FORMAT()的使用示例详解》`DATE_FORMAT()`是MySQL中用于格式化日期时间的函数,本文详细介绍了其语法、格式化字符串的含义以及常见日期... 目录一、DATE_FORMAT()语法二、格式化字符串详解三、常见日期时间格式组合四、业务场景五、总结一、