• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/libdirac_libschro.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00026 #include "libdirac_libschro.h"
00027 
00028 static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = {
00029     { 640,  480,  24000, 1001},
00030     { 176,  120,  15000, 1001},
00031     { 176,  144,  25,    2   },
00032     { 352,  240,  15000, 1001},
00033     { 352,  288,  25,    2   },
00034     { 704,  480,  15000, 1001},
00035     { 704,  576,  25,    2   },
00036     { 720,  480,  30000, 1001},
00037     { 720,  576,  25,    1   },
00038     { 1280, 720,  60000, 1001},
00039     { 1280, 720,  50,    1   },
00040     { 1920, 1080, 30000, 1001},
00041     { 1920, 1080, 25,    1   },
00042     { 1920, 1080, 60000, 1001},
00043     { 1920, 1080, 50,    1   },
00044     { 2048, 1080, 24,    1   },
00045     { 4096, 2160, 24,    1   },
00046 };
00047 
00048 unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext)
00049 {
00050     unsigned int ret_idx = 0;
00051     unsigned int idx;
00052     unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) /
00053                                sizeof(ff_dirac_schro_video_format_info[0]);
00054 
00055     for (idx = 1 ; idx < num_formats; ++idx ) {
00056         const FfmpegDiracSchroVideoFormatInfo *vf =
00057                                         &ff_dirac_schro_video_format_info[idx];
00058         if (avccontext->width  == vf->width &&
00059             avccontext->height == vf->height){
00060             ret_idx = idx;
00061             if (avccontext->time_base.den == vf->frame_rate_num &&
00062                 avccontext->time_base.num == vf->frame_rate_denom) {
00063                 return idx;
00064             }
00065         }
00066     }
00067     return ret_idx;
00068 }
00069 
00070 void ff_dirac_schro_queue_init (FfmpegDiracSchroQueue *queue)
00071 {
00072     queue->p_head = queue->p_tail = NULL;
00073     queue->size = 0;
00074 }
00075 
00076 void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue,
00077                                 void (*free_func)(void *))
00078 {
00079     while (queue->p_head) {
00080         free_func( ff_dirac_schro_queue_pop(queue) );
00081     }
00082 }
00083 
00084 int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data)
00085 {
00086     FfmpegDiracSchroQueueElement *p_new =
00087                              av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
00088 
00089     if (p_new == NULL)
00090         return -1;
00091 
00092     p_new->data = p_data;
00093 
00094     if (queue->p_head == NULL)
00095         queue->p_head = p_new;
00096     else
00097         queue->p_tail->next = p_new;
00098     queue->p_tail = p_new;
00099 
00100     ++queue->size;
00101     return 0;
00102 }
00103 
00104 void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue)
00105 {
00106     FfmpegDiracSchroQueueElement *top = queue->p_head;
00107 
00108     if (top != NULL) {
00109         void *data = top->data;
00110         queue->p_head = queue->p_head->next;
00111         --queue->size;
00112         av_freep (&top);
00113         return data;
00114     }
00115 
00116     return NULL;
00117 }

Generated on Sat Feb 16 2013 09:23:12 for ffmpeg by  doxygen 1.7.1