FFmpeg  4.4.9
dv.h
Go to the documentation of this file.
1 /*
2  * Constants for DV codec
3  * Copyright (c) 2002 Fabrice Bellard
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 /**
23  * @file
24  * Constants for DV codec.
25  */
26 
27 #ifndef AVCODEC_DV_H
28 #define AVCODEC_DV_H
29 
30 #include "avcodec.h"
31 #include "dv_profile.h"
32 #include "me_cmp.h"
33 #include "vlc.h"
34 #include "idctdsp.h"
35 #include "pixblockdsp.h"
36 
37 typedef struct DVwork_chunk {
38  uint16_t buf_offset;
39  uint16_t mb_coordinates[5];
40 } DVwork_chunk;
41 
42 typedef struct DVVideoContext {
44  const AVDVProfile *sys;
45  const AVFrame *frame;
48 
50 
51  void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize);
52  void (*fdct[2])(int16_t *block);
53  void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block);
55  DVwork_chunk work_chunks[4 * 12 * 27];
56  uint32_t idct_factor[2 * 4 * 16 * 64];
58 
60 
63 
67  dv_sect_vaux = 0x56,
68  dv_sect_audio = 0x76,
69  dv_sect_video = 0x96,
70 };
71 
73  dv_header525 = 0x3f, /* see dv_write_pack for important details on */
74  dv_header625 = 0xbf, /* these two packs */
75  dv_timecode = 0x13,
85 };
86 
87 #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
88 #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1))
89 #define DV_PROFILE_IS_1080i60(p) (((p)->video_stype == 0x14) && ((p)->dsf == 0))
90 #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1))
91 
92 /**
93  * largest possible DV frame, in bytes (1080i50)
94  */
95 #define DV_MAX_FRAME_SIZE 576000
96 
97 /**
98  * maximum number of blocks per macroblock in any DV format
99  */
100 #define DV_MAX_BPM 8
101 
102 #define TEX_VLC_BITS 10
103 
104 extern RL_VLC_ELEM ff_dv_rl_vlc[1664];
105 
107 
108 int ff_dvvideo_init(AVCodecContext *avctx);
109 
110 static inline int dv_work_pool_size(const AVDVProfile *d)
111 {
112  int size = d->n_difchan * d->difseg_size * 27;
113  if (DV_PROFILE_IS_1080i50(d))
114  size -= 3 * 27;
115  if (DV_PROFILE_IS_720p50(d))
116  size -= 4 * 27;
117  return size;
118 }
119 
120 static inline void dv_calculate_mb_xy(DVVideoContext *s,
121  DVwork_chunk *work_chunk,
122  int m, int *mb_x, int *mb_y)
123 {
124  *mb_x = work_chunk->mb_coordinates[m] & 0xff;
125  *mb_y = work_chunk->mb_coordinates[m] >> 8;
126 
127  /* We work with 720p frames split in half.
128  * The odd half-frame (chan == 2,3) is displaced :-( */
129  if (s->sys->height == 720 && !(s->buf[1] & 0x0C))
130  /* shifting the Y coordinate down by 72/2 macro blocks */
131  *mb_y -= (*mb_y > 17) ? 18 : -72;
132 }
133 
134 #endif /* AVCODEC_DV_H */
uint8_t
Libavcodec external API header.
#define s(width, name)
Definition: cbs_vp9.c:257
static void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y)
Definition: dv.h:120
dv_pack_type
Definition: dv.h:72
@ dv_video_recdate
Definition: dv.h:82
@ dv_header525
Definition: dv.h:73
@ dv_unknown_pack
Definition: dv.h:84
@ dv_timecode
Definition: dv.h:75
@ dv_audio_control
Definition: dv.h:77
@ dv_video_source
Definition: dv.h:80
@ dv_video_control
Definition: dv.h:81
@ dv_audio_recdate
Definition: dv.h:78
@ dv_audio_rectime
Definition: dv.h:79
@ dv_header625
Definition: dv.h:74
@ dv_video_rectime
Definition: dv.h:83
@ dv_audio_source
Definition: dv.h:76
int ff_dvvideo_init(AVCodecContext *avctx)
Definition: dv.c:198
#define DV_PROFILE_IS_1080i50(p)
Definition: dv.h:88
static int dv_work_pool_size(const AVDVProfile *d)
Definition: dv.h:110
#define DV_PROFILE_IS_720p50(p)
Definition: dv.h:90
int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d)
Definition: dv.c:175
dv_section_type
Definition: dv.h:64
@ dv_sect_header
Definition: dv.h:65
@ dv_sect_audio
Definition: dv.h:68
@ dv_sect_video
Definition: dv.h:69
@ dv_sect_vaux
Definition: dv.h:67
@ dv_sect_subcode
Definition: dv.h:66
RL_VLC_ELEM ff_dv_rl_vlc[1664]
Definition: dv.c:52
int stride
Definition: mace.c:144
int(* me_cmp_func)(struct MpegEncContext *c, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h)
Definition: me_cmp.h:48
typedef void(RENAME(mix_any_func_type))
Describe the class of an AVClass context structure.
Definition: log.h:67
main external API structure.
Definition: avcodec.h:536
int n_difchan
Definition: dv_profile.h:44
int difseg_size
Definition: dv_profile.h:43
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
const AVFrame * frame
Definition: dv.h:45
uint8_t dv_zigzag[2][64]
Definition: dv.h:49
me_cmp_func ildct_cmp
Definition: dv.h:54
uint32_t idct_factor[2 *4 *16 *64]
Definition: dv.h:56
DVwork_chunk work_chunks[4 *12 *27]
Definition: dv.h:55
void(* idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: dv.h:53
int quant_deadzone
Definition: dv.h:59
IDCTDSPContext idsp
Definition: dv.h:57
AVClass * avclass
Definition: dv.h:43
const AVDVProfile * sys
Definition: dv.h:44
void(* fdct[2])(int16_t *block)
Definition: dv.h:52
AVCodecContext * avctx
Definition: dv.h:46
PixblockDSPContext pdsp
Definition: dv.h:61
uint8_t * buf
Definition: dv.h:47
void(* get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize)
Definition: dv.h:51
uint16_t mb_coordinates[5]
Definition: dv.h:39
uint16_t buf_offset
Definition: dv.h:38
static int16_t block[64]
Definition: dct.c:116
int size