Skip to content

Commit 8642e2b

Browse files
committed
A couple of fixes
1 parent f488f8b commit 8642e2b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

Player/FrameTransformer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// FrameTransformer.cpp (implementation - trimmed for clarity)
21
#include "stdafx.h"
32

43
#include "FrameTransformer.h"
@@ -8,6 +7,7 @@
87
extern "C" {
98
#include <libavutil/opt.h>
109
#include <libavutil/imgutils.h>
10+
#include <libavutil/pixfmt.h>
1111
}
1212

1313
const auto PIX_FMT = AV_PIX_FMT_NV12;
@@ -47,8 +47,14 @@ int FrameTransformer::create_graph(int in_w, int in_h, AVPixelFormat in_pix_fmt)
4747
if (ret < 0) goto fail;
4848

4949
// Set buffersink to accept NV12 output
50-
enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_NV12, AV_PIX_FMT_NONE };
51-
ret = av_opt_set_int_list(buffersink_ctx_, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
50+
enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_NV12 };
51+
ret = av_opt_set_bin(
52+
buffersink_ctx_,
53+
"pix_fmts",
54+
(const uint8_t*)pix_fmts,
55+
sizeof(pix_fmts),
56+
AV_OPT_SEARCH_CHILDREN
57+
);
5258
if (ret < 0) goto fail;
5359

5460
// Parse and link the user filter chain between src and sink

video/videoparserunnable.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ bool frameToImage(
281281
SwsContext*& imageCovertContext,
282282
AVPixelFormat pixelFormat)
283283
{
284+
if (videoFrame->format == AV_PIX_FMT_NONE)
285+
{
286+
return false;
287+
}
288+
284289
if (videoFrame->format == pixelFormat
285290
|| videoFrame->format == AV_PIX_FMT_DXVA2_VLD)
286291
{

0 commit comments

Comments
 (0)