MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / lpcmInfo

Function lpcmInfo

libhb/declpcm.c:67–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65};
66
67static void lpcmInfo( hb_work_object_t *w, hb_buffer_t *in )
68{
69 hb_work_private_t * pv = w->private_data;
70
71 /*
72 * LPCM packets have a 7 byte header (the substream id is stripped off
73 * before we get here so it's numbered -1 below)::
74 * byte -1 Substream id
75 * byte 0 Number of frames that begin in this packet
76 * (last frame may finish in next packet)
77 * byte 1,2 offset to first frame that begins in this packet (not including hdr)
78 * byte 3:
79 * bits 0-4 continuity counter (increments modulo 20)
80 * bit 5 reserved
81 * bit 6 audio mute on/off
82 * bit 7 audio emphasis on/off
83 * byte 4:
84 * bits 0-2 #channels - 1 (e.g., stereo = 1)
85 * bit 3 reserved
86 * bits 4-5 sample rate (0=48K,1=96K,2=44.1K,3=32K)
87 * bits 6-7 bits per sample (0=16 bit, 1=20 bit, 2=24 bit)
88 * byte 5 Dynamic range control (0x80 = off)
89 *
90 * The audio is viewed as "frames" of 150 90KHz ticks each (80 samples @ 48KHz).
91 * The frames are laid down continuously without regard to MPEG packet
92 * boundaries. E.g., for 48KHz stereo, the first packet will contain 6
93 * frames plus the start of the 7th, the second packet will contain the
94 * end of the 7th, 8-13 & the start of 14, etc. The frame structure is
95 * important because the PTS on the packet gives the time of the first
96 * frame that starts in the packet *NOT* the time of the first sample
97 * in the packet. Also samples get split across packet boundaries
98 * so we can't assume that we can consume all the data in one packet
99 * on every call to the work routine.
100 */
101 pv->offset = ( ( in->data[1] << 8 ) | in->data[2] ) + 2;
102 if ( pv->offset >= HB_DVD_READ_BUFFER_SIZE )
103 {
104 hb_log( "declpcm: illegal frame offset %d", pv->offset );
105 pv->offset = 2; /*XXX*/
106 }
107 pv->nchannels = ( in->data[4] & 7 ) + 1;
108 pv->samplerate = hdr2samplerate[ ( in->data[4] >> 4 ) & 0x3 ];
109 pv->sample_size = hdr2samplesize[in->data[4] >> 6];
110
111 // 20 and 24 bit lpcm is always encoded in sample pairs. So take this
112 // into account when computing sizes.
113 int chunk_size = pv->sample_size / 8;
114 int samples_per_chunk = 1;
115
116 switch( pv->sample_size )
117 {
118 case 20:
119 chunk_size = 5;
120 samples_per_chunk = 2;
121 break;
122 case 24:
123 chunk_size = 6;
124 samples_per_chunk = 2;

Callers 1

declpcmWorkFunction · 0.85

Calls 1

hb_logFunction · 0.85

Tested by

no test coverage detected