Mercurial > libavformat.hg
annotate dvcore.c @ 236:ee98d63dbba7 libavformat
kernel header bug workaround by (Ronald Bultje <rbultje at ronald dot bitfreak dot net>)
author | michaelni |
---|---|
date | Tue, 09 Sep 2003 19:14:05 +0000 |
parents | 23a6daaa93dd |
children | 3d92f793fd67 |
rev | line source |
---|---|
203
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
1 /* |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
2 * DV format muxer/demuxer |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
3 * Copyright (c) 2003 Roman Shaposhnik |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
4 * |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
5 * Many thanks to Dan Dennedy <dan@dennedy.org> for providing wealth |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
6 * of DV technical info, and SMPTE 314M specification. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
7 * |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
8 * This library is free software; you can redistribute it and/or |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
11 * version 2 of the License, or (at your option) any later version. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
12 * |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
13 * This library is distributed in the hope that it will be useful, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
17 * |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
19 * License along with this library; if not, write to the Free Software |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
21 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
22 #include "avformat.h" |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
23 #include "dvcore.h" |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
24 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
25 /* |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
26 * The reason why the following three big ugly looking tables are |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
27 * here is my lack of DV spec IEC 61834. The tables were basically |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
28 * constructed to make code that places packs in SSYB, VAUX and |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
29 * AAUX blocks very simple and table-driven. They conform to the |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
30 * SMPTE 314M and the output of my personal DV camcorder, neither |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
31 * of which is sufficient for a reliable DV stream producing. Thus |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
32 * while code is still in development I'll be gathering input from |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
33 * people with different DV equipment and modifying the tables to |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
34 * accommodate all the quirks. Later on, if possible, some of them |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
35 * will be folded into smaller tables and/or switch-if logic. For |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
36 * now, my only excuse is -- they don't eat up that much of a space. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
37 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
38 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
39 static const int dv_ssyb_packs_dist[12][6] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
40 { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
41 { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
42 { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
43 { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
44 { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
45 { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
46 { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
47 { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
48 { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
49 { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
50 { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
51 { 0x13, 0x62, 0x63, 0x13, 0x62, 0x63 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
52 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
53 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
54 static const int dv_vaux_packs_dist[12][15] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
55 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
56 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
57 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
58 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
59 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
60 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
61 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
62 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
63 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
64 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
65 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
66 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
67 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
68 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
69 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
70 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
71 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
72 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
73 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
74 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
75 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
76 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
77 { 0x60, 0x61, 0x62, 0x63, 0xff, 0xff, 0xff, 0xff, 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
78 0x60, 0x61, 0x62, 0x63, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
79 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
80 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
81 static const int dv_aaux_packs_dist[12][9] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
82 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
83 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
84 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
85 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
86 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
87 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
88 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
89 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
90 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
91 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
92 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
93 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
94 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
95 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
96 enum dv_section_type { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
97 dv_sect_header = 0x1f, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
98 dv_sect_subcode = 0x3f, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
99 dv_sect_vaux = 0x56, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
100 dv_sect_audio = 0x76, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
101 dv_sect_video = 0x96, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
102 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
103 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
104 enum dv_pack_type { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
105 dv_header525 = 0x3f, /* see dv_write_pack for important details on */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
106 dv_header625 = 0xbf, /* these two packs */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
107 dv_timecode = 0x13, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
108 dv_audio_source = 0x50, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
109 dv_audio_control = 0x51, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
110 dv_audio_recdate = 0x52, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
111 dv_audio_rectime = 0x53, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
112 dv_video_source = 0x60, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
113 dv_video_control = 0x61, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
114 dv_viedo_recdate = 0x62, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
115 dv_video_rectime = 0x63, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
116 dv_unknown_pack = 0xff, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
117 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
118 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
119 static const uint16_t dv_audio_shuffle525[10][9] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
120 { 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
121 { 6, 36, 66, 26, 56, 86, 16, 46, 76 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
122 { 12, 42, 72, 2, 32, 62, 22, 52, 82 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
123 { 18, 48, 78, 8, 38, 68, 28, 58, 88 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
124 { 24, 54, 84, 14, 44, 74, 4, 34, 64 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
125 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
126 { 1, 31, 61, 21, 51, 81, 11, 41, 71 }, /* 2nd channel */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
127 { 7, 37, 67, 27, 57, 87, 17, 47, 77 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
128 { 13, 43, 73, 3, 33, 63, 23, 53, 83 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
129 { 19, 49, 79, 9, 39, 69, 29, 59, 89 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
130 { 25, 55, 85, 15, 45, 75, 5, 35, 65 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
131 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
132 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
133 static const uint16_t dv_audio_shuffle625[12][9] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
134 { 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
135 { 6, 42, 78, 32, 68, 104, 22, 58, 94}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
136 { 12, 48, 84, 2, 38, 74, 28, 64, 100}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
137 { 18, 54, 90, 8, 44, 80, 34, 70, 106}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
138 { 24, 60, 96, 14, 50, 86, 4, 40, 76}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
139 { 30, 66, 102, 20, 56, 92, 10, 46, 82}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
140 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
141 { 1, 37, 73, 27, 63, 99, 17, 53, 89}, /* 2nd channel */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
142 { 7, 43, 79, 33, 69, 105, 23, 59, 95}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
143 { 13, 49, 85, 3, 39, 75, 29, 65, 101}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
144 { 19, 55, 91, 9, 45, 81, 35, 71, 107}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
145 { 25, 61, 97, 15, 51, 87, 5, 41, 77}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
146 { 31, 67, 103, 21, 57, 93, 11, 47, 83}, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
147 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
148 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
149 static const int dv_audio_frequency[3] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
150 48000, 44100, 32000, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
151 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
152 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
153 const DVprofile dv_profiles[2] = { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
154 { .dsf = 0, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
155 .frame_size = 120000, /* 525/60 system (NTSC) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
156 .difseg_size = 10, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
157 .frame_rate = 30000, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
158 .ltc_divisor = 30, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
159 .frame_rate_base = 1001, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
160 .height = 480, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
161 /* .video_place = dv_place_411, */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
162 .audio_stride = 90, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
163 .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32Khz */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
164 .audio_samples_dist = { 1602, 1601, 1602, 1601, 1602 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
165 .audio_shuffle = dv_audio_shuffle525, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
166 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
167 { .dsf = 1, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
168 .frame_size = 144000, /* 625/50 system (PAL) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
169 .difseg_size = 12, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
170 .frame_rate = 25, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
171 .frame_rate_base = 1, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
172 .ltc_divisor = 25, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
173 .height = 576, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
174 /* .video_place = dv_place_420, */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
175 .audio_stride = 108, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
176 .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
177 .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
178 .audio_shuffle = dv_audio_shuffle525, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
179 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
180 }; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
181 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
182 static inline uint16_t dv_audio_12to16(uint16_t sample) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
183 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
184 uint16_t shift, result; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
185 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
186 sample = (sample < 0x800) ? sample : sample | 0xf000; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
187 shift = (sample & 0xf00) >> 8; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
188 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
189 if (shift < 0x2 || shift > 0xd) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
190 result = sample; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
191 } else if (shift < 0x8) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
192 shift--; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
193 result = (sample - (256 * shift)) << shift; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
194 } else { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
195 shift = 0xe - shift; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
196 result = ((sample + ((256 * shift) + 1)) << shift) - 1; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
197 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
198 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
199 return result; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
200 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
201 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
202 static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* buf) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
203 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
204 struct tm tc; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
205 time_t ct; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
206 int ltc_frame; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
207 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
208 buf[0] = (uint8_t)pack_id; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
209 switch (pack_id) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
210 case dv_header525: /* I can't imagine why these two weren't defined as real */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
211 case dv_header625: /* packs in SMPTE314M -- they definitely look like ones */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
212 buf[1] = 0xf8 | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
213 (0 & 0x07); /* APT: Track application ID */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
214 buf[2] = (0 << 7) | /* TF1: audio data is 0 - valid; 1 - invalid */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
215 (0x0f << 3) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
216 (0 & 0x07); /* AP1: Audio application ID */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
217 buf[3] = (0 << 7) | /* TF2: video data is 0 - valid; 1 - invalid */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
218 (0x0f << 3) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
219 (0 & 0x07); /* AP2: Video application ID */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
220 buf[4] = (0 << 7) | /* TF3: subcode(SSYB) is 0 - valid; 1 - invalid */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
221 (0x0f << 3) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
222 (0 & 0x07); /* AP3: Subcode application ID */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
223 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
224 case dv_timecode: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
225 ct = (time_t)(c->frames / ((float)c->sys->frame_rate / |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
226 (float)c->sys->frame_rate_base)); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
227 localtime_r(&ct, &tc); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
228 /* |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
229 * LTC drop-frame frame counter drops two frames (0 and 1) every |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
230 * minute, unless it is exactly divisible by 10 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
231 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
232 ltc_frame = (c->frames + 2*ct/60 - 2*ct/600) % c->sys->ltc_divisor; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
233 buf[1] = (0 << 7) | /* Color fame: 0 - unsync; 1 - sync mode */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
234 (1 << 6) | /* Drop frame timecode: 0 - nondrop; 1 - drop */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
235 ((ltc_frame / 10) << 4) | /* Tens of frames */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
236 (ltc_frame % 10); /* Units of frames */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
237 buf[2] = (1 << 7) | /* Biphase mark polarity correction: 0 - even; 1 - odd */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
238 ((tc.tm_sec / 10) << 4) | /* Tens of seconds */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
239 (tc.tm_sec % 10); /* Units of seconds */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
240 buf[3] = (1 << 7) | /* Binary group flag BGF0 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
241 ((tc.tm_min / 10) << 4) | /* Tens of minutes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
242 (tc.tm_min % 10); /* Units of minutes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
243 buf[4] = (1 << 7) | /* Binary group flag BGF2 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
244 (1 << 6) | /* Binary group flag BGF1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
245 ((tc.tm_hour / 10) << 4) | /* Tens of hours */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
246 (tc.tm_hour % 10); /* Units of hours */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
247 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
248 case dv_audio_source: /* AAUX source pack */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
249 buf[1] = (0 << 7) | /* locked mode */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
250 (1 << 6) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
251 (dv_audio_frame_size(c->sys, c->frames) - |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
252 c->sys->audio_min_samples[0]); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
253 /* # of samples */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
254 buf[2] = (0 << 7) | /* multi-stereo */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
255 (0 << 5) | /* #of audio channels per block: 0 -- 1 channel */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
256 (0 << 4) | /* pair bit: 0 -- one pair of channels */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
257 0; /* audio mode */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
258 buf[3] = (1 << 7) | /* res */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
259 (1 << 6) | /* multi-language flag */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
260 (c->sys->dsf << 5) | /* system: 60fields/50fields */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
261 0; /* definition: 0 -- SD (525/625) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
262 buf[4] = (1 << 7) | /* emphasis: 1 -- off */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
263 (0 << 6) | /* emphasis time constant: 0 -- reserved */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
264 (0 << 3) | /* frequency: 0 -- 48Khz, 1 -- 44,1Khz, 2 -- 32Khz */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
265 0; /* quantization: 0 -- 16bit linear, 1 -- 12bit nonlinear */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
266 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
267 case dv_audio_control: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
268 buf[1] = (0 << 6) | /* copy protection: 0 -- unrestricted */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
269 (1 << 4) | /* input source: 1 -- digital input */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
270 (3 << 2) | /* compression: 3 -- no information */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
271 0; /* misc. info/SMPTE emphasis off */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
272 buf[2] = (1 << 7) | /* recording start point: 1 -- no */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
273 (1 << 6) | /* recording end point: 1 -- no */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
274 (1 << 3) | /* recording mode: 1 -- original */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
275 7; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
276 buf[3] = (1 << 7) | /* direction: 1 -- forward */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
277 0x20; /* speed */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
278 buf[4] = (1 << 7) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
279 0x7f; /* genre category */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
280 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
281 case dv_audio_recdate: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
282 case dv_viedo_recdate: /* VAUX recording date */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
283 ct = c->start_time + (time_t)(c->frames / |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
284 ((float)c->sys->frame_rate / (float)c->sys->frame_rate_base)); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
285 localtime_r(&ct, &tc); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
286 buf[1] = 0xff; /* ds, tm, tens of time zone, units of time zone */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
287 /* 0xff is very likely to be "unknown" */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
288 buf[2] = (3 << 6) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
289 ((tc.tm_mday / 10) << 4) | /* Tens of day */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
290 (tc.tm_mday % 10); /* Units of day */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
291 buf[3] = /* we set high 4 bits to 0, shouldn't we set them to week? */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
292 (tc.tm_mon % 10); /* Units of month */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
293 buf[4] = (((tc.tm_year % 100) / 10) << 4) | /* Tens of year */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
294 (tc.tm_year % 10); /* Units of year */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
295 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
296 case dv_audio_rectime: /* AAUX recording time */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
297 case dv_video_rectime: /* VAUX recording time */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
298 ct = c->start_time + (time_t)(c->frames / |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
299 ((float)c->sys->frame_rate / (float)c->sys->frame_rate_base)); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
300 localtime_r(&ct, &tc); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
301 buf[1] = (3 << 6) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
302 0x3f; /* tens of frame, units of frame: 0x3f - "unknown" ? */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
303 buf[2] = (1 << 7) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
304 ((tc.tm_sec / 10) << 4) | /* Tens of seconds */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
305 (tc.tm_sec % 10); /* Units of seconds */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
306 buf[3] = (1 << 7) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
307 ((tc.tm_min / 10) << 4) | /* Tens of minutes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
308 (tc.tm_min % 10); /* Units of minutes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
309 buf[4] = (3 << 6) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
310 ((tc.tm_hour / 10) << 4) | /* Tens of hours */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
311 (tc.tm_hour % 10); /* Units of hours */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
312 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
313 case dv_video_source: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
314 buf[1] = 0xff; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
315 buf[2] = (1 << 7) | /* B/W: 0 - b/w, 1 - color */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
316 (1 << 6) | /* following CLF is valid - 0, invalid - 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
317 (3 << 4) | /* CLF: color frames id (see ITU-R BT.470-4) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
318 0xf; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
319 buf[3] = (3 << 6) | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
320 (c->sys->dsf << 5) | /* system: 60fields/50fields */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
321 0; /* signal type video compression */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
322 buf[4] = 0xff; /* VISC: 0xff -- no information */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
323 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
324 case dv_video_control: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
325 buf[1] = (0 << 6) | /* Copy generation management (CGMS) 0 -- free */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
326 0x3f; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
327 buf[2] = 0xc8 | /* reserved -- always b11001xxx */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
328 c->aspect; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
329 buf[3] = (1 << 7) | /* Frame/field flag 1 -- frame, 0 -- field */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
330 (1 << 6) | /* First/second field flag 0 -- field 2, 1 -- field 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
331 (1 << 5) | /* Frame change flag 0 -- same picture as before, 1 -- different */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
332 (1 << 4) | /* 1 - interlaced, 0 - noninterlaced */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
333 0xc; /* reserved -- always b1100 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
334 buf[4] = 0xff; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
335 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
336 default: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
337 buf[1] = buf[2] = buf[3] = buf[4] = 0xff; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
338 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
339 return 5; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
340 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
341 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
342 static inline int dv_write_dif_id(enum dv_section_type t, uint8_t seq_num, |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
343 uint8_t dif_num, uint8_t* buf) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
344 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
345 buf[0] = (uint8_t)t; /* Section type */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
346 buf[1] = (seq_num<<4) | /* DIF seq number 0-9 for 525/60; 0-11 for 625/50 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
347 (0 << 3) | /* FSC: for 50Mb/s 0 - first channel; 1 - second */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
348 7; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
349 buf[2] = dif_num; /* DIF block number Video: 0-134, Audio: 0-8 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
350 return 3; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
351 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
352 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
353 static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t* buf) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
354 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
355 if (syb_num == 0 || syb_num == 6) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
356 buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
357 (0<<4) | /* AP3 (Subcode application ID) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
358 0x0f; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
359 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
360 else if (syb_num == 11) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
361 buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
362 0x7f; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
363 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
364 else { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
365 buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
366 (0<<4) | /* APT (Track application ID) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
367 0x0f; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
368 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
369 buf[1] = 0xf0 | /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
370 (syb_num & 0x0f); /* SSYB number 0 - 11 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
371 buf[2] = 0xff; /* reserved -- always 1 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
372 return 3; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
373 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
374 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
375 void dv_format_frame(DVMuxContext *c, uint8_t* buf) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
376 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
377 int i, j, k; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
378 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
379 for (i = 0; i < c->sys->difseg_size; i++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
380 memset(buf, 0xff, 80 * 6); /* First 6 DIF blocks are for control data */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
381 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
382 /* DV header: 1DIF */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
383 buf += dv_write_dif_id(dv_sect_header, i, 0, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
384 buf += dv_write_pack((c->sys->dsf ? dv_header625 : dv_header525), c, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
385 buf += 72; /* unused bytes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
386 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
387 /* DV subcode: 2DIFs */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
388 for (j = 0; j < 2; j++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
389 buf += dv_write_dif_id( dv_sect_subcode, i, j, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
390 for (k = 0; k < 6; k++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
391 buf += dv_write_ssyb_id(k, (i < c->sys->difseg_size/2), buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
392 buf += dv_write_pack(dv_ssyb_packs_dist[i][k], c, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
393 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
394 buf += 29; /* unused bytes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
395 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
396 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
397 /* DV VAUX: 3DIFs */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
398 for (j = 0; j < 3; j++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
399 buf += dv_write_dif_id(dv_sect_vaux, i, j, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
400 for (k = 0; k < 15 ; k++) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
401 buf += dv_write_pack(dv_vaux_packs_dist[i][k], c, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
402 buf += 2; /* unused bytes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
403 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
404 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
405 /* DV Audio/Video: 135 Video DIFs + 9 Audio DIFs */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
406 for (j = 0; j < 135; j++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
407 if (j%15 == 0) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
408 buf += dv_write_dif_id(dv_sect_audio, i, j/15, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
409 buf += dv_write_pack(dv_aaux_packs_dist[i][j/15], c, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
410 buf += 72; /* shuffled PCM audio */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
411 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
412 buf += dv_write_dif_id(dv_sect_video, i, j, buf); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
413 buf += 77; /* 1 video macro block: 1 bytes control |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
414 4 * 14 bytes Y 8x8 data |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
415 10 bytes Cr 8x8 data |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
416 10 bytes Cb 8x8 data */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
417 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
418 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
419 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
420 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
421 void dv_inject_audio(DVMuxContext *c, uint8_t* pcm, uint8_t* frame_ptr) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
422 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
423 int i, j, d, of; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
424 for (i = 0; i < c->sys->difseg_size; i++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
425 frame_ptr += 6 * 80; /* skip DIF segment header */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
426 for (j = 0; j < 9; j++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
427 for (d = 8; d < 80; d+=2) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
428 of = c->sys->audio_shuffle[i][j] + (d - 8)/2 * c->sys->audio_stride; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
429 frame_ptr[d] = pcm[of*2+1]; // FIXME: may be we have to admit |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
430 frame_ptr[d+1] = pcm[of*2]; // that DV is a big endian PCM |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
431 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
432 frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
433 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
434 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
435 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
436 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
437 void dv_inject_video(DVMuxContext *c, uint8_t* video_data, uint8_t* frame_ptr) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
438 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
439 int i, j; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
440 int ptr = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
441 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
442 for (i = 0; i < c->sys->difseg_size; i++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
443 ptr += 6 * 80; /* skip DIF segment header */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
444 for (j = 0; j < 135; j++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
445 if (j%15 == 0) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
446 ptr += 80; /* skip Audio DIF */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
447 ptr += 3; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
448 memcpy(frame_ptr + ptr, video_data + ptr, 77); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
449 ptr += 77; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
450 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
451 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
452 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
453 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
454 int dv_audio_frame_size(const DVprofile* sys, int frame) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
455 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
456 return sys->audio_samples_dist[frame % (sizeof(sys->audio_samples_dist)/ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
457 sizeof(sys->audio_samples_dist[0]))]; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
458 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
459 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
460 const DVprofile* dv_frame_profile(uint8_t* frame) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
461 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
462 return &dv_profiles[!!(frame[3] & 0x80)]; /* Header, DSF flag */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
463 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
464 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
465 /* |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
466 * This is the dumbest implementation of all -- it simply looks at |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
467 * a fixed offset and if pack isn't there -- fails. We might want |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
468 * to have a fallback mechanism for complete search of missing packs. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
469 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
470 const uint8_t* dv_extract_pack(uint8_t* frame, enum dv_pack_type t) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
471 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
472 int offs; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
473 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
474 switch (t) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
475 case dv_audio_source: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
476 offs = (80*6 + 80*16*3 + 3); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
477 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
478 case dv_audio_control: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
479 offs = (80*6 + 80*16*4 + 3); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
480 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
481 case dv_video_control: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
482 offs = (80*5 + 48 + 5); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
483 break; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
484 default: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
485 return NULL; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
486 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
487 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
488 return (frame[offs] == t ? &frame[offs] : NULL); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
489 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
490 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
491 /* |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
492 * There's a couple of assumptions being made here: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
493 * 1. By default we silence erroneous (0x8000/16bit 0x800/12bit) audio samples. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
494 * We can pass them upwards when ffmpeg will be ready to deal with them. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
495 * 2. We don't do software emphasis. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
496 * 3. Audio is always returned as 16bit linear samples: 12bit nonlinear samples |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
497 * are converted into 16bit linear ones. |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
498 */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
499 int dv_extract_audio(uint8_t* frame, uint8_t* pcm, AVCodecContext* avctx) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
500 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
501 int size, i, j, d, of, smpls, freq, quant; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
502 uint16_t lc, rc; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
503 const DVprofile* sys; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
504 const uint8_t* as_pack; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
505 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
506 as_pack = dv_extract_pack(frame, dv_audio_source); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
507 if (!as_pack) /* No audio ? */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
508 return 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
509 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
510 sys = dv_frame_profile(frame); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
511 smpls = as_pack[1] & 0x3f; /* samples in this frame - min. samples */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
512 freq = (as_pack[4] >> 3) & 0x07; /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
513 quant = as_pack[4] & 0x07; /* 0 - 16bit linear, 1 - 12bit nonlinear */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
514 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
515 if (quant > 1) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
516 return -1; /* Unsupported quantization */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
517 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
518 avctx->sample_rate = dv_audio_frequency[freq]; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
519 avctx->channels = 2; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
520 avctx->bit_rate = avctx->channels * avctx->sample_rate * 16; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
521 // What about: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
522 // avctx->frame_size = |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
523 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
524 size = (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
525 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
526 /* for each DIF segment */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
527 for (i = 0; i < sys->difseg_size; i++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
528 frame += 6 * 80; /* skip DIF segment header */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
529 for (j = 0; j < 9; j++) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
530 for (d = 8; d < 80; d += 2) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
531 if (quant == 0) { /* 16bit quantization */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
532 of = sys->audio_shuffle[i][j] + (d - 8)/2 * sys->audio_stride; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
533 pcm[of*2] = frame[d+1]; // FIXME: may be we have to admit |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
534 pcm[of*2+1] = frame[d]; // that DV is a big endian PCM |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
535 if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
536 pcm[of*2+1] = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
537 } else { /* 12bit quantization */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
538 if (i >= sys->difseg_size/2) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
539 goto out; /* We're not doing 4ch at this time */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
540 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
541 lc = ((uint16_t)frame[d] << 4) | |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
542 ((uint16_t)frame[d+2] >> 4); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
543 rc = ((uint16_t)frame[d+1] << 4) | |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
544 ((uint16_t)frame[d+2] & 0x0f); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
545 lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
546 rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc)); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
547 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
548 of = sys->audio_shuffle[i][j] + (d - 8)/3 * sys->audio_stride; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
549 pcm[of*2] = lc & 0xff; // FIXME: may be we have to admit |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
550 pcm[of*2+1] = lc >> 8; // that DV is a big endian PCM |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
551 of = sys->audio_shuffle[i+sys->difseg_size/2][j] + |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
552 (d - 8)/3 * sys->audio_stride; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
553 pcm[of*2] = rc & 0xff; // FIXME: may be we have to admit |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
554 pcm[of*2+1] = rc >> 8; // that DV is a big endian PCM |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
555 ++d; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
556 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
557 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
558 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
559 frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
560 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
561 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
562 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
563 out: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
564 return size; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
565 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
566 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
567 /* FIXME: The following three functions could be underengineered ;-) */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
568 void dv_assemble_frame(DVMuxContext *c, uint8_t* video, uint8_t* audio, int asize) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
569 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
570 uint8_t pcm[8192]; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
571 uint8_t* frame = &c->frame_buf[0]; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
572 int fsize, reqasize; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
573 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
574 if (c->has_audio && c->has_video) { /* must be a stale frame */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
575 dv_format_frame(c, frame); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
576 c->frames++; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
577 c->has_audio = c->has_video = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
578 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
579 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
580 if (video) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
581 /* FIXME: we have to have more sensible approach than this one */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
582 if (c->has_video) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
583 fprintf(stderr, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
584 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
585 dv_inject_video(c, video, frame); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
586 c->has_video = 1; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
587 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
588 if (audio) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
589 reqasize = 4 * dv_audio_frame_size(c->sys, c->frames); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
590 fsize = fifo_size(&c->audio_data, c->audio_data.rptr); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
591 if (fsize + asize >= reqasize) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
592 if (fsize >= reqasize) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
593 fifo_read(&c->audio_data, &pcm[0], reqasize, &c->audio_data.rptr); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
594 } else { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
595 fifo_read(&c->audio_data, &pcm[0], fsize, &c->audio_data.rptr); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
596 memcpy(&pcm[fsize], &audio[0], reqasize - fsize); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
597 audio += reqasize - fsize; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
598 asize -= reqasize - fsize; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
599 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
600 dv_inject_audio(c, &pcm[0], frame); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
601 c->has_audio = 1; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
602 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
603 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
604 /* FIXME: we have to have more sensible approach than this one */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
605 if (fifo_size(&c->audio_data, c->audio_data.rptr) + asize >= AVCODEC_MAX_AUDIO_FRAME_SIZE) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
606 fprintf(stderr, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
607 fifo_write(&c->audio_data, audio, asize, &c->audio_data.wptr); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
608 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
609 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
610 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
611 int dv_core_init(DVMuxContext *c, AVStream *streams[]) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
612 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
613 /* We have to sort out where audio and where video stream is */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
614 if (streams[0]->codec.codec_type == CODEC_TYPE_VIDEO && |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
615 streams[1]->codec.codec_type == CODEC_TYPE_AUDIO) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
616 c->vst = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
617 c->ast = 1; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
618 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
619 else if (streams[1]->codec.codec_type == CODEC_TYPE_VIDEO && |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
620 streams[0]->codec.codec_type == CODEC_TYPE_AUDIO) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
621 c->vst = 1; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
622 c->ast = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
623 } else |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
624 goto bail_out; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
625 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
626 /* Some checks -- DV format is very picky about its incoming streams */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
627 if (streams[c->vst]->codec.codec_id != CODEC_ID_DVVIDEO || |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
628 streams[c->ast]->codec.codec_id != CODEC_ID_PCM_S16LE) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
629 goto bail_out; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
630 if (streams[c->ast]->codec.sample_rate != 48000 || |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
631 streams[c->ast]->codec.channels != 2) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
632 goto bail_out; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
633 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
634 if (streams[c->vst]->codec.frame_rate == 25 && |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
635 streams[c->vst]->codec.frame_rate_base == 1) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
636 /* May be we have to pick sys for every frame */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
637 c->sys = &dv_profiles[1]; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
638 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
639 else if (streams[c->vst]->codec.frame_rate == 30000 && |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
640 streams[c->vst]->codec.frame_rate_base == 1001) { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
641 /* May be we have to pick sys for every frame */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
642 c->sys = &dv_profiles[0]; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
643 } else |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
644 goto bail_out; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
645 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
646 /* Ok, everything seems to be in working order */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
647 c->frames = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
648 c->has_audio = c->has_video = 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
649 c->start_time = time(NULL); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
650 c->aspect = 0; /* 4:3 is the default */ |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
651 if (streams[c->vst]->codec.aspect_ratio == 16.0 / 9.0) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
652 c->aspect = 0x07; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
653 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
654 if (fifo_init(&c->audio_data, AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
655 goto bail_out; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
656 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
657 dv_format_frame(c, &c->frame_buf[0]); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
658 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
659 return 0; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
660 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
661 bail_out: |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
662 return -1; |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
663 } |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
664 |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
665 void dv_core_delete(DVMuxContext *c) |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
666 { |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
667 fifo_free(&c->audio_data); |
184d22d04c84
* Phase 1 for DV encoding support. Muxing/demuxing of DV streams is now
romansh
parents:
diff
changeset
|
668 } |