Mercurial > libavcodec.hg
comparison libdirac_libschro.c @ 6663:33627a932270 libavcodec
Rename diracschro_common.[ch] to libdirac_libschro.[ch], external library
glue code should have a lib prefix in its name.
author | diego |
---|---|
date | Tue, 22 Apr 2008 16:26:15 +0000 |
parents | diracschro_common.c@c5432b7e7bc1 |
children | 238a3511f183 |
comparison
equal
deleted
inserted
replaced
6662:c5432b7e7bc1 | 6663:33627a932270 |
---|---|
1 /* | |
2 * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > | |
3 * | |
4 * This file is part of FFmpeg. | |
5 * | |
6 * FFmpeg is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 2.1 of the License, or (at your option) any later version. | |
10 * | |
11 * FFmpeg is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with FFmpeg; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 */ | |
20 | |
21 /** | |
22 * @file libdirac_libschro.c | |
23 * functions common to libdirac and libschroedinger | |
24 */ | |
25 | |
26 #include "libdirac_libschro.h" | |
27 | |
28 static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = { | |
29 { 640, 480, 24000, 1001}, | |
30 { 176, 120, 15000, 1001}, | |
31 { 176, 144, 25, 2 }, | |
32 { 352, 240, 15000, 1001}, | |
33 { 352, 288, 25, 2 }, | |
34 { 704, 480, 15000, 1001}, | |
35 { 704, 576, 25, 2 }, | |
36 { 720, 480, 30000, 1001}, | |
37 { 720, 576, 25, 1 }, | |
38 { 1280, 720, 60000, 1001}, | |
39 { 1280, 720, 50, 1 }, | |
40 { 1920, 1080, 30000, 1001}, | |
41 { 1920, 1080, 25, 1 }, | |
42 { 1920, 1080, 60000, 1001}, | |
43 { 1920, 1080, 50, 1 }, | |
44 { 2048, 1080, 24, 1 }, | |
45 { 4096, 2160, 24, 1 }, | |
46 }; | |
47 | |
48 unsigned int ff_dirac_schro_get_video_format_idx (AVCodecContext *avccontext) | |
49 { | |
50 unsigned int ret_idx = 0; | |
51 unsigned int idx; | |
52 unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) / | |
53 sizeof(ff_dirac_schro_video_format_info[0]); | |
54 | |
55 for (idx = 1 ; idx < num_formats; ++idx ) { | |
56 const FfmpegDiracSchroVideoFormatInfo *vf = | |
57 &ff_dirac_schro_video_format_info[idx]; | |
58 if (avccontext->width == vf->width && | |
59 avccontext->height == vf->height){ | |
60 ret_idx = idx; | |
61 if (avccontext->time_base.den == vf->frame_rate_num && | |
62 avccontext->time_base.num == vf->frame_rate_denom) { | |
63 return idx; | |
64 } | |
65 } | |
66 } | |
67 return ret_idx; | |
68 } | |
69 | |
70 void ff_dirac_schro_queue_init (FfmpegDiracSchroQueue *queue) | |
71 { | |
72 queue->p_head = queue->p_tail = NULL; | |
73 } | |
74 | |
75 void ff_dirac_schro_queue_free (FfmpegDiracSchroQueue *queue, | |
76 void (*free_func)(void *)) | |
77 { | |
78 while (queue->p_head) { | |
79 free_func( ff_dirac_schro_queue_pop(queue) ); | |
80 } | |
81 } | |
82 | |
83 int ff_dirac_schro_queue_push_back (FfmpegDiracSchroQueue *queue, void *p_data) | |
84 { | |
85 FfmpegDiracSchroQueueElement *p_new = | |
86 av_mallocz(sizeof(FfmpegDiracSchroQueueElement)); | |
87 | |
88 if (p_new == NULL) | |
89 return -1; | |
90 | |
91 p_new->data = p_data; | |
92 | |
93 if (queue->p_head == NULL) | |
94 queue->p_head = p_new; | |
95 else | |
96 queue->p_tail->next = p_new; | |
97 queue->p_tail = p_new; | |
98 | |
99 return 0; | |
100 } | |
101 | |
102 void *ff_dirac_schro_queue_pop (FfmpegDiracSchroQueue *queue) | |
103 { | |
104 FfmpegDiracSchroQueueElement *top = queue->p_head; | |
105 | |
106 if (top != NULL) { | |
107 void *data = top->data; | |
108 queue->p_head = queue->p_head->next; | |
109 av_freep (&top); | |
110 return data; | |
111 } | |
112 | |
113 return NULL; | |
114 } |