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

相关文章

Python itertools中accumulate函数用法及使用运用详细讲解

《Pythonitertools中accumulate函数用法及使用运用详细讲解》:本文主要介绍Python的itertools库中的accumulate函数,该函数可以计算累积和或通过指定函数... 目录1.1前言:1.2定义:1.3衍生用法:1.3Leetcode的实际运用:总结 1.1前言:本文将详

轻松上手MYSQL之JSON函数实现高效数据查询与操作

《轻松上手MYSQL之JSON函数实现高效数据查询与操作》:本文主要介绍轻松上手MYSQL之JSON函数实现高效数据查询与操作的相关资料,MySQL提供了多个JSON函数,用于处理和查询JSON数... 目录一、jsON_EXTRACT 提取指定数据二、JSON_UNQUOTE 取消双引号三、JSON_KE

MySQL数据库函数之JSON_EXTRACT示例代码

《MySQL数据库函数之JSON_EXTRACT示例代码》:本文主要介绍MySQL数据库函数之JSON_EXTRACT的相关资料,JSON_EXTRACT()函数用于从JSON文档中提取值,支持对... 目录前言基本语法路径表达式示例示例 1: 提取简单值示例 2: 提取嵌套值示例 3: 提取数组中的值注意

Java function函数式接口的使用方法与实例

《Javafunction函数式接口的使用方法与实例》:本文主要介绍Javafunction函数式接口的使用方法与实例,函数式接口如一支未完成的诗篇,用Lambda表达式作韵脚,将代码的机械美感... 目录引言-当代码遇见诗性一、函数式接口的生物学解构1.1 函数式接口的基因密码1.2 六大核心接口的形态学

JAVA系统中Spring Boot应用程序的配置文件application.yml使用详解

《JAVA系统中SpringBoot应用程序的配置文件application.yml使用详解》:本文主要介绍JAVA系统中SpringBoot应用程序的配置文件application.yml的... 目录文件路径文件内容解释1. Server 配置2. Spring 配置3. Logging 配置4. Ma

Java如何通过反射机制获取数据类对象的属性及方法

《Java如何通过反射机制获取数据类对象的属性及方法》文章介绍了如何使用Java反射机制获取类对象的所有属性及其对应的get、set方法,以及如何通过反射机制实现类对象的实例化,感兴趣的朋友跟随小编一... 目录一、通过反射机制获取类对象的所有属性以及相应的get、set方法1.遍历类对象的所有属性2.获取

spring6+JDK17实现SSM起步配置文件

《spring6+JDK17实现SSM起步配置文件》本文介绍了使用Spring6和JDK17配置SSM(Spring+SpringMVC+MyBatis)框架,文中通过示例代码介绍的非常详细,对大家的... 目录1.配置POM文件2.在resource目录下新建beans.XML文件,用于配置spirng3

Mysql8.0修改配置文件my.ini的坑及解决

《Mysql8.0修改配置文件my.ini的坑及解决》使用记事本直接编辑my.ini文件保存后,可能会导致MySQL无法启动,因为MySQL会以ANSI编码读取该文件,解决方法是使用Notepad++... 目录Myhttp://www.chinasem.cnsql8.0修改配置文件my.ini的坑出现的问题

Oracle的to_date()函数详解

《Oracle的to_date()函数详解》Oracle的to_date()函数用于日期格式转换,需要注意Oracle中不区分大小写的MM和mm格式代码,应使用mi代替分钟,此外,Oracle还支持毫... 目录oracle的to_date()函数一.在使用Oracle的to_date函数来做日期转换二.日

一文带你搞懂Nginx中的配置文件

《一文带你搞懂Nginx中的配置文件》Nginx(发音为“engine-x”)是一款高性能的Web服务器、反向代理服务器和负载均衡器,广泛应用于全球各类网站和应用中,下面就跟随小编一起来了解下如何... 目录摘要一、Nginx 配置文件结构概述二、全局配置(Global Configuration)1. w