请问:ffplay里面播放和解码时间戳的保存

请教:ffplay里面播放和解码时间戳的保存
大家好,最近在分析ffplay播放器的源码,其中时间戳的保存方式是用一个全局变量来进行保存的:
C/C++ code

static uint64_t global_video_pkt_pts= AV_NOPTS_VALUE;


还重写了分配帧和销毁帧的方法:
C/C++ code

static int my_get_buffer(struct AVCodecContext *c, AVFrame *pic){
    int ret= avcodec_default_get_buffer(c, pic);
    uint64_t *pts= av_malloc(sizeof(uint64_t));
    *pts= global_video_pkt_pts;
    pic->opaque= pts;
    return ret;
}

static void my_release_buffer(struct AVCodecContext *c, AVFrame *pic){
    if(pic) av_freep(&pic->opaque);
    avcodec_default_release_buffer(c, pic);


在使用这个全局时间戳的时候,是这样使用的:
C/C++ code

/* NOTE: ipts is the PTS of the _first_ picture beginning in
   this packet, if any */
global_video_pkt_pts= pkt->pts;
len1 = avcodec_decode_video(is->video_st->codec,
                            frame, &got_picture,
                            pkt->data, pkt->size);

if(   (decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE)
   && frame->opaque && *(uint64_t*)frame->opaque != AV_NOPTS_VALUE)
    pts= *(uint64_t*)frame->opaque;
else if(pkt->dts != AV_NOPTS_VALUE)
    pts= pkt->dts;
else
    pts= 0;
pts *= av_q2d(is->video_st->time_base);

//    if (len1 < 0)
//        break;
if (got_picture) {
    if (output_picture2(is, frame, pts) < 0)
        goto the_end;
}
av_free_packet(pkt);
if (step)
    if (cur_stream)
        stream_pause(cur_stream);


请问,这里为什么要使用一个全局变量,而不是用临时变量呢?
而且,一般是不到万不得已,是不是用全局变量的啊。

------解决方案--------------------
查看代码,如果不需要暂存信息,就可以不用。
它这里用,应该是有道理的。
------解决方案--------------------
之所以用全局变量,是因为在my_get_buffer里要用到