qml: make TabButtonExt text bold
[vlc.git] / src / test / picture_pool.c
blob9b43c25fdd4d8f068831b11079102c5b97f60f6d
1 /*****************************************************************************
2 * picture_pool.c: test cases for picture_poo_t
3 *****************************************************************************
4 * Copyright (C) 2014 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <stdbool.h>
26 #undef NDEBUG
27 #include <assert.h>
29 #include <vlc_common.h>
30 #include <vlc_es.h>
31 #include <vlc_picture_pool.h>
33 #define PICTURES 10
35 const char vlc_module_name[] = "test_picture_pool";
37 static video_format_t fmt;
38 static picture_pool_t *pool, *reserve;
40 static void test(bool zombie)
42 picture_t *pics[PICTURES];
44 pool = picture_pool_NewFromFormat(&fmt, PICTURES);
45 assert(pool != NULL);
47 for (unsigned i = 0; i < PICTURES; i++) {
48 pics[i] = picture_pool_Get(pool);
49 assert(pics[i] != NULL);
52 for (unsigned i = 0; i < PICTURES; i++)
53 assert(picture_pool_Get(pool) == NULL);
55 // Reserve currently assumes that all pictures are free (or reserved).
56 //assert(picture_pool_Reserve(pool, 1) == NULL);
58 for (unsigned i = 0; i < PICTURES / 2; i++)
59 picture_Hold(pics[i]);
61 for (unsigned i = 0; i < PICTURES / 2; i++)
62 picture_Release(pics[i]);
64 for (unsigned i = 0; i < PICTURES; i++) {
65 void *plane = pics[i]->p[0].p_pixels;
66 assert(plane != NULL);
67 picture_Release(pics[i]);
69 pics[i] = picture_pool_Get(pool);
70 assert(pics[i] != NULL);
71 assert(pics[i]->p[0].p_pixels == plane);
74 for (unsigned i = 0; i < PICTURES; i++)
75 picture_Release(pics[i]);
77 for (unsigned i = 0; i < PICTURES; i++) {
78 pics[i] = picture_pool_Wait(pool);
79 assert(pics[i] != NULL);
82 for (unsigned i = 0; i < PICTURES; i++)
83 picture_Release(pics[i]);
85 reserve = picture_pool_Reserve(pool, PICTURES / 2);
86 assert(reserve != NULL);
88 for (unsigned i = 0; i < PICTURES / 2; i++) {
89 pics[i] = picture_pool_Get(pool);
90 assert(pics[i] != NULL);
93 for (unsigned i = PICTURES / 2; i < PICTURES; i++) {
94 assert(picture_pool_Get(pool) == NULL);
95 pics[i] = picture_pool_Get(reserve);
96 assert(pics[i] != NULL);
99 if (!zombie)
100 for (unsigned i = 0; i < PICTURES; i++)
101 picture_Release(pics[i]);
103 picture_pool_Release(reserve);
104 picture_pool_Release(pool);
106 if (zombie)
107 for (unsigned i = 0; i < PICTURES; i++)
108 picture_Release(pics[i]);
111 int main(void)
113 video_format_Setup(&fmt, VLC_CODEC_I420, 320, 200, 320, 200, 1, 1);
115 pool = picture_pool_NewFromFormat(&fmt, PICTURES);
116 assert(pool != NULL);
118 reserve = picture_pool_Reserve(pool, PICTURES / 2);
119 assert(reserve != NULL);
121 picture_pool_Release(reserve);
122 picture_pool_Release(pool);
124 test(false);
125 test(true);
127 return 0;