aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/exiv2_extractor.cc692
-rw-r--r--src/plugins/previewopus_extractor.c34
-rw-r--r--src/plugins/thumbnailffmpeg_extractor.c44
3 files changed, 381 insertions, 389 deletions
diff --git a/src/plugins/exiv2_extractor.cc b/src/plugins/exiv2_extractor.cc
index ef402a8..78f9bda 100644
--- a/src/plugins/exiv2_extractor.cc
+++ b/src/plugins/exiv2_extractor.cc
@@ -43,189 +43,194 @@ class ExtractorIO : public Exiv2::BasicIo
43{ 43{
44private: 44private:
45 45
46 /** 46/**
47 * Extract context we are using. 47 * Extract context we are using.
48 */ 48 */
49 struct EXTRACTOR_ExtractContext *ec; 49struct EXTRACTOR_ExtractContext *ec;
50 50
51public: 51public:
52 52
53 /** 53/**
54 * Constructor. 54 * Constructor.
55 * 55 *
56 * @param s_ec extract context to wrap 56 * @param s_ec extract context to wrap
57 */ 57 */
58 ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec) 58ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec)
59 { 59{
60 ec = s_ec; 60 ec = s_ec;
61 } 61}
62 62
63 /**
64 * Destructor.
65 */
66 virtual ~ExtractorIO ()
67 {
68 /* nothing to do */
69 }
70 63
71 /** 64/**
72 * Open stream. 65 * Destructor.
73 * 66 */
74 * @return 0 (always successful) 67virtual ~ExtractorIO ()
75 */ 68{
76 virtual int open (); 69 /* nothing to do */
77 70}
78 /** 71
79 * Close stream. 72
80 * 73/**
81 * @return 0 (always successful) 74 * Open stream.
82 */ 75 *
83 virtual int close (); 76 * @return 0 (always successful)
84 77 */
85 /** 78virtual int open ();
86 * Read up to 'rcount' bytes into a buffer 79
87 * 80/**
88 * @param rcount number of bytes to read 81 * Close stream.
89 * @return buffer with data read, empty buffer (!) on failure (!) 82 *
90 */ 83 * @return 0 (always successful)
91 virtual Exiv2::DataBuf read (long rcount); 84 */
92 85virtual int close ();
93 /** 86
94 * Read up to 'rcount' bytes into 'buf'. 87/**
95 * 88 * Read up to 'rcount' bytes into a buffer
96 * @param buf buffer to fill 89 *
97 * @param rcount size of 'buf' 90 * @param rcount number of bytes to read
98 * @return number of bytes read successfully, 0 on failure (!) 91 * @return buffer with data read, empty buffer (!) on failure (!)
99 */ 92 */
100 virtual long read (Exiv2::byte *buf, 93virtual Exiv2::DataBuf read (long rcount);
101 long rcount); 94
102 95/**
103 /** 96 * Read up to 'rcount' bytes into 'buf'.
104 * Read a single character. 97 *
105 * 98 * @param buf buffer to fill
106 * @return the character 99 * @param rcount size of 'buf'
107 * @throw exception on errors 100 * @return number of bytes read successfully, 0 on failure (!)
108 */ 101 */
109 virtual int getb (); 102virtual long read (Exiv2::byte *buf,
110 103 long rcount);
111 /** 104
112 * Write to stream. 105/**
113 * 106 * Read a single character.
114 * @param data data to write 107 *
115 * @param wcount how many bytes to write 108 * @return the character
116 * @return -1 (always fails) 109 * @throw exception on errors
117 */ 110 */
118 virtual long write (const Exiv2::byte *data, 111virtual int getb ();
119 long wcount); 112
120 113/**
121 /** 114 * Write to stream.
122 * Write to stream. 115 *
123 * 116 * @param data data to write
124 * @param src stream to copy 117 * @param wcount how many bytes to write
125 * @return -1 (always fails) 118 * @return -1 (always fails)
126 */ 119 */
127 virtual long write (Exiv2::BasicIo &src); 120virtual long write (const Exiv2::byte *data,
128 121 long wcount);
129 /** 122
130 * Write a single byte. 123/**
131 * 124 * Write to stream.
132 * @param data byte to write 125 *
133 * @return -1 (always fails) 126 * @param src stream to copy
134 */ 127 * @return -1 (always fails)
135 virtual int putb (Exiv2::byte data); 128 */
136 129virtual long write (Exiv2::BasicIo &src);
137 /** 130
138 * Not supported. 131/**
139 * 132 * Write a single byte.
140 * @throws error 133 *
141 */ 134 * @param data byte to write
142 virtual void transfer (Exiv2::BasicIo& src); 135 * @return -1 (always fails)
143 136 */
144 /** 137virtual int putb (Exiv2::byte data);
145 * Seek to the given offset. 138
146 * 139/**
147 * @param offset desired offset 140 * Not supported.
148 * @parma pos offset is relative to where? 141 *
149 * @return -1 on failure, 0 on success 142 * @throws error
150 */ 143 */
151 virtual int seek (long offset, 144virtual void transfer (Exiv2::BasicIo& src);
152 Exiv2::BasicIo::Position pos); 145
153 146/**
154 /** 147 * Seek to the given offset.
155 * Not supported. 148 *
156 * 149 * @param offset desired offset
157 * @throws error 150 * @parma pos offset is relative to where?
158 */ 151 * @return -1 on failure, 0 on success
159 virtual Exiv2::byte* mmap (bool isWritable); 152 */
160 153virtual int seek (long offset,
161 /** 154 Exiv2::BasicIo::Position pos);
162 * Not supported. 155
163 * 156/**
164 * @return -1 (error) 157 * Not supported.
165 */ 158 *
166 virtual int munmap (); 159 * @throws error
167 160 */
168 /** 161virtual Exiv2::byte*mmap (bool isWritable);
169 * Return our current offset in the file. 162
170 * 163/**
171 * @return -1 on error 164 * Not supported.
172 */ 165 *
173 virtual long int tell (void) const; 166 * @return -1 (error)
174 167 */
175 /** 168virtual int munmap ();
176 * Return overall size of the file. 169
177 * 170/**
178 * @return -1 on error 171 * Return our current offset in the file.
179 */ 172 *
180#if EXIV2_TEST_VERSION(0,26,0) 173 * @return -1 on error
181 virtual size_t size (void) const; 174 */
175virtual long int tell (void) const;
176
177/**
178 * Return overall size of the file.
179 *
180 * @return -1 on error
181 */
182#if EXIV2_TEST_VERSION (0,26,0)
183virtual size_t size (void) const;
184
182#else 185#else
183 virtual long int size (void) const; 186virtual long int size (void) const;
187
184#endif 188#endif
185 189
186 /** 190/**
187 * Check if file is open. 191 * Check if file is open.
188 * 192 *
189 * @return true (always). 193 * @return true (always).
190 */ 194 */
191 virtual bool isopen () const; 195virtual bool isopen () const;
192 196
193 /** 197/**
194 * Check if this file source is in error mode. 198 * Check if this file source is in error mode.
195 * 199 *
196 * @return 0 (always all is fine). 200 * @return 0 (always all is fine).
197 */ 201 */
198 virtual int error () const; 202virtual int error () const;
199 203
200 /** 204/**
201 * Check if current position of the file is at the end 205 * Check if current position of the file is at the end
202 * 206 *
203 * @return true if at EOF, false if not. 207 * @return true if at EOF, false if not.
204 */ 208 */
205 virtual bool eof () const; 209virtual bool eof () const;
206 210
207 /** 211/**
208 * Not supported. 212 * Not supported.
209 * 213 *
210 * @throws error 214 * @throws error
211 */ 215 */
212 virtual std::string path () const; 216virtual std::string path () const;
213 217
214#ifdef EXV_UNICODE_PATH 218#ifdef EXV_UNICODE_PATH
215 /** 219/**
216 * Not supported. 220 * Not supported.
217 * 221 *
218 * @throws error 222 * @throws error
219 */ 223 */
220 virtual std::wstring wpath () const; 224virtual std::wstring wpath () const;
225
221#endif 226#endif
222 227
223 /** 228/**
224 * Not supported. 229 * Not supported.
225 * 230 *
226 * @throws error 231 * @throws error
227 */ 232 */
228 virtual Exiv2::BasicIo::AutoPtr temporary () const; 233virtual Exiv2::BasicIo::AutoPtr temporary () const;
229 234
230}; 235};
231 236
@@ -241,6 +246,7 @@ ExtractorIO::open ()
241 return 0; 246 return 0;
242} 247}
243 248
249
244/** 250/**
245 * Close stream. 251 * Close stream.
246 * 252 *
@@ -280,7 +286,7 @@ ExtractorIO::read (long rcount)
280 */ 286 */
281long 287long
282ExtractorIO::read (Exiv2::byte *buf, 288ExtractorIO::read (Exiv2::byte *buf,
283 long rcount) 289 long rcount)
284{ 290{
285 void *data; 291 void *data;
286 ssize_t ret; 292 ssize_t ret;
@@ -288,14 +294,14 @@ ExtractorIO::read (Exiv2::byte *buf,
288 294
289 got = 0; 295 got = 0;
290 while (got < rcount) 296 while (got < rcount)
291 { 297 {
292 if (-1 == (ret = ec->read (ec->cls, &data, rcount - got))) 298 if (-1 == (ret = ec->read (ec->cls, &data, rcount - got)))
293 return got; 299 return got;
294 if (0 == ret) 300 if (0 == ret)
295 break; 301 break;
296 memcpy (&buf[got], data, ret); 302 memcpy (&buf[got], data, ret);
297 got += ret; 303 got += ret;
298 } 304 }
299 return got; 305 return got;
300} 306}
301 307
@@ -313,7 +319,7 @@ ExtractorIO::getb ()
313 const unsigned char *r; 319 const unsigned char *r;
314 320
315 if (1 != ec->read (ec->cls, &data, 1)) 321 if (1 != ec->read (ec->cls, &data, 1))
316#if EXIV2_TEST_VERSION(0,27,0) 322#if EXIV2_TEST_VERSION (0,27,0)
317 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 323 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
318#else 324#else
319 throw Exiv2::BasicError<char> (42 /* error code */); 325 throw Exiv2::BasicError<char> (42 /* error code */);
@@ -332,7 +338,7 @@ ExtractorIO::getb ()
332 */ 338 */
333long 339long
334ExtractorIO::write (const Exiv2::byte *data, 340ExtractorIO::write (const Exiv2::byte *data,
335 long wcount) 341 long wcount)
336{ 342{
337 return -1; 343 return -1;
338} 344}
@@ -372,8 +378,8 @@ ExtractorIO::putb (Exiv2::byte data)
372void 378void
373ExtractorIO::transfer (Exiv2::BasicIo& src) 379ExtractorIO::transfer (Exiv2::BasicIo& src)
374{ 380{
375#if EXIV2_TEST_VERSION(0,27,0) 381#if EXIV2_TEST_VERSION (0,27,0)
376 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 382 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
377#else 383#else
378 throw Exiv2::BasicError<char> (42 /* error code */); 384 throw Exiv2::BasicError<char> (42 /* error code */);
379#endif 385#endif
@@ -389,24 +395,24 @@ ExtractorIO::transfer (Exiv2::BasicIo& src)
389 */ 395 */
390int 396int
391ExtractorIO::seek (long offset, 397ExtractorIO::seek (long offset,
392 Exiv2::BasicIo::Position pos) 398 Exiv2::BasicIo::Position pos)
393{ 399{
394 int rel; 400 int rel;
395 401
396 switch (pos) 402 switch (pos)
397 { 403 {
398 case beg: // Exiv2::BasicIo::beg: 404 case beg: // Exiv2::BasicIo::beg:
399 rel = SEEK_SET; 405 rel = SEEK_SET;
400 break; 406 break;
401 case cur: 407 case cur:
402 rel = SEEK_CUR; 408 rel = SEEK_CUR;
403 break; 409 break;
404 case end: 410 case end:
405 rel = SEEK_END; 411 rel = SEEK_END;
406 break; 412 break;
407 default: 413 default:
408 abort (); 414 abort ();
409 } 415 }
410 if (-1 == ec->seek (ec->cls, offset, rel)) 416 if (-1 == ec->seek (ec->cls, offset, rel))
411 return -1; 417 return -1;
412 return 0; 418 return 0;
@@ -421,8 +427,8 @@ ExtractorIO::seek (long offset,
421Exiv2::byte * 427Exiv2::byte *
422ExtractorIO::mmap (bool isWritable) 428ExtractorIO::mmap (bool isWritable)
423{ 429{
424#if EXIV2_TEST_VERSION(0,27,0) 430#if EXIV2_TEST_VERSION (0,27,0)
425 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 431 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
426#else 432#else
427 throw Exiv2::BasicError<char> (42 /* error code */); 433 throw Exiv2::BasicError<char> (42 /* error code */);
428#endif 434#endif
@@ -458,7 +464,7 @@ ExtractorIO::tell (void) const
458 * 464 *
459 * @return -1 on error 465 * @return -1 on error
460 */ 466 */
461#if EXIV2_TEST_VERSION(0,26,0) 467#if EXIV2_TEST_VERSION (0,26,0)
462size_t 468size_t
463#else 469#else
464long int 470long int
@@ -513,8 +519,8 @@ ExtractorIO::eof () const
513std::string 519std::string
514ExtractorIO::path () const 520ExtractorIO::path () const
515{ 521{
516#if EXIV2_TEST_VERSION(0,27,0) 522#if EXIV2_TEST_VERSION (0,27,0)
517 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 523 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
518#else 524#else
519 throw Exiv2::BasicError<char> (42 /* error code */); 525 throw Exiv2::BasicError<char> (42 /* error code */);
520#endif 526#endif
@@ -530,12 +536,14 @@ ExtractorIO::path () const
530std::wstring 536std::wstring
531ExtractorIO::wpath () const 537ExtractorIO::wpath () const
532{ 538{
533#if EXIV2_TEST_VERSION(0,27,0) 539#if EXIV2_TEST_VERSION (0,27,0)
534 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 540 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
535#else 541#else
536 throw Exiv2::BasicError<char> (42 /* error code */); 542 throw Exiv2::BasicError<char> (42 /* error code */);
537#endif 543#endif
538} 544}
545
546
539#endif 547#endif
540 548
541 549
@@ -548,8 +556,8 @@ Exiv2::BasicIo::AutoPtr
548ExtractorIO::temporary () const 556ExtractorIO::temporary () const
549{ 557{
550 fprintf (stderr, "throwing temporary error\n"); 558 fprintf (stderr, "throwing temporary error\n");
551#if EXIV2_TEST_VERSION(0,27,0) 559#if EXIV2_TEST_VERSION (0,27,0)
552 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed); 560 throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
553#else 561#else
554 throw Exiv2::BasicError<char> (42 /* error code */); 562 throw Exiv2::BasicError<char> (42 /* error code */);
555#endif 563#endif
@@ -563,7 +571,11 @@ ExtractorIO::temporary () const
563 * @param s 0-terminated UTF8 string value with the meta data 571 * @param s 0-terminated UTF8 string value with the meta data
564 * @param type libextractor type for the meta data 572 * @param type libextractor type for the meta data
565 */ 573 */
566#define ADD(s, type) do { if (0 != proc (proc_cls, "exiv2", type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return 1; } while (0) 574#define ADD(s, type) do { if (0 != proc (proc_cls, "exiv2", type, \
575 EXTRACTOR_METAFORMAT_UTF8, \
576 "text/plain", s, strlen (s) \
577 + 1)) return 1; \
578} while (0)
567 579
568 580
569/** 581/**
@@ -579,10 +591,10 @@ ExtractorIO::temporary () const
579 */ 591 */
580static int 592static int
581add_exiv2_tag (const Exiv2::ExifData& exifData, 593add_exiv2_tag (const Exiv2::ExifData& exifData,
582 const std::string& key, 594 const std::string& key,
583 enum EXTRACTOR_MetaType type, 595 enum EXTRACTOR_MetaType type,
584 EXTRACTOR_MetaDataProcessor proc, 596 EXTRACTOR_MetaDataProcessor proc,
585 void *proc_cls) 597 void *proc_cls)
586{ 598{
587 const char *str; 599 const char *str;
588 Exiv2::ExifKey ek (key); 600 Exiv2::ExifKey ek (key);
@@ -590,8 +602,8 @@ add_exiv2_tag (const Exiv2::ExifData& exifData,
590 602
591 if (exifData.end () == md) 603 if (exifData.end () == md)
592 return 0; /* not found */ 604 return 0; /* not found */
593 std::string ccstr = Exiv2::toString(*md); 605 std::string ccstr = Exiv2::toString (*md);
594 str = ccstr.c_str(); 606 str = ccstr.c_str ();
595 /* skip over whitespace */ 607 /* skip over whitespace */
596 while ( (strlen (str) > 0) && isspace ((unsigned char) str[0])) 608 while ( (strlen (str) > 0) && isspace ((unsigned char) str[0]))
597 str++; 609 str++;
@@ -615,28 +627,28 @@ add_exiv2_tag (const Exiv2::ExifData& exifData,
615 */ 627 */
616static int 628static int
617add_iptc_data (const Exiv2::IptcData& iptcData, 629add_iptc_data (const Exiv2::IptcData& iptcData,
618 const std::string& key, 630 const std::string& key,
619 enum EXTRACTOR_MetaType type, 631 enum EXTRACTOR_MetaType type,
620 EXTRACTOR_MetaDataProcessor proc, 632 EXTRACTOR_MetaDataProcessor proc,
621 void *proc_cls) 633 void *proc_cls)
622{ 634{
623 const char *str; 635 const char *str;
624 Exiv2::IptcKey ek (key); 636 Exiv2::IptcKey ek (key);
625 Exiv2::IptcData::const_iterator md = iptcData.findKey (ek); 637 Exiv2::IptcData::const_iterator md = iptcData.findKey (ek);
626 638
627 while (iptcData.end () != md) 639 while (iptcData.end () != md)
628 { 640 {
629 if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ())) 641 if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ()))
630 break; 642 break;
631 std::string ccstr = Exiv2::toString (*md); 643 std::string ccstr = Exiv2::toString (*md);
632 str = ccstr.c_str (); 644 str = ccstr.c_str ();
633 /* skip over whitespace */ 645 /* skip over whitespace */
634 while ((strlen (str) > 0) && isspace ((unsigned char) str[0])) 646 while ((strlen (str) > 0) && isspace ((unsigned char) str[0]))
635 str++; 647 str++;
636 if (strlen (str) > 0) 648 if (strlen (str) > 0)
637 ADD (str, type); 649 ADD (str, type);
638 md++; 650 md++;
639 } 651 }
640 return 0; 652 return 0;
641} 653}
642 654
@@ -654,26 +666,27 @@ add_iptc_data (const Exiv2::IptcData& iptcData,
654 */ 666 */
655static int 667static int
656add_xmp_data (const Exiv2::XmpData& xmpData, 668add_xmp_data (const Exiv2::XmpData& xmpData,
657 const std::string& key, 669 const std::string& key,
658 enum EXTRACTOR_MetaType type, 670 enum EXTRACTOR_MetaType type,
659 EXTRACTOR_MetaDataProcessor proc, 671 EXTRACTOR_MetaDataProcessor proc,
660 void *proc_cls) 672 void *proc_cls)
661{ 673{
662 const char * str; 674 const char *str;
663 Exiv2::XmpKey ek (key); 675 Exiv2::XmpKey ek (key);
664 Exiv2::XmpData::const_iterator md = xmpData.findKey (ek); 676 Exiv2::XmpData::const_iterator md = xmpData.findKey (ek);
665 677
666 while (xmpData.end () != md) 678 while (xmpData.end () != md)
667 { 679 {
668 if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ())) 680 if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ()))
669 break; 681 break;
670 std::string ccstr = Exiv2::toString (*md); 682 std::string ccstr = Exiv2::toString (*md);
671 str = ccstr.c_str (); 683 str = ccstr.c_str ();
672 while ( (strlen (str) > 0) && isspace ((unsigned char) str[0])) str++; 684 while ( (strlen (str) > 0) && isspace ((unsigned char) str[0]))
673 if (strlen (str) > 0) 685 str++;
674 ADD (str, type); 686 if (strlen (str) > 0)
675 md++; 687 ADD (str, type);
676 } 688 md++;
689 }
677 return 0; 690 return 0;
678} 691}
679 692
@@ -685,7 +698,8 @@ add_xmp_data (const Exiv2::XmpData& xmpData,
685 * @param s key to lookup 698 * @param s key to lookup
686 * @param type libextractor type to use for the meta data found under the given key 699 * @param type libextractor type to use for the meta data found under the given key
687 */ 700 */
688#define ADDEXIV(s,t) do { if (0 != add_exiv2_tag (exifData, s, t, ec->proc, ec->cls)) return; } while (0) 701#define ADDEXIV(s,t) do { if (0 != add_exiv2_tag (exifData, s, t, ec->proc, \
702 ec->cls)) return; } while (0)
689 703
690 704
691/** 705/**
@@ -695,7 +709,8 @@ add_xmp_data (const Exiv2::XmpData& xmpData,
695 * @param s key to lookup 709 * @param s key to lookup
696 * @param type libextractor type to use for the meta data found under the given key 710 * @param type libextractor type to use for the meta data found under the given key
697 */ 711 */
698#define ADDIPTC(s,t) do { if (0 != add_iptc_data (iptcData, s, t, ec->proc, ec->cls)) return; } while (0) 712#define ADDIPTC(s,t) do { if (0 != add_iptc_data (iptcData, s, t, ec->proc, \
713 ec->cls)) return; } while (0)
699 714
700 715
701/** 716/**
@@ -705,7 +720,8 @@ add_xmp_data (const Exiv2::XmpData& xmpData,
705 * @param s key to lookup 720 * @param s key to lookup
706 * @param type libextractor type to use for the meta data found under the given key 721 * @param type libextractor type to use for the meta data found under the given key
707 */ 722 */
708#define ADDXMP(s,t) do { if (0 != add_xmp_data (xmpData, s, t, ec->proc, ec->cls)) return; } while (0) 723#define ADDXMP(s,t) do { if (0 != add_xmp_data (xmpData, s, t, ec->proc, \
724 ec->cls)) return; } while (0)
709 725
710 726
711/** 727/**
@@ -717,97 +733,105 @@ extern "C" void
717EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec) 733EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec)
718{ 734{
719 try 735 try
720 { 736 {
721#if !EXIV2_TEST_VERSION(0,24,0) 737#if ! EXIV2_TEST_VERSION (0,24,0)
722 Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute); 738 Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute);
723#endif 739#endif
724 std::auto_ptr<Exiv2::BasicIo> eio(new ExtractorIO (ec)); 740 std::auto_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec));
725 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio); 741 Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio);
726 if (0 == image.get ()) 742 if (0 == image.get ())
727 return; 743 return;
728 image->readMetadata (); 744 image->readMetadata ();
729 Exiv2::ExifData &exifData = image->exifData (); 745 Exiv2::ExifData &exifData = image->exifData ();
730 if (! exifData.empty ()) 746 if (! exifData.empty ())
731 {
732 ADDEXIV ("Exif.Image.Copyright", EXTRACTOR_METATYPE_COPYRIGHT);
733 ADDEXIV ("Exif.Photo.UserComment", EXTRACTOR_METATYPE_COMMENT);
734 ADDEXIV ("Exif.GPSInfo.GPSLatitudeRef", EXTRACTOR_METATYPE_GPS_LATITUDE_REF);
735 ADDEXIV ("Exif.GPSInfo.GPSLatitude", EXTRACTOR_METATYPE_GPS_LATITUDE);
736 ADDEXIV ("Exif.GPSInfo.GPSLongitudeRef", EXTRACTOR_METATYPE_GPS_LONGITUDE_REF);
737 ADDEXIV ("Exif.GPSInfo.GPSLongitude", EXTRACTOR_METATYPE_GPS_LONGITUDE);
738 ADDEXIV ("Exif.Image.Make", EXTRACTOR_METATYPE_CAMERA_MAKE);
739 ADDEXIV ("Exif.Image.Model", EXTRACTOR_METATYPE_CAMERA_MODEL);
740 ADDEXIV ("Exif.Image.Orientation", EXTRACTOR_METATYPE_ORIENTATION);
741 ADDEXIV ("Exif.Photo.DateTimeOriginal", EXTRACTOR_METATYPE_CREATION_DATE);
742 ADDEXIV ("Exif.Photo.ExposureBiasValue", EXTRACTOR_METATYPE_EXPOSURE_BIAS);
743 ADDEXIV ("Exif.Photo.Flash", EXTRACTOR_METATYPE_FLASH);
744 ADDEXIV ("Exif.CanonSi.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
745 ADDEXIV ("Exif.Panasonic.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
746 ADDEXIV ("Exif.Olympus.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
747 ADDEXIV ("Exif.Photo.FocalLength", EXTRACTOR_METATYPE_FOCAL_LENGTH);
748 ADDEXIV ("Exif.Photo.FocalLengthIn35mmFilm", EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM);
749 ADDEXIV ("Exif.Photo.ISOSpeedRatings", EXTRACTOR_METATYPE_ISO_SPEED);
750 ADDEXIV ("Exif.CanonSi.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
751 ADDEXIV ("Exif.Nikon1.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
752 ADDEXIV ("Exif.Nikon2.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
753 ADDEXIV ("Exif.Nikon3.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
754 ADDEXIV ("Exif.Photo.ExposureProgram", EXTRACTOR_METATYPE_EXPOSURE_MODE);
755 ADDEXIV ("Exif.CanonCs.ExposureProgram", EXTRACTOR_METATYPE_EXPOSURE_MODE);
756 ADDEXIV ("Exif.Photo.MeteringMode", EXTRACTOR_METATYPE_METERING_MODE);
757 ADDEXIV ("Exif.CanonCs.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
758 ADDEXIV ("Exif.Fujifilm.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
759 ADDEXIV ("Exif.Olympus.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
760 ADDEXIV ("Exif.Panasonic.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
761 ADDEXIV ("Exif.CanonCs.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
762 ADDEXIV ("Exif.Fujifilm.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
763 ADDEXIV ("Exif.Sigma.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
764 ADDEXIV ("Exif.Nikon1.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
765 ADDEXIV ("Exif.Nikon2.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
766 ADDEXIV ("Exif.Nikon3.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
767 ADDEXIV ("Exif.Olympus.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
768 ADDEXIV ("Exif.Panasonic.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
769 ADDEXIV ("Exif.CanonSi.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
770 ADDEXIV ("Exif.Fujifilm.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
771 ADDEXIV ("Exif.Sigma.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
772 ADDEXIV ("Exif.Nikon1.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
773 ADDEXIV ("Exif.Nikon2.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
774 ADDEXIV ("Exif.Nikon3.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
775 ADDEXIV ("Exif.Olympus.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
776 ADDEXIV ("Exif.Panasonic.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
777 ADDEXIV ("Exif.Photo.FNumber", EXTRACTOR_METATYPE_APERTURE);
778 ADDEXIV ("Exif.Photo.ExposureTime", EXTRACTOR_METATYPE_EXPOSURE);
779 }
780
781 Exiv2::IptcData &iptcData = image->iptcData();
782 if (! iptcData.empty())
783 {
784 ADDIPTC ("Iptc.Application2.Keywords", EXTRACTOR_METATYPE_KEYWORDS);
785 ADDIPTC ("Iptc.Application2.City", EXTRACTOR_METATYPE_LOCATION_CITY);
786 ADDIPTC ("Iptc.Application2.SubLocation", EXTRACTOR_METATYPE_LOCATION_SUBLOCATION);
787 ADDIPTC ("Iptc.Application2.CountryName", EXTRACTOR_METATYPE_LOCATION_COUNTRY);
788 }
789
790 Exiv2::XmpData &xmpData = image->xmpData();
791 if (! xmpData.empty())
792 {
793 ADDXMP ("Xmp.photoshop.Country", EXTRACTOR_METATYPE_LOCATION_COUNTRY);
794 ADDXMP ("Xmp.photoshop.City", EXTRACTOR_METATYPE_LOCATION_CITY);
795 ADDXMP ("Xmp.xmp.Rating", EXTRACTOR_METATYPE_RATING);
796 ADDXMP ("Xmp.MicrosoftPhoto.Rating", EXTRACTOR_METATYPE_RATING);
797 ADDXMP ("Xmp.iptc.CountryCode", EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE);
798 ADDXMP ("Xmp.xmp.CreatorTool", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
799 ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT);
800 }
801 }
802 catch (const Exiv2::AnyError& e)
803 { 747 {
804#if DEBUG 748 ADDEXIV ("Exif.Image.Copyright", EXTRACTOR_METATYPE_COPYRIGHT);
805 std::cerr << "Caught Exiv2 exception '" << e << "'\n"; 749 ADDEXIV ("Exif.Photo.UserComment", EXTRACTOR_METATYPE_COMMENT);
806#endif 750 ADDEXIV ("Exif.GPSInfo.GPSLatitudeRef",
751 EXTRACTOR_METATYPE_GPS_LATITUDE_REF);
752 ADDEXIV ("Exif.GPSInfo.GPSLatitude", EXTRACTOR_METATYPE_GPS_LATITUDE);
753 ADDEXIV ("Exif.GPSInfo.GPSLongitudeRef",
754 EXTRACTOR_METATYPE_GPS_LONGITUDE_REF);
755 ADDEXIV ("Exif.GPSInfo.GPSLongitude", EXTRACTOR_METATYPE_GPS_LONGITUDE);
756 ADDEXIV ("Exif.Image.Make", EXTRACTOR_METATYPE_CAMERA_MAKE);
757 ADDEXIV ("Exif.Image.Model", EXTRACTOR_METATYPE_CAMERA_MODEL);
758 ADDEXIV ("Exif.Image.Orientation", EXTRACTOR_METATYPE_ORIENTATION);
759 ADDEXIV ("Exif.Photo.DateTimeOriginal", EXTRACTOR_METATYPE_CREATION_DATE);
760 ADDEXIV ("Exif.Photo.ExposureBiasValue",
761 EXTRACTOR_METATYPE_EXPOSURE_BIAS);
762 ADDEXIV ("Exif.Photo.Flash", EXTRACTOR_METATYPE_FLASH);
763 ADDEXIV ("Exif.CanonSi.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
764 ADDEXIV ("Exif.Panasonic.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
765 ADDEXIV ("Exif.Olympus.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
766 ADDEXIV ("Exif.Photo.FocalLength", EXTRACTOR_METATYPE_FOCAL_LENGTH);
767 ADDEXIV ("Exif.Photo.FocalLengthIn35mmFilm",
768 EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM);
769 ADDEXIV ("Exif.Photo.ISOSpeedRatings", EXTRACTOR_METATYPE_ISO_SPEED);
770 ADDEXIV ("Exif.CanonSi.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
771 ADDEXIV ("Exif.Nikon1.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
772 ADDEXIV ("Exif.Nikon2.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
773 ADDEXIV ("Exif.Nikon3.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
774 ADDEXIV ("Exif.Photo.ExposureProgram", EXTRACTOR_METATYPE_EXPOSURE_MODE);
775 ADDEXIV ("Exif.CanonCs.ExposureProgram",
776 EXTRACTOR_METATYPE_EXPOSURE_MODE);
777 ADDEXIV ("Exif.Photo.MeteringMode", EXTRACTOR_METATYPE_METERING_MODE);
778 ADDEXIV ("Exif.CanonCs.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
779 ADDEXIV ("Exif.Fujifilm.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
780 ADDEXIV ("Exif.Olympus.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
781 ADDEXIV ("Exif.Panasonic.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
782 ADDEXIV ("Exif.CanonCs.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
783 ADDEXIV ("Exif.Fujifilm.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
784 ADDEXIV ("Exif.Sigma.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
785 ADDEXIV ("Exif.Nikon1.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
786 ADDEXIV ("Exif.Nikon2.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
787 ADDEXIV ("Exif.Nikon3.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
788 ADDEXIV ("Exif.Olympus.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
789 ADDEXIV ("Exif.Panasonic.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
790 ADDEXIV ("Exif.CanonSi.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
791 ADDEXIV ("Exif.Fujifilm.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
792 ADDEXIV ("Exif.Sigma.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
793 ADDEXIV ("Exif.Nikon1.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
794 ADDEXIV ("Exif.Nikon2.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
795 ADDEXIV ("Exif.Nikon3.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
796 ADDEXIV ("Exif.Olympus.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
797 ADDEXIV ("Exif.Panasonic.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
798 ADDEXIV ("Exif.Photo.FNumber", EXTRACTOR_METATYPE_APERTURE);
799 ADDEXIV ("Exif.Photo.ExposureTime", EXTRACTOR_METATYPE_EXPOSURE);
807 } 800 }
808 catch (void *anything) 801
802 Exiv2::IptcData &iptcData = image->iptcData ();
803 if (! iptcData.empty ())
804 {
805 ADDIPTC ("Iptc.Application2.Keywords", EXTRACTOR_METATYPE_KEYWORDS);
806 ADDIPTC ("Iptc.Application2.City", EXTRACTOR_METATYPE_LOCATION_CITY);
807 ADDIPTC ("Iptc.Application2.SubLocation",
808 EXTRACTOR_METATYPE_LOCATION_SUBLOCATION);
809 ADDIPTC ("Iptc.Application2.CountryName",
810 EXTRACTOR_METATYPE_LOCATION_COUNTRY);
811 }
812
813 Exiv2::XmpData &xmpData = image->xmpData ();
814 if (! xmpData.empty ())
809 { 815 {
816 ADDXMP ("Xmp.photoshop.Country", EXTRACTOR_METATYPE_LOCATION_COUNTRY);
817 ADDXMP ("Xmp.photoshop.City", EXTRACTOR_METATYPE_LOCATION_CITY);
818 ADDXMP ("Xmp.xmp.Rating", EXTRACTOR_METATYPE_RATING);
819 ADDXMP ("Xmp.MicrosoftPhoto.Rating", EXTRACTOR_METATYPE_RATING);
820 ADDXMP ("Xmp.iptc.CountryCode", EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE);
821 ADDXMP ("Xmp.xmp.CreatorTool", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
822 ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT);
810 } 823 }
824 }
825 catch (const Exiv2::AnyError& e)
826 {
827#if DEBUG
828 std::cerr << "Caught Exiv2 exception '" << e << "'\n";
829#endif
830 }
831 catch (void *anything)
832 {
833 }
811} 834}
812 835
836
813/* end of exiv2_extractor.cc */ 837/* end of exiv2_extractor.cc */
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c
index 9423dcd..a47cdbc 100644
--- a/src/plugins/previewopus_extractor.c
+++ b/src/plugins/previewopus_extractor.c
@@ -37,35 +37,13 @@
37#include "extractor.h" 37#include "extractor.h"
38#include <magic.h> 38#include <magic.h>
39 39
40#if HAVE_LIBAVUTIL_AVUTIL_H
41#include <libavutil/avutil.h> 40#include <libavutil/avutil.h>
42#include <libavutil/audio_fifo.h> 41#include <libavutil/audio_fifo.h>
43#include <libavutil/opt.h> 42#include <libavutil/opt.h>
44#include <libavutil/mathematics.h> 43#include <libavutil/mathematics.h>
45
46#elif HAVE_FFMPEG_AVUTIL_H
47#include <ffmpeg/avutil.h>
48#include <ffmpeg/audio_fifo.h>
49#include <ffmpeg/opt.h>
50#include <ffmpeg/mathematics.h>
51#endif
52#if HAVE_LIBAVFORMAT_AVFORMAT_H
53#include <libavformat/avformat.h> 44#include <libavformat/avformat.h>
54#elif HAVE_FFMPEG_AVFORMAT_H
55#include <ffmpeg/avformat.h>
56#endif
57#if HAVE_LIBAVCODEC_AVCODEC_H
58#include <libavcodec/avcodec.h> 45#include <libavcodec/avcodec.h>
59#elif HAVE_FFMPEG_AVCODEC_H
60#include <ffmpeg/avcodec.h>
61#endif
62#if HAVE_LIBSWSCALE_SWSCALE_H
63#include <libswscale/swscale.h> 46#include <libswscale/swscale.h>
64#elif HAVE_FFMPEG_SWSCALE_H
65#include <ffmpeg/swscale.h>
66#endif
67
68// TODO: Check for ffmpeg
69#include <libavresample/avresample.h> 47#include <libavresample/avresample.h>
70 48
71 49
@@ -466,7 +444,7 @@ decode_audio_frame (AVFrame *frame,
466 fprintf (stderr, "Could not decode frame (error '%s')\n", 444 fprintf (stderr, "Could not decode frame (error '%s')\n",
467 get_error_text (error)); 445 get_error_text (error));
468#endif 446#endif
469 av_free_packet (&input_packet); 447 av_packet_unref (&input_packet);
470 return error; 448 return error;
471 } 449 }
472 450
@@ -476,7 +454,7 @@ decode_audio_frame (AVFrame *frame,
476 */ 454 */
477 if (*finished && *data_present) 455 if (*finished && *data_present)
478 *finished = 0; 456 *finished = 0;
479 av_free_packet (&input_packet); 457 av_packet_unref (&input_packet);
480 return 0; 458 return 0;
481} 459}
482 460
@@ -810,7 +788,7 @@ encode_audio_frame (AVFrame *frame,
810 fprintf (stderr, "Could not encode frame (error '%s')\n", 788 fprintf (stderr, "Could not encode frame (error '%s')\n",
811 get_error_text (error)); 789 get_error_text (error));
812#endif 790#endif
813 av_free_packet (&output_packet); 791 av_packet_unref (&output_packet);
814 return error; 792 return error;
815 } 793 }
816 794
@@ -824,11 +802,11 @@ encode_audio_frame (AVFrame *frame,
824 get_error_text (error)); 802 get_error_text (error));
825#endif 803#endif
826 804
827 av_free_packet (&output_packet); 805 av_packet_unref (&output_packet);
828 return error; 806 return error;
829 } 807 }
830 808
831 av_free_packet (&output_packet); 809 av_packet_unref (&output_packet);
832 } 810 }
833 811
834 return 0; 812 return 0;
@@ -1261,8 +1239,6 @@ void __attribute__ ((constructor))
1261previewopus_lib_init (void) 1239previewopus_lib_init (void)
1262{ 1240{
1263 av_log_set_callback (&previewopus_av_log_callback); 1241 av_log_set_callback (&previewopus_av_log_callback);
1264 av_register_all ();
1265
1266} 1242}
1267 1243
1268 1244
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c
index 72f0137..9bed4ec 100644
--- a/src/plugins/thumbnailffmpeg_extractor.c
+++ b/src/plugins/thumbnailffmpeg_extractor.c
@@ -38,26 +38,11 @@
38#include "extractor.h" 38#include "extractor.h"
39#include <magic.h> 39#include <magic.h>
40 40
41#if HAVE_LIBAVUTIL_AVUTIL_H
42#include <libavutil/avutil.h> 41#include <libavutil/avutil.h>
43#elif HAVE_FFMPEG_AVUTIL_H 42#include <libavutil/imgutils.h>
44#include <ffmpeg/avutil.h>
45#endif
46#if HAVE_LIBAVFORMAT_AVFORMAT_H
47#include <libavformat/avformat.h> 43#include <libavformat/avformat.h>
48#elif HAVE_FFMPEG_AVFORMAT_H
49#include <ffmpeg/avformat.h>
50#endif
51#if HAVE_LIBAVCODEC_AVCODEC_H
52#include <libavcodec/avcodec.h> 44#include <libavcodec/avcodec.h>
53#elif HAVE_FFMPEG_AVCODEC_H
54#include <ffmpeg/avcodec.h>
55#endif
56#if HAVE_LIBSWSCALE_SWSCALE_H
57#include <libswscale/swscale.h> 45#include <libswscale/swscale.h>
58#elif HAVE_FFMPEG_SWSCALE_H
59#include <ffmpeg/swscale.h>
60#endif
61 46
62#if USE_JPEG 47#if USE_JPEG
63#ifdef PIX_FMT_YUVJ420P 48#ifdef PIX_FMT_YUVJ420P
@@ -257,8 +242,10 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
257 return 0; 242 return 0;
258 } 243 }
259 if (NULL == (dst_buffer = 244 if (NULL == (dst_buffer =
260 av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT, 245 av_malloc (av_image_get_buffer_size (PIX_OUTPUT_FORMAT,
261 dst_width, dst_height)))) 246 dst_width,
247 dst_height,
248 1))))
262 { 249 {
263#if DEBUG 250#if DEBUG
264 fprintf (stderr, 251 fprintf (stderr,
@@ -272,9 +259,13 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
272 sws_freeContext (scaler_ctx); 259 sws_freeContext (scaler_ctx);
273 return 0; 260 return 0;
274 } 261 }
275 avpicture_fill ((AVPicture *) dst_frame, dst_buffer, 262 av_image_fill_arrays (dst_frame->data,
276 PIX_OUTPUT_FORMAT, 263 dst_frame->linesize,
277 dst_width, dst_height); 264 dst_buffer,
265 PIX_OUTPUT_FORMAT,
266 dst_width,
267 dst_height,
268 1);
278 sws_scale (scaler_ctx, 269 sws_scale (scaler_ctx,
279 src_data, 270 src_data,
280 src_stride, 271 src_stride,
@@ -383,7 +374,7 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
383 err = pkt.size; 374 err = pkt.size;
384 memcpy (encoder_output_buffer,pkt.data, pkt.size); 375 memcpy (encoder_output_buffer,pkt.data, pkt.size);
385 376
386 av_free_packet (&pkt); 377 av_packet_unref (&pkt);
387 378
388 379
389#else 380#else
@@ -622,6 +613,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
622 AVIOContext *io_ctx; 613 AVIOContext *io_ctx;
623 struct AVFormatContext *format_ctx; 614 struct AVFormatContext *format_ctx;
624 AVCodecContext *codec_ctx; 615 AVCodecContext *codec_ctx;
616 AVCodecParameters *codecpar;
625 AVCodec *codec; 617 AVCodec *codec;
626 AVDictionary *options; 618 AVDictionary *options;
627 AVFrame *frame; 619 AVFrame *frame;
@@ -675,10 +667,11 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
675 video_stream_index = -1; 667 video_stream_index = -1;
676 for (i = 0; i<format_ctx->nb_streams; i++) 668 for (i = 0; i<format_ctx->nb_streams; i++)
677 { 669 {
670 codecpar = format_ctx->streams[i]->codecpar;
678 codec_ctx = format_ctx->streams[i]->codec; 671 codec_ctx = format_ctx->streams[i]->codec;
679 if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type) 672 if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type)
680 continue; 673 continue;
681 if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id))) 674 if (NULL == (codec = avcodec_find_decoder (codecpar->codec_id)))
682 continue; 675 continue;
683 options = NULL; 676 options = NULL;
684 if (0 != (err = avcodec_open2 (codec_ctx, codec, &options))) 677 if (0 != (err = avcodec_open2 (codec_ctx, codec, &options)))
@@ -760,11 +753,11 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
760 &packet); 753 &packet);
761 if (frame_finished && frame->key_frame) 754 if (frame_finished && frame->key_frame)
762 { 755 {
763 av_free_packet (&packet); 756 av_packet_unref (&packet);
764 break; 757 break;
765 } 758 }
766 } 759 }
767 av_free_packet (&packet); 760 av_packet_unref (&packet);
768 } 761 }
769 762
770 if (! frame_finished) 763 if (! frame_finished)
@@ -945,7 +938,6 @@ void __attribute__ ((constructor))
945thumbnailffmpeg_lib_init (void) 938thumbnailffmpeg_lib_init (void)
946{ 939{
947 av_log_set_callback (&thumbnailffmpeg_av_log_callback); 940 av_log_set_callback (&thumbnailffmpeg_av_log_callback);
948 av_register_all ();
949 magic = magic_open (MAGIC_MIME_TYPE); 941 magic = magic_open (MAGIC_MIME_TYPE);
950 if (0 != magic_load (magic, NULL)) 942 if (0 != magic_load (magic, NULL))
951 { 943 {