FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
canopus.c
Go to the documentation of this file.
1
/*
2
* Canopus common routines
3
* Copyright (c) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
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 <stdint.h>
23
24
#include "
libavutil/rational.h
"
25
26
#include "
avcodec.h
"
27
#include "
bytestream.h
"
28
#include "
canopus.h
"
29
30
int
ff_canopus_parse_info_tag
(
AVCodecContext
*avctx,
31
const
uint8_t
*
src
,
size_t
size
)
32
{
33
GetByteContext
gbc;
34
int
par_x, par_y, field_order;
35
36
bytestream2_init
(&gbc, src, size);
37
38
/* Parse aspect ratio. */
39
bytestream2_skip
(&gbc, 8);
// unknown, 16 bits 1
40
par_x = bytestream2_get_le32(&gbc);
41
par_y = bytestream2_get_le32(&gbc);
42
if
(par_x && par_y)
43
av_reduce
(&avctx->
sample_aspect_ratio
.
num
,
44
&avctx->
sample_aspect_ratio
.
den
,
45
par_x, par_y, 255);
46
47
/* Short INFO tag (used in CLLC) has only AR data. */
48
if
(size == 0x18)
49
return
0;
50
51
bytestream2_skip
(&gbc, 16);
// unknown RDRT tag
52
53
/* Parse FIEL tag. */
54
bytestream2_skip
(&gbc, 8);
// 'FIEL' and 4 bytes 0
55
field_order = bytestream2_get_le32(&gbc);
56
switch
(field_order) {
57
case
0: avctx->
field_order
=
AV_FIELD_TT
;
break
;
58
case
1: avctx->
field_order
=
AV_FIELD_BB
;
break
;
59
case
2: avctx->
field_order
=
AV_FIELD_PROGRESSIVE
;
break
;
60
}
61
62
return
0;
63
}
GetByteContext
Definition:
bytestream.h:33
ff_canopus_parse_info_tag
int ff_canopus_parse_info_tag(AVCodecContext *avctx, const uint8_t *src, size_t size)
Definition:
canopus.c:30
AVRational::num
int num
Numerator.
Definition:
rational.h:59
AVCodecContext::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
Definition:
avcodec.h:2143
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition:
bytestream.h:133
src
#define src
Definition:
vp8dsp.c:254
uint8_t
uint8_t
Definition:
audio_convert.c:194
size
ptrdiff_t size
Definition:
opengl_enc.c:101
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition:
rational.c:35
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition:
bytestream.h:164
bytestream.h
AV_FIELD_TT
Definition:
avcodec.h:1713
avcodec.h
Libavcodec external API header.
AVCodecContext
main external API structure.
Definition:
avcodec.h:1732
AV_FIELD_PROGRESSIVE
Definition:
avcodec.h:1712
AV_FIELD_BB
Definition:
avcodec.h:1714
rational.h
Utilties for rational number calculation.
canopus.h
AVRational::den
int den
Denominator.
Definition:
rational.h:60
AVCodecContext::field_order
enum AVFieldOrder field_order
Field order.
Definition:
avcodec.h:2491
Generated on Fri Jan 12 2018 01:45:36 for FFmpeg by
1.8.6