2008-04-22 15:22:21 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
|
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* This file is part of Libav.
|
2008-04-22 15:22:21 +02:00
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2008-04-22 15:22:21 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2008-04-22 15:22:21 +02:00
|
|
|
* 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
|
2011-03-18 18:35:10 +01:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2008-04-22 15:22:21 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-20 16:45:34 +02:00
|
|
|
* @file
|
2008-04-22 15:22:21 +02:00
|
|
|
* functions common to libdirac and libschroedinger
|
|
|
|
*/
|
|
|
|
|
2008-04-22 18:26:15 +02:00
|
|
|
#include "libdirac_libschro.h"
|
2008-04-22 15:22:21 +02:00
|
|
|
|
|
|
|
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 },
|
|
|
|
};
|
|
|
|
|
2009-08-15 13:42:15 +02:00
|
|
|
unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext)
|
2008-04-22 15:22:21 +02:00
|
|
|
{
|
|
|
|
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]);
|
|
|
|
|
2009-08-15 13:42:15 +02:00
|
|
|
for (idx = 1; idx < num_formats; ++idx) {
|
|
|
|
const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx];
|
2008-04-22 15:22:21 +02:00
|
|
|
if (avccontext->width == vf->width &&
|
2009-08-15 13:42:15 +02:00
|
|
|
avccontext->height == vf->height) {
|
2008-04-22 15:22:21 +02:00
|
|
|
ret_idx = idx;
|
|
|
|
if (avccontext->time_base.den == vf->frame_rate_num &&
|
2009-08-15 13:12:47 +02:00
|
|
|
avccontext->time_base.num == vf->frame_rate_denom)
|
2008-04-22 15:22:21 +02:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret_idx;
|
|
|
|
}
|
|
|
|
|
2009-08-15 13:42:15 +02:00
|
|
|
void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue)
|
2008-04-22 15:22:21 +02:00
|
|
|
{
|
|
|
|
queue->p_head = queue->p_tail = NULL;
|
2008-07-10 13:40:19 +02:00
|
|
|
queue->size = 0;
|
2008-04-22 15:22:21 +02:00
|
|
|
}
|
|
|
|
|
2009-08-15 13:42:15 +02:00
|
|
|
void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue,
|
|
|
|
void (*free_func)(void *))
|
2008-04-22 15:22:21 +02:00
|
|
|
{
|
2009-08-15 13:12:47 +02:00
|
|
|
while (queue->p_head)
|
2009-08-15 13:42:15 +02:00
|
|
|
free_func(ff_dirac_schro_queue_pop(queue));
|
2008-04-22 15:22:21 +02:00
|
|
|
}
|
|
|
|
|
2009-08-15 13:42:15 +02:00
|
|
|
int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data)
|
2008-04-22 15:22:21 +02:00
|
|
|
{
|
2009-08-15 13:42:15 +02:00
|
|
|
FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement));
|
2008-04-22 15:22:21 +02:00
|
|
|
|
2009-08-15 13:02:50 +02:00
|
|
|
if (!p_new)
|
2008-04-22 15:22:21 +02:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
p_new->data = p_data;
|
|
|
|
|
2009-08-15 13:02:50 +02:00
|
|
|
if (!queue->p_head)
|
2008-04-22 15:22:21 +02:00
|
|
|
queue->p_head = p_new;
|
|
|
|
else
|
|
|
|
queue->p_tail->next = p_new;
|
|
|
|
queue->p_tail = p_new;
|
|
|
|
|
2008-07-10 13:40:19 +02:00
|
|
|
++queue->size;
|
2008-04-22 15:22:21 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-15 13:42:15 +02:00
|
|
|
void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue)
|
2008-04-22 15:22:21 +02:00
|
|
|
{
|
|
|
|
FfmpegDiracSchroQueueElement *top = queue->p_head;
|
|
|
|
|
2009-08-15 13:02:50 +02:00
|
|
|
if (top) {
|
2008-04-22 15:22:21 +02:00
|
|
|
void *data = top->data;
|
|
|
|
queue->p_head = queue->p_head->next;
|
2008-07-10 13:40:19 +02:00
|
|
|
--queue->size;
|
2009-08-15 13:42:15 +02:00
|
|
|
av_freep(&top);
|
2008-04-22 15:22:21 +02:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|