FFmpeg  4.0
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 
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;
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];
55 
58 
62  dv_sect_vaux = 0x56,
63  dv_sect_audio = 0x76,
64  dv_sect_video = 0x96,
65 };
66 
68  dv_header525 = 0x3f, /* see dv_write_pack for important details on */
69  dv_header625 = 0xbf, /* these two packs */
70  dv_timecode = 0x13,
80 };
81 
82 #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
83 #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1))
84 #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1))
85 
86 /**
87  * largest possible DV frame, in bytes (1080i50)
88  */
89 #define DV_MAX_FRAME_SIZE 576000
90 
91 /**
92  * maximum number of blocks per macroblock in any DV format
93  */
94 #define DV_MAX_BPM 8
95 
96 #define TEX_VLC_BITS 10
97 
98 extern RL_VLC_ELEM ff_dv_rl_vlc[1664];
99 
101 
102 int ff_dvvideo_init(AVCodecContext *avctx);
103 
104 static inline int dv_work_pool_size(const AVDVProfile *d)
105 {
106  int size = d->n_difchan * d->difseg_size * 27;
107  if (DV_PROFILE_IS_1080i50(d))
108  size -= 3 * 27;
109  if (DV_PROFILE_IS_720p50(d))
110  size -= 4 * 27;
111  return size;
112 }
113 
114 static inline void dv_calculate_mb_xy(DVVideoContext *s,
115  DVwork_chunk *work_chunk,
116  int m, int *mb_x, int *mb_y)
117 {
118  *mb_x = work_chunk->mb_coordinates[m] & 0xff;
119  *mb_y = work_chunk->mb_coordinates[m] >> 8;
120 
121  /* We work with 720p frames split in half.
122  * The odd half-frame (chan == 2,3) is displaced :-( */
123  if (s->sys->height == 720 && !(s->buf[1] & 0x0C))
124  /* shifting the Y coordinate down by 72/2 macro blocks */
125  *mb_y -= (*mb_y > 17) ? 18 : -72;
126 }
127 
128 #endif /* AVCODEC_DV_H */
const char * s
Definition: avisynth_c.h:768
int size
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
me_cmp_func ildct_cmp
Definition: dv.h:52
int quant_deadzone
Definition: dv.h:56
int stride
Definition: mace.c:144
uint8_t * buf
Definition: dv.h:45
static int16_t block[64]
Definition: dct.c:115
#define DV_PROFILE_IS_1080i50(p)
Definition: dv.h:83
AVCodecContext * avctx
Definition: dv.h:44
dv_pack_type
Definition: dv.h:67
uint8_t
int difseg_size
Definition: dv_profile.h:43
int(* me_cmp_func)(struct MpegEncContext *c, uint8_t *blk1, uint8_t *blk2, ptrdiff_t stride, int h)
Definition: me_cmp.h:48
#define DV_PROFILE_IS_720p50(p)
Definition: dv.h:84
uint16_t mb_coordinates[5]
Definition: dv.h:37
static int dv_work_pool_size(const AVDVProfile *d)
Definition: dv.h:104
const AVFrame * frame
Definition: dv.h:43
int ff_dvvideo_init(AVCodecContext *avctx)
Definition: dv.c:198
static void idct_put(FourXContext *f, int x, int y)
Definition: 4xm.c:550
Libavcodec external API header.
typedef void(RENAME(mix_any_func_type))
Definition: dv.h:70
main external API structure.
Definition: avcodec.h:1518
Describe the class of an AVClass context structure.
Definition: log.h:67
AVClass * avclass
Definition: dv.h:41
int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d)
Definition: dv.c:175
RL_VLC_ELEM ff_dv_rl_vlc[1664]
Definition: dv.c:52
dv_section_type
Definition: dv.h:59
uint16_t buf_offset
Definition: dv.h:36
int pixels
Definition: avisynth_c.h:429
static void dv_calculate_mb_xy(DVVideoContext *s, DVwork_chunk *work_chunk, int m, int *mb_x, int *mb_y)
Definition: dv.h:114
const AVDVProfile * sys
Definition: dv.h:42
int n_difchan
Definition: dv_profile.h:44