MediaProcessors
ffmpeg_video.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Rafael Antoniello
3  *
4  * This file is part of MediaProcessors.
5  *
6  * MediaProcessors is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * MediaProcessors is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with MediaProcessors. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
27 #ifndef MEDIAPROCESSORS_SRC_FFMPEG_VIDEO_H_
28 #define MEDIAPROCESSORS_SRC_FFMPEG_VIDEO_H_
29 
30 #include <libmediaprocsutils/mem_utils.h>
31 #include <libmediaprocs/proc.h>
32 
33 /* **** Definitions **** */
34 
35 #define SCALE_FLAGS SWS_BICUBIC
36 
37 /* Forward declarations */
38 typedef struct AVCodec AVCodec;
39 typedef struct AVCodecContext AVCodecContext;
40 typedef struct AVFrame AVFrame;
41 typedef struct AVPacket AVPacket;
42 typedef struct AVDictionary AVDictionary;
43 typedef struct SwsContext SwsContext;
46 
50 typedef struct ffmpeg_video_enc_ctx_s {
59  const AVCodec *avcodec;
63  AVCodecContext *avcodecctx;
68  AVDictionary *avdictionary;
74  AVFrame *avframe_tmp;
75  struct SwsContext *sws_ctx;
93 
97 typedef struct ffmpeg_video_dec_ctx_s {
106  const AVCodec *avcodec;
110  AVCodecContext *avcodecctx;
112 
113 /* **** Prototypes **** */
114 
127 int ffmpeg_video_enc_ctx_init(ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx,
128  int avcodecid, const video_settings_enc_ctx_t *video_settings_enc_ctx,
129  log_ctx_t *log_ctx);
130 
139 void ffmpeg_video_enc_ctx_deinit(ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx,
140  log_ctx_t *log_ctx);
141 
153 int ffmpeg_video_enc_frame(ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx,
154  AVFrame *avframe_iput, fifo_ctx_t* oput_fifo_ctx, log_ctx_t *log_ctx);
155 
168 int ffmpeg_video_dec_ctx_init(ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx,
169  int avcodecid, const video_settings_dec_ctx_t *video_settings_dec_ctx,
170  log_ctx_t *log_ctx);
171 
180 void ffmpeg_video_dec_ctx_deinit(ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx,
181  log_ctx_t *log_ctx);
182 
194 int ffmpeg_video_dec_frame(ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx,
195  AVPacket *avpacket_iput, fifo_ctx_t* oput_fifo_ctx, log_ctx_t *log_ctx);
196 
209  volatile void *video_settings_opaque, int flag_is_encoder,
210  log_ctx_t *log_ctx);
211 
212 #endif /* MEDIAPROCESSORS_SRC_FFMPEG_VIDEO_H_ */
struct ffmpeg_video_enc_ctx_s ffmpeg_video_enc_ctx_t
const AVCodec * avcodec
Definition: ffmpeg_video.h:106
void ffmpeg_video_dec_ctx_deinit(ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:403
int ffmpeg_video_dec_frame(ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx, AVPacket *avpacket_iput, fifo_ctx_t *oput_fifo_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:413
int ffmpeg_video_dec_ctx_init(ffmpeg_video_dec_ctx_t *ffmpeg_video_dec_ctx, int avcodecid, const video_settings_dec_ctx_t *video_settings_dec_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:348
const AVCodec * avcodec
Definition: ffmpeg_video.h:59
void ffmpeg_video_reset_on_new_settings(proc_ctx_t *proc_ctx, volatile void *video_settings_opaque, int flag_is_encoder, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:496
AVDictionary * avdictionary
Definition: ffmpeg_video.h:68
AVCodecContext * avcodecctx
Definition: ffmpeg_video.h:63
struct proc_ctx_s proc_ctx
Definition: ffmpeg_video.h:55
int ffmpeg_video_enc_ctx_init(ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx, int avcodecid, const video_settings_enc_ctx_t *video_settings_enc_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:53
int ffmpeg_video_enc_frame(ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx, AVFrame *avframe_iput, fifo_ctx_t *oput_fifo_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:186
AVCodecContext * avcodecctx
Definition: ffmpeg_video.h:110
Definition: log.c:102
struct ffmpeg_video_dec_ctx_s ffmpeg_video_dec_ctx_t
log_ctx_t * log_ctx
Definition: proc.h:103
void ffmpeg_video_enc_ctx_deinit(ffmpeg_video_enc_ctx_t *ffmpeg_video_enc_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_video.c:163