本文对openHevc工程代码中的主循环部分采用广度遍历模式,用伪代码记录代码结构。并且添加部分注释。
Main loop
1 av_read_frame(); // to do
2 got_picture=libOpenHevcDecoder();
2.1 for i:max_decoders
if (i<=active_layer) av_pkt.size=packet.size;av_pkt.data=buffer;
else av_pkt.size =0;av_pkt.data=NULL
//???????????? todo??????????? ..
2.2
3 if(got_picture>0)
3.1 fflush();//clean buffer;
3.2 libOpenHevcGetPicureInfo(); //get picture info
3.3 if(Width!=Info.Width||Height!=Info.Height) //need to be resize
if(fout) fclose(fout); //set output file
if(output_file) fout=fopen();
if(USE_SDL&&display_flag==ENABLE) Init_SDL(); //Init SDL
if(fout)
GetPictureInfo();
if(openHevcFrameCpy.pvY) free(openHevcFrameCpy.pvY/U/V);//
openHevcFrameCpy.pvY/U/V = calloc();
3.4 if(USE_SDL)
frame_rate_Delay_SDL();
if(display_flag==ENABLE)
libOpenHevcGetOutput();
libOpenHevcGetInfo();
SDL_Display(); //display one frame
3.5 if(fout) //fwriteYUV streams
libOpenHevcGetOutputCpy();
fwrite(openHevcFrameCpy.pvY);
fwrite(openHevcFrameCpy.pvU);
fwrite(openHevcFrameCpy.pvV);
3.6 nb_frame++;
if(nb_frame=num_frames) stop=1; //stop here
else if(stop_dec==1&&nb_frame) stop=1;
3.7 av_free_packet(); //freepacket