~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_encoder/adm_encyv12.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-12-15 17:13:20 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215171320-w79pvpehxx2fr217
Tags: 1:2.3.0-0.0ubuntu1
* Merge from debian-multimedia.org, remaining Ubuntu change:
  - desktop file,
  - no support for ccache and make -j.
* Closes Ubuntu: #69614.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          adm_encxvid.cpp  -  description
 
3
                             -------------------
 
4
                             Encoder for Xvid 1.0x (dev-api4)
 
5
    begin                : Sun Jul 14 2002
 
6
    copyright            : (C) 2002/2003 by mean
 
7
    email                : fixounet@free.fr
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *                                                                         *
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 ***************************************************************************/
 
18
#include <config.h>
 
19
 
 
20
#include <stdio.h>
 
21
#include <stdlib.h>
 
22
#include <math.h>
 
23
#include <unistd.h>
 
24
 
 
25
#include <time.h>
 
26
#include <sys/time.h>
 
27
 
 
28
 
 
29
#include "fourcc.h"
 
30
#include "avi_vars.h"
 
31
#include "ADM_toolkit/toolkit.hxx"
 
32
#include <ADM_assert.h>
 
33
 
 
34
#include "ADM_encoder/ADM_vidEncode.hxx"
 
35
 
 
36
#include "ADM_video/ADM_genvideo.hxx"
 
37
#include "ADM_encoder/adm_encoder.h"
 
38
#include "ADM_encoder/adm_encyv12.h"
 
39
 
 
40
 
 
41
#define aprintf printf
 
42
 
 
43
/*_________________________________________________*/
 
44
EncoderYV12::EncoderYV12 (void)
 
45
{
 
46
 
 
47
  _frametogo = 0;
 
48
};
 
49
EncoderYV12::~EncoderYV12 ()
 
50
{
 
51
 
 
52
  stop ();
 
53
 
 
54
};
 
55
//--------------------------------
 
56
uint8_t
 
57
EncoderYV12::configure (AVDMGenericVideoStream * instream)
 
58
{
 
59
  ADM_assert (instream);
 
60
  ADV_Info *info;
 
61
 
 
62
  _in = instream;
 
63
  info = instream->getInfo ();
 
64
  _w = info->width;
 
65
  _h = info->height;
 
66
  _frametogo = info->nb_frames;
 
67
  _vbuffer = new ADMImage (_w, _h);
 
68
  ADM_assert (_vbuffer);
 
69
  printf ("\n Yv12 Encoder ready , w: %lu h:%lu mode:%d", _w, _h, _state);
 
70
  return 1;
 
71
}
 
72
 
 
73
//______________________________
 
74
uint8_t
 
75
        EncoderYV12::encode (uint32_t frame, ADMBitstream *out)
 
76
{
 
77
  uint32_t l, f, q;
 
78
 
 
79
  ADM_assert (_in);
 
80
 
 
81
  if (!_in->getFrameNumberNoAlloc (frame, &l, _vbuffer, &f))
 
82
    {
 
83
      printf ("\n Error : Cannot read incoming frame !");
 
84
      return 0;
 
85
    }
 
86
  l = (_w * _h * 3) >> 1;
 
87
  out->len = l;
 
88
  out->flags = AVI_KEY_FRAME;
 
89
  memcpy (out->data, _vbuffer->data, l);
 
90
  return 1;
 
91
}
 
92
 
 
93
//_______________________________
 
94
uint8_t EncoderYV12::stop (void)
 
95
{
 
96
  return 1;
 
97
 
 
98
}
 
99
// EOF