`Page 1/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`1
`+++++¬
`…
`¬2
`$Id: bmptorgb.c,v 1.5 2001/10/02 21:04:10 guyc Exp $¬
`3
`¬4
`Copyright (c) 2001 BeComm Corporation¬
`5
`¬6
`Filename:¬
`7
`¬8
` bmptorgb.c¬
`9
`¬10
`Notes:¬
`11
`¬12
` currently the bead uses the rgbcontext implementation¬
`13
` which does not allow us to convey the bmp-specific¬
`14
` palette information. This is okay, since the decoder¬
`15
` currenly only supports formats that don't use the¬
`16
` color info, but to extend this to support all bmp files¬
`17
` the context will need to convey the color info¬
`18
` somehow - either within the path context or the message.¬
`19
`¬20
`Abstract:¬
`21
`¬22
` Converts encoded bitmaps to 24-bit RGB bitmaps.¬
`23
`¬24
`Owner:¬
`25
`¬26
` Guy Carpenter (guyc)¬
`27
`¬28
`--------------------------------------------------------------------------
`29
`---*/¬
`…
`¬30
`#define SOS_DEBUG_ZONE "/beads/bmptorgb"¬
`31
`#include <sosstrings.h>¬
`32
`#include "bmpformat.h"¬
`33
`#include "bmpdecoder.h"¬
`34
`#include <sosmultimedia.h>¬
`35
`¬36
`SOS_SOURCE_VERSION("$Id: bmptorgb.c,v 1.5 2001/10/02 21:04:10 guyc Exp
`37
`$");¬
`…
`¬38
`#define video¬
`39
`¬40
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`41
`+++++¬
`…
`
`Page 1 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 2/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`Named Constants¬
`42
`--------------------------------------------------------------------------
`43
`---*/¬
`…
`¬44
`/*¬
`45
` * Name of bead¬
`46
` */¬
`47
`static const char BEAD_NAME[] = "bmptorgb";¬
`48
`¬49
`static const char VIDEOCONTEXT_CLASS_NAME[] = "rgbcontext";¬
`50
`¬51
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`52
`+++++¬
`…
`Structs¬
`53
`--------------------------------------------------------------------------
`54
`---*/¬
`…
`¬55
`typedef struct {¬
`56
` BMP_FORMAT BmpFormat;¬
`57
` BMP_DECODER * BmpDecoder;¬
`58
` SOS_IVIDEOCONTEXT * InVideoContext;¬
`59
` SOS_IVIDEOCONTEXT * OutVideoContext;¬
`60
` SOS_VIDEO_TIMESTAMP FrameNumber;¬
`61
`} BMPTORGB_CONTEXT;¬
`62
`¬63
`¬64
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`65
`+++++¬
`…
`Context Stuff¬
`66
`--------------------------------------------------------------------------
`67
`---*/¬
`…
`¬68
`static¬
`69
`void¬
`70
`BmpToRgb_ContextDestroy(¬
`71
` BMPTORGB_CONTEXT * Context¬
`72
`)¬
`73
`{¬
`74
` if (Context) {¬
`75
` ¬
`76
` if (Context->BmpDecoder) {¬
`77
` BmpDecoder_Destroy(Context->BmpDecoder);¬
`78
` }¬
`79
`¬80
` SOS_Interface_Release(Context->InVideoContext);¬
`81
`
`Page 2 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 3/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
` SOS_Interface_Release(Context->OutVideoContext);¬
`82
`¬83
` SOS_Mem_Free(Context);¬
`84
` }¬
`85
`}¬
`86
`¬87
`static¬
`88
`BMPTORGB_CONTEXT *¬
`89
`BmpToRgb_ContextCreate(¬
`90
` void¬
`91
`)¬
`92
`{¬
`93
` SOS_STATUS status = SOS_Success;¬
`94
` BMPTORGB_CONTEXT *context;¬
`95
`¬96
` context = SOS_Mem_Alloc(sizeof(*context));¬
`97
` if (context) {¬
`98
` SOS_memset(context, 0, sizeof(*context));¬
`99
`¬
`100
` context->BmpDecoder = BmpDecoder_Create();¬
`101
` if (!context->BmpDecoder) {¬
`102
` /* failed to create decoder */¬
`103
` status = SOS_Error;¬
`104
` }¬
`105
` ¬
`106
` /*¬
`107
` * If anything went wrong we should cleanup ¬
`108
` */¬
`109
` if (SOS_FAILED(status)) {¬
`110
` BmpToRgb_ContextDestroy(context);¬
`111
` context = NULL;¬
`112
` }¬
`113
` } else {¬
`114
` /* failed mallocing context */¬
`115
` status = SOS_ErrorResourceAllocation;¬
`116
` }¬
`117
`¬
`118
` return context;¬
`119
`}¬
`120
`¬
`121
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`122
`+++++¬
`…
`¬
`123
`++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`124
`+++*/¬
`…
`
`Page 3 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 4/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`125
`126
`127
`128
`129
`130
`131
`132
`133
`134
`135
`136
`137
`138
`139
`140
`141
`142
`143
`144
`145
`146
`147
`148
`149
`150
`151
`152
`153
`154
`155
`156
`157
`158
`159
`160
`161
`162
`163
`164
`165
`166
`167
`168
`169
`
`static¬
`SOS_STATUS¬
`ContextPrepare(¬
` BMPTORGB_CONTEXT* Context,¬
` SOS_PATH* Path¬
`)¬
`{¬
` SOS_STATUS status = SOS_Success;¬
` SOS_REGOBJECT *videoContextObject;¬
`¬
` status = SOS_Path_AttributeGet(¬
` Path,¬
` SOS_VIDEOCONTEXT_NAME,¬
` &videoContextObject¬
` );¬
`¬
` SOS_ASSERT_SOFT_ERROR(¬
` SOS_SUCCEEDED(status),¬
` "Path context does not contain a video context"¬
` );¬
`¬
` if (SOS_SUCCEEDED(status)) {¬
` status = SOS_RegObject_InterfaceGet(¬
` videoContextObject,¬
` SOS_IVIDEOCONTEXT_ID,¬
` (void**)&(Context->InVideoContext)¬
` );¬
`¬
` SOS_RegObject_Release(videoContextObject);¬
` }¬
` ¬
` ¬
` Context->OutVideoContext = SOS_Interface_CreateFromClassName(¬
` VIDEOCONTEXT_CLASS_NAME,¬
` SOS_IVIDEOCONTEXT_ID¬
` );¬
`¬
` SOS_ASSERT_ASSUMPTION(¬
` Context->OutVideoContext!=NULL,¬
` "Couldn't create video context"¬
` );¬
`¬
` if (Context->OutVideoContext) {¬
`¬
` status = SOS_Path_AttributeSet(¬
`
`Page 4 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 5/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`170
`171
`172
`173
`174
`175
`176
`177
`178
`179
`180
`181
`182
`183
`184
`185
`186
`187
`188
`189
`190
`191
`192
`193
`194
`195
`196
`197
`198
`199
`200
`201
`202
`203
`204
`205
`206
`207
`…
`208
`209
`210
`211
`212
`213
`
` Path,¬
` SOS_VIDEOCONTEXT_NAME,¬
` SOS_Interface_ObjectPeek(Context->OutVideoContext)¬
` );¬
` }¬
`¬
` return status;¬
`}¬
`¬
`¬
`SOS_STATUS¬
`DecodeFrame(¬
` SOS_PATH * Path,¬
` BMPTORGB_CONTEXT * Context,¬
` SOS_MESSAGE * Message¬
`¬
`)¬
`{¬
` SOS_STATUS status = SOS_Success;¬
` SOS_VIDEO_FORMAT inFormat, outFormat;¬
` SOS_VIDEO_TIMESTAMP timeStamp;¬
`¬
` SOS_MESSAGE *outMessage = SOS_Message_Create();¬
` size_t encodedFrameSize = 0;¬
` size_t decodedFrameSize = 0;¬
` void *encodedFrame = NULL;¬
` void *decodedFrame = NULL;¬
`¬
` status = Context->InVideoContext->Unpack(¬
` Context->InVideoContext,¬
` Message,¬
` &inFormat,¬
` &timeStamp¬
` );¬
`¬
` if (SOS_SUCCEEDED(status)) {¬
` encodedFrameSize = SOS_Message_LengthGet(Message);¬
` decodedFrameSize = inFormat.Width * inFormat.Height *
`sizeof(SOS_UINT32);¬
` ¬
` encodedFrame = SOS_Mem_Alloc(encodedFrameSize);¬
` decodedFrame = SOS_Mem_Alloc(decodedFrameSize);¬
` }¬
`¬
` if (encodedFrame && decodedFrame) {¬
`
`Page 5 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 6/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`214
`215
`216
`217
`218
`219
`220
`221
`222
`223
`224
`225
`226
`227
`228
`229
`230
`231
`232
`233
`234
`235
`236
`237
`238
`239
`240
`241
`242
`243
`244
`245
`246
`247
`248
`249
`250
`251
`252
`253
`254
`255
`256
`257
`258
`
` BMP_FORMAT bmpFormat;¬
` ¬
` SOS_Message_HeadDataPop(¬
` Message,¬
` encodedFrameSize,¬
` encodedFrame,¬
` NULL¬
` );¬
` ¬
` bmpFormat.Width = inFormat.Width;¬
` bmpFormat.Height = inFormat.Height;¬
` bmpFormat.Compression = inFormat.Encoding;¬
`¬
` BmpDecoder_FormatSet(¬
` Context->BmpDecoder,¬
` &bmpFormat,¬
` NULL, /* no color information */¬
` 0 /* size of no color information */¬
` );¬
` ¬
` BmpDecoder_FrameDecode(¬
` Context->BmpDecoder,¬
` encodedFrame,¬
` encodedFrameSize,¬
` decodedFrame,¬
` decodedFrameSize¬
` );¬
`¬
` status = SOS_Message_HeadDataPush(¬
` outMessage,¬
` decodedFrame,¬
` decodedFrameSize,¬
` SOS_Mem_Free¬
` );¬
`¬
` if (SOS_SUCCEEDED(status)) {¬
` outFormat = inFormat;¬
` outFormat.Encoding = SOS_VIDEO_RGBL24;¬
`¬
` Context->OutVideoContext->FormatSet(¬
` Context->OutVideoContext,¬
` &outFormat¬
` );¬
` ¬
` Context->OutVideoContext->Pack(¬
`
`Page 6 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 7/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`259
`260
`261
`262
`263
`264
`265
`266
`267
`268
`269
`270
`271
`272
`273
`274
`275
`276
`277
`278
`279
`280
`281
`282
`283
`284
`285
`…
`286
`287
`…
`288
`289
`290
`291
`292
`293
`294
`295
`296
`297
`298
`299
`300
`301
`
` Context->OutVideoContext,¬
` outMessage,¬
` NULL,¬
` timeStamp¬
` );¬
` }¬
` ¬
` if (SOS_SUCCEEDED(status)) {¬
` status = SOS_Path_MessageSend(¬
` Path,¬
` outMessage¬
` );¬
` }¬
` ¬
` SOS_Mem_Free(encodedFrame);¬
` ¬
` } else {¬
` SOS_Message_Destroy(outMessage);¬
` SOS_Mem_Free(encodedFrame);¬
` SOS_Mem_Free(decodedFrame);¬
` status = SOS_ErrorResourceAllocation;¬
` }¬
` ¬
` return status;¬
`}¬
`¬
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++++¬
`Bead Definition¬
`--------------------------------------------------------------------------
`---*/¬
`static¬
`SOS_STATUS¬
`BmpToRgb_KeyCreate(¬
` SOS_PATH *Path,¬
` SOS_MESSAGE *Message¬
`)¬
`{¬
` static SOS_UINT32 s_UniqueId = 0;¬
` SOS_REGOBJECT* uniqueSessionKey;¬
` ¬
` uniqueSessionKey = SOS_UInt32_Create(s_UniqueId++);¬
` SOS_Path_SessionKeySet(Path, uniqueSessionKey);¬
` SOS_RegObject_Release(uniqueSessionKey);¬
`¬
`
`Page 7 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 8/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`302
`303
`304
`305
`306
`307
`308
`309
`310
`311
`312
`313
`314
`315
`316
`317
`318
`319
`320
`321
`322
`323
`324
`325
`326
`327
`328
`329
`330
`331
`332
`333
`334
`335
`336
`337
`…
`338
`339
`…
`340
`341
`342
`343
`344
`
` return SOS_Success;¬
`}¬
`¬
`¬
`static¬
`SOS_STATUS¬
`BmpToRgb_MessageHandler(¬
` SOS_PATH *Path,¬
` SOS_MESSAGE *Message¬
`)¬
`{¬
` SOS_STATUS status = SOS_Success;¬
` BMPTORGB_CONTEXT *context;¬
`¬
` SOS_DEBUGOUT_FUNC_TRACE("BmpToRgb_MessageHandler\n");¬
`¬
` SOS_Path_SessionContextPeek(Path, (void**)&context);¬
`¬
` if (!context->InVideoContext) {¬
` status = ContextPrepare(context, Path);¬
` }¬
`¬
` if (SOS_SUCCEEDED(status)) {¬
` DecodeFrame(¬
` Path,¬
` context,¬
` Message¬
` );¬
` }¬
` ¬
` SOS_Message_Destroy(Message);¬
`¬
` return status;¬
`}¬
`¬
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++++¬
`Session Setup¬
`++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++*/¬
`¬
`static¬
`SOS_STATUS¬
`BmpToRgb_SessionInit(¬
` SOS_PATH *Path¬
`
`Page 8 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/bea…/…/main/bmptorgb.c
`Page 9/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`345
`346
`347
`348
`349
`350
`351
`352
`353
`354
`355
`356
`357
`358
`359
`360
`361
`362
`363
`364
`365
`366
`367
`368
`369
`370
`371
`372
`373
`374
`375
`376
`377
`…
`378
`379
`…
`380
`381
`382
`383
`384
`385
`386
`387
`
`)¬
`{¬
` SOS_STATUS status = SOS_Success;¬
` BMPTORGB_CONTEXT *context = BmpToRgb_ContextCreate();¬
`¬
` if (context) {¬
` SOS_Path_SessionContextPut(Path, context);¬
` } else {¬
` status = SOS_Error;¬
` }¬
` ¬
` return status;¬
`}¬
`¬
`static¬
`SOS_STATUS¬
`BmpToRgb_SessionUninit(¬
` SOS_PATH *Path¬
`)¬
`{¬
` SOS_STATUS status = SOS_Success;¬
` BMPTORGB_CONTEXT *context;¬
`¬
` SOS_Path_SessionContextPeek(Path, (void**)&context);¬
`¬
` if (context) {¬
` BmpToRgb_ContextDestroy(context);¬
` }¬
`¬
` return status;¬
`}¬
`¬
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++++¬
`Bead Setup¬
`++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++*/¬
`¬
`static¬
`SOS_STATUS¬
`BmpToRgb_BeadInit(¬
` SOS_BEAD *Bead,¬
` SOS_REGOBJECT *InitContext¬
`)¬
`{¬
`
`Page 9 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/be…/…/main/bmptorgb.c
`Page 10/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
`388
`389
`390
`391
`392
`393
`394
`395
`396
`397
`398
`399
`400
`401
`402
`403
`404
`405
`406
`407
`408
`409
`410
`411
`412
`413
`414
`415
`416
`417
`418
`419
`…
`420
`421
`…
`422
`423
`424
`425
`426
`427
`428
`429
`430
`
` SOS_STATUS status;¬
` ¬
` /* register Decode Edge */¬
` status = SOS_Edge_Register(¬
` Bead,¬
` "decode",¬
` NULL,¬
` NULL,¬
` NULL,¬
` BmpToRgb_KeyCreate,¬
` BmpToRgb_MessageHandler,¬
` NULL,¬
` NULL,¬
` NULL,¬
` NULL);¬
`¬
` if (SOS_FAILED(status)) {¬
` SOS_DEBUGOUT_MAJOR_EVENT( "Could not register decode edge");¬
` }¬
` return status;¬
`}¬
`¬
`static¬
`SOS_STATUS¬
`BmpToRgb_BeadUninit(¬
` void *BeadContext¬
`)¬
`{¬
` return SOS_Success;¬
`}¬
`¬
`/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++++¬
`Module Setup¬
`++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
`+++*/¬
`¬
`SOS_STATUS¬
`SOS_ModuleInit (¬
` SOS_OBJECTFILE *ObjectFile,¬
` SOS_REGOBJECT *InitContext¬
`)¬
`{¬
` SOS_STATUS status;¬
` ¬
`
`Page 10 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`
`
`/Users/implicit/Desktop/Source Code/2001.11.01/be…/…/main/bmptorgb.c
`Page 11/11
`Saved: 10/2/01, 4:04:10 PM
`Printed for: Implicit
`
` /* register the Bead */¬
` status = SOS_Bead_Register(¬
` ObjectFile,¬
` BEAD_NAME,¬
` NULL, /* Bead context */¬
` BmpToRgb_BeadInit,¬
` BmpToRgb_BeadUninit,¬
` BmpToRgb_SessionInit,¬
` BmpToRgb_SessionUninit¬
` );¬
`¬
` return status;¬
`}¬
`¬
`¬
`void¬
`SOS_ModuleUninit (¬
` SOS_OBJECTFILE *ObjectFile¬
`)¬
`{¬
`¬
`}¬
`
`431
`432
`433
`434
`435
`436
`437
`438
`439
`440
`441
`442
`443
`444
`445
`446
`447
`448
`449
`450
`451
`452
`453
`
`Page 11 of 11
`
`Implicit Exhibit 2045
`Sonos v. Implicit, IPR2018-0766, -0767
`
`