[FFmpeg-cvslog] r12923 - in trunk/libavcodec: diracschro_common.c diracschro_common.h

lu_zero subversion
Tue Apr 22 15:22:22 CEST 2008


Author: lu_zero
Date: Tue Apr 22 15:22:21 2008
New Revision: 12923

Log:
libdirac and libschro common code, patch from Anuradha Suraparaju anuradhaAtrdDoTbbcDoTcoDotuk

Added:
   trunk/libavcodec/diracschro_common.c
   trunk/libavcodec/diracschro_common.h

Added: trunk/libavcodec/diracschro_common.c
==============================================================================
--- (empty file)
+++ trunk/libavcodec/diracschro_common.c	Tue Apr 22 15:22:21 2008
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+* @file diracschro_common.c
+* functions common to libdirac and libschroedinger
+*/
+
+#include "diracschro_common.h"
+
+static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
+    { 640,  480,  24000, 1001},
+    { 176,  120,  15000, 1001},
+    { 176,  144,  25,    2   },
+    { 352,  240,  15000, 1001},
+    { 352,  288,  25,    2   },
+    { 704,  480,  15000, 1001},
+    { 704,  576,  25,    2   },
+    { 720,  480,  30000, 1001},
+    { 720,  576,  25,    1   },
+    { 1280, 720,  60000, 1001},
+    { 1280, 720,  50,    1   },
+    { 1920, 1080, 30000, 1001},
+    { 1920, 1080, 25,    1   },
+    { 1920, 1080, 60000, 1001},
+    { 1920, 1080, 50,    1   },
+    { 2048, 1080, 24,    1   },
+    { 4096, 2160, 24,    1   },
+};
+
+unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext)
+{
+    unsigned int ret_idx = 0;
+    unsigned int idx;
+    unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) /
+                               sizeof(ff_dirac_schro_video_format_info[0]);
+
+    for (idx = 1 ; idx < num_formats; ++idx ) {
+        const FfmpegDiracSchroVideoFormatInfo *vf =
+                                        &ff_dirac_schro_video_format_info[idx];
+        if (avccontext->width  == vf->width &&
+            avccontext->height == vf->height){
+            ret_idx = idx;
+            if (avccontext->time_base.den == vf->frame_rate_num &&
+                avccontext->time_base.num == vf->frame_rate_denom) {
+                return idx;
+            }
+        }
+    }
+    return ret_idx;
+}
+
+void ff_dirac_schro_queue_init (FfmpegDiracSchroQueue *queue)
+{
+    queue->p_head = queue->p_tail = NULL;
+}
+
+void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue,
+                                void (*free_func)(void *))
+{
+    while (queue->p_head) {
+        free_func( ff_dirac_schro_queue_pop(queue) );
+    }
+}
+
+int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data)
+{
+    FfmpegDiracSchroQueueElement *p_new =
+                             av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
+
+    if (p_new == NULL)
+        return -1;
+
+    p_new->data = p_data;
+
+    if (queue->p_head == NULL)
+        queue->p_head = p_new;
+    else
+        queue->p_tail->next = p_new;
+    queue->p_tail = p_new;
+
+    return 0;
+}
+
+void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue)
+{
+    FfmpegDiracSchroQueueElement *top = queue->p_head;
+
+    if (top != NULL) {
+        void *data = top->data;
+        queue->p_head = queue->p_head->next;
+        av_freep (&top);
+        return data;
+    }
+
+    return NULL;
+}

Added: trunk/libavcodec/diracschro_common.h
==============================================================================
--- (empty file)
+++ trunk/libavcodec/diracschro_common.h	Tue Apr 22 15:22:21 2008
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+* @file diracschro_common.h
+* data structures common to libdirac and libschroedinger
+*/
+
+#ifndef FFMPEG_DIRACSCHRO_COMMON_H
+#define FFMPEG_DIRACSCHRO_COMMON_H
+
+#include "avcodec.h"
+
+typedef struct
+{
+    uint16_t width;
+    uint16_t height;
+    uint16_t frame_rate_num;
+    uint16_t frame_rate_denom;
+} FfmpegDiracSchroVideoFormatInfo;
+
+/**
+* Returns the index into the Dirac Schro common video format info table
+*/
+unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext);
+
+/**
+* contains a single encoded frame returned from Dirac or Schroedinger
+*/
+typedef struct FfmpegDiracSchroEncodedFrame
+{
+    /** encoded frame data */
+    uint8_t *p_encbuf;
+
+    /** encoded frame size */
+    uint32_t size;
+
+    /** encoded frame number. Will be used as pts */
+    uint32_t frame_num;
+
+    /** key frame flag. 1 : is key frame , 0 : in not key frame */
+    uint16_t key_frame;
+} FfmpegDiracSchroEncodedFrame;
+
+/**
+* queue element
+*/
+typedef struct FfmpegDiracSchroQueueElement
+{
+    /** Data to be stored in queue*/
+    void *data;
+    /** Pointer to next element queue */
+    struct FfmpegDiracSchroQueueElement *next;
+} FfmpegDiracSchroQueueElement;
+
+
+/**
+* A simple queue implementation used in libdirac and libschroedinger
+*/
+typedef struct FfmpegDiracSchroQueue
+{
+    /** Pointer to head of queue */
+    FfmpegDiracSchroQueueElement *p_head;
+    /** Pointer to tail of queue */
+    FfmpegDiracSchroQueueElement *p_tail;
+} FfmpegDiracSchroQueue;
+
+/**
+* Initialise the queue
+*/
+void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue);
+
+/**
+* Add an element to the end of the queue
+*/
+int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data);
+
+/**
+* Return the first element in the queue
+*/
+void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue);
+
+/**
+* Free the queue resources. free_func is a function supplied by the caller to
+* free any resources allocated by the caller. The data field of the queue
+* element is passed to it.
+*/
+void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
+                               void (*free_func)(void *));
+#endif /* FFMPEG_DIRACSCHRO_COMMON_H */




More information about the ffmpeg-cvslog mailing list