av_rescale_q_rnd”: 不能將參數 4 從“int”轉換爲“AVRounding” 1> 轉換爲枚舉

先看下函數

int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
                         enum AVRounding rnd) av_const;

看到第四個參數的確是枚舉類型AVRounding。

但是爲什麼我的函數調用仍然報錯呢?

pkt.pts = av_rescale_q_rnd(pkt.pts - pts_start_from[pkt.stream_index], in_stream->time_base,
                                    out_stream->time_base, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
pkt.dts = av_rescale_q_rnd(pkt.dts - dts_start_from[pkt.stream_index], in_stream->time_base,
                                    out_stream->time_base, AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);

原來在使用VS2017的時候,編譯器默認先對枚舉進行了計算,計算的結果爲int 型,此處需要強制轉換成枚舉類型即可!

pkt.pts = av_rescale_q_rnd(pkt.pts - pts_start_from[pkt.stream_index], in_stream->time_base,
                                    out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
pkt.dts = av_rescale_q_rnd(pkt.dts - dts_start_from[pkt.stream_index], in_stream->time_base,
                                    out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));

編譯成功了!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章