Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: source/mjpeg_decoder.cc

Issue 2264293002: Suppress MJPEG fprintf() runtime warning (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const int MJpegDecoder::kColorSpaceYCbCr = JCS_YCbCr; 55 const int MJpegDecoder::kColorSpaceYCbCr = JCS_YCbCr;
56 const int MJpegDecoder::kColorSpaceCMYK = JCS_CMYK; 56 const int MJpegDecoder::kColorSpaceCMYK = JCS_CMYK;
57 const int MJpegDecoder::kColorSpaceYCCK = JCS_YCCK; 57 const int MJpegDecoder::kColorSpaceYCCK = JCS_YCCK;
58 58
59 // Methods that are passed to jpeglib. 59 // Methods that are passed to jpeglib.
60 boolean fill_input_buffer(jpeg_decompress_struct* cinfo); 60 boolean fill_input_buffer(jpeg_decompress_struct* cinfo);
61 void init_source(jpeg_decompress_struct* cinfo); 61 void init_source(jpeg_decompress_struct* cinfo);
62 void skip_input_data(jpeg_decompress_struct* cinfo, long num_bytes); // NOLINT 62 void skip_input_data(jpeg_decompress_struct* cinfo, long num_bytes); // NOLINT
63 void term_source(jpeg_decompress_struct* cinfo); 63 void term_source(jpeg_decompress_struct* cinfo);
64 void ErrorHandler(jpeg_common_struct* cinfo); 64 void ErrorHandler(jpeg_common_struct* cinfo);
65 void OutputHandler(jpeg_common_struct* cinfo);
65 66
66 MJpegDecoder::MJpegDecoder() 67 MJpegDecoder::MJpegDecoder()
67 : has_scanline_padding_(LIBYUV_FALSE), 68 : has_scanline_padding_(LIBYUV_FALSE),
68 num_outbufs_(0), 69 num_outbufs_(0),
69 scanlines_(NULL), 70 scanlines_(NULL),
70 scanlines_sizes_(NULL), 71 scanlines_sizes_(NULL),
71 databuf_(NULL), 72 databuf_(NULL),
72 databuf_strides_(NULL) { 73 databuf_strides_(NULL) {
73 decompress_struct_ = new jpeg_decompress_struct; 74 decompress_struct_ = new jpeg_decompress_struct;
74 source_mgr_ = new jpeg_source_mgr; 75 source_mgr_ = new jpeg_source_mgr;
75 #ifdef HAVE_SETJMP 76 #ifdef HAVE_SETJMP
76 error_mgr_ = new SetJmpErrorMgr; 77 error_mgr_ = new SetJmpErrorMgr;
77 decompress_struct_->err = jpeg_std_error(&error_mgr_->base); 78 decompress_struct_->err = jpeg_std_error(&error_mgr_->base);
78 // Override standard exit()-based error handler. 79 // Override standard exit()-based error handler.
79 error_mgr_->base.error_exit = &ErrorHandler; 80 error_mgr_->base.error_exit = &ErrorHandler;
81 error_mgr_->base.output_message = &OutputHandler;
80 #endif 82 #endif
81 decompress_struct_->client_data = NULL; 83 decompress_struct_->client_data = NULL;
82 source_mgr_->init_source = &init_source; 84 source_mgr_->init_source = &init_source;
83 source_mgr_->fill_input_buffer = &fill_input_buffer; 85 source_mgr_->fill_input_buffer = &fill_input_buffer;
84 source_mgr_->skip_input_data = &skip_input_data; 86 source_mgr_->skip_input_data = &skip_input_data;
85 source_mgr_->resync_to_restart = &jpeg_resync_to_restart; 87 source_mgr_->resync_to_restart = &jpeg_resync_to_restart;
86 source_mgr_->term_source = &term_source; 88 source_mgr_->term_source = &term_source;
87 jpeg_create_decompress(decompress_struct_); 89 jpeg_create_decompress(decompress_struct_);
88 decompress_struct_->src = source_mgr_; 90 decompress_struct_->src = source_mgr_;
89 buf_vec_.buffers = &buf_; 91 buf_vec_.buffers = &buf_;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 char buf[JMSG_LENGTH_MAX]; 451 char buf[JMSG_LENGTH_MAX];
450 (*cinfo->err->format_message)(cinfo, buf); 452 (*cinfo->err->format_message)(cinfo, buf);
451 // ERROR: Error in jpeglib: buf 453 // ERROR: Error in jpeglib: buf
452 #endif 454 #endif
453 455
454 SetJmpErrorMgr* mgr = reinterpret_cast<SetJmpErrorMgr*>(cinfo->err); 456 SetJmpErrorMgr* mgr = reinterpret_cast<SetJmpErrorMgr*>(cinfo->err);
455 // This rewinds the call stack to the point of the corresponding setjmp() 457 // This rewinds the call stack to the point of the corresponding setjmp()
456 // and causes it to return (for a second time) with value 1. 458 // and causes it to return (for a second time) with value 1.
457 longjmp(mgr->setjmp_buffer, 1); 459 longjmp(mgr->setjmp_buffer, 1);
458 } 460 }
459 #endif 461
462 void OutputHandler(j_common_ptr cinfo) {
463 // Suppress fprintf warnings.
464 }
465
466 #endif // HAVE_SETJMP
460 467
461 void MJpegDecoder::AllocOutputBuffers(int num_outbufs) { 468 void MJpegDecoder::AllocOutputBuffers(int num_outbufs) {
462 if (num_outbufs != num_outbufs_) { 469 if (num_outbufs != num_outbufs_) {
463 // We could perhaps optimize this case to resize the output buffers without 470 // We could perhaps optimize this case to resize the output buffers without
464 // necessarily having to delete and recreate each one, but it's not worth 471 // necessarily having to delete and recreate each one, but it's not worth
465 // it. 472 // it.
466 DestroyOutputBuffers(); 473 DestroyOutputBuffers();
467 474
468 scanlines_ = new uint8** [num_outbufs]; 475 scanlines_ = new uint8** [num_outbufs];
469 scanlines_sizes_ = new int[num_outbufs]; 476 scanlines_sizes_ = new int[num_outbufs];
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 if (subsample_x[0] == 1 && subsample_y[0] == 1) { 568 if (subsample_x[0] == 1 && subsample_y[0] == 1) {
562 return kJpegYuv400; 569 return kJpegYuv400;
563 } 570 }
564 } 571 }
565 return kJpegUnknown; 572 return kJpegUnknown;
566 } 573 }
567 574
568 } // namespace libyuv 575 } // namespace libyuv
569 #endif // HAVE_JPEG 576 #endif // HAVE_JPEG
570 577
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698