分享

JM中一些变量的关系(img,currSlice,currStream,dp等等)

 pgj555 2014-03-06

转自-中华视频网

看代码有一段时间了,一直跟踪代码时注重的都是整个流程及宏观上的结构,看到程序时诸多的img,currSlice,currStream,dp时也没在意,因为知道个大概的意思,后来看的多了,发现这几个变量之间关系不理清对看程序很不利,于是追根溯源跟踪了一遍,大致关系如下(解码器,编码器应该也差不多):

global.h中有变量类型定义

// image parameters

typedef struct img_par

{

……

Slice       *currentSlice;

  Macroblock          *mb_data;

……

} ImageParameters;



typedef struct

{

……

  DataPartition       *partArr;

……

} Slice;



typedef struct

{

  // CABAC Decoding

  int           read_len;         

  int           code_len;         

  int           frame_bitoffset;   

  int           bitstream_length;  

  byte          *streamBuffer;      

} Bitstream;



typedef struct datapartition

{

  Bitstream           *bitstream;

  DecodingEnvironment de_cabac;

  int     (*readSyntaxElement)(SyntaxElement *, struct img_par *, struct inp_par *, struct datapartition *);

} DataPartition;



然后在ldecod.c中有:

struct img_par    *img;    在global.h中有相对应extern ImageParameters *img;

进入main()中

  if ((img =  (struct img_par *)calloc(1, sizeof(struct img_par)))==NULL) no_mem_exit("main: img");

……

  malloc_slice(input,img);  //肯定是完成对img的一些初始化操作

进去看一下:

  Slice *currSlice;

  img->currentSlice = (Slice *) calloc(1, sizeof(Slice));  //img与currSlice对应上了

之后进行的对currSlice的操作及对img->currentSlice在进行操作。

跳出来继续main

  init(img);   //看函数名就知道了

之后进行一系列初始化

进行decode_one_frame

有定义  Slice *currSlice = img->currentSlice;

进入read_new_slice

  Slice *currSlice = img->currentSlice; //这里不存在重复定义的情况,虽然外面定义过,但Slice *currSlice是局部变量没有将其传进来,img是全局变量。

  Bitstream *currStream;

进入switch,处理的第一个nalu是pps,进去看一下

  DataPartition *dp = AllocPartition(1);

  memcpy (dp->bitstream->streamBuffer, &nalu->buf[1], nalu->len-1); //变量与nalu对应上了,

  dummy = InterpretSPS (dp, sps);

进去看一下

  Bitstream *s = p->bitstream;

……

  sps->profile_idc      = u_v  (8, "SPS: profile_idc"      , s);  //对应上了

跳出来继续switch

进 case NALU_TYPE_IDR:看一下

currStream = currSlice->partArr[0].bitstream;

memcpy (currStream->streamBuffer, &nalu->buf[1], nalu->len-1);  //这里几个变量之间的关系全对应上了,也和码流对应上了

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多