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

Side by Side Diff: ppapi/examples/video_decode/video_decode.cc

Issue 10392141: Plumb texture target to VideoDecodeAccelerator::Client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/dev/video_decoder_client_dev.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string.h> 5 #include <string.h>
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <sstream> 8 #include <sstream>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // pp::Graphics3DClient implementation. 53 // pp::Graphics3DClient implementation.
54 virtual void Graphics3DContextLost() { 54 virtual void Graphics3DContextLost() {
55 // TODO(vrk/fischman): Properly reset after a lost graphics context. In 55 // TODO(vrk/fischman): Properly reset after a lost graphics context. In
56 // particular need to delete context_ and re-create textures. 56 // particular need to delete context_ and re-create textures.
57 // Probably have to recreate the decoder from scratch, because old textures 57 // Probably have to recreate the decoder from scratch, because old textures
58 // can still be outstanding in the decoder! 58 // can still be outstanding in the decoder!
59 assert(!"Unexpectedly lost graphics context"); 59 assert(!"Unexpectedly lost graphics context");
60 } 60 }
61 61
62 // pp::VideoDecoderClient_Dev implementation. 62 // pp::VideoDecoderClient_Dev implementation.
63 virtual void ProvidePictureBuffers(PP_Resource decoder, 63 virtual void ProvidePictureBuffers(
64 uint32_t req_num_of_bufs, 64 PP_Resource decoder,
65 const PP_Size& dimensions); 65 uint32_t req_num_of_bufs,
66 const PP_Size& dimensions,
67 uint32_t texture_target);
66 virtual void DismissPictureBuffer(PP_Resource decoder, 68 virtual void DismissPictureBuffer(PP_Resource decoder,
67 int32_t picture_buffer_id); 69 int32_t picture_buffer_id);
68 virtual void PictureReady(PP_Resource decoder, const PP_Picture_Dev& picture); 70 virtual void PictureReady(PP_Resource decoder, const PP_Picture_Dev& picture);
69 virtual void NotifyError(PP_Resource decoder, PP_VideoDecodeError_Dev error); 71 virtual void NotifyError(PP_Resource decoder, PP_VideoDecodeError_Dev error);
70 72
71 private: 73 private:
72 enum { kNumConcurrentDecodes = 7, 74 enum { kNumConcurrentDecodes = 7,
73 kNumDecoders = 2 }; // Baked into viewport rendering. 75 kNumDecoders = 2 }; // Baked into viewport rendering.
74 76
75 // A single decoder's client interface. 77 // A single decoder's client interface.
76 class DecoderClient { 78 class DecoderClient {
77 public: 79 public:
78 DecoderClient(VideoDecodeDemoInstance* gles2, 80 DecoderClient(VideoDecodeDemoInstance* gles2,
79 pp::VideoDecoder_Dev* decoder); 81 pp::VideoDecoder_Dev* decoder);
80 ~DecoderClient(); 82 ~DecoderClient();
81 83
82 void DecodeNextNALUs(); 84 void DecodeNextNALUs();
83 85
84 // Per-decoder implementation of part of pp::VideoDecoderClient_Dev. 86 // Per-decoder implementation of part of pp::VideoDecoderClient_Dev.
85 void ProvidePictureBuffers(uint32_t req_num_of_bufs, 87 void ProvidePictureBuffers(
86 PP_Size dimensions); 88 uint32_t req_num_of_bufs,
89 PP_Size dimensions,
90 uint32_t texture_target);
87 void DismissPictureBuffer(int32_t picture_buffer_id); 91 void DismissPictureBuffer(int32_t picture_buffer_id);
88 92
89 const PP_PictureBuffer_Dev& GetPictureBufferById(int id); 93 const PP_PictureBuffer_Dev& GetPictureBufferById(int id);
90 pp::VideoDecoder_Dev* decoder() { return decoder_; } 94 pp::VideoDecoder_Dev* decoder() { return decoder_; }
91 95
92 private: 96 private:
93 void DecodeNextNALU(); 97 void DecodeNextNALU();
94 static void GetNextNALUBoundary(size_t start_pos, size_t* end_pos); 98 static void GetNextNALUBoundary(size_t start_pos, size_t* end_pos);
95 void DecoderBitstreamDone(int32_t result, int bitstream_buffer_id); 99 void DecoderBitstreamDone(int32_t result, int bitstream_buffer_id);
96 void DecoderFlushDone(int32_t result); 100 void DecoderFlushDone(int32_t result);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 assert(bitstream_buffers_by_id_.insert(std::make_pair(id, buffer)).second); 317 assert(bitstream_buffers_by_id_.insert(std::make_pair(id, buffer)).second);
314 318
315 pp::CompletionCallback cb = 319 pp::CompletionCallback cb =
316 callback_factory_.NewCallback( 320 callback_factory_.NewCallback(
317 &VideoDecodeDemoInstance::DecoderClient::DecoderBitstreamDone, id); 321 &VideoDecodeDemoInstance::DecoderClient::DecoderBitstreamDone, id);
318 assert(bitstream_ids_at_decoder_.insert(id).second); 322 assert(bitstream_ids_at_decoder_.insert(id).second);
319 encoded_data_next_pos_to_decode_ = end_pos; 323 encoded_data_next_pos_to_decode_ = end_pos;
320 decoder_->Decode(bitstream_buffer, cb); 324 decoder_->Decode(bitstream_buffer, cb);
321 } 325 }
322 326
323 void VideoDecodeDemoInstance::ProvidePictureBuffers( 327 void VideoDecodeDemoInstance::ProvidePictureBuffers(PP_Resource decoder,
324 PP_Resource decoder, uint32_t req_num_of_bufs, const PP_Size& dimensions) { 328 uint32_t req_num_of_bufs,
329 const PP_Size& dimensions,
330 uint32_t texture_target) {
325 DecoderClient* client = video_decoders_[decoder]; 331 DecoderClient* client = video_decoders_[decoder];
326 assert(client); 332 assert(client);
327 client->ProvidePictureBuffers(req_num_of_bufs, dimensions); 333 client->ProvidePictureBuffers(req_num_of_bufs, dimensions, texture_target);
328 } 334 }
329 335
330 void VideoDecodeDemoInstance::DecoderClient::ProvidePictureBuffers( 336 void VideoDecodeDemoInstance::DecoderClient::ProvidePictureBuffers(
331 uint32_t req_num_of_bufs, PP_Size dimensions) { 337 uint32_t req_num_of_bufs,
338 PP_Size dimensions,
339 uint32_t texture_target) {
340 // TODO(sail): Add support for GL_TEXTURE_RECTANGLE_ARB.
341 assert(texture_target == GL_TEXTURE_2D);
332 std::vector<PP_PictureBuffer_Dev> buffers; 342 std::vector<PP_PictureBuffer_Dev> buffers;
333 for (uint32_t i = 0; i < req_num_of_bufs; ++i) { 343 for (uint32_t i = 0; i < req_num_of_bufs; ++i) {
334 PP_PictureBuffer_Dev buffer; 344 PP_PictureBuffer_Dev buffer;
335 buffer.size = dimensions; 345 buffer.size = dimensions;
336 buffer.texture_id = 346 buffer.texture_id =
337 gles2_->CreateTexture(dimensions.width, dimensions.height); 347 gles2_->CreateTexture(dimensions.width, dimensions.height);
338 int id = ++next_picture_buffer_id_; 348 int id = ++next_picture_buffer_id_;
339 buffer.id = id; 349 buffer.id = id;
340 buffers.push_back(buffer); 350 buffers.push_back(buffer);
341 assert(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second); 351 assert(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 gles2_if_->DeleteShader(context_->pp_resource(), shader); 586 gles2_if_->DeleteShader(context_->pp_resource(), shader);
577 } 587 }
578 } // anonymous namespace 588 } // anonymous namespace
579 589
580 namespace pp { 590 namespace pp {
581 // Factory function for your specialization of the Module object. 591 // Factory function for your specialization of the Module object.
582 Module* CreateModule() { 592 Module* CreateModule() {
583 return new VideoDecodeDemoModule(); 593 return new VideoDecodeDemoModule();
584 } 594 }
585 } // namespace pp 595 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/video_decoder_client_dev.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698