Commit a21369fa authored by Philipp Schafft's avatar Philipp Schafft 🦁
Browse files

Feature: Decode METADATA_BLOCK_PICTURE in vorbis comment blocks

parent 775ca1a2
......@@ -27,8 +27,10 @@ man_MANS = $(mans)
AM_CPPFLAGS = @SHARE_CFLAGS@ @OGG_CFLAGS@ @VORBIS_CFLAGS@ @KATE_CFLAGS@ @I18N_CFLAGS@
ogginfo_LDADD = @SHARE_LIBS@ @VORBIS_LIBS@ @KATE_LIBS@ @OGG_LIBS@ @LIBICONV@ @I18N_LIBS@
ogginfo_DEPENDENCIES = @SHARE_LIBS@
ogginfo_LDADD = @SHARE_LIBS@ @VORBIS_LIBS@ @KATE_LIBS@ @OGG_LIBS@ @LIBICONV@ @I18N_LIBS@ \
$(top_builddir)/share/libpicture.a $(top_builddir)/share/libbase64.a
ogginfo_DEPENDENCIES = @SHARE_LIBS@ \
$(top_builddir)/share/libpicture.a $(top_builddir)/share/libbase64.a
ogginfo_SOURCES = $(ogginfosources)
EXTRA_ogginfo_SOURCES = $(man_MANS)
......
......@@ -16,6 +16,7 @@
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <getopt.h>
#include <math.h>
#include <inttypes.h>
......@@ -334,11 +335,58 @@ void check_xiph_comment(stream_processor *stream, int i, const char *comment, in
*sep = 0;
if (!broken) {
info("\t%s=%s\n", comment, decoded);
if (strcasecmp(comment, "METADATA_BLOCK_PICTURE") == 0) {
flac_picture_t *picture = flac_picture_parse_from_base64(decoded);
check_flac_picture(picture, "\t");
flac_picture_free(picture);
}
free(decoded);
}
}
}
void check_flac_picture(flac_picture_t *picture, const char *prefix)
{
if (!picture) {
warn("%s%s", prefix, _("Picture: <corrupted>"));
return;
}
info("%s", prefix);
info(_("Picture: %d (%s)\n"), (int)picture->type, flac_picture_type_string(picture->type));
if (picture->media_type) {
info("%s", prefix);
info(_("\tMIME-Type: %s\n"), picture->media_type);
}
if (picture->description) {
info("%s", prefix);
info(_("\tDescription: %s\n"), picture->description);
}
info("%s", prefix);
info(_("\tWidth: %ld\n"), (long int)picture->width);
info("%s", prefix);
info(_("\tHeight: %ld\n"), (long int)picture->height);
info("%s", prefix);
info(_("\tColor depth: %ld\n"), (long int)picture->depth);
if (picture->colors) {
info("%s", prefix);
info(_("\tUsed colors: %ld\n"), (long int)picture->colors);
}
if (picture->uri) {
info("%s", prefix);
info(_("\tURL: %s\n"), picture->uri);
}
if (picture->binary_length) {
info("%s", prefix);
info(_("\tSize: %ld bytes\n"), (long int)picture->binary_length);
}
}
static void free_stream_set(stream_set *set)
{
int i;
......
......@@ -12,6 +12,8 @@
#ifndef __VORBIS_TOOLS__PRIVATE_H__
#define __VORBIS_TOOLS__PRIVATE_H__
#include "picture.h"
typedef struct _stream_processor {
void (*process_page)(struct _stream_processor *, ogg_page *);
void (*process_end)(struct _stream_processor *);
......@@ -52,6 +54,7 @@ void error(const char *format, ...);
void print_summary(stream_processor *stream, size_t bytes, double time);
int handle_vorbis_comments(stream_processor *stream, const unsigned char *in, size_t length, size_t *end);
void check_xiph_comment(stream_processor *stream, int i, const char *comment, int comment_length);
void check_flac_picture(flac_picture_t *picture, const char *prefix);
void vorbis_start(stream_processor *stream);
void theora_start(stream_processor *stream);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment