FFmpeg  4.0
codec2utils.c
Go to the documentation of this file.
1 /*
2  * codec2 utility functions
3  * Copyright (c) 2017 Tomas Härdin
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <string.h>
23 #include "internal.h"
24 #include "libavcodec/codec2utils.h"
25 
26 int avpriv_codec2_mode_bit_rate(void *logctx, int mode)
27 {
28  int frame_size = avpriv_codec2_mode_frame_size(logctx, mode);
29  int block_align = avpriv_codec2_mode_block_align(logctx, mode);
30 
31  if (frame_size <= 0 || block_align <= 0) {
32  return 0;
33  }
34 
35  return 8 * 8000 * block_align / frame_size;
36 }
37 
38 int avpriv_codec2_mode_frame_size(void *logctx, int mode)
39 {
40  int frame_size_table[AVPRIV_CODEC2_MODE_MAX+1] = {
41  160, // 3200
42  160, // 2400
43  320, // 1600
44  320, // 1400
45  320, // 1300
46  320, // 1200
47  320, // 700
48  320, // 700B
49  320, // 700C
50  };
51 
53  av_log(logctx, AV_LOG_ERROR, "unknown codec2 mode %i, can't find frame_size\n", mode);
54  return 0;
55  } else {
56  return frame_size_table[mode];
57  }
58 }
59 
60 int avpriv_codec2_mode_block_align(void *logctx, int mode)
61 {
62  int block_align_table[AVPRIV_CODEC2_MODE_MAX+1] = {
63  8, // 3200
64  6, // 2400
65  8, // 1600
66  7, // 1400
67  7, // 1300
68  6, // 1200
69  4, // 700
70  4, // 700B
71  4, // 700C
72  };
73 
75  av_log(logctx, AV_LOG_ERROR, "unknown codec2 mode %i, can't find block_align\n", mode);
76  return 0;
77  } else {
78  return block_align_table[mode];
79  }
80 }
int avpriv_codec2_mode_bit_rate(void *logctx, int mode)
Definition: codec2utils.c:26
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int avpriv_codec2_mode_frame_size(void *logctx, int mode)
Definition: codec2utils.c:38
int frame_size
Definition: mxfenc.c:1947
int avpriv_codec2_mode_block_align(void *logctx, int mode)
Definition: codec2utils.c:60
common internal api header.
#define AVPRIV_CODEC2_MODE_MAX
Definition: codec2utils.h:30
mode
Use these values in ebur128_init (or&#39;ed).
Definition: ebur128.h:83