summaryrefslogtreecommitdiff
path: root/tests/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-06 21:31:08 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-05-06 21:53:19 +0200
commit715c8a5a5052d67423f27192444474a3d61dce60 (patch)
tree4d96bf6fdbbbebef82f0263d2fde088cd4ee9a09 /tests/utils.c
parentcbbc4724672ec5839427f9b4129051fac9de390b (diff)
parentfb5c1aaea60a714dab3d4e6e71228855fd816222 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (28 commits) dfa: use more meaningful return codes eatgv: check vector_bits eatgv: check motion vectors Mark a number of variables only used in av_dlog() calls as av_unused. dvdec: drop const qualifier from variable to eliminate a warning avcodec: Improve comment for thread_safe_callbacks to avoid misinterpretation. tests/utils: don't ignore the return value of fwrite() lavfi/formats: use sizeof(var) instead of sizeof(type). lavfi: remove avfilter_default_config_input_link() declaration lavfi: always enable the scale filter and depend on sws. vf_split: support user-specifiable number of outputs. avconv: remove stray useless comment. mpegmux: add stuffing to avoid incomplete PCM frames rtsp: avoid const warnings from strtol() call avserver: check return value of ftruncate() lagarith: make offset array type unsigned dfa: add some checks to ensure that decoder won't write past frame end aacps: NEON optimisations aacps: align some arrays aacps: move some loops to function pointers ... Conflicts: configure doc/filters.texi libavcodec/dfa.c libavcodec/eatgv.c libavfilter/Makefile libavfilter/allfilters.c libavfilter/avfilter.h libavfilter/formats.c libavfilter/vf_split.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'tests/utils.c')
-rw-r--r--tests/utils.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/utils.c b/tests/utils.c
index aaed470415..3fef048476 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -18,13 +18,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#define SCALEBITS 8
#define ONE_HALF (1 << (SCALEBITS - 1))
#define FIX(x) ((int) ((x) * (1L << SCALEBITS) + 0.5))
+#define err_if(expr) do { \
+ if (expr) { \
+ fprintf(stderr, "%s\n", strerror(errno)); \
+ exit(1); \
+ } \
+} while (0)
+
static void rgb24_to_yuv420p(unsigned char *lum, unsigned char *cb,
unsigned char *cr, unsigned char *src,
int width, int height)
@@ -110,14 +119,14 @@ static void pgmyuv_save(const char *filename, int w, int h,
f = fopen(filename, "wb");
fprintf(f, "P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
- fwrite(lum_tab, 1, w * h, f);
+ err_if(fwrite(lum_tab, 1, w * h, f) != w * h);
h2 = h / 2;
w2 = w / 2;
cb = cb_tab;
cr = cr_tab;
for (i = 0; i < h2; i++) {
- fwrite(cb, 1, w2, f);
- fwrite(cr, 1, w2, f);
+ err_if(fwrite(cb, 1, w2, f) != w2);
+ err_if(fwrite(cr, 1, w2, f) != w2);
cb += w2;
cr += w2;
}