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

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: Created 8 years, 7 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
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 PP_VideoDecoder_TextureTarget_Dev 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 PP_VideoDecoder_TextureTarget_Dev 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 320
317 pp::CompletionCallback cb = 321 pp::CompletionCallback cb =
318 callback_factory_.NewCallback( 322 callback_factory_.NewCallback(
319 &VideoDecodeDemoInstance::DecoderClient::DecoderBitstreamDone, id); 323 &VideoDecodeDemoInstance::DecoderClient::DecoderBitstreamDone, id);
320 assert(bitstream_ids_at_decoder_.insert(id).second); 324 assert(bitstream_ids_at_decoder_.insert(id).second);
321 encoded_data_next_pos_to_decode_ = end_pos; 325 encoded_data_next_pos_to_decode_ = end_pos;
322 decoder_->Decode(bitstream_buffer, cb); 326 decoder_->Decode(bitstream_buffer, cb);
323 } 327 }
324 328
325 void VideoDecodeDemoInstance::ProvidePictureBuffers( 329 void VideoDecodeDemoInstance::ProvidePictureBuffers(
326 PP_Resource decoder, uint32_t req_num_of_bufs, const PP_Size& dimensions) { 330 PP_Resource decoder,
331 uint32_t req_num_of_bufs,
332 const PP_Size& dimensions,
333 PP_VideoDecoder_TextureTarget_Dev texture_target) {
327 DecoderClient* client = video_decoders_[decoder]; 334 DecoderClient* client = video_decoders_[decoder];
328 assert(client); 335 assert(client);
329 client->ProvidePictureBuffers(req_num_of_bufs, dimensions); 336 client->ProvidePictureBuffers(req_num_of_bufs, dimensions, texture_target);
330 } 337 }
331 338
332 void VideoDecodeDemoInstance::DecoderClient::ProvidePictureBuffers( 339 void VideoDecodeDemoInstance::DecoderClient::ProvidePictureBuffers(
333 uint32_t req_num_of_bufs, PP_Size dimensions) { 340 uint32_t req_num_of_bufs,
341 PP_Size dimensions,
342 PP_VideoDecoder_TextureTarget_Dev texture_target) {
343 // TODO(sail): Add support for ARB texture types.
Ami GONE FROM CHROMIUM 2012/05/23 23:42:33 Can you do this as part of this CL?
sail 2012/05/29 18:58:09 This part is implemented in this CL: http://codere
344 assert(texture_target == PP_VIDEODECODER_TEXTURE_TARGET_2D);
334 std::vector<PP_PictureBuffer_Dev> buffers; 345 std::vector<PP_PictureBuffer_Dev> buffers;
335 for (uint32_t i = 0; i < req_num_of_bufs; ++i) { 346 for (uint32_t i = 0; i < req_num_of_bufs; ++i) {
336 PP_PictureBuffer_Dev buffer; 347 PP_PictureBuffer_Dev buffer;
337 buffer.size = dimensions; 348 buffer.size = dimensions;
338 buffer.texture_id = 349 buffer.texture_id =
339 gles2_->CreateTexture(dimensions.width, dimensions.height); 350 gles2_->CreateTexture(dimensions.width, dimensions.height);
340 int id = ++next_picture_buffer_id_; 351 int id = ++next_picture_buffer_id_;
341 buffer.id = id; 352 buffer.id = id;
342 buffers.push_back(buffer); 353 buffers.push_back(buffer);
343 assert(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second); 354 assert(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 gles2_if_->DeleteShader(context_->pp_resource(), shader); 589 gles2_if_->DeleteShader(context_->pp_resource(), shader);
579 } 590 }
580 } // anonymous namespace 591 } // anonymous namespace
581 592
582 namespace pp { 593 namespace pp {
583 // Factory function for your specialization of the Module object. 594 // Factory function for your specialization of the Module object.
584 Module* CreateModule() { 595 Module* CreateModule() {
585 return new VideoDecodeDemoModule(); 596 return new VideoDecodeDemoModule();
586 } 597 }
587 } // namespace pp 598 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698