Refactor FFmpeg decoder for improved readability and efficiency
Simplify the frame reading process and metadata extraction in `ffmpegdecoder.cpp` by reducing redundant code and improving variable initialization. Add a helper function in `ffmpegdecoder.h` to map FFmpeg field orders to Olive interlacing types, enhancing code clarity. Adjust the condition for interleaved write in `ffmpegencoder.cpp` for better handling.
This commit is contained in:
@@ -42,6 +42,20 @@ extern "C" {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
// 头文件里先备好枚举映射
|
||||
static VideoParams::Interlacing FFmpegFieldOrderToOlive(AVFieldOrder fo)
|
||||
{
|
||||
switch (fo) {
|
||||
case AV_FIELD_TT: // 隔行,顶场在前
|
||||
return VideoParams::kInterlacedTopFirst;
|
||||
case AV_FIELD_BB: // 隔行,底场在前
|
||||
return VideoParams::kInterlacedBottomFirst;
|
||||
case AV_FIELD_PROGRESSIVE:
|
||||
default:
|
||||
return VideoParams::kInterlaceNone;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A Decoder derivative that wraps FFmpeg functions as on Olive decoder
|
||||
*/
|
||||
@@ -124,6 +138,10 @@ private:
|
||||
{
|
||||
return avstream_;
|
||||
}
|
||||
AVCodecContext *codec_ctx()
|
||||
{
|
||||
return codec_ctx_;
|
||||
}
|
||||
|
||||
private:
|
||||
AVFormatContext *fmt_ctx_;
|
||||
|
||||
Reference in New Issue
Block a user