changeset 916:4be0046a09e4 trunk

[svn] - more work here
author nenolod
date Wed, 05 Apr 2006 11:07:10 -0700
parents 5da5c262b1ef
children 822114b4b8a8
files Plugins/Input/shorten/Makefile Plugins/Input/shorten/avformat.h Plugins/Input/shorten/futils.c Plugins/Input/shorten/init.c Plugins/Input/shorten/shorten_container.c Plugins/Input/shorten/shorten_plugin.c Plugins/Input/shorten/utils.c
diffstat 7 files changed, 122 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/shorten/Makefile	Wed Apr 05 07:50:49 2006 -0700
+++ b/Plugins/Input/shorten/Makefile	Wed Apr 05 11:07:10 2006 -0700
@@ -3,12 +3,14 @@
 
 OBJECTIVE_LIBS=	libshorten.so
 
+LIBDIR= $(plugindir)/$(INPUT_PLUGIN_DIR)
+
 SOURCES= 	avio.c aviobuf.c \
 		common.c \
 		cutils.c dsputil.c \
 		fft.c file.c futils.c golomb.c init.c mdct.c \
 		os_support.c \
-		parser.c simple_idct.c shorten_decoder.c shorten_plugin.c \
+		parser.c simple_idct.c shorten_decoder.c shorten_plugin.c shorten_container.c \
 		utils.h utils.c
 
 CFLAGS+=	-fPIC -DPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -I../../.. -I../../../intl $(GTK_CFLAGS)
--- a/Plugins/Input/shorten/avformat.h	Wed Apr 05 07:50:49 2006 -0700
+++ b/Plugins/Input/shorten/avformat.h	Wed Apr 05 11:07:10 2006 -0700
@@ -56,6 +56,7 @@
 }
 
 int av_new_packet(AVPacket *pkt, int size);
+int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
 int av_dup_packet(AVPacket *pkt);
 
 /**
--- a/Plugins/Input/shorten/futils.c	Wed Apr 05 07:50:49 2006 -0700
+++ b/Plugins/Input/shorten/futils.c	Wed Apr 05 11:07:10 2006 -0700
@@ -158,6 +158,33 @@
     return 0;
 }
 
+/**
+ * Allocate and read the payload of a packet and intialized its fields to default values.
+ *
+ * @param pkt packet
+ * @param size wanted payload size
+ * @return >0 (read size) if OK. AVERROR_xxx otherwise.
+ */
+int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size)
+{   
+    int ret= av_new_packet(pkt, size);
+
+    if(ret<0)
+        return ret;
+
+#ifdef NOTYET
+    pkt->pos= url_ftell(s);
+#endif
+
+    ret= get_buffer(s, pkt->data, size);
+    if(ret<=0)
+        av_free_packet(pkt);
+    else
+        pkt->size= ret;
+
+    return ret;
+}   
+
 /* This is a hack - the packet memory allocation stuff is broken. The
    packet is allocated if it was not really allocated */
 int av_dup_packet(AVPacket *pkt)
--- a/Plugins/Input/shorten/init.c	Wed Apr 05 07:50:49 2006 -0700
+++ b/Plugins/Input/shorten/init.c	Wed Apr 05 11:07:10 2006 -0700
@@ -40,6 +40,7 @@
 {
 	avcodec_init();
 	avcodec_register_all();
+	raw_init();
 
 	/* file protocols */
 	register_protocol(&file_protocol);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Input/shorten/shorten_container.c	Wed Apr 05 11:07:10 2006 -0700
@@ -0,0 +1,83 @@
+/*
+ * Shorten container management.
+ *   Copyright (c) 2006 William Pitcock <nenolod -at- nenolod.net>
+ *   Copyright (c) 2006 Thomas Cort <tcort -at- cs.ubishops.ca>
+ *
+ * RAW encoder and decoder
+ *   Copyright (c) 2001 Fabrice Bellard.
+ *   Copyright (c) 2005 Alex Beregszaszi.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avformat.h"
+#include "utils.h"
+
+#define RAW_PACKET_SIZE 1024
+
+static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    int ret, size;
+    //    AVStream *st = s->streams[0];
+
+    size= RAW_PACKET_SIZE;
+
+    ret= av_get_packet(&s->pb, pkt, size);
+
+    pkt->stream_index = 0;
+    if (ret <= 0) {
+        return AVERROR_IO;
+    }
+    /* note: we need to modify the packet size here to handle the last
+       packet */
+    pkt->size = ret;
+    return ret;
+}
+
+static int raw_read_close(AVFormatContext *s)
+{   
+    return 0;
+}
+
+static int shorten_read_header(AVFormatContext *s,
+                               AVFormatParameters *ap)
+{
+    AVStream *st;
+
+    st = av_new_stream(s, 0);
+    if (!st)
+        return AVERROR_NOMEM;
+    st->codec.codec_type = CODEC_TYPE_AUDIO;
+    st->codec.codec_id = CODEC_ID_SHORTEN;
+    st->need_parsing = 1;
+    /* the parameters will be extracted from the compressed bitstream */
+    return 0;
+}
+
+AVInputFormat shorten_iformat = {
+    "shn",
+    "raw shorten",
+    0,
+    NULL,
+    shorten_read_header,
+    raw_read_packet,
+    raw_read_close,
+    .extensions = "shn",
+};
+
+int raw_init(void)
+{
+    av_register_input_format(&shorten_iformat);
+    return 0;
+}
--- a/Plugins/Input/shorten/shorten_plugin.c	Wed Apr 05 07:50:49 2006 -0700
+++ b/Plugins/Input/shorten/shorten_plugin.c	Wed Apr 05 11:07:10 2006 -0700
@@ -145,7 +145,11 @@
 {
     AVCodec *codec2;
 
-    if(av_open_input_file(&ic2, str_twenty_to_space(filename), NULL, 0, NULL) < 0) return 0;
+    if(av_open_input_file(&ic2, str_twenty_to_space(filename), NULL, 0, NULL) < 0)
+    {
+	puts("Error");
+	return 0;
+    }
 
     for(shn_idx2 = 0; shn_idx2 < ic2->nb_streams; shn_idx2++) {
         c2 = &ic2->streams[shn_idx2]->codec;
@@ -156,6 +160,8 @@
 
     codec2 = avcodec_find_decoder(c2->codec_id);
 
+    printf("%d\n", c2->codec_id);
+
     if(!codec2) {
         av_close_input_file(ic2);
 	return 0;
--- a/Plugins/Input/shorten/utils.c	Wed Apr 05 07:50:49 2006 -0700
+++ b/Plugins/Input/shorten/utils.c	Wed Apr 05 11:07:10 2006 -0700
@@ -630,4 +630,3 @@
 {
     av_log_callback = callback;
 }
-