hornetseye-ffmpeg 0.11.0 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +3 -3
  2. data/ext/avinput.cc +14 -11
  3. data/ext/avoutput.cc +7 -8
  4. metadata +29 -3
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'hornetseye-ffmpeg'
10
- PKG_VERSION = '0.11.0'
10
+ PKG_VERSION = '0.11.2'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
@@ -46,7 +46,7 @@ desc 'Compile Ruby extension (default)'
46
46
  task :all => [ SO_FILE ]
47
47
 
48
48
  file SO_FILE => OBJ do |t|
49
- sh "#{CXX} -shared -o #{t.name} #{OBJ} -lavformat -lswscale #{$LIBRUBYARG}"
49
+ sh "#{CXX} -shared -o #{t.name} #{OBJ} -lavformat -lavcodec -lavutil -lswscale #{$LIBRUBYARG}"
50
50
  end
51
51
 
52
52
  task :test => [ SO_FILE ]
@@ -80,7 +80,7 @@ def check_program
80
80
  f_base_name = 'rakeconf'
81
81
  begin
82
82
  File.open( "#{f_base_name}.cc", 'w' ) { |f| yield f }
83
- `#{CXX} -S #{$CXXFLAGS} -c -o #{f_base_name}.o #{f_base_name}.cc 2>&1 >> rake.log`
83
+ `#{CXX} #{$CXXFLAGS} -c -o #{f_base_name}.o #{f_base_name}.cc 2>&1 >> rake.log`
84
84
  $?.exitstatus == 0
85
85
  ensure
86
86
  File.delete *Dir.glob( "#{f_base_name}.*" )
data/ext/avinput.cc CHANGED
@@ -16,7 +16,6 @@
16
16
  #ifndef NDEBUG
17
17
  #include <iostream>
18
18
  #endif
19
- #include <malloc.h>
20
19
  #include "avinput.hh"
21
20
 
22
21
  #if !defined(INT64_C)
@@ -43,9 +42,9 @@ AVInput::AVInput( const string &mrl, bool audio ) throw (Error):
43
42
  ERRORMACRO( err >= 0, Error, , "Error finding stream info for file \""
44
43
  << mrl << "\": " << strerror( errno ) );
45
44
  for ( unsigned int i=0; i<m_ic->nb_streams; i++ ) {
46
- if ( m_ic->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO )
45
+ if ( m_ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
47
46
  m_videoStream = i;
48
- if ( audio && m_ic->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO )
47
+ if ( audio && m_ic->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
49
48
  m_audioStream = i;
50
49
  };
51
50
  #ifndef NDEBUG
@@ -137,8 +136,8 @@ void AVInput::readAV(void) throw (Error)
137
136
  while ( av_read_frame( m_ic, &packet ) >= 0 ) {
138
137
  if ( packet.stream_index == m_videoStream ) {
139
138
  int frameFinished;
140
- int err = avcodec_decode_video( m_videoDec, m_avFrame, &frameFinished,
141
- packet.data, packet.size );
139
+ int err = avcodec_decode_video2( m_videoDec, m_avFrame, &frameFinished,
140
+ &packet );
142
141
  ERRORMACRO( err >= 0, Error, ,
143
142
  "Error decoding video frame of video \"" << m_mrl << "\"" );
144
143
  if ( firstPacketPts == AV_NOPTS_VALUE ) firstPacketPts = packet.pts;
@@ -174,20 +173,22 @@ void AVInput::readAV(void) throw (Error)
174
173
  m_audioFrame.reset();
175
174
  unsigned char *data = packet.data;
176
175
  int size = packet.size;
177
- while ( size > 0 ) {
178
- short int *buffer =
179
- (short int *)memalign( 16, AVCODEC_MAX_AUDIO_FRAME_SIZE * 3 / 2 );
176
+ while ( packet.size > 0 ) {
177
+ short int *buffer;
178
+ ERRORMACRO(posix_memalign((void **)&buffer, 16,
179
+ AVCODEC_MAX_AUDIO_FRAME_SIZE * 3 / 2) == 0, Error, ,
180
+ "Error allocating aligned memory");
180
181
  buffer[ AVCODEC_MAX_AUDIO_FRAME_SIZE * 3 / 4 - 1 ] = '\000';
181
182
  int bufSize = AVCODEC_MAX_AUDIO_FRAME_SIZE * 3 / 2;
182
- int len = avcodec_decode_audio2( m_audioDec, buffer, &bufSize, data, size );
183
+ int len = avcodec_decode_audio3( m_audioDec, buffer, &bufSize, &packet );
183
184
  if ( len < 0 ) {
184
185
  free( buffer );
185
186
  m_audioFrame.reset();
186
187
  ERRORMACRO( false, Error, , "Error decoding audio frame of video \""
187
188
  << m_mrl << "\"" );
188
189
  };
189
- data += len;
190
- size -= len;
190
+ packet.data += len;
191
+ packet.size -= len;
191
192
  if ( bufSize > 0 ) {
192
193
  if ( m_audioFrame.get() ) {
193
194
  SequencePtr extended( new Sequence( m_audioFrame->size() + bufSize ) );
@@ -201,6 +202,8 @@ void AVInput::readAV(void) throw (Error)
201
202
  };
202
203
  free( buffer );
203
204
  };
205
+ packet.data = data;
206
+ packet.size = size;
204
207
  av_free_packet( &packet );
205
208
  if ( m_audioFrame.get() ) break;
206
209
  } else
data/ext/avoutput.cc CHANGED
@@ -17,6 +17,7 @@
17
17
  #ifndef NDEBUG
18
18
  #include <iostream>
19
19
  #endif
20
+ #include <libavutil/mathematics.h>
20
21
  #include "avoutput.hh"
21
22
 
22
23
  #if !defined(INT64_C)
@@ -42,8 +43,8 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
42
43
  {
43
44
  try {
44
45
  AVOutputFormat *format;
45
- format = guess_format( NULL, mrl.c_str(), NULL );
46
- if ( format == NULL ) format = guess_format( "mpeg", NULL, NULL );
46
+ format = av_guess_format( NULL, mrl.c_str(), NULL );
47
+ if ( format == NULL ) format = av_guess_format( "mpeg", NULL, NULL );
47
48
  ERRORMACRO( format != NULL, Error, ,
48
49
  "Could not find suitable output format for \"" << mrl << "\"" );
49
50
  #ifdef HAVE_LIBAVFORMAT_ALLOC_CONTEXT
@@ -62,7 +63,7 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
62
63
  m_videoStream->sample_aspect_ratio.den = aspectRatioDen;
63
64
  AVCodecContext *c = m_videoStream->codec;
64
65
  c->codec_id = videoCodec != CODEC_ID_NONE ? videoCodec : format->video_codec;
65
- c->codec_type = CODEC_TYPE_VIDEO;
66
+ c->codec_type = AVMEDIA_TYPE_VIDEO;
66
67
  c->bit_rate = videoBitRate;
67
68
  c->width = width;
68
69
  c->height = height;
@@ -79,7 +80,7 @@ AVOutput::AVOutput( const string &mrl, int videoBitRate, int width, int height,
79
80
  ERRORMACRO( m_audioStream != NULL, Error, , "Could not allocate audio stream" );
80
81
  AVCodecContext *c = m_audioStream->codec;
81
82
  c->codec_id = audioCodec != CODEC_ID_NONE ? audioCodec : format->audio_codec;
82
- c->codec_type = CODEC_TYPE_AUDIO;
83
+ c->codec_type = AVMEDIA_TYPE_AUDIO;
83
84
  c->bit_rate = audioBitRate;
84
85
  c->sample_rate = sampleRate;
85
86
  c->channels = channels;
@@ -273,7 +274,7 @@ void AVOutput::writeVideo( FramePtr frame ) throw (Error)
273
274
  packet.pts = av_rescale_q( c->coded_frame->pts, c->time_base,
274
275
  m_videoStream->time_base );
275
276
  if ( c->coded_frame->key_frame )
276
- packet.flags |= PKT_FLAG_KEY;
277
+ packet.flags |= AV_PKT_FLAG_KEY;
277
278
  packet.stream_index = m_videoStream->index;
278
279
  packet.data = (uint8_t *)m_videoBuf;
279
280
  packet.size = packetSize;
@@ -303,7 +304,7 @@ void AVOutput::writeAudio( SequencePtr frame ) throw (Error)
303
304
  if ( c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE )
304
305
  packet.pts = av_rescale_q( c->coded_frame->pts, c->time_base,
305
306
  m_audioStream->time_base );
306
- packet.flags |= PKT_FLAG_KEY;
307
+ packet.flags |= AV_PKT_FLAG_KEY;
307
308
  packet.stream_index = m_audioStream->index;
308
309
  packet.data = (uint8_t *)m_audioBuf;
309
310
  packet.size = packetSize;
@@ -444,8 +445,6 @@ VALUE AVOutput::registerRubyClass( VALUE rbModule )
444
445
  INT2FIX( CODEC_ID_VIXL ) );
445
446
  rb_define_const( cRubyClass, "CODEC_ID_QPEG",
446
447
  INT2FIX( CODEC_ID_QPEG ) );
447
- rb_define_const( cRubyClass, "CODEC_ID_XVID",
448
- INT2FIX( CODEC_ID_XVID ) );
449
448
  rb_define_const( cRubyClass, "CODEC_ID_PNG",
450
449
  INT2FIX( CODEC_ID_PNG ) );
451
450
  rb_define_const( cRubyClass, "CODEC_ID_PPM",
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hornetseye-ffmpeg
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 55
4
5
  prerelease:
5
- version: 0.11.0
6
+ segments:
7
+ - 0
8
+ - 11
9
+ - 2
10
+ version: 0.11.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - Jan Wedekind
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-08-02 00:00:00 Z
18
+ date: 2012-05-19 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: malloc
@@ -20,6 +25,10 @@ dependencies:
20
25
  requirements:
21
26
  - - ~>
22
27
  - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 1
31
+ - 2
23
32
  version: "1.2"
24
33
  type: :runtime
25
34
  version_requirements: *id001
@@ -31,6 +40,10 @@ dependencies:
31
40
  requirements:
32
41
  - - ~>
33
42
  - !ruby/object:Gem::Version
43
+ hash: 37
44
+ segments:
45
+ - 0
46
+ - 23
34
47
  version: "0.23"
35
48
  type: :runtime
36
49
  version_requirements: *id002
@@ -42,6 +55,10 @@ dependencies:
42
55
  requirements:
43
56
  - - ~>
44
57
  - !ruby/object:Gem::Version
58
+ hash: 29
59
+ segments:
60
+ - 0
61
+ - 11
45
62
  version: "0.11"
46
63
  type: :runtime
47
64
  version_requirements: *id003
@@ -53,6 +70,9 @@ dependencies:
53
70
  requirements:
54
71
  - - ">="
55
72
  - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
56
76
  version: "0"
57
77
  type: :development
58
78
  version_requirements: *id004
@@ -97,17 +117,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
117
  requirements:
98
118
  - - ">="
99
119
  - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
100
123
  version: "0"
101
124
  required_rubygems_version: !ruby/object:Gem::Requirement
102
125
  none: false
103
126
  requirements:
104
127
  - - ">="
105
128
  - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
106
132
  version: "0"
107
133
  requirements: []
108
134
 
109
135
  rubyforge_project: hornetseye
110
- rubygems_version: 1.8.5
136
+ rubygems_version: 1.8.15
111
137
  signing_key:
112
138
  specification_version: 3
113
139
  summary: Read/write video frames using libffmpeg