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