- "AVCodecContext *", который используется только как указатель во всех функциях кроме освобождения.
Код: Выделить всё
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
Код: Выделить всё
void avcodec_free_context(AVCodecContext **avctx);
Код: Выделить всё
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
Код: Выделить всё
std::shared_ptr av_codec_context(avcodec_alloc_context3(av_codec),
[](AVCodecContext* _context)
{
if (_context) avcodec_free_context(&_context);
});
avcodec_open2(av_codec_context.get(), av_codec, NULL)
- "AVDictionary **" который используется во всех функциях только как указатель на указатель.
Код: Выделить всё
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
Бесплатно:
Код: Выделить всё
void av_dict_free(AVDictionary **m);
Код: Выделить всё
std::shared_ptr av_dict(new (AVDictionary*),
[](AVDictionary** _dict)
{
if (_dict)
{
if(*_dict)
av_dict_free(_dict);
delete _dict;
}
});
av_dict_set(av_dict.get(), "key", "value", 0);
- "AVFormatContext *", который используется и как указатель, и как указатель на указатель.
Код: Выделить всё
AVFormatContext *avformat_alloc_context(void);
Код: Выделить всё
void avformat_free_context(AVFormatContext *s);
Код: Выделить всё
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
Код: Выделить всё
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options);
Тогда умный указатель:
Код: Выделить всё
std::shared_ptr av_format_context(avformat_alloc_context(),
[](AVFormatContext* _context)
{
if(_context)
avformat_free_context(_context);
});
avformat_find_stream_info(av_format_context.get(), NULL);
Подробнее здесь: https://stackoverflow.com/questions/790 ... eg-objects