FFmpegfs Fuse Multi Media Filesystem 2.16
ffmpeg_subtitle.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2024 Norbert Schlia (nschlia@oblivion-software.de)
3 *
4 * This program 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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 * On Debian systems, the complete text of the GNU General Public License
19 * Version 3 can be found in `/usr/share/common-licenses/GPL-3'.
20 */
21
32#ifdef __cplusplus
33extern "C" {
34#endif
35// Disable annoying warnings outside our code
36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wconversion"
38#pragma GCC diagnostic ignored "-Wsign-conversion"
39#include <libavcodec/avcodec.h>
40#pragma GCC diagnostic pop
41#ifdef __cplusplus
42}
43#endif
44
45#include "ffmpeg_subtitle.h"
46
48 std::shared_ptr<AVSubtitle>(alloc_subtitle(), &FFmpeg_Subtitle::delete_subtitle),
49 m_res(0),
50 m_stream_idx(stream_index)
51{
52 m_res = (get() != nullptr) ? 0 : AVERROR(ENOMEM);
53}
54
56{
57 reset();
58}
59
61{
62 return m_res;
63}
64
65FFmpeg_Subtitle::operator AVSubtitle*()
66{
67 return get();
68}
69
70FFmpeg_Subtitle::operator const AVSubtitle*() const
71{
72 return get();
73}
74
76{
77 return get();
78}
79
81{
82 return reinterpret_cast<AVSubtitle *>(av_mallocz(sizeof(AVSubtitle)));
83}
84
85void FFmpeg_Subtitle::delete_subtitle(AVSubtitle *subtitle)
86{
87 if (subtitle != nullptr)
88 {
89 avsubtitle_free(subtitle);
90 av_free(subtitle);
91 }
92}
The FFmpeg_Subtitle class.
FFmpeg_Subtitle(int stream_index=INVALID_STREAM)
Construct FFmpeg_Subtitle object.
void unref() noexcept
Unreference underlying frame. Synonym for shared_ptr::reset().
int m_res
0 if last operation was successful, or negative AVERROR value
static void delete_subtitle(AVSubtitle *subtitle)
Delete a subtitle.
AVSubtitle * operator->()
operator ->: Do as if we were a pointer to AVSubtitle
int res() const
Get result of last operation.
AVSubtitle * alloc_subtitle()
Allocate a subtitle.
FFmpeg AVSubtitle extension.