summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Niebel <Markus.Niebel@ew.tq-group.com>2025-01-28 11:13:50 +0100
committerRodrigo M. Duarte <rodrigo.duarte@ossystems.com.br>2025-04-02 09:18:55 -0300
commit6c4cc8e0c7589620d5d12889300f4a5b3c11167d (patch)
tree49177d7d6550dbb1d91310b02696f4888021f3ec
parentbe18f7307c5121a2bae9e455ea97ef3df506df97 (diff)
downloadmeta-freescale-6c4cc8e0c7589620d5d12889300f4a5b3c11167d.tar.gz
tinycompress: update to the version used in LF6.6.52_2.2.0
Bump revision to 1.2.5 and remove old patches. This also switches to new upstream location at github. The old location uses git-protocol which can cause problems in corporate network environments. Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
-rwxr-xr-xrecipes-multimedia/tinycompress/tinycompress/0001-tinycompress-Add-id3-decoding.patch1002
-rwxr-xr-xrecipes-multimedia/tinycompress/tinycompress/0002-cplay-Support-wave-file.patch215
-rwxr-xr-xrecipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch146
-rwxr-xr-xrecipes-multimedia/tinycompress/tinycompress/0004-tinycompress-pass-NULL-buffer-with-0-size-to-driver.patch40
-rwxr-xr-xrecipes-multimedia/tinycompress/tinycompress/0005-cplay-Support-aac-streams.patch251
-rw-r--r--recipes-multimedia/tinycompress/tinycompress_1.1.6.bb16
-rw-r--r--recipes-multimedia/tinycompress/tinycompress_1.2.5.bb18
7 files changed, 18 insertions, 1670 deletions
diff --git a/recipes-multimedia/tinycompress/tinycompress/0001-tinycompress-Add-id3-decoding.patch b/recipes-multimedia/tinycompress/tinycompress/0001-tinycompress-Add-id3-decoding.patch
deleted file mode 100755
index 78ff6989..00000000
--- a/recipes-multimedia/tinycompress/tinycompress/0001-tinycompress-Add-id3-decoding.patch
+++ /dev/null
@@ -1,1002 +0,0 @@
1From 16f6b7a5baec41f18fde75fd311fb988e3c31810 Mon Sep 17 00:00:00 2001
2From: Shengjiu Wang <shengjiu.wang@nxp.com>
3Date: Fri, 13 Jul 2018 18:13:24 +0800
4Subject: [PATCH] tinycompress: Add id3 decoding
5
6Upstream-Status: Pending
7Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
8---
9 include/tinycompress/id3_tag_decode.h | 198 +++++++++++
10 src/utils/Makefile.am | 2 +-
11 src/utils/cplay.c | 88 +++++
12 src/utils/id3_tag_decode.c | 642 ++++++++++++++++++++++++++++++++++
13 4 files changed, 929 insertions(+), 1 deletion(-)
14 create mode 100644 include/tinycompress/id3_tag_decode.h
15 create mode 100644 src/utils/id3_tag_decode.c
16
17diff --git a/include/tinycompress/id3_tag_decode.h b/include/tinycompress/id3_tag_decode.h
18new file mode 100644
19index 0000000..1a911d7
20--- /dev/null
21+++ b/include/tinycompress/id3_tag_decode.h
22@@ -0,0 +1,198 @@
23+/*
24+ * Copyright (c) 2006-2017 Cadence Design Systems, Inc.
25+ * Copyright 2018 NXP
26+ *
27+ * Permission is hereby granted, free of charge, to any person obtaining
28+ * a copy of this software and associated documentation files (the
29+ * "Software"), to deal in the Software without restriction, including
30+ * without limitation the rights to use, copy, modify, merge, publish,
31+ * distribute, sublicense, and/or sell copies of the Software, and to
32+ * permit persons to whom the Software is furnished to do so, subject to
33+ * the following conditions:
34+ *
35+ * The above copyright notice and this permission notice shall be included
36+ * in all copies or substantial portions of the Software.
37+ *
38+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
39+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
41+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
42+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
43+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45+ */
46+
47+/******************************************************************
48+ * file name : id3_tag_decode.h
49+ *
50+ * description : stores typedefs of structures specific to MP3 tag
51+ *
52+ * revision history:
53+ * 29 04 2004 DK creation
54+ *****************************************************************/
55+
56+#ifndef ID3_TAG_DECODE_H
57+#define ID3_TAG_DECODE_H
58+
59+typedef signed char WORD8;
60+typedef signed char * pWORD8;
61+typedef unsigned char UWORD8;
62+typedef unsigned char * pUWORD8;
63+
64+typedef signed short WORD16;
65+typedef signed short * pWORD16;
66+typedef unsigned short UWORD16;
67+typedef unsigned short * pUWORD16;
68+
69+typedef signed int WORD24;
70+typedef signed int * pWORD24;
71+typedef unsigned int UWORD24;
72+typedef unsigned int * pUWORD24;
73+
74+typedef signed int WORD32;
75+typedef signed int * pWORD32;
76+typedef unsigned int UWORD32;
77+typedef unsigned int * pUWORD32;
78+
79+typedef void VOID;
80+typedef void * pVOID;
81+
82+typedef signed int BOOL;
83+typedef unsigned int UBOOL;
84+typedef signed int FLAG;
85+typedef unsigned int UFLAG;
86+typedef signed int LOOPIDX;
87+typedef unsigned int ULOOPIDX;
88+typedef signed int WORD;
89+typedef unsigned int UWORD;
90+
91+#define MAX_TAG_FRAME_SIZE 100
92+
93+#define ID3V1 (0x544147) /* 0x544147 is TAG in WORD8 */
94+
95+#define ID3V2 (0x494433) /* 0x494433 is ID3 in WORD8 */
96+
97+/*
98+ * structure corresponding to ID3 tag v1 header.
99+ * this structure has all the field corresponding to ID3 tag v1 header.
100+ */
101+
102+typedef struct {
103+ WORD32 tag; // 3 bytes
104+
105+ WORD16 version; // 2 bytes
106+
107+ WORD8 flag; //1 byte
108+
109+ WORD32 size; //4 bytes
110+
111+} id3_v2_header_struct;
112+
113+/* structure which will store the frame data and
114+ * also put a limit max data to be stored
115+ */
116+typedef struct {
117+ WORD8 frame_data[MAX_TAG_FRAME_SIZE];
118+
119+ WORD32 max_size; //4 bytes
120+
121+ WORD16 tag_present;
122+
123+ WORD16 exceeds_buffer_size;
124+
125+} id3_v2_frame_struct;
126+
127+/*
128+ * structure corresponding to ID3 tag v2.
129+ * this structure has some of the field corresponding to ID3 tag v2.
130+ * if user wants to read some more tag information from
131+ * the MP3 file, he can add that field in this structure and pass address
132+ * of that element to get_inf function in id3_tag_decode.c under the
133+ * corresponding field frame header. few fields which are needed are already
134+ * populated by reading from the TAG header.
135+ */
136+typedef struct {
137+ id3_v2_frame_struct album_movie_show_title;
138+
139+ id3_v2_frame_struct composer_name;
140+
141+ id3_v2_frame_struct content_type;
142+
143+ id3_v2_frame_struct encoded_by;
144+
145+ id3_v2_frame_struct lyricist_text_writer;
146+
147+ id3_v2_frame_struct content_group_description;
148+
149+ id3_v2_frame_struct title_songname_content_description;
150+
151+ id3_v2_frame_struct medxa_type;
152+
153+ id3_v2_frame_struct original_album_movie_show_title;
154+
155+ id3_v2_frame_struct original_filename;
156+
157+ id3_v2_frame_struct original_lyricist_text_writer;
158+
159+ id3_v2_frame_struct original_artist_performer;
160+
161+ id3_v2_frame_struct file_owner_licensee;
162+
163+ id3_v2_frame_struct lead_performer_soloist;
164+
165+ id3_v2_frame_struct publisher;
166+
167+ id3_v2_frame_struct private_frame;
168+
169+ id3_v2_frame_struct other_info;
170+
171+ id3_v2_header_struct id3_v2_header;
172+
173+ WORD32 header_end;
174+
175+ WORD32 bytes_consumed;
176+
177+} id3v2_struct;
178+
179+/*
180+ * structure corresponding to ID3 tag v1.
181+ * this structure has all the field corresponding to ID3 tag v1.
182+ */
183+typedef struct {
184+ WORD8 song_title[30]; //30 word8acters
185+
186+ WORD8 artist[30]; //30 word8acters
187+
188+ WORD8 album[30]; //30 word8acters
189+
190+ WORD8 year[4]; //4 word8acters
191+
192+ WORD8 comment[30]; //30 word8acters
193+
194+ WORD8 genre[1]; //1 byte
195+
196+} id3v1_struct;
197+
198+WORD32 get_info(const char *inp_buffer,
199+ unsigned int avail_inp,
200+ WORD32 tag_size,
201+ id3_v2_frame_struct *dest);
202+
203+WORD32 search_id3_v2(UWORD8 *buffer);
204+
205+WORD32 decode_id3_v2(const char *const buffer,
206+ id3v2_struct *id3v2,
207+ WORD32 continue_flag,
208+ WORD32 insize);
209+
210+WORD32 get_id3_v2_bytes(UWORD8 *buffer);
211+
212+WORD32 get_v1_info(UWORD8 *buffer, id3v1_struct *id3v1);
213+
214+WORD32 search_id3_v1(UWORD8 *buffer);
215+
216+WORD32 decode_id3_v1(UWORD8 *buffer, id3v1_struct *id3v1);
217+
218+void init_id3v2_field(id3v2_struct *id3v2);
219+
220+#endif
221diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
222index 1b996d4..e813689 100644
223--- a/src/utils/Makefile.am
224+++ b/src/utils/Makefile.am
225@@ -1,6 +1,6 @@
226 bin_PROGRAMS = cplay crecord
227
228-cplay_SOURCES = cplay.c
229+cplay_SOURCES = cplay.c id3_tag_decode.c
230 crecord_SOURCES = crecord.c
231
232 cplay_CFLAGS = -I$(top_srcdir)/include
233diff --git a/src/utils/cplay.c b/src/utils/cplay.c
234index 87863a3..2a52b52 100644
235--- a/src/utils/cplay.c
236+++ b/src/utils/cplay.c
237@@ -72,6 +72,7 @@
238 #include "sound/compress_params.h"
239 #include "tinycompress/tinycompress.h"
240 #include "tinycompress/tinymp3.h"
241+#include "tinycompress/id3_tag_decode.h"
242
243 static int verbose;
244 static const unsigned int DEFAULT_CODEC_ID = SND_AUDIOCODEC_PCM;
245@@ -245,12 +246,97 @@ int main(int argc, char **argv)
246 exit(EXIT_SUCCESS);
247 }
248
249+void shift_buffer(char *buf, int buf_size, int bytes_consumed)
250+{
251+ int i;
252+
253+ if (bytes_consumed <= 0)
254+ return;
255+
256+ for (i = 0; i < buf_size - bytes_consumed; i++)
257+ buf[i] = buf[i + bytes_consumed];
258+}
259+
260+void parse_id3(FILE *file, int *offset) {
261+ /* ID3 tag specific declarations */
262+ unsigned char id3_buf[128];
263+ unsigned char id3v2_buf[4096];
264+ signed int id3_v1_found = 0, id3_v1_decoded = 0;
265+ signed int id3_v2_found = 0, id3_v2_complete = 0;
266+ signed int i_bytes_consumed = 0;
267+ signed int i_fread_bytes;
268+ id3v1_struct id3v1;
269+ id3v2_struct id3v2;
270+
271+ {
272+ fseek(file, -128, SEEK_END);
273+ fread(id3_buf, 1, 128, file);
274+
275+ /* search for ID3V1 */
276+ id3_v1_found = search_id3_v1(id3_buf + 0);
277+ if (id3_v1_found) {
278+ /* if ID3V1 is found, decode ID3V1 */
279+ decode_id3_v1(id3_buf + 3, &id3v1);
280+ id3_v1_decoded = 1;
281+ }
282+ fseek(file, 0, SEEK_SET);
283+ }
284+
285+ {
286+ signed int flag = 0;
287+ signed int continue_flag = 0;
288+
289+ i_fread_bytes = fread(id3v2_buf,
290+ sizeof(char), 0x1000, file);
291+
292+ /* search for ID3V2 */
293+ id3_v2_found =
294+ search_id3_v2(id3v2_buf);
295+
296+ if (id3_v2_found) {
297+ /* initialise the max fields */
298+ init_id3v2_field(&id3v2);
299+
300+ while (!id3_v2_complete && id3_v2_found) {
301+ /* if ID3V2 is found, decode ID3V2 */
302+ id3_v2_complete = decode_id3_v2((const char *const)id3v2_buf,
303+ &id3v2, continue_flag, i_fread_bytes);
304+
305+ if (!id3_v2_complete) {
306+ continue_flag = 1;
307+ i_bytes_consumed = id3v2.bytes_consumed;
308+
309+ fseek(file, i_bytes_consumed, SEEK_SET);
310+
311+ i_fread_bytes = fread(id3v2_buf,
312+ sizeof(unsigned char), 0x1000, file);
313+ if (i_fread_bytes <= 0) {
314+ return;
315+ }
316+ }
317+ }
318+
319+ if (id3_v2_complete) {
320+ i_bytes_consumed = id3v2.bytes_consumed;
321+ fseek(file, i_bytes_consumed, SEEK_SET);
322+ }
323+ }
324+ }
325+
326+ *offset = i_bytes_consumed;
327+}
328+
329 void get_codec_mp3(FILE *file, struct compr_config *config,
330 struct snd_codec *codec)
331 {
332 size_t read;
333 struct mp3_header header;
334 unsigned int channels, rate, bits;
335+ int offset = 0;
336+
337+ parse_id3(file, &offset);
338+
339+ fseek(file, offset, SEEK_SET);
340
341 read = fread(&header, 1, sizeof(header), file);
342 if (read != sizeof(header)) {
343@@ -279,6 +365,8 @@ void get_codec_mp3(FILE *file, struct compr_config *config,
344 codec->level = 0;
345 codec->ch_mode = 0;
346 codec->format = 0;
347+
348+ fseek(file, offset, SEEK_SET);
349 }
350
351 void get_codec_iec(FILE *file, struct compr_config *config,
352diff --git a/src/utils/id3_tag_decode.c b/src/utils/id3_tag_decode.c
353new file mode 100644
354index 0000000..393967a
355--- /dev/null
356+++ b/src/utils/id3_tag_decode.c
357@@ -0,0 +1,642 @@
358+/*
359+ * Copyright (c) 2006-2017 Cadence Design Systems, Inc.
360+ * Copyright 2018 NXP
361+ *
362+ * Permission is hereby granted, free of charge, to any person obtaining
363+ * a copy of this software and associated documentation files (the
364+ * "Software"), to deal in the Software without restriction, including
365+ * without limitation the rights to use, copy, modify, merge, publish,
366+ * distribute, sublicense, and/or sell copies of the Software, and to
367+ * permit persons to whom the Software is furnished to do so, subject to
368+ * the following conditions:
369+ *
370+ * The above copyright notice and this permission notice shall be included
371+ * in all copies or substantial portions of the Software.
372+ *
373+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
374+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
375+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
376+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
377+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
378+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
379+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
380+ */
381+#include <ctype.h>
382+#include "tinycompress/id3_tag_decode.h"
383+
384+#define CHAR4(c1, c2, c3, c4) \
385+ (int)(((unsigned char)(c1) << 24) | \
386+ ((unsigned char)(c2) << 16) | \
387+ ((unsigned char)(c3) << 8) | \
388+ ((unsigned char)c4))
389+
390+#ifndef MSVC_BUILD
391+unsigned int umin(unsigned int a, unsigned int b)
392+{
393+ return (a < b ? a : b);
394+}
395+
396+#else
397+unsigned int umin(unsigned int a, unsigned int b)
398+{
399+ return (a < b ? a : b);
400+}
401+#endif
402+
403+/***********************************************************
404+ * function name : display
405+ *
406+ * description : display ID3 tag contents.
407+ *
408+ * arguments : input parameters
409+ *
410+ * values returned : 0
411+ ***********************************************************/
412+
413+static void display2(const id3_v2_frame_struct * const src,
414+ int size,
415+ const char * const disp)
416+{
417+ int j;
418+
419+
420+ for (j = 0; j < size; j++) {
421+ int c = src->frame_data[j];
422+
423+ if (c) {
424+ if (!isprint(c))
425+ break;
426+ }
427+ }
428+}
429+
430+static VOID display1(WORD8 src[], WORD32 size, WORD8 disp[])
431+{
432+ WORD32 j;
433+
434+ for (j = 0; j < size ; j++) {
435+ int c = src[j];
436+
437+ if (c) {
438+ if (!isprint(c))
439+ break;
440+ }
441+ }
442+}
443+
444+/*****************************************************************
445+ * function name : init_id3_header
446+ *
447+ * description : initialise the max filed size of teh farem.
448+ *
449+ * arguments : input parameters
450+ *
451+ * values returned : 0
452+ ****************************************************************/
453+
454+VOID init_id3v2_field(id3v2_struct *id3v2)
455+{
456+ id3v2->album_movie_show_title.max_size = MAX_TAG_FRAME_SIZE;
457+ id3v2->composer_name.max_size = MAX_TAG_FRAME_SIZE;
458+ id3v2->content_type.max_size = MAX_TAG_FRAME_SIZE;
459+ id3v2->encoded_by.max_size = MAX_TAG_FRAME_SIZE;
460+ id3v2->lyricist_text_writer.max_size = MAX_TAG_FRAME_SIZE;
461+ id3v2->content_group_description.max_size = MAX_TAG_FRAME_SIZE;
462+ id3v2->title_songname_content_description.max_size = MAX_TAG_FRAME_SIZE;
463+ id3v2->medxa_type.max_size = MAX_TAG_FRAME_SIZE;
464+ id3v2->original_album_movie_show_title.max_size = MAX_TAG_FRAME_SIZE;
465+ id3v2->original_filename.max_size = MAX_TAG_FRAME_SIZE;
466+ id3v2->original_lyricist_text_writer.max_size = MAX_TAG_FRAME_SIZE;
467+ id3v2->original_artist_performer.max_size = MAX_TAG_FRAME_SIZE;
468+ id3v2->file_owner_licensee.max_size = MAX_TAG_FRAME_SIZE;
469+ id3v2->lead_performer_soloist.max_size = MAX_TAG_FRAME_SIZE;
470+ id3v2->publisher.max_size = MAX_TAG_FRAME_SIZE;
471+ id3v2->private_frame.max_size = MAX_TAG_FRAME_SIZE;
472+ id3v2->other_info.max_size = MAX_TAG_FRAME_SIZE;
473+
474+ /* resetting the flag to indicate presese of frame */
475+ id3v2->album_movie_show_title.tag_present = 0;
476+ id3v2->composer_name.tag_present = 0;
477+ id3v2->content_type.tag_present = 0;
478+ id3v2->encoded_by.tag_present = 0;
479+ id3v2->lyricist_text_writer.tag_present = 0;
480+ id3v2->content_group_description.tag_present = 0;
481+ id3v2->title_songname_content_description.tag_present = 0;
482+ id3v2->medxa_type.tag_present = 0;
483+ id3v2->original_album_movie_show_title.tag_present = 0;
484+ id3v2->original_filename.tag_present = 0;
485+ id3v2->original_lyricist_text_writer.tag_present = 0;
486+ id3v2->original_artist_performer.tag_present = 0;
487+ id3v2->file_owner_licensee.tag_present = 0;
488+ id3v2->lead_performer_soloist.tag_present = 0;
489+ id3v2->publisher.tag_present = 0;
490+ id3v2->private_frame.tag_present = 0;
491+ id3v2->other_info.tag_present = 0;
492+
493+ /* resetting the flag which indicates that size of the frame has
494+ * exceeded the max buffer size
495+ */
496+ id3v2->album_movie_show_title.exceeds_buffer_size = 0;
497+ id3v2->composer_name.exceeds_buffer_size = 0;
498+ id3v2->content_type.exceeds_buffer_size = 0;
499+ id3v2->encoded_by.exceeds_buffer_size = 0;
500+ id3v2->lyricist_text_writer.exceeds_buffer_size = 0;
501+ id3v2->content_group_description.exceeds_buffer_size = 0;
502+ id3v2->title_songname_content_description.exceeds_buffer_size = 0;
503+ id3v2->medxa_type.exceeds_buffer_size = 0;
504+ id3v2->original_album_movie_show_title.exceeds_buffer_size = 0;
505+ id3v2->original_filename.exceeds_buffer_size = 0;
506+ id3v2->original_lyricist_text_writer.exceeds_buffer_size = 0;
507+ id3v2->original_artist_performer.exceeds_buffer_size = 0;
508+ id3v2->file_owner_licensee.exceeds_buffer_size = 0;
509+ id3v2->lead_performer_soloist.exceeds_buffer_size = 0;
510+ id3v2->publisher.exceeds_buffer_size = 0;
511+ id3v2->private_frame.exceeds_buffer_size = 0;
512+ id3v2->other_info.exceeds_buffer_size = 0;
513+
514+ id3v2->bytes_consumed = 0;
515+ id3v2->header_end = 0;
516+}
517+
518+/***************************************************************
519+ * function name : search_id3_v2
520+ *
521+ * description : finds if ID3V2 starts at the start of given buffer.
522+ *
523+ * arguments : input parameters
524+ * buffer input buffer
525+ *
526+ * values returned : FLAG 1: ID3 found 0: ID3 not found
527+ ***************************************************************/
528+WORD32 search_id3_v2(UWORD8 *buffer)
529+{
530+ UWORD32 temp;
531+
532+ temp = buffer[0] << 16;
533+ temp |= buffer[1] << 8;
534+ temp |= buffer[2];
535+
536+ if (temp == ID3V2)
537+ return 1; /* ID3 found */
538+
539+ return 0; /* ID3 not found */
540+}
541+
542+/**************************************************************
543+ * function name : search_id3_v1
544+ *
545+ * description : finds if ID3V1 starts at the start of given buffer.
546+ *
547+ * arguments : input parameters
548+ * buffer input buffer
549+ *
550+ * values returned : FLAG 1: ID3 found 0: ID3 not found
551+ **************************************************************/
552+WORD32 search_id3_v1(UWORD8 *buffer)
553+{
554+ UWORD32 temp;
555+
556+ temp = buffer[0] << 16;
557+ temp |= buffer[1] << 8;
558+ temp |= buffer[2];
559+
560+ if (temp == ID3V1)
561+ return 1; /* ID3 found */
562+
563+ return 0; /* ID3 not found */
564+}
565+
566+/***************************************************************
567+ * function name : decode_id3_v1
568+ *
569+ * description : decodes ID3V1 tag.
570+ *
571+ * arguments : input parameters
572+ * buffer input buffer
573+ * id3v1 structure
574+ *
575+ * values returned : bytes consumed
576+ **************************************************************/
577+WORD32 decode_id3_v1(UWORD8 *buffer, id3v1_struct *id3v1)
578+{
579+ WORD32 bytes_consumed = 0;
580+ short tag_type;
581+
582+ /* setting the tag type */
583+ tag_type = 1;
584+
585+ bytes_consumed = get_v1_info(buffer, id3v1);
586+
587+ return bytes_consumed;
588+}
589+
590+/***********************************************************
591+ * function name : get_v1_info
592+ *
593+ * description : gets ID3V1 information fields.
594+ *
595+ * arguments : input parameters
596+ * buffer input buffer
597+ * id3v1 structure
598+ *
599+ * values returned : bytes consumed
600+ ***********************************************************/
601+WORD32 get_v1_info(UWORD8 *buffer, id3v1_struct *id3v1)
602+{
603+ WORD32 i;
604+ WORD32 bytes_consumed = 0;
605+
606+ /* get song_title */
607+ for (i = 0; i < 30; i++)
608+ id3v1->song_title[i] = buffer[i];
609+
610+ buffer += 30;
611+ bytes_consumed += 30;
612+ display1(id3v1->song_title, 30, (WORD8 *)"song_title : ");
613+
614+ /* get artist */
615+ for (i = 0; i < 30; i++)
616+ id3v1->artist[i] = buffer[i];
617+
618+ buffer += 30;
619+ bytes_consumed += 30;
620+ display1(id3v1->artist, 30, (WORD8 *)"artist : ");
621+
622+ /* get album */
623+ for (i = 0; i < 30; i++)
624+ id3v1->album[i] = buffer[i];
625+
626+ buffer += 30;
627+ bytes_consumed += 30;
628+ display1(id3v1->album, 30, (WORD8 *)"album : ");
629+
630+ /* get year */
631+ for (i = 0; i < 4; i++)
632+ id3v1->year[i] = buffer[i];
633+
634+ buffer += 4;
635+ bytes_consumed += 4;
636+ display1(id3v1->year, 4, (WORD8 *)"year : ");
637+
638+ /* get comment */
639+ for (i = 0; i < 30; i++)
640+ id3v1->comment[i] = buffer[i];
641+
642+ buffer += 30;
643+ bytes_consumed += 30;
644+ display1(id3v1->comment, 30, (WORD8 *)"comment : ");
645+
646+ /* get genre */
647+ for (i = 0; i < 1; i++)
648+ id3v1->genre[i] = buffer[i];
649+
650+ buffer += 1;
651+ bytes_consumed += 1;
652+
653+ return bytes_consumed;
654+}
655+
656+/*****************************************************
657+ * function name : decode_id3_v2
658+ *
659+ * description : decodes ID3V2 tag.
660+ *
661+ * arguments : input parameters
662+ * buffer input buffer
663+ * id3v2 structure
664+ * continue_flag FLAG to indicate whether
665+ * it is first call or not
666+ * insize input buffer size
667+ *
668+ * values returned : bytes consumed
669+ ******************************************************/
670+WORD32 decode_id3_v2(const char *const buffer,
671+ id3v2_struct *const id3v2,
672+ WORD32 continue_flag,
673+ WORD32 insize)
674+{
675+ UWORD32 size = 0, flag;
676+ WORD32 i, buf_update_val;
677+ UWORD8 buf[4], frame_header[10], id3_buffer[10];
678+ WORD8 *bitstream_ptr;
679+ short tag_type;
680+
681+ WORD32 bytes_consumed = 0;
682+
683+ if (id3v2->header_end == 1) {
684+ id3v2->bytes_consumed += insize;
685+ if (id3v2->bytes_consumed < id3v2->id3_v2_header.size)
686+ return 0;
687+
688+ id3v2->bytes_consumed = (id3v2->id3_v2_header.size + 10);
689+ return 1;
690+ }
691+
692+ bitstream_ptr = (WORD8 *)id3_buffer;
693+
694+ if (!continue_flag) {
695+ bytes_consumed += 3;
696+ /* setting the tag type */
697+ tag_type = 2;
698+ id3v2->id3_v2_header.version = buffer[bytes_consumed + 0] << 8;
699+ id3v2->id3_v2_header.version |= buffer[bytes_consumed + 1];
700+ id3v2->id3_v2_header.flag = buffer[bytes_consumed + 2];
701+
702+ /* making the msb of each byte zero */
703+ buf[0] = buffer[bytes_consumed + 6] & 0x7f;
704+ buf[1] = buffer[bytes_consumed + 5] & 0x7f;
705+ buf[2] = buffer[bytes_consumed + 4] & 0x7f;
706+ buf[3] = buffer[bytes_consumed + 3] & 0x7f;
707+
708+ bytes_consumed += 7;
709+
710+ /* concatenation the bytes after making
711+ * 7th bit zero to get 28 bits size
712+ */
713+ size = buf[0];
714+ size |= (buf[1] << 7);
715+ size |= (buf[2] << 14);
716+ size |= (buf[3] << 21);
717+ /* storing the size */
718+ id3v2->id3_v2_header.size = size;
719+
720+ /* check for extended header */
721+ if (id3v2->id3_v2_header.flag & 0x20) {
722+ for (i = 0; i < 10; i++)
723+ bitstream_ptr[i] = buffer[bytes_consumed + i];
724+
725+ i = 0;
726+ bytes_consumed += 10;
727+
728+ size = bitstream_ptr[i++] << 24;
729+ size |= bitstream_ptr[i++] << 16;
730+ size |= bitstream_ptr[i++] << 8;
731+ size |= bitstream_ptr[i++];
732+
733+ /* two bytes for flag */
734+ i += 2;
735+ {
736+ UWORD32 padding_size;
737+
738+ padding_size = bitstream_ptr[i++] << 24;
739+ padding_size |= bitstream_ptr[i++] << 16;
740+ padding_size |= bitstream_ptr[i++] << 8;
741+ padding_size |= bitstream_ptr[i++];
742+
743+ /* skipping the padding and frame size
744+ * number of bytes
745+ */
746+ bytes_consumed += (padding_size + size);
747+ }
748+ }
749+ }
750+
751+ while (id3v2->header_end != 1) {
752+ char *key;
753+ id3_v2_frame_struct *value;
754+ unsigned int avail_inp;
755+
756+ /* reading the 10 bytes to get the frame header */
757+
758+ for (i = 0; i < 10; i++)
759+ frame_header[i] = buffer[bytes_consumed + i];
760+ bytes_consumed += 10;
761+
762+ /* getting the size from the header */
763+ size = frame_header[4] << 24;
764+ size |= frame_header[5] << 16;
765+ size |= frame_header[6] << 8;
766+ size |= frame_header[7];
767+
768+ /* decoding the flag, currently not used */
769+ flag = frame_header[8] << 8;
770+ flag |= frame_header[9];
771+
772+ avail_inp = insize - bytes_consumed;
773+
774+ /* switching to the frame type */
775+ switch (CHAR4(frame_header[0],
776+ frame_header[1],
777+ frame_header[2],
778+ frame_header[3])) {
779+ case CHAR4('A', 'E', 'N', 'C'):
780+ case CHAR4('A', 'P', 'I', 'C'):
781+ case CHAR4('C', 'O', 'M', 'M'):
782+ case CHAR4('C', 'O', 'M', 'R'):
783+ case CHAR4('E', 'N', 'C', 'R'):
784+ case CHAR4('E', 'Q', 'U', 'A'):
785+ case CHAR4('E', 'T', 'C', 'O'):
786+ case CHAR4('G', 'E', 'O', 'B'):
787+ case CHAR4('G', 'R', 'I', 'D'):
788+ case CHAR4('I', 'P', 'L', 'S'):
789+ case CHAR4('L', 'I', 'N', 'K'):
790+ case CHAR4('M', 'C', 'D', 'I'):
791+ case CHAR4('M', 'L', 'L', 'T'):
792+ case CHAR4('O', 'W', 'N', 'E'):
793+ case CHAR4('P', 'C', 'N', 'T'):
794+ case CHAR4('P', 'O', 'P', 'M'):
795+ case CHAR4('P', 'O', 'S', 'S'):
796+ case CHAR4('R', 'B', 'U', 'F'):
797+ case CHAR4('R', 'V', 'A', 'D'):
798+ case CHAR4('R', 'V', 'R', 'B'):
799+ case CHAR4('S', 'Y', 'L', 'T'):
800+ case CHAR4('S', 'Y', 'T', 'C'):
801+ case CHAR4('T', 'B', 'P', 'M'):
802+ case CHAR4('T', 'C', 'O', 'P'):
803+ case CHAR4('T', 'D', 'A', 'T'):
804+ case CHAR4('T', 'D', 'L', 'Y'):
805+ case CHAR4('T', 'F', 'L', 'T'):
806+ case CHAR4('T', 'I', 'M', 'E'):
807+ case CHAR4('T', 'K', 'E', 'Y'):
808+ case CHAR4('T', 'L', 'A', 'N'):
809+ case CHAR4('T', 'L', 'E', 'N'):
810+ case CHAR4('T', 'M', 'E', 'D'):
811+ case CHAR4('T', 'O', 'F', 'N'):
812+ case CHAR4('T', 'O', 'L', 'Y'):
813+ case CHAR4('T', 'O', 'R', 'Y'):
814+ case CHAR4('T', 'P', 'E', '2'):
815+ case CHAR4('T', 'P', 'E', '3'):
816+ case CHAR4('T', 'P', 'E', '4'):
817+ case CHAR4('T', 'P', 'O', 'S'):
818+ case CHAR4('T', 'R', 'C', 'K'):
819+ case CHAR4('T', 'R', 'D', 'A'):
820+ case CHAR4('T', 'R', 'S', 'N'):
821+ case CHAR4('T', 'R', 'S', 'O'):
822+ case CHAR4('T', 'S', 'I', 'Z'):
823+ case CHAR4('T', 'S', 'R', 'C'):
824+ case CHAR4('T', 'S', 'S', 'E'):
825+ case CHAR4('T', 'Y', 'E', 'R'):
826+ case CHAR4('T', 'X', 'X', 'X'):
827+ case CHAR4('U', 'F', 'I', 'D'):
828+ case CHAR4('U', 'S', 'E', 'R'):
829+ case CHAR4('U', 'S', 'L', 'T'):
830+ case CHAR4('W', 'C', 'O', 'M'):
831+ case CHAR4('W', 'C', 'O', 'P'):
832+ case CHAR4('W', 'O', 'A', 'F'):
833+ case CHAR4('W', 'O', 'A', 'R'):
834+ case CHAR4('W', 'O', 'A', 'S'):
835+ case CHAR4('W', 'O', 'R', 'S'):
836+ case CHAR4('W', 'P', 'A', 'Y'):
837+ case CHAR4('W', 'P', 'U', 'B'):
838+ case CHAR4('W', 'X', 'X', 'X'):
839+ case CHAR4('T', 'I', 'T', '3'):
840+ key = "other_info : ";
841+ value = &id3v2->other_info;
842+ break;
843+ case CHAR4('P', 'R', 'I', 'V'):
844+ key = "private_frame : ";
845+ value = &id3v2->private_frame;
846+ break;
847+ case CHAR4('T', 'A', 'L', 'B'):
848+ key = "album_movie_show_title : ";
849+ value = &id3v2->album_movie_show_title;
850+ break;
851+ case CHAR4('T', 'C', 'O', 'M'):
852+ key = "composer_name : ";
853+ value = &id3v2->composer_name;
854+ break;
855+ case CHAR4('T', 'C', 'O', 'N'):
856+ key = "content_type : ";
857+ value = &id3v2->content_type;
858+ break;
859+ case CHAR4('T', 'E', 'N', 'C'):
860+ key = "encoded_by : ";
861+ value = &id3v2->encoded_by;
862+ break;
863+ case CHAR4('T', 'E', 'X', 'T'):
864+ key = "lyricist_text_writer : ";
865+ value = &id3v2->lyricist_text_writer;
866+ break;
867+ case CHAR4('T', 'I', 'T', '1'):
868+ key = "content_group_description : ";
869+ value = &id3v2->content_group_description;
870+ break;
871+ case CHAR4('T', 'I', 'T', '2'):
872+ key = "title_songname_content_description : ";
873+ value = &id3v2->title_songname_content_description;
874+ break;
875+ case CHAR4('T', 'O', 'A', 'L'):
876+ key = "original_album_movie_show_title : ";
877+ value = &id3v2->original_album_movie_show_title;
878+ break;
879+ case CHAR4('T', 'O', 'P', 'E'):
880+ key = "original_artist_performer : ";
881+ value = &id3v2->original_artist_performer;
882+ break;
883+ case CHAR4('T', 'O', 'W', 'N'):
884+ key = "file_owner_licensee : ";
885+ value = &id3v2->file_owner_licensee;
886+ break;
887+ case CHAR4('T', 'P', 'E', '1'):
888+ key = "lead_performer_soloist : ";
889+ value = &id3v2->lead_performer_soloist;
890+ break;
891+ case CHAR4('T', 'P', 'U', 'B'):
892+ key = "publisher : ";
893+ value = &id3v2->publisher;
894+ break;
895+ default:
896+ /* skipping the read 10 bytes */
897+ buf_update_val = -10;
898+ id3v2->header_end = 1;
899+ value = 0;
900+ key = 0;
901+ break;
902+ }
903+
904+ if (value != 0)
905+ buf_update_val = get_info(&buffer[bytes_consumed],
906+ avail_inp, size, value);
907+
908+ /* Negative value for buf_update_val means one of two things:
909+ * 1. The default case happened and we're done with ID3V2 tag
910+ * frames, or
911+ * 2. get_info() returned -1 to indicate that more input is
912+ * required to decode this frame of the tag.
913+ */
914+ if (buf_update_val >= 0)
915+ display2(value,
916+ umin(value->max_size, buf_update_val), key);
917+
918+ if (buf_update_val == -1) {
919+ id3v2->bytes_consumed += bytes_consumed;
920+ return 1;
921+ }
922+
923+ bytes_consumed += buf_update_val;
924+
925+ /* Is there enough input left (10 bytes) to begin
926+ * decoding another frame? If not, bag out temporarily
927+ * now. The caller will refill our input buffer and
928+ * call us again with continue_flag == 1.
929+ */
930+ if (insize - bytes_consumed < 10) {
931+ id3v2->bytes_consumed += bytes_consumed;
932+ return 0; /* not completely decoded */
933+ }
934+ }
935+
936+ id3v2->bytes_consumed += bytes_consumed;
937+ if ((id3v2->bytes_consumed + 10) < id3v2->id3_v2_header.size)
938+ return 0; /* not completely decoded */
939+
940+ return 1; /* completely decoded */
941+}
942+
943+/*******************************************************
944+ * function name : get_id3_v2_bytes
945+ *
946+ * description : tells the size of ID3V2 tag.
947+ *
948+ * arguments : input parameters
949+ * buffer input buffer
950+ *
951+ * values returned : bytes consumed
952+ ********************************************************/
953+WORD32 get_id3_v2_bytes(UWORD8 *buffer)
954+{
955+ WORD32 size;
956+
957+ /* making the msb of each byte zero */
958+ size = (buffer[9] & 0x7f);
959+ size |= ((buffer[8] & 0x7f) << 7);
960+ size |= ((buffer[7] & 0x7f) << 14);
961+ size |= ((buffer[6] & 0x7f) << 21);
962+
963+ return (size + 10);
964+}
965+
966+/****************************************************
967+ * function name : get_info
968+ *
969+ * description : read the frame information from the input buffer.
970+ *
971+ * arguments : input parameters
972+ *
973+ * values returned : update value for buffer
974+ ****************************************************/
975+WORD32 get_info(const char *inp_buffer,
976+ unsigned int avail_inp,
977+ WORD32 tag_size,
978+ id3_v2_frame_struct *dest)
979+{
980+ WORD32 j;
981+
982+ /* setting the tag to indicate the presence of frame */
983+ dest->tag_present = 1;
984+ /* If there isn't enough input available, we punt back to the top
985+ * level and ask for more.
986+ */
987+ if (avail_inp < umin(tag_size, dest->max_size))
988+ return -1;
989+
990+ if (dest->max_size >= tag_size) {
991+ for (j = 0; j < tag_size ; j++)
992+ dest->frame_data[j] = inp_buffer[j];
993+ } else {
994+ dest->exceeds_buffer_size = 1;
995+ for (j = 0; j < dest->max_size ; j++)
996+ dest->frame_data[j] = inp_buffer[j];
997+ }
998+ return tag_size;
999+}
1000--
10012.7.4
1002
diff --git a/recipes-multimedia/tinycompress/tinycompress/0002-cplay-Support-wave-file.patch b/recipes-multimedia/tinycompress/tinycompress/0002-cplay-Support-wave-file.patch
deleted file mode 100755
index 79544711..00000000
--- a/recipes-multimedia/tinycompress/tinycompress/0002-cplay-Support-wave-file.patch
+++ /dev/null
@@ -1,215 +0,0 @@
1From 4d4bc0a958fe254531920095fbabc241aad88113 Mon Sep 17 00:00:00 2001
2From: Shengjiu Wang <shengjiu.wang@nxp.com>
3Date: Tue, 28 Jul 2020 13:00:36 +0800
4Subject: [PATCH] cplay: Support wave file
5
6The supported format is mono/stereo, S16_LE/S32_LE, 8kHz-192kHz.
7Command is:
8cplay -c x -I PCM test.wav
9
10Upstream-Status: Inappropriate [i.MX specific]
11Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
12---
13 include/tinycompress/wave_formats.h | 51 +++++++++++++
14 src/utils/cplay.c | 107 ++++++++++++++++++++++++++++
15 2 files changed, 158 insertions(+)
16 create mode 100644 include/tinycompress/wave_formats.h
17
18--- /dev/null
19+++ b/include/tinycompress/wave_formats.h
20@@ -0,0 +1,53 @@
21+#ifndef WAVE_FORMATS_H
22+#define WAVE_FORMATS_H 1
23+
24+#include <sys/types.h>
25+
26+#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
27+
28+#define WAV_RIFF COMPOSE_ID('R','I','F','F')
29+#define WAV_RIFX COMPOSE_ID('R','I','F','X')
30+#define WAV_WAVE COMPOSE_ID('W','A','V','E')
31+#define WAV_FMT COMPOSE_ID('f','m','t',' ')
32+#define WAV_DATA COMPOSE_ID('d','a','t','a')
33+
34+/* WAVE fmt block constants from Microsoft mmreg.h header */
35+#define WAV_FMT_PCM 0x0001
36+#define WAV_FMT_IEEE_FLOAT 0x0003
37+#define WAV_FMT_DOLBY_AC3_SPDIF 0x0092
38+#define WAV_FMT_EXTENSIBLE 0xfffe
39+
40+/* Used with WAV_FMT_EXTENSIBLE format */
41+#define WAV_GUID_TAG "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
42+
43+typedef struct {
44+ u_int magic; /* 'RIFF' */
45+ u_int length; /* filelen */
46+ u_int type; /* 'WAVE' */
47+} WaveHeader;
48+
49+typedef struct {
50+ u_short format; /* see WAV_FMT_* */
51+ u_short channels;
52+ u_int sample_fq; /* frequence of sample */
53+ u_int byte_p_sec;
54+ u_short byte_p_spl; /* samplesize; 1 or 2 bytes */
55+ u_short bit_p_spl; /* 8, 12 or 16 bit */
56+} WaveFmtBody;
57+
58+typedef struct {
59+ WaveFmtBody format;
60+ u_short ext_size;
61+ u_short bit_p_spl;
62+ u_int channel_mask;
63+ u_short guid_format; /* WAV_FMT_* */
64+ u_char guid_tag[14]; /* WAV_GUID_TAG */
65+} WaveFmtExtensibleBody;
66+
67+typedef struct {
68+ u_int type; /* 'data' */
69+ u_int length; /* samplecount */
70+} WaveChunkHeader;
71+
72+
73+#endif /* FORMATS */
74--- a/src/utils/cplay.c
75+++ b/src/utils/cplay.c
76@@ -1,4 +1,6 @@
77 /*
78+ * Copyright 2020 NXP
79+ *
80 * This file is provided under a dual BSD/LGPLv2.1 license. When using or
81 * redistributing this file, you may do so under either license.
82 *
83@@ -73,6 +75,8 @@
84 #include "tinycompress/tinycompress.h"
85 #include "tinycompress/tinymp3.h"
86 #include "tinycompress/id3_tag_decode.h"
87+#include "tinycompress/wave_formats.h"
88+#include <alsa/asoundlib.h>
89
90 static int verbose;
91 static const unsigned int DEFAULT_CODEC_ID = SND_AUDIOCODEC_PCM;
92@@ -166,6 +170,77 @@ static int parse_mp3_header(struct mp3_h
93 return 0;
94 }
95
96+static int parse_wav_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate,
97+ unsigned int *format) {
98+ WaveHeader wave_header;
99+ WaveChunkHeader chunk_header;
100+ WaveFmtBody fmt_body;
101+ int more_chunks = 1;
102+
103+ fread(&wave_header, sizeof(WaveHeader), 1, file);
104+ if ((wave_header.magic != WAV_RIFF) ||
105+ (wave_header.type != WAV_WAVE)) {
106+ fprintf(stderr, "Error: it is not a riff/wave file\n");
107+ return -1;
108+ }
109+
110+ do {
111+ fread(&chunk_header, sizeof(WaveChunkHeader), 1, file);
112+ switch (chunk_header.type) {
113+ case WAV_FMT:
114+ fread(&fmt_body, sizeof(WaveFmtBody), 1, file);
115+ /* If the format header is larger, skip the rest */
116+ if (chunk_header.length > sizeof(WaveFmtBody))
117+ fseek(file, chunk_header.length - sizeof(WaveFmtBody), SEEK_CUR);
118+
119+ *num_channels = fmt_body.channels;
120+ *sample_rate = fmt_body.sample_fq;
121+
122+ switch (fmt_body.bit_p_spl) {
123+ case 8:
124+ *format = SND_PCM_FORMAT_U8;
125+ break;
126+ case 16:
127+ *format = SND_PCM_FORMAT_S16_LE;
128+ break;
129+ case 24:
130+ switch (fmt_body.byte_p_spl / fmt_body.channels) {
131+ case 3:
132+ *format = SND_PCM_FORMAT_S24_3LE;
133+ break;
134+ case 4:
135+ *format = SND_PCM_FORMAT_S24_LE;
136+ break;
137+ default:
138+ fprintf(stderr, "format error\n");
139+ return -1;
140+ }
141+ break;
142+ case 32:
143+ if (fmt_body.format == WAV_FMT_PCM) {
144+ *format = SND_PCM_FORMAT_S32_LE;
145+ } else if (fmt_body.format == WAV_FMT_IEEE_FLOAT) {
146+ *format = SND_PCM_FORMAT_FLOAT_LE;
147+ }
148+ break;
149+ default:
150+ fprintf(stderr, "format error\n");
151+ return -1;
152+ }
153+ break;
154+ case WAV_DATA:
155+ /* Stop looking for chunks */
156+ more_chunks = 0;
157+ break;
158+ default:
159+ /* Unknown chunk, skip bytes */
160+ fseek(file, chunk_header.length, SEEK_CUR);
161+ }
162+ } while (more_chunks);
163+
164+ return 0;
165+}
166+
167 static int print_time(struct compress *compress)
168 {
169 unsigned int avail;
170@@ -385,6 +460,35 @@ void get_codec_iec(FILE *file, struct co
171 codec->format = 0;
172 }
173
174+void get_codec_pcm(FILE *file, struct compr_config *config,
175+ struct snd_codec *codec)
176+{
177+ unsigned int channels, rate, format;
178+
179+ if (parse_wav_header(file, &channels, &rate, &format) == -1) {
180+ fclose(file);
181+ exit(EXIT_FAILURE);
182+ }
183+
184+ if (channels > 2 || (format != SND_PCM_FORMAT_S16_LE && format != SND_PCM_FORMAT_S32_LE) ||
185+ rate > 192000) {
186+ fprintf(stderr, "unsupported wave file\n");
187+ fclose(file);
188+ exit(EXIT_FAILURE);
189+ }
190+
191+ codec->id = SND_AUDIOCODEC_PCM;
192+ codec->ch_in = channels;
193+ codec->ch_out = channels;
194+ codec->sample_rate = rate;
195+ codec->bit_rate = 0;
196+ codec->rate_control = 0;
197+ codec->profile = SND_AUDIOPROFILE_PCM;
198+ codec->level = 0;
199+ codec->ch_mode = 0;
200+ codec->format = format;
201+}
202+
203 void play_samples(char *name, unsigned int card, unsigned int device,
204 unsigned long buffer_size, unsigned int frag,
205 unsigned long codec_id)
206@@ -411,6 +515,9 @@ void play_samples(char *name, unsigned i
207 case SND_AUDIOCODEC_IEC61937:
208 get_codec_iec(file, &config, &codec);
209 break;
210+ case SND_AUDIOCODEC_PCM:
211+ get_codec_pcm(file, &config, &codec);
212+ break;
213 default:
214 fprintf(stderr, "codec ID %ld is not supported\n", codec_id);
215 exit(EXIT_FAILURE);
diff --git a/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch b/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch
deleted file mode 100755
index 7d8492b7..00000000
--- a/recipes-multimedia/tinycompress/tinycompress/0003-cplay-Add-pause-feature.patch
+++ /dev/null
@@ -1,146 +0,0 @@
1From 6f778c21ee357a662cdd758cff578a3e4b85eedf Mon Sep 17 00:00:00 2001
2From: Zhang Peng <peng.zhang_8@nxp.com>
3Date: Tue, 4 Aug 2020 15:29:29 +0800
4Subject: [PATCH] cplay: Add pause feature
5
6Add option: -p pause
7
8Upstream-Status: Inappropriate [i.MX specific]
9Signed-off-by: Zhang Peng <peng.zhang_8@nxp.com>
10---
11 src/utils/cplay.c | 56 +++++++++++++++++++++++++++++++++++++++++++----
12 1 file changed, 52 insertions(+), 4 deletions(-)
13
14diff --git a/src/utils/cplay.c b/src/utils/cplay.c
15index 8882f4d..8e3dcbb 100644
16--- a/src/utils/cplay.c
17+++ b/src/utils/cplay.c
18@@ -117,6 +117,9 @@ static void usage(void)
19 "-f\tfragments\n\n"
20 "-v\tverbose mode\n"
21 "-h\tPrints this help list\n\n"
22+ "-p\tpause\n"
23+ "-m\tpause blocks\n"
24+ "-n\tpause time duration\n"
25 "Example:\n"
26 "\tcplay -c 1 -d 2 test.mp3\n"
27 "\tcplay -f 5 test.mp3\n\n"
28@@ -133,7 +136,8 @@ static void usage(void)
29
30 void play_samples(char *name, unsigned int card, unsigned int device,
31 unsigned long buffer_size, unsigned int frag,
32- unsigned long codec_id);
33+ unsigned long codec_id, int pause_count, int pause_block,
34+ int pause_duration);
35
36 struct mp3_header {
37 uint16_t sync;
38@@ -262,12 +266,15 @@ int main(int argc, char **argv)
39 int c, i;
40 unsigned int card = 0, device = 0, frag = 0;
41 unsigned int codec_id = SND_AUDIOCODEC_MP3;
42+ int pause_count = 0;
43+ int pause_block = 6;
44+ int pause_duration = 10;
45
46 if (argc < 2)
47 usage();
48
49 verbose = 0;
50- while ((c = getopt(argc, argv, "hvb:f:c:d:I:")) != -1) {
51+ while ((c = getopt(argc, argv, "hvb:f:c:d:I:p:m:n:")) != -1) {
52 switch (c) {
53 case 'h':
54 usage();
55@@ -306,6 +313,23 @@ int main(int argc, char **argv)
56 case 'v':
57 verbose = 1;
58 break;
59+ case 'p':
60+ pause_count = strtol(optarg, NULL, 10);
61+ break;
62+ case 'm':
63+ pause_block = strtol(optarg, NULL, 10);
64+ if (pause_duration < 0) {
65+ printf("Set wrong paramter! Set duration default 6.\n");
66+ pause_duration = 6;
67+ }
68+ break;
69+ case 'n':
70+ pause_duration = strtol(optarg, NULL, 10);
71+ if (pause_duration < 0) {
72+ printf("Set wrong paramter! Set duration default 10.\n");
73+ pause_duration = 10;
74+ }
75+ break;
76 default:
77 exit(EXIT_FAILURE);
78 }
79@@ -315,7 +339,7 @@ int main(int argc, char **argv)
80
81 file = argv[optind];
82
83- play_samples(file, card, device, buffer_size, frag, codec_id);
84+ play_samples(file, card, device, buffer_size, frag, codec_id, pause_count, pause_block, pause_duration);
85
86 fprintf(stderr, "Finish Playing.... Close Normally\n");
87 exit(EXIT_SUCCESS);
88@@ -491,7 +515,8 @@ void get_codec_pcm(FILE *file, struct compr_config *config,
89
90 void play_samples(char *name, unsigned int card, unsigned int device,
91 unsigned long buffer_size, unsigned int frag,
92- unsigned long codec_id)
93+ unsigned long codec_id, int pause_count, int pause_block,
94+ int pause_duration)
95 {
96 struct compr_config config;
97 struct snd_codec codec;
98@@ -499,6 +524,7 @@ void play_samples(char *name, unsigned int card, unsigned int device,
99 FILE *file;
100 char *buffer;
101 int size, num_read, wrote;
102+ int write_count = 0;
103
104 if (verbose)
105 printf("%s: entry\n", __func__);
106@@ -574,6 +600,13 @@ void play_samples(char *name, unsigned int card, unsigned int device,
107 if (verbose)
108 printf("%s: You should hear audio NOW!!!\n", __func__);
109
110+ if (pause_count > 0) {
111+ printf("sleep...\n");
112+ compress_pause(compress);
113+ sleep(pause_duration);
114+ compress_resume(compress);
115+ }
116+
117 do {
118 num_read = fread(buffer, 1, size, file);
119 if (num_read > 0) {
120@@ -592,8 +625,23 @@ void play_samples(char *name, unsigned int card, unsigned int device,
121 printf("%s: wrote %d\n", __func__, wrote);
122 }
123 }
124+ write_count++;
125+ if ((pause_count > 0) && (write_count % pause_block == 0)) {
126+ printf("pause...\n");
127+ compress_pause(compress);
128+ sleep(pause_duration);
129+ printf("pause release...\n");
130+ compress_resume(compress);
131+ pause_count--;
132+ }
133 } while (num_read > 0);
134
135+ if (pause_count > 0) {
136+ compress_pause(compress);
137+ sleep(5);
138+ compress_resume(compress);
139+ }
140+
141 if (verbose)
142 printf("%s: exit success\n", __func__);
143 /* issue drain if it supports */
144--
1452.17.1
146
diff --git a/recipes-multimedia/tinycompress/tinycompress/0004-tinycompress-pass-NULL-buffer-with-0-size-to-driver.patch b/recipes-multimedia/tinycompress/tinycompress/0004-tinycompress-pass-NULL-buffer-with-0-size-to-driver.patch
deleted file mode 100755
index dfedd186..00000000
--- a/recipes-multimedia/tinycompress/tinycompress/0004-tinycompress-pass-NULL-buffer-with-0-size-to-driver.patch
+++ /dev/null
@@ -1,40 +0,0 @@
1From a2892bf5db7520689fa9cb1d1589fa804bd9dc1a Mon Sep 17 00:00:00 2001
2From: Bing Song <bing.song@nxp.com>
3Date: Tue, 18 Aug 2020 15:26:51 +0800
4Subject: [PATCH] tinycompress: pass NULL buffer with 0 size to driver.
5
6The NULL buffer with 0 size to indecate driver drain input data with
7non-block mode. The defaul drain is block mode.
8
9Upstream-Status: Inappropriate [i.MX specific]
10Signed-off-by: Bing Song <bing.song@nxp.com>
11---
12 src/lib/compress.c | 5 +++--
13 1 file changed, 3 insertions(+), 2 deletions(-)
14
15diff --git a/src/lib/compress.c b/src/lib/compress.c
16index bba4fcf..d66df0b 100644
17--- a/src/lib/compress.c
18+++ b/src/lib/compress.c
19@@ -315,7 +315,8 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
20 fds.events = POLLOUT;
21
22 /*TODO: treat auto start here first */
23- while (size) {
24+ /* NULL buffer with 0 size for non-block drain */
25+ do {
26 if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &avail))
27 return oops(compress, errno, "cannot get avail");
28
29@@ -357,7 +358,7 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
30 size -= written;
31 cbuf += written;
32 total += written;
33- }
34+ } while (size);
35 return total;
36 }
37
38--
392.17.1
40
diff --git a/recipes-multimedia/tinycompress/tinycompress/0005-cplay-Support-aac-streams.patch b/recipes-multimedia/tinycompress/tinycompress/0005-cplay-Support-aac-streams.patch
deleted file mode 100755
index 2f36551a..00000000
--- a/recipes-multimedia/tinycompress/tinycompress/0005-cplay-Support-aac-streams.patch
+++ /dev/null
@@ -1,251 +0,0 @@
1From 2912f8573cea25fbd38ac7a8b68af2ea6a05e599 Mon Sep 17 00:00:00 2001
2From: Zhang Peng <peng.zhang_8@nxp.com>
3Date: Wed, 28 Oct 2020 19:08:53 +0800
4Subject: [PATCH] cplay: Support aac streams
5
6Support run aac format streams for cplay.
7
8Upstream-Status: Inappropriate [i.MX specific]
9Signed-off-by: Zhang Peng <peng.zhang_8@nxp.com>
10---
11 src/utils/cplay.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++
12 1 file changed, 210 insertions(+)
13
14diff --git a/src/utils/cplay.c b/src/utils/cplay.c
15index 8e3dcbb..2a1464a 100644
16--- a/src/utils/cplay.c
17+++ b/src/utils/cplay.c
18@@ -245,6 +245,190 @@ static int parse_wav_header(FILE *file, unsigned int *num_channels, unsigned int
19 return 0;
20 }
21
22+int find_adts_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate, unsigned int *format)
23+{
24+ int ret;
25+ unsigned char buf[5];
26+
27+ ret = fread(buf, sizeof(buf), 1, file);
28+ if (ret < 0) {
29+ fprintf(stderr, "open file error: %d\n", ret);
30+ return 0;
31+ }
32+ fseek(file, 0, SEEK_SET);
33+
34+ if ((buf[0] != 0xff) || (buf[1] & 0xf0 != 0xf0))
35+ return 0;
36+ /* mpeg id */
37+ switch (buf[1]>>3 & 0x1) {
38+ case 0x0:
39+ *format = SND_AUDIOSTREAMFORMAT_MP4ADTS;
40+ break;
41+ case 0x1:
42+ *format = SND_AUDIOSTREAMFORMAT_MP2ADTS;
43+ break;
44+ default:
45+ fprintf(stderr, "can't find stream format\n");
46+ break;
47+ }
48+ /* sample_rate */
49+ switch (buf[2]>>2 & 0xf) {
50+ case 0x0:
51+ *sample_rate = 96000;
52+ break;
53+ case 0x1:
54+ *sample_rate = 88200;
55+ break;
56+ case 0x2:
57+ *sample_rate = 64000;
58+ break;
59+ case 0x3:
60+ *sample_rate = 48000;
61+ break;
62+ case 0x4:
63+ *sample_rate = 44100;
64+ break;
65+ case 0x5:
66+ *sample_rate = 32000;
67+ break;
68+ case 0x6:
69+ *sample_rate = 24000;
70+ break;
71+ case 0x7:
72+ *sample_rate = 22050;
73+ break;
74+ case 0x8:
75+ *sample_rate = 16000;
76+ break;
77+ case 0x9:
78+ *sample_rate = 12000;
79+ break;
80+ case 0xa:
81+ *sample_rate = 11025;
82+ break;
83+ case 0xb:
84+ *sample_rate = 8000;
85+ break;
86+ case 0xc:
87+ *sample_rate = 7350;
88+ break;
89+ default:
90+ break;
91+ }
92+ /* channel */
93+ switch (((buf[2]&0x1) << 2) | (buf[3]>>6)) {
94+ case 1:
95+ *num_channels = 1;
96+ break;
97+ case 2:
98+ *num_channels = 2;
99+ break;
100+ case 3:
101+ *num_channels = 3;
102+ break;
103+ case 4:
104+ *num_channels = 4;
105+ break;
106+ case 5:
107+ *num_channels = 5;
108+ break;
109+ case 6:
110+ *num_channels = 6;
111+ break;
112+ case 7:
113+ *num_channels = 7;
114+ break;
115+ default:
116+ break;
117+ }
118+ return 1;
119+}
120+
121+static const int aac_sample_rates[] = { 96000, 88200, 64000, 48000, 44100,
122+ 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350
123+};
124+
125+#define MAX_SR_NUM sizeof(aac_sample_rates)/sizeof(aac_sample_rates[0])
126+
127+static int get_sample_rate_from_index(int sr_index)
128+{
129+ if (sr_index >= 0 && sr_index < MAX_SR_NUM)
130+ return aac_sample_rates[sr_index];
131+
132+ return 0;
133+}
134+
135+int find_adif_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate, unsigned int *format)
136+{
137+ int ret;
138+ unsigned char adif_id[4];
139+ unsigned char adif_header[20];
140+ int bitstream_type;
141+ int bitrate;
142+ int object_type;
143+ int sr_index;
144+ int skip_size = 0;
145+
146+ ret = fread(adif_id, sizeof(unsigned char), 4, file);
147+ if (ret < 0) {
148+ fprintf(stderr, "read data from file err: %d\n", ret);
149+ return 0;
150+ }
151+ /* adif id */
152+ if ((adif_id[0] != 0x41) || (adif_id[1] != 0x44) ||
153+ (adif_id[2] != 0x49) || (adif_id[3] != 0x46))
154+ return 0;
155+
156+ fread(adif_header, sizeof(unsigned char), 20, file);
157+
158+ /* copyright string */
159+ if (adif_header[0] & 0x80)
160+ skip_size = 9;
161+
162+ bitstream_type = adif_header[0 + skip_size] & 0x10;
163+ bitrate =
164+ ((unsigned int) (adif_header[0 + skip_size] & 0x0f) << 19) |
165+ ((unsigned int) adif_header[1 + skip_size] << 11) |
166+ ((unsigned int) adif_header[2 + skip_size] << 3) |
167+ ((unsigned int) adif_header[3 + skip_size] & 0xe0);
168+
169+ if (bitstream_type == 0) {
170+ object_type = ((adif_header[6 + skip_size] & 0x01) << 1) |
171+ ((adif_header[7 + skip_size] & 0x80) >> 7);
172+ sr_index = (adif_header[7 + skip_size] & 0x78) >> 3;
173+ }
174+ /* VBR */
175+ else {
176+ object_type = (adif_header[4 + skip_size] & 0x18) >> 3;
177+ sr_index = ((adif_header[4 + skip_size] & 0x07) << 1) |
178+ ((adif_header[5 + skip_size] & 0x80) >> 7);
179+ }
180+
181+ /* sample rate */
182+ *sample_rate = get_sample_rate_from_index(sr_index);
183+
184+ /* FIXME: assume channels is 2 */
185+ *num_channels = 2;
186+
187+ *format = SND_AUDIOSTREAMFORMAT_ADIF;
188+ fseek(file, 0, SEEK_SET);
189+ return 1;
190+}
191+
192+static int parse_aac_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate, unsigned int *format)
193+{
194+ if (find_adts_header(file, num_channels, sample_rate, format))
195+ return 1;
196+ else if (find_adif_header(file, num_channels, sample_rate, format))
197+ return 1;
198+ else {
199+ fprintf(stderr, "can't find streams format\n");
200+ return 0;
201+ }
202+
203+ return 1;
204+}
205+
206 static int print_time(struct compress *compress)
207 {
208 unsigned int avail;
209@@ -513,6 +697,29 @@ void get_codec_pcm(FILE *file, struct compr_config *config,
210 codec->format = format;
211 }
212
213+void get_codec_aac(FILE *file, struct compr_config *config,
214+ struct snd_codec *codec)
215+{
216+ unsigned int channels, rate, format;
217+
218+ if (parse_aac_header(file, &channels, &rate, &format) == 0) {
219+ fclose(file);
220+ exit(EXIT_FAILURE);
221+ };
222+ fseek(file, 0, SEEK_SET);
223+
224+ codec->id = SND_AUDIOCODEC_AAC;
225+ codec->ch_in = channels;
226+ codec->ch_out = channels;
227+ codec->sample_rate = rate;
228+ codec->bit_rate = 0;
229+ codec->rate_control = 0;
230+ codec->profile = SND_AUDIOPROFILE_AAC;
231+ codec->level = 0;
232+ codec->ch_mode = 0;
233+ codec->format = format;
234+
235+}
236 void play_samples(char *name, unsigned int card, unsigned int device,
237 unsigned long buffer_size, unsigned int frag,
238 unsigned long codec_id, int pause_count, int pause_block,
239@@ -544,6 +751,9 @@ void play_samples(char *name, unsigned int card, unsigned int device,
240 case SND_AUDIOCODEC_PCM:
241 get_codec_pcm(file, &config, &codec);
242 break;
243+ case SND_AUDIOCODEC_AAC:
244+ get_codec_aac(file, &config, &codec);
245+ break;
246 default:
247 fprintf(stderr, "codec ID %ld is not supported\n", codec_id);
248 exit(EXIT_FAILURE);
249--
2502.17.1
251
diff --git a/recipes-multimedia/tinycompress/tinycompress_1.1.6.bb b/recipes-multimedia/tinycompress/tinycompress_1.1.6.bb
deleted file mode 100644
index 5cad5ba6..00000000
--- a/recipes-multimedia/tinycompress/tinycompress_1.1.6.bb
+++ /dev/null
@@ -1,16 +0,0 @@
1DESCRIPTION = "A library to handle compressed formats like MP3 etc."
2LICENSE = "LGPL-2.1-only | BSD-3-Clause"
3LIC_FILES_CHKSUM = "file://COPYING;md5=cf9105c1a2d4405cbe04bbe3367373a0"
4DEPENDS = "alsa-lib"
5
6SRC_URI = "git://git.alsa-project.org/http/tinycompress.git;protocol=https;branch=master \
7 file://0001-tinycompress-Add-id3-decoding.patch \
8 file://0002-cplay-Support-wave-file.patch \
9 file://0003-cplay-Add-pause-feature.patch \
10 file://0004-tinycompress-pass-NULL-buffer-with-0-size-to-driver.patch \
11 file://0005-cplay-Support-aac-streams.patch \
12"
13SRCREV = "995f2ed91045dad8c20485ab1a64727d22cd92e5"
14S = "${WORKDIR}/git"
15
16inherit autotools pkgconfig
diff --git a/recipes-multimedia/tinycompress/tinycompress_1.2.5.bb b/recipes-multimedia/tinycompress/tinycompress_1.2.5.bb
new file mode 100644
index 00000000..f37e786b
--- /dev/null
+++ b/recipes-multimedia/tinycompress/tinycompress_1.2.5.bb
@@ -0,0 +1,18 @@
1DESCRIPTION = "A library to handle compressed formats like MP3 etc."
2LICENSE = "LGPL-2.1-only | BSD-3-Clause"
3LIC_FILES_CHKSUM = "file://COPYING;md5=cf9105c1a2d4405cbe04bbe3367373a0"
4DEPENDS = "alsa-lib"
5
6inherit autotools pkgconfig
7
8PV .= "+git"
9
10SRC_URI = "git://github.com/alsa-project/tinycompress.git;protocol=https;branch=master \
11"
12SRCREV = "f3ba6e5c2126f2fb07e3d890f990d50c3e204e67"
13
14EXTRA_OECONF:append = " --enable-pcm"
15
16S = "${WORKDIR}/git"
17
18inherit autotools pkgconfig