~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/output/yuvDumper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  writes yuv images on HD
 
3
  Copyright (C) 2000  Martin Vogt
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU Library General Public License as published by
 
7
  the Free Software Foundation.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#include "yuvDumper.h"
 
15
 
 
16
YUVDumper::YUVDumper() {
 
17
  picCnt=1;
 
18
  method=_DUMP_YUV_AS_STREAM;
 
19
}
 
20
 
 
21
YUVDumper::~YUVDumper() {
 
22
}
 
23
 
 
24
 
 
25
int YUVDumper::openWindow(int w, int h,const char*) {
 
26
  
 
27
  FILE* formatFile=fopen("stream.yuv.format","w+");
 
28
  fprintf(formatFile,"Version 0.1\nw:%dh:%d\n",w,h);
 
29
  fclose(formatFile);
 
30
 
 
31
 
 
32
 
 
33
  if (method == _DUMP_YUV_AS_STREAM) {
 
34
    FILE* outFile=fopen("stream.yuv","w+");
 
35
    fclose(outFile);
 
36
  }
 
37
 return true;
 
38
}
 
39
 
 
40
void YUVDumper::closeWindow() {
 
41
}
 
42
 
 
43
 
 
44
void YUVDumper::flushWindow() {
 
45
}
 
46
 
 
47
 
 
48
int YUVDumper::getMethod() {
 
49
  return method;
 
50
}
 
51
 
 
52
 
 
53
void YUVDumper::setMethod(int method) {
 
54
  this->method=method;
 
55
}
 
56
 
 
57
void YUVDumper::unlockPictureArray(PictureArray* pictureArray) {
 
58
  YUVPicture* pic=pictureArray->getYUVPictureCallback();
 
59
  if (pic == NULL) {
 
60
    return;
 
61
  }
 
62
 
 
63
  FILE* outFile=NULL;
 
64
 
 
65
  if (method == _DUMP_YUV_AS_STREAM) {
 
66
    outFile=fopen("stream.yuv","a+");
 
67
  }
 
68
 
 
69
  if (outFile == NULL) {
 
70
      perror("fopen");
 
71
      return;
 
72
  }
 
73
 
 
74
  int lumSize=pic->getLumLength();
 
75
  int colorSize=pic->getColorLength();
 
76
  fwrite(pic->getLuminancePtr(),1,lumSize,outFile);
 
77
  fwrite(pic->getCrPtr(),1,colorSize,outFile);
 
78
  fwrite(pic->getCbPtr(),1,colorSize,outFile);
 
79
  fclose(outFile);
 
80
 
 
81
}