FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
ffmpeg_swscontext.cc
1/*
2 * This file is part of FFmpegfs.
3 *
4 * FFmpegfs is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 */
9
10#include "ffmpeg_swscontext.h"
11
12extern "C" {
13#include <libswscale/swscale.h>
14}
15
17 : m_ctx(nullptr)
18{
19}
20
22 : m_ctx(ctx)
23{
24}
25
30
32 : m_ctx(ctx.release())
33{
34}
35
36FFmpeg_SwsContext& FFmpeg_SwsContext::operator=(FFmpeg_SwsContext&& ctx) noexcept
37{
38 if (this != &ctx)
39 {
40 reset(ctx.release());
41 }
42 return *this;
43}
44
45SwsContext *FFmpeg_SwsContext::get() const
46{
47 return m_ctx;
48}
49
51{
52 SwsContext *ctx = m_ctx;
53 m_ctx = nullptr;
54 return ctx;
55}
56
57bool FFmpeg_SwsContext::reset(SwsContext *ctx)
58{
59 bool closed = false;
60
61 if (m_ctx != nullptr)
62 {
63 sws_freeContext(m_ctx);
64 closed = true;
65 }
66
67 m_ctx = ctx;
68
69 return closed;
70}
71
73{
74 return m_ctx == nullptr;
75}
76
77FFmpeg_SwsContext::operator bool() const
78{
79 return m_ctx != nullptr;
80}
81
82FFmpeg_SwsContext::operator SwsContext *() const
83{
84 return m_ctx;
85}
86
88{
89 return m_ctx;
90}
RAII wrapper for SwsContext.
bool empty() const
Check whether the wrapper currently owns a scaler context.
FFmpeg_SwsContext()
Construct an empty scaler-context wrapper.
SwsContext * release()
Release ownership without freeing the scaler context.
~FFmpeg_SwsContext()
Release the owned scaler context, if any.
bool reset(SwsContext *ctx=nullptr)
Replace the owned context.
SwsContext * operator->() const
Access members of the underlying scaler context.
SwsContext * m_ctx
Pointer to underlying SwsContext.
SwsContext * get() const
Get the owned FFmpeg scaler context pointer.
FFmpeg SwsContext RAII wrapper.