MediaProcessors
ffmpeg_audio.c
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 
25 #include "ffmpeg_audio.h"
26 
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
30 #include <pthread.h>
31 
32 #include <libavformat/avformat.h>
33 #include <libavcodec/avcodec.h>
34 #include <libavutil/mathematics.h>
35 #include <libavutil/opt.h>
36 #include <libswscale/swscale.h>
37 #include <libmediaprocsutils/log.h>
38 #include <libmediaprocsutils/stat_codes.h>
39 #include <libmediaprocsutils/check_utils.h>
40 #include <libmediaprocsutils/fair_lock.h>
41 #include <libmediaprocsutils/fifo.h>
42 #include <libmediaprocs/proc_if.h>
43 #include <libmediaprocs/proc.h>
44 
45 #include "audio_settings.h"
46 
47 /* **** Definitions **** */
48 
49 #define LOOP_GUARD_MAX 20
50 
51 /* **** Prototypes **** */
52 
53 /* **** Implementations **** */
54 
56  int avcodecid, const audio_settings_enc_ctx_t *audio_settings_enc_ctx,
57  log_ctx_t *log_ctx)
58 {
59  const enum AVSampleFormat *samplefmt;
60  int loop_guard, ret_code, end_code= STAT_ERROR;
61  const AVCodec *avcodec= NULL; // Do not release
62  AVCodecContext *avcodecctx= NULL; // Do not release
63  AVDictionary *avdictionary= NULL;
64  LOG_CTX_INIT(log_ctx);
65 
66  /* Check arguments */
67  CHECK_DO(ffmpeg_audio_enc_ctx!= NULL, return STAT_ERROR);
68  CHECK_DO(audio_settings_enc_ctx!= NULL, return STAT_ERROR);
69  // Note: argument 'log_ctx' is allowed to be NULL
70 
71  /* Initialize FFmpeg's static CODEC context characterizing audio encoder.
72  * Find the encoder and get its static definition structure.
73  */
74  avcodec= avcodec_find_encoder((enum AVCodecID)avcodecid);
75  if(avcodec== NULL) {
76  LOGE("Audio encoder not supported '%s'\n", avcodec_get_name(
77  (enum AVCodecID)avcodecid));
78  end_code= STAT_EBAVFORMAT;
79  goto end;
80  }
81  ffmpeg_audio_enc_ctx->avcodec= avcodec;
82  CHECK_DO(avcodec->type== AVMEDIA_TYPE_AUDIO, goto end);
83 
84  /* Initialize FFmpeg's CODEC instance context structure */
85  avcodecctx= avcodec_alloc_context3(avcodec);
86  CHECK_DO(avcodecctx!= NULL, goto end);
87  ffmpeg_audio_enc_ctx->avcodecctx= avcodecctx;
88 
89  /* Put settings.
90  * NOTE:
91  * - Only signed 16 bits planar sample format is supported;
92  * - Stereo layout is selected by default.
93  */
94  avcodecctx->codec_id= avcodecid;
95  avcodecctx->bit_rate= audio_settings_enc_ctx->bit_rate_output;
96  avcodecctx->sample_fmt= AV_SAMPLE_FMT_NONE;
97  for(samplefmt= avcodec->sample_fmts, loop_guard= 0;
98  *samplefmt!= AV_SAMPLE_FMT_NONE && loop_guard< LOOP_GUARD_MAX;
99  samplefmt++, loop_guard++) {
100  if(*samplefmt== AV_SAMPLE_FMT_S16P) {
101  avcodecctx->sample_fmt= AV_SAMPLE_FMT_S16P;
102  break;
103  }
104  }
105  if(avcodecctx->sample_fmt!= AV_SAMPLE_FMT_S16P) {
106  LOGE("Unsupported audio sample format %s\n", av_get_sample_fmt_name(
107  avcodecctx->sample_fmt));
108  goto end;
109  }
110  avcodecctx->sample_rate= audio_settings_enc_ctx->sample_rate_output;
111  avcodecctx->channel_layout= AV_CH_LAYOUT_STEREO;
112  avcodecctx->channels= av_get_channel_layout_nb_channels(
113  avcodecctx->channel_layout);
114  /* Note: It is not necessary to set AVCodecContext::time_base as we do not
115  * use this parameter. For example, PTSs and DTSs are just passed through
116  * by FFmpeg's audio encoders.
117  * avcodecctx->time_base= (AVRational){1, avcodecctx->sample_rate};
118  */
119 
120  /* Now that all the parameters are set, we can open the audio encoder and
121  * allocate the necessary encoding buffers.
122  */
123  ret_code= avcodec_open2(ffmpeg_audio_enc_ctx->avcodecctx,
124  ffmpeg_audio_enc_ctx->avcodec, NULL);
125  if(ret_code< 0) {
126  LOGE("Could not open audio encoder: %s.\n", av_err2str(ret_code));
127  goto end;
128  }
129 
130  end_code= STAT_SUCCESS;
131 end:
132  if(avdictionary!= NULL)
133  av_dict_free(&avdictionary);
134  if(end_code!= STAT_SUCCESS)
135  ffmpeg_audio_enc_ctx_deinit(ffmpeg_audio_enc_ctx, LOG_CTX_GET());
136  return end_code;
137 }
138 
140  log_ctx_t *log_ctx)
141 {
142  if(ffmpeg_audio_enc_ctx== NULL)
143  return;
144 
145  if(ffmpeg_audio_enc_ctx->avcodecctx!= NULL)
146  avcodec_free_context(&ffmpeg_audio_enc_ctx->avcodecctx);
147 }
148 
150  AVFrame *avframe_iput, fifo_ctx_t* oput_fifo_ctx, log_ctx_t *log_ctx)
151 {
152  const proc_if_t *proc_if;
153  uint64_t flag_proc_features;
154  int ret_code, end_code= STAT_ERROR;
155  proc_ctx_t *proc_ctx= NULL; // Do not release
156  AVCodecContext *avcodecctx= NULL; // Do not release
157  //AVRational src_time_base= {1, 1000000}; //[usec] // Not used
158  AVPacket pkt_oput= {0};
159  LOG_CTX_INIT(log_ctx);
160 
161  /* Check arguments */
162  CHECK_DO(ffmpeg_audio_enc_ctx!= NULL, return STAT_ERROR);
163  CHECK_DO(avframe_iput!= NULL, return STAT_ERROR);
164  CHECK_DO(oput_fifo_ctx!= NULL, return STAT_ERROR);
165  // Note: argument 'log_ctx' is allowed to be NULL
166 
167  /* Get (cast to) processor context structure */
168  proc_ctx= (proc_ctx_t*)ffmpeg_audio_enc_ctx;
169 
170  /* Get required variables from PROC interface structure */
171  proc_if= proc_ctx->proc_if;
172  CHECK_DO(proc_if!= NULL, goto end);
173  flag_proc_features= proc_if->flag_proc_features;
174 
175  /* Get audio CODEC context */
176  avcodecctx= ffmpeg_audio_enc_ctx->avcodecctx;
177  CHECK_DO(avcodecctx!= NULL, goto end);
178 
179  /* Initialize output audio packet */
180  av_init_packet(&pkt_oput);
181 
182  /* Change time-stamp base before encoding */
183  //LOGV("Input frame: pts: %"PRId64"\n", avframe_iput->pts); //comment-me
184  //avframe_iput->pts= av_rescale_q(avframe_iput->pts, src_time_base,
185  // avcodecctx->time_base); // Not necessary
186 
187  /* Send the frame to the encoder */
188  ret_code= avcodec_send_frame(avcodecctx, avframe_iput);
189  CHECK_DO(ret_code>= 0, goto end);
190 
191  /* Read output packet from the encoder and put into output FIFO buffer */
192  while(ret_code>= 0 && proc_ctx->flag_exit== 0) {
193  av_packet_unref(&pkt_oput);
194  ret_code= avcodec_receive_packet(avcodecctx, &pkt_oput);
195  if(ret_code== AVERROR(EAGAIN) || ret_code== AVERROR_EOF) {
196  end_code= STAT_EAGAIN;
197  goto end;
198  }
199  CHECK_DO(ret_code>= 0, goto end);
200 
201  /* Restore time-stamps base */
202  //pkt_oput.pts= av_rescale_q(pkt_oput.pts, avcodecctx->time_base,
203  // src_time_base); // Not necessary
204  //LOGV("Output frame: pts: %"PRId64" (size=%d)\n", pkt_oput.pts,
205  // pkt_oput.size); //comment-me
206 
207  /* Set sampling rate at output frame.
208  * HACK- implementation note:
209  * We use AVPacket::pos field to pass 'sampling rate' as
210  * no specific field exist for this parameter.
211  */
212  pkt_oput.pos= avcodecctx->sample_rate;
213 
214  /* Latency statistics related */
215  if((flag_proc_features&PROC_FEATURE_LATENCY) &&
216  pkt_oput.pts!= AV_NOPTS_VALUE)
217  proc_stats_register_accumulated_latency(proc_ctx, pkt_oput.pts);
218 
219  /* Put output frame into output FIFO */
220  fifo_put_dup(oput_fifo_ctx, &pkt_oput, sizeof(void*));
221  }
222 
223  end_code= STAT_SUCCESS;
224 end:
225  av_packet_unref(&pkt_oput);
226  return end_code;
227 }
228 
230  int avcodecid, const audio_settings_dec_ctx_t *audio_settings_dec_ctx,
231  log_ctx_t *log_ctx)
232 {
233  char *fmt_output;
234  int ret_code, end_code= STAT_ERROR;
235  const AVCodec *avcodec= NULL; // Do not release
236  AVCodecContext *avcodecctx= NULL; // Do not release
237  LOG_CTX_INIT(log_ctx);
238 
239  /* Check arguments */
240  CHECK_DO(ffmpeg_audio_dec_ctx!= NULL, return STAT_ERROR);
241  CHECK_DO(audio_settings_dec_ctx!= NULL, return STAT_ERROR);
242  // Note: argument 'log_ctx' is allowed to be NULL
243 
244  /* Initialize FFmpeg's static CODEC context characterizing audio decoder.
245  * Find the decoder and get its static definition structure.
246  */
247  avcodec= avcodec_find_decoder((enum AVCodecID)avcodecid);
248  if(avcodec== NULL) {
249  LOGE("Audio decoder not supported '%s'\n", avcodec_get_name(
250  (enum AVCodecID)avcodecid));
251  end_code= STAT_EBAVFORMAT;
252  goto end;
253  }
254  ffmpeg_audio_dec_ctx->avcodec= avcodec;
255  CHECK_DO(avcodec->type== AVMEDIA_TYPE_AUDIO, goto end);
256 
257  /* Initialize FFmpeg's CODEC instance context structure */
258  avcodecctx= avcodec_alloc_context3(avcodec);
259  CHECK_DO(avcodecctx!= NULL, goto end);
260  ffmpeg_audio_dec_ctx->avcodecctx= avcodecctx;
261 
262  /* Initialize user specified samples output format
263  * (may differ from native-decoder format).
264  */
265  fmt_output= audio_settings_dec_ctx->samples_format_output;
266  CHECK_DO(fmt_output!= NULL, goto end);
267  ffmpeg_audio_dec_ctx->sample_fmt_output= AV_SAMPLE_FMT_NONE;
268  if(strncmp(fmt_output, "planar_signed_16b",
269  strlen("planar_signed_16b"))== 0) {
270  ffmpeg_audio_dec_ctx->sample_fmt_output= AV_SAMPLE_FMT_S16P;
271  } else if(strncmp(fmt_output, "interleaved_signed_16b",
272  strlen("interleaved_signed_16b"))== 0) {
273  ffmpeg_audio_dec_ctx->sample_fmt_output= AV_SAMPLE_FMT_S16;
274  }
275  CHECK_DO(ffmpeg_audio_dec_ctx->sample_fmt_output!= AV_SAMPLE_FMT_NONE,
276  goto end);
277 
278  /* Put settings */
279  /* Note: It is not necessary to set AVCodecContext::time_base as we do not
280  * use this parameter. For example, PTSs and DTSs are just passed through
281  * by FFmpeg's audio decoders.
282  * avcodecctx->time_base= (AVRational){1, 'sample_rate'};
283  */
284  // Reserved for future use: put other new settings here...
285 
286  /* Now that all the parameters are set, we can open the audio decoder */
287  ret_code= avcodec_open2(ffmpeg_audio_dec_ctx->avcodecctx,
288  ffmpeg_audio_dec_ctx->avcodec, NULL);
289  if(ret_code< 0) {
290  LOGE("Could not open audio decoder: %s.\n", av_err2str(ret_code));
291  goto end;
292  }
293 
294  end_code= STAT_SUCCESS;
295 end:
296  if(end_code!= STAT_SUCCESS)
297  ffmpeg_audio_dec_ctx_deinit(ffmpeg_audio_dec_ctx, LOG_CTX_GET());
298  return end_code;
299 }
300 
302  log_ctx_t *log_ctx)
303 {
304  if(ffmpeg_audio_dec_ctx== NULL)
305  return;
306 
307  if(ffmpeg_audio_dec_ctx->avcodecctx!= NULL)
308  avcodec_free_context(&ffmpeg_audio_dec_ctx->avcodecctx);
309 }
310 
312  AVPacket *avpacket_iput, fifo_ctx_t* oput_fifo_ctx, log_ctx_t *log_ctx)
313 {
314  const proc_if_t *proc_if;
315  uint64_t flag_proc_features;
316  int ret_code, end_code= STAT_ERROR;
317  proc_ctx_t *proc_ctx= NULL; // Do not release
318  AVCodecContext *avcodecctx= NULL; // Do not release;
319  //AVRational src_time_base= {1, 1000000}; //[usec] // Not used
320  AVFrame *avframe_oput= NULL;
321  LOG_CTX_INIT(log_ctx);
322 
323  /* Check arguments */
324  CHECK_DO(ffmpeg_audio_dec_ctx!= NULL, return STAT_ERROR);
325  CHECK_DO(avpacket_iput!= NULL, return STAT_ERROR);
326  CHECK_DO(oput_fifo_ctx!= NULL, return STAT_ERROR);
327  // Note: argument 'log_ctx' is allowed to be NULL
328 
329  /* Get (cast to) processor context structure */
330  proc_ctx= (proc_ctx_t*)ffmpeg_audio_dec_ctx;
331 
332  /* Get required variables from PROC interface structure */
333  proc_if= proc_ctx->proc_if;
334  CHECK_DO(proc_if!= NULL, goto end);
335  flag_proc_features= proc_if->flag_proc_features;
336 
337  /* Get audio CODEC context */
338  avcodecctx= ffmpeg_audio_dec_ctx->avcodecctx;
339  CHECK_DO(avcodecctx!= NULL, goto end);
340 
341  /* Change time-stamps base before decoding */
342  //LOGV("Input frame: pts: %"PRId64"\n", avpacket_iput->pts); //comment-me
343  //avpacket_iput->pts= av_rescale_q(avpacket_iput->pts, src_time_base,
344  // avcodecctx->time_base); // Not necessary
345 
346  /* Send the packet to the decoder */
347  ret_code= avcodec_send_packet(avcodecctx, avpacket_iput);
348  CHECK_DO(ret_code>= 0, goto end);
349 
350  /* Read output frame from the decoder and put into output FIFO buffer */
351  while(ret_code>= 0 && proc_ctx->flag_exit== 0) {
352  if(avframe_oput!= NULL)
353  av_frame_free(&avframe_oput);
354  avframe_oput= av_frame_alloc();
355  CHECK_DO(avframe_oput!= NULL, goto end);
356  ret_code= avcodec_receive_frame(avcodecctx, avframe_oput);
357  if(ret_code== AVERROR(EAGAIN) || ret_code== AVERROR_EOF) {
358  end_code= STAT_EAGAIN;
359  goto end;
360  }
361  CHECK_DO(ret_code>= 0, goto end);
362 
363  /* Restore time-stamps base */
364  //avframe_oput->pts= av_rescale_q(avframe_oput->pts,
365  // avcodecctx->time_base, src_time_base); // Not necessary
366  //LOGV("Output frame: pts: %"PRId64"\n",
367  // avframe_oput->pts); //comment-me
368 
369  /* Set format to use in 'fifo_put_dup()' */
370  avframe_oput->format= ffmpeg_audio_dec_ctx->sample_fmt_output;
371 
372  /* Set sampling rate at output frame */
373  avframe_oput->sample_rate= avcodecctx->sample_rate;
374 
375  /* Latency statistics related */
376  if((flag_proc_features&PROC_FEATURE_LATENCY) &&
377  avframe_oput->pts!= AV_NOPTS_VALUE)
378  proc_stats_register_accumulated_latency(proc_ctx,
379  avframe_oput->pts);
380 
381  /* Put output frame into output FIFO */
382  fifo_put_dup(oput_fifo_ctx, avframe_oput, sizeof(void*));
383  }
384 
385  end_code= STAT_SUCCESS;
386 end:
387  if(avframe_oput!= NULL)
388  av_frame_free(&avframe_oput);
389  return end_code;
390 }
391 
393  volatile void *audio_settings_opaque, int flag_is_encoder,
394  log_ctx_t *log_ctx)
395 {
396  int ret_code, flag_io_locked= 0, flag_thr_joined= 0;
397  void *thread_end_code= NULL;
398  LOG_CTX_INIT(log_ctx);
399 
400  /* Check arguments */
401  CHECK_DO(proc_ctx!= NULL, return);
402 
403  /* If processor interface was not set yet, it means this function is being
404  * call in processor opening phase, so it must be skipped.
405  */
406  if(proc_ctx->proc_if== NULL)
407  return;
408 
409  /* Firstly, stop processing thread:
410  * - Signal processing to end;
411  * - Unlock i/o FIFOs;
412  * - Lock i/o critical section (to make FIFOs unreachable);
413  * - Join the thread.
414  * IMPORTANT: *do not* set a jump here (return or goto)
415  */
416  proc_ctx->flag_exit= 1;
417  fifo_set_blocking_mode(proc_ctx->fifo_ctx_array[PROC_IPUT], 0);
418  fifo_set_blocking_mode(proc_ctx->fifo_ctx_array[PROC_OPUT], 0);
419  fair_lock(proc_ctx->fair_lock_io_array[PROC_IPUT]);
420  fair_lock(proc_ctx->fair_lock_io_array[PROC_OPUT]);
421  flag_io_locked= 1;
422  //LOGV("Waiting thread to join... "); // comment-me
423  pthread_join(proc_ctx->proc_thread, &thread_end_code);
424  if(thread_end_code!= NULL) {
425  ASSERT(*((int*)thread_end_code)== STAT_SUCCESS);
426  free(thread_end_code);
427  thread_end_code= NULL;
428  }
429  //LOGV("joined O.K.\n"); // comment-me
430  flag_thr_joined= 1;
431 
432  /* Empty i/o FIFOs */
433  fifo_empty(proc_ctx->fifo_ctx_array[PROC_IPUT]);
434  fifo_empty(proc_ctx->fifo_ctx_array[PROC_OPUT]);
435 
436  /* Reset FFmpeg resources */
437  if(flag_is_encoder!= 0) {
438  enum AVCodecID avcodecid;
439  AVCodecContext *avcodecctx= NULL; // Do not release;
440  ffmpeg_audio_enc_ctx_t *ffmpeg_audio_enc_ctx= (ffmpeg_audio_enc_ctx_t*)
441  proc_ctx;
442  audio_settings_enc_ctx_t *audio_settings_enc_ctx=
443  (audio_settings_enc_ctx_t*)audio_settings_opaque;
444 
445  /* Get audio CODEC context and CODEC Id. */
446  avcodecctx= ffmpeg_audio_enc_ctx->avcodecctx;
447  CHECK_DO(avcodecctx!= NULL, goto end);
448  avcodecid= avcodecctx->codec_id;
449 
450  ffmpeg_audio_enc_ctx_deinit(ffmpeg_audio_enc_ctx, LOG_CTX_GET());
451  ret_code= ffmpeg_audio_enc_ctx_init(ffmpeg_audio_enc_ctx,
452  (int)avcodecid, audio_settings_enc_ctx, LOG_CTX_GET());
453  CHECK_DO(ret_code== STAT_SUCCESS, goto end);
454  } else {
455  enum AVCodecID avcodecid;
456  AVCodecContext *avcodecctx= NULL; // Do not release;
457  ffmpeg_audio_dec_ctx_t *ffmpeg_audio_dec_ctx= (ffmpeg_audio_dec_ctx_t*)
458  proc_ctx;
459  audio_settings_dec_ctx_t *audio_settings_dec_ctx=
460  (audio_settings_dec_ctx_t*)audio_settings_opaque;
461 
462  /* Get audio CODEC context and CODEC Id. */
463  avcodecctx= ffmpeg_audio_dec_ctx->avcodecctx;
464  CHECK_DO(avcodecctx!= NULL, goto end);
465  avcodecid= avcodecctx->codec_id;
466 
467  ffmpeg_audio_dec_ctx_deinit(ffmpeg_audio_dec_ctx, LOG_CTX_GET());
468  ret_code= ffmpeg_audio_dec_ctx_init(ffmpeg_audio_dec_ctx,
469  (int)avcodecid, audio_settings_dec_ctx, LOG_CTX_GET());
470  CHECK_DO(ret_code== STAT_SUCCESS, goto end);
471  }
472 
473 end:
474  /* Restore FIFOs blocking mode if applicable */
475  fifo_set_blocking_mode(proc_ctx->fifo_ctx_array[PROC_IPUT], 1);
476  fifo_set_blocking_mode(proc_ctx->fifo_ctx_array[PROC_OPUT], 1);
477 
478  /* Re-launch PROC thread if applicable */
479  if(flag_thr_joined!= 0) {
480  proc_ctx->flag_exit= 0;
481  ret_code= pthread_create(&proc_ctx->proc_thread, NULL,
482  (void*(*)(void*))proc_ctx->start_routine, proc_ctx);
483  CHECK_DO(ret_code== 0, goto end);
484  }
485 
486  /* Unlock i/o critical sections if applicable */
487  if(flag_io_locked!= 0) {
488  fair_unlock(proc_ctx->fair_lock_io_array[PROC_IPUT]);
489  fair_unlock(proc_ctx->fair_lock_io_array[PROC_OPUT]);
490  }
491  return;
492 }
AVCodecContext * avcodecctx
Definition: ffmpeg_audio.h:78
void ffmpeg_audio_enc_ctx_deinit(ffmpeg_audio_enc_ctx_t *ffmpeg_audio_enc_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:139
int fifo_put_dup(fifo_ctx_t *fifo_ctx, const void *elem, size_t elem_size)
Definition: fifo.c:355
void fifo_set_blocking_mode(fifo_ctx_t *fifo_ctx, int do_block)
Definition: fifo.c:332
void ffmpeg_audio_dec_ctx_deinit(ffmpeg_audio_dec_ctx_t *ffmpeg_audio_dec_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:301
int ffmpeg_audio_enc_frame(ffmpeg_audio_enc_ctx_t *ffmpeg_audio_enc_ctx, AVFrame *avframe_iput, fifo_ctx_t *oput_fifo_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:149
int ffmpeg_audio_dec_frame(ffmpeg_audio_dec_ctx_t *ffmpeg_audio_dec_ctx, AVPacket *avpacket_iput, fifo_ctx_t *oput_fifo_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:311
pthread_t proc_thread
Definition: proc.h:173
Generic processor module context (see type proc_ctx_t) extension for audio encoders and decoders...
const AVCodec * avcodec
Definition: ffmpeg_audio.h:74
void fifo_empty(fifo_ctx_t *fifo_ctx)
Definition: fifo.c:456
uint64_t flag_proc_features
Definition: proc_if.h:190
const void *(* start_routine)(void *)
Definition: proc.h:181
void ffmpeg_audio_reset_on_new_settings(proc_ctx_t *proc_ctx, volatile void *audio_settings_opaque, int flag_is_encoder, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:392
#define CHECK_DO(COND, ACTION)
Definition: check_utils.h:57
volatile int flag_exit
Definition: proc.h:169
const proc_if_t * proc_if
Definition: proc.h:89
fifo_ctx_t * fifo_ctx_array[PROC_IO_NUM]
Definition: proc.h:107
AVCodecContext * avcodecctx
Definition: ffmpeg_audio.h:59
Audio encoder and decoder generic settings.
#define ASSERT(COND)
Definition: check_utils.h:51
const AVCodec * avcodec
Definition: ffmpeg_audio.h:55
int ffmpeg_audio_enc_ctx_init(ffmpeg_audio_enc_ctx_t *ffmpeg_audio_enc_ctx, int avcodecid, const audio_settings_enc_ctx_t *audio_settings_enc_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:55
int ffmpeg_audio_dec_ctx_init(ffmpeg_audio_dec_ctx_t *ffmpeg_audio_dec_ctx, int avcodecid, const audio_settings_dec_ctx_t *audio_settings_dec_ctx, log_ctx_t *log_ctx)
Definition: ffmpeg_audio.c:229
Definition: log.c:102
fair_lock_t * fair_lock_io_array[PROC_IO_NUM]
Definition: proc.h:111