FFmpeg
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 "idctdsp.h"
34 
35 typedef struct DVwork_chunk {
36  uint16_t buf_offset;
37  uint16_t mb_coordinates[5];
38 } DVwork_chunk;
39 
40 typedef struct DVVideoContext {
42  const AVDVProfile *sys;
43  const AVFrame *frame;
45  uint8_t *buf;
46 
47  uint8_t dv_zigzag[2][64];
48 
49  void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize);
50  void (*fdct[2])(int16_t *block);
51  void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block);
53  DVwork_chunk work_chunks[4 * 12 * 27];
54  uint32_t idct_factor[2 * 4 * 16 * 64];
56 
59 
63  dv_sect_vaux = 0x56,
64  dv_sect_audio = 0x76,
65  dv_sect_video = 0x96,
66 };
67 
69  dv_header525 = 0x3f, /* see dv_write_pack for important details on */
70  dv_header625 = 0xbf, /* these two packs */
71  dv_timecode = 0x13,
81 };
82 
83 #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
84 #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1))
85 #define DV_PROFILE_IS_1080i60(p) (((p)->video_stype == 0x14) && ((p)->dsf == 0))
86 #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1))
87 
88 /**
89  * largest possible DV frame, in bytes (1080i50)
90  */
91 #define DV_MAX_FRAME_SIZE 576000
92 
93 /**
94  * maximum number of blocks per macroblock in any DV format
95  */
96 #define DV_MAX_BPM 8
97 
99 
100 int ff_dvvideo_init(AVCodecContext *avctx);
101 
102 static inline int dv_work_pool_size(const AVDVProfile *d)
103 {
104  int size = d->n_difchan * d->difseg_size * 27;
106  size -= 3 * 27;
107  if (DV_PROFILE_IS_720p50(d))
108  size -= 4 * 27;
109  return size;
110 }
111 
112 static inline void dv_calculate_mb_xy(DVVideoContext *s,
113  DVwork_chunk *work_chunk,
114  int m, int *mb_x, int *mb_y)
115 {
116  *mb_x = work_chunk->mb_coordinates[m] & 0xff;
117  *mb_y = work_chunk->mb_coordinates[m] >> 8;
118 
119  /* We work with 720p frames split in half.
120  * The odd half-frame (chan == 2,3) is displaced :-( */
121  if (s->sys->height == 720 && !(s->buf[1] & 0x0C))
122  /* shifting the Y coordinate down by 72/2 macro blocks */
123  *mb_y -= (*mb_y > 17) ? 18 : -72;
124 }
125 
126 #endif /* AVCODEC_DV_H */
DVVideoContext::idct_put
void(* idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block)
Definition: dv.h:51
DVwork_chunk::buf_offset
uint16_t buf_offset
Definition: dv.h:36
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
dv_sect_vaux
@ dv_sect_vaux
Definition: dv.h:63
DVwork_chunk
Definition: dv.h:35
dv_header625
@ dv_header625
Definition: dv.h:70
dv_audio_source
@ dv_audio_source
Definition: dv.h:72
DVVideoContext::quant_deadzone
int quant_deadzone
Definition: dv.h:57
dv_sect_subcode
@ dv_sect_subcode
Definition: dv.h:62
dv_sect_audio
@ dv_sect_audio
Definition: dv.h:64
dv_profile.h
DV_PROFILE_IS_1080i50
#define DV_PROFILE_IS_1080i50(p)
Definition: dv.h:84
dv_pack_type
dv_pack_type
Definition: dv.h:68
s
#define s(width, name)
Definition: cbs_vp9.c:256
DVVideoContext::dv_zigzag
uint8_t dv_zigzag[2][64]
Definition: dv.h:47
DV_PROFILE_IS_720p50
#define DV_PROFILE_IS_720p50(p)
Definition: dv.h:86
dv_audio_control
@ dv_audio_control
Definition: dv.h:73
dv_video_source
@ dv_video_source
Definition: dv.h:76
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
DVVideoContext::work_chunks
DVwork_chunk work_chunks[4 *12 *27]
Definition: dv.h:53
ff_dvvideo_init
int ff_dvvideo_init(AVCodecContext *avctx)
Definition: dv.c:188
DVVideoContext
Definition: dv.h:40
dv_audio_recdate
@ dv_audio_recdate
Definition: dv.h:74
DVVideoContext::idsp
IDCTDSPContext idsp
Definition: dv.h:55
dv_sect_header
@ dv_sect_header
Definition: dv.h:61
dv_unknown_pack
@ dv_unknown_pack
Definition: dv.h:80
size
int size
Definition: twinvq_data.h:10344
DVVideoContext::buf
uint8_t * buf
Definition: dv.h:45
dv_header525
@ dv_header525
Definition: dv.h:69
DVVideoContext::frame
const AVFrame * frame
Definition: dv.h:43
dv_audio_rectime
@ dv_audio_rectime
Definition: dv.h:75
DVVideoContext::avctx
AVCodecContext * avctx
Definition: dv.h:44
DVVideoContext::fdct
void(* fdct[2])(int16_t *block)
Definition: dv.h:50
dv_work_pool_size
static int dv_work_pool_size(const AVDVProfile *d)
Definition: dv.h:102
dv_video_control
@ dv_video_control
Definition: dv.h:77
DVVideoContext::ildct_cmp
me_cmp_func ildct_cmp
Definition: dv.h:52
dv_video_recdate
@ dv_video_recdate
Definition: dv.h:78
dv_section_type
dv_section_type
Definition: dv.h:60
dv_timecode
@ dv_timecode
Definition: dv.h:71
idctdsp.h
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
dv_calculate_mb_xy
static void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y)
Definition: dv.h:112
IDCTDSPContext
Definition: idctdsp.h:53
DVVideoContext::idct_factor
uint32_t idct_factor[2 *4 *16 *64]
Definition: dv.h:54
me_cmp.h
DVwork_chunk::mb_coordinates
uint16_t mb_coordinates[5]
Definition: dv.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:389
DVVideoContext::sys
const AVDVProfile * sys
Definition: dv.h:42
dv_sect_video
@ dv_sect_video
Definition: dv.h:65
AVDVProfile
Definition: dv_profile.h:38
dv_video_rectime
@ dv_video_rectime
Definition: dv.h:79
DVVideoContext::avclass
AVClass * avclass
Definition: dv.h:41
ff_dv_init_dynamic_tables
int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d)
Definition: dv.c:165
me_cmp_func
int(* me_cmp_func)(struct MpegEncContext *c, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h)
Definition: me_cmp.h:48
d
d
Definition: ffmpeg_filter.c:153
DVVideoContext::get_pixels
void(* get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize)
Definition: dv.h:49
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207