File: yuvstdout.c

package info (click to toggle)
mjpegtools 1%3A2.1.0%2Bdebian-5
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 8,876 kB
  • ctags: 8,239
  • sloc: ansic: 60,401; cpp: 32,321; sh: 13,910; makefile: 785; python: 291; asm: 103
file content (67 lines) | stat: -rw-r--r-- 1,924 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 *  Copyright (C) 2001 Kawamata/Hitoshi <hitoshi.kawamata@nifty.ne.jp>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <config.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <mpegconsts.h>
#include "yuvfilters.h"

DEFINE_STD_YFTASKCLASS(yuvstdout);

static const char *
do_usage(void)
{
  return "";
}

static YfTaskCore_t *
do_init(int argc, char **argv, const YfTaskCore_t *h0)
{
  YfTaskCore_t *h;

  --argc; ++argv;
  if (!(h = YfAllocateTask(&yuvstdout, sizeof *h, h0)))
    return NULL;
  y4m_si_set_width(&h->si, h0->width);
  y4m_si_set_height(&h->si, h0->height);
  y4m_si_set_framerate(&h->si, mpeg_framerate(h0->fpscode));
  if (y4m_write_stream_header(1, &h->si) != Y4M_OK) {
    YfFreeTask(h);
    h = NULL;
  }
  return h;
}

static void
do_fini(YfTaskCore_t *handle)
{
  YfFreeTask(handle);
}

static int
do_frame(YfTaskCore_t *handle, const YfTaskCore_t *h0, const YfFrame_t * frame0)
{
  uint8_t * yuv[3];
  yuv[0] = (uint8_t*)frame0->data;
  yuv[1] = yuv[0] + (handle->width * handle->height);
  yuv[2] = yuv[1] + ((handle->width  / CWDIV(y4m_si_get_chroma(&handle->si))) *
		     (handle->height / CHDIV(y4m_si_get_chroma(&handle->si))));
  return y4m_write_frame(1, &handle->si, &frame0->fi, yuv);
}