Directory: | ../../../ffmpeg/ |
---|---|
File: | src/libavcodec/dv.h |
Date: | 2022-07-05 19:52:29 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 13 | 13 | 100.0% |
Branches: | 12 | 14 | 85.7% |
Line | Branch | Exec | Source |
---|---|---|---|
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 | |||
36 | typedef struct DVwork_chunk { | ||
37 | uint16_t buf_offset; | ||
38 | uint16_t mb_coordinates[5]; | ||
39 | } DVwork_chunk; | ||
40 | |||
41 | typedef struct DVVideoContext { | ||
42 | AVClass *avclass; | ||
43 | const AVDVProfile *sys; | ||
44 | const AVFrame *frame; | ||
45 | AVCodecContext *avctx; | ||
46 | uint8_t *buf; | ||
47 | |||
48 | uint8_t dv_zigzag[2][64]; | ||
49 | |||
50 | void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t linesize); | ||
51 | void (*fdct[2])(int16_t *block); | ||
52 | void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block); | ||
53 | me_cmp_func ildct_cmp; | ||
54 | DVwork_chunk work_chunks[4 * 12 * 27]; | ||
55 | uint32_t idct_factor[2 * 4 * 16 * 64]; | ||
56 | IDCTDSPContext idsp; | ||
57 | |||
58 | int quant_deadzone; | ||
59 | } DVVideoContext; | ||
60 | |||
61 | enum dv_section_type { | ||
62 | dv_sect_header = 0x1f, | ||
63 | dv_sect_subcode = 0x3f, | ||
64 | dv_sect_vaux = 0x56, | ||
65 | dv_sect_audio = 0x76, | ||
66 | dv_sect_video = 0x96, | ||
67 | }; | ||
68 | |||
69 | enum dv_pack_type { | ||
70 | dv_header525 = 0x3f, /* see dv_write_pack for important details on */ | ||
71 | dv_header625 = 0xbf, /* these two packs */ | ||
72 | dv_timecode = 0x13, | ||
73 | dv_audio_source = 0x50, | ||
74 | dv_audio_control = 0x51, | ||
75 | dv_audio_recdate = 0x52, | ||
76 | dv_audio_rectime = 0x53, | ||
77 | dv_video_source = 0x60, | ||
78 | dv_video_control = 0x61, | ||
79 | dv_video_recdate = 0x62, | ||
80 | dv_video_rectime = 0x63, | ||
81 | dv_unknown_pack = 0xff, | ||
82 | }; | ||
83 | |||
84 | #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10) | ||
85 | #define DV_PROFILE_IS_1080i50(p) (((p)->video_stype == 0x14) && ((p)->dsf == 1)) | ||
86 | #define DV_PROFILE_IS_1080i60(p) (((p)->video_stype == 0x14) && ((p)->dsf == 0)) | ||
87 | #define DV_PROFILE_IS_720p50(p) (((p)->video_stype == 0x18) && ((p)->dsf == 1)) | ||
88 | |||
89 | /** | ||
90 | * largest possible DV frame, in bytes (1080i50) | ||
91 | */ | ||
92 | #define DV_MAX_FRAME_SIZE 576000 | ||
93 | |||
94 | /** | ||
95 | * maximum number of blocks per macroblock in any DV format | ||
96 | */ | ||
97 | #define DV_MAX_BPM 8 | ||
98 | |||
99 | int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d); | ||
100 | |||
101 | int ff_dvvideo_init(AVCodecContext *avctx); | ||
102 | |||
103 | 2023 | static inline int dv_work_pool_size(const AVDVProfile *d) | |
104 | { | ||
105 | 2023 | int size = d->n_difchan * d->difseg_size * 27; | |
106 |
3/4✓ Branch 0 taken 404 times.
✓ Branch 1 taken 1619 times.
✓ Branch 2 taken 404 times.
✗ Branch 3 not taken.
|
2023 | if (DV_PROFILE_IS_1080i50(d)) |
107 | 404 | size -= 3 * 27; | |
108 |
3/4✓ Branch 0 taken 405 times.
✓ Branch 1 taken 1618 times.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
|
2023 | if (DV_PROFILE_IS_720p50(d)) |
109 | 405 | size -= 4 * 27; | |
110 | 2023 | return size; | |
111 | } | ||
112 | |||
113 | 6072840 | static inline void dv_calculate_mb_xy(DVVideoContext *s, | |
114 | DVwork_chunk *work_chunk, | ||
115 | int m, int *mb_x, int *mb_y) | ||
116 | { | ||
117 | 6072840 | *mb_x = work_chunk->mb_coordinates[m] & 0xff; | |
118 | 6072840 | *mb_y = work_chunk->mb_coordinates[m] >> 8; | |
119 | |||
120 | /* We work with 720p frames split in half. | ||
121 | * The odd half-frame (chan == 2,3) is displaced :-( */ | ||
122 |
4/4✓ Branch 0 taken 1093500 times.
✓ Branch 1 taken 4979340 times.
✓ Branch 2 taken 540000 times.
✓ Branch 3 taken 553500 times.
|
6072840 | if (s->sys->height == 720 && !(s->buf[1] & 0x0C)) |
123 | /* shifting the Y coordinate down by 72/2 macro blocks */ | ||
124 |
2/2✓ Branch 0 taken 432000 times.
✓ Branch 1 taken 108000 times.
|
540000 | *mb_y -= (*mb_y > 17) ? 18 : -72; |
125 | 6072840 | } | |
126 | |||
127 | #endif /* AVCODEC_DV_H */ | ||
128 |